From owner-freebsd-current@FreeBSD.ORG Thu Apr 2 09:47:32 2009 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1BC831065672 for ; Thu, 2 Apr 2009 09:47:32 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.terabit.net.ua (mail.terabit.net.ua [195.137.202.147]) by mx1.freebsd.org (Postfix) with ESMTP id B2FF38FC12 for ; Thu, 2 Apr 2009 09:47:31 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from skuns.zoral.com.ua ([91.193.166.194] helo=mail.zoral.com.ua) by mail.terabit.net.ua with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63 (FreeBSD)) (envelope-from ) id 1LpJWE-00060O-Bj; Thu, 02 Apr 2009 12:47:30 +0300 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id n329lRMm014472 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 2 Apr 2009 12:47:27 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3) with ESMTP id n329lRkG032014; Thu, 2 Apr 2009 12:47:27 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id n329lR32032013; Thu, 2 Apr 2009 12:47:27 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 2 Apr 2009 12:47:27 +0300 From: Kostik Belousov To: Luigi Rizzo Message-ID: <20090402094727.GC31897@deviant.kiev.zoral.com.ua> References: <20090402070605.GA96848@onelab2.iet.unipi.it> <20090402084833.GZ31897@deviant.kiev.zoral.com.ua> <20090402085854.GA2237@onelab2.iet.unipi.it> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="j9j9RojA/SLAeXkU" Content-Disposition: inline In-Reply-To: <20090402085854.GA2237@onelab2.iet.unipi.it> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.94.2, clamav-milter version 0.94.2 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua X-Virus-Scanned: mail.terabit.net.ua 1LpJWE-00060O-Bj 7790033e8dd309314ea97696bd01659a X-Terabit: YES Cc: current@freebsd.org Subject: Re: cmpxchg / atomic_cmpset_int emulation for userland (i386) ? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Apr 2009 09:47:32 -0000 --j9j9RojA/SLAeXkU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 02, 2009 at 10:58:54AM +0200, Luigi Rizzo wrote: > On Thu, Apr 02, 2009 at 11:48:33AM +0300, Kostik Belousov wrote: > > On Thu, Apr 02, 2009 at 09:06:05AM +0200, Luigi Rizzo wrote: > > > Hi, > > > I have some list manipulation algorithm that I would like to use > > > that relies rather centrally on atomic_cmpset_int(). > > >=20 > > > This is an atomic instruction on 486+, but not available on 386 > > > and maybe other platforms. i386/atomic.h has a replacement > > > but it uses "pushfl; cli; ... popfl;" so it cannot run in userland. > > >=20 > > > I was wondering if there is a good emulation for that instruction > > > on the i386 that is suitable for userland (other architectures > > > we support have a CPU instruction that does it, or in the case of ARM, > > > a usable emulation for userland). > >=20 > > FreeBSD cannot boot on anything < 486, i.e. cmpxchgl and xaddl may be > > considered always supported by the CPU. >=20 > It was a slightly more generic question -- this stuff is for userland > so while we can assume it works on modern FreeBSD versions, I would > like to see what constraints it has on older versions of FreeBSD. > Of course I can emulate the critical section with a pthread lock, > but that would be the worst case option. Support for FPU-less operations was removed from HEAD in Jul 2003. The support for i386+387 seems to be removed in 2004, i.e. before 5.x. The kernel explicitely requires working read-only mappings of the pages for kernel mode, AKA WP bit in CR0. Also, kernel assumes that cmpxchgl is always present. Do you want to support 4.x ? --j9j9RojA/SLAeXkU Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAknUia4ACgkQC3+MBN1Mb4jb2wCgrRut4dpvGPNjneo1ztK1Y8lL p8gAn1wPPu5RY9r1jVP201S7j4CcJ3BL =E0sP -----END PGP SIGNATURE----- --j9j9RojA/SLAeXkU--