From owner-svn-src-all@FreeBSD.ORG Fri Jun 24 16:11:22 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (unknown [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 78CDB1065670; Fri, 24 Jun 2011 16:11:22 +0000 (UTC) (envelope-from marcel@xcllnt.net) Received: from mail.xcllnt.net (mail.xcllnt.net [70.36.220.4]) by mx1.freebsd.org (Postfix) with ESMTP id 453FB8FC20; Fri, 24 Jun 2011 16:11:21 +0000 (UTC) Received: from sa-nc-common-177.static.jnpr.net (natint3.juniper.net [66.129.224.36]) (authenticated bits=0) by mail.xcllnt.net (8.14.4/8.14.4) with ESMTP id p5OGBGDw079902 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Fri, 24 Jun 2011 09:11:22 -0700 (PDT) (envelope-from marcel@xcllnt.net) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Marcel Moolenaar In-Reply-To: <201106232221.p5NMLSFj019042@svn.freebsd.org> Date: Fri, 24 Jun 2011 09:11:09 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <1B2D07F9-3716-4581-8426-11BE78CE1D1F@xcllnt.net> References: <201106232221.p5NMLSFj019042@svn.freebsd.org> To: Nathan Whitehorn X-Mailer: Apple Mail (2.1084) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r223485 - in head/sys/powerpc: aim booke include ofw powerpc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jun 2011 16:11:22 -0000 On Jun 23, 2011, at 3:21 PM, Nathan Whitehorn wrote: > Author: nwhitehorn > Date: Thu Jun 23 22:21:28 2011 > New Revision: 223485 > URL: http://svn.freebsd.org/changeset/base/223485 >=20 > Log: > Use the ABI-mandated thread pointer register (r2 for ppc32, r13 for = ppc64) > instead of a PCPU field for curthread. This averts a race on SMP = systems > with a high interrupt rate where the thread looking up the value of > curthread could be preempted and migrated between obtaining the PCPU > pointer and reading the value of pc_curthread, resulting in curthread = being > observed to be the current thread on the thread's original CPU. This = played > merry havoc with the system, in particular with mutexes. Many thanks = to > jhb for helping me work this one out. Nice catch! Another approach would be to have r2/r13 hold the address of the PCPU structure and simply do a load from that address to get curthread. The difference between the approaches is the need to to a memory load or not for curthread. But with r2/r13 pointing to the PCPU, you may be faster to get other PCPU fields if reading from the a SPR adds to the overhead. Plus, it's easier to be atomic if you don't have to read the SPR first and then do a load. Is curthread the only field that needs to be atomically accessed or are other fields in the PCPU susceptible to race conditions? --=20 Marcel Moolenaar marcel@xcllnt.net