From owner-svn-src-all@FreeBSD.ORG Thu Jan 19 17:53:34 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A3F8D106564A; Thu, 19 Jan 2012 17:53:34 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail03.syd.optusnet.com.au (mail03.syd.optusnet.com.au [211.29.132.184]) by mx1.freebsd.org (Postfix) with ESMTP id 3C66B8FC15; Thu, 19 Jan 2012 17:53:33 +0000 (UTC) Received: from c211-30-171-136.carlnfd1.nsw.optusnet.com.au (c211-30-171-136.carlnfd1.nsw.optusnet.com.au [211.30.171.136]) by mail03.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q0JHrU3S018951 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 20 Jan 2012 04:53:31 +1100 Date: Fri, 20 Jan 2012 04:53:30 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Bruce Evans In-Reply-To: <20120120030456.O1411@besplex.bde.org> Message-ID: <20120120041332.V1706@besplex.bde.org> References: <201201160615.q0G6FE9r019542@svn.freebsd.org> <4F178CDC.3030807@gmail.com> <4F17B0DE.3060008@gmail.com> <201201191023.28426.jhb@freebsd.org> <20120120030456.O1411@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, davidxu@FreeBSD.org, John Baldwin Subject: Re: svn commit: r230201 - head/lib/libc/gen 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: Thu, 19 Jan 2012 17:53:34 -0000 On Fri, 20 Jan 2012, Bruce Evans wrote: > ... > % + v = *p; \ > % + __asm __volatile("lfence" ::: "memory"); \ > > Style bug (missing spaces around binary operator `:') which becomes > a syntax error for C++. Other places in this file use ` : : : '. > > lfence() should be in cpufunc.h if it can be done separately > like this. However, I think it can't be done separately -- > it needs to be done in the same asm as the load/store, since > separate C statements may be reordered. This is the same > problem that forces us to write __asm volatile("sti; hlt"); > instead of sti(); hlt(); in too many places for idling in > machdep.c. BTW, sti() and hlt() are bogusly not in cpufunc.h > either: > - I misnamed sti() as disable_intr() since disable_intr() was > supposed to be MI and I didn't understand that any MI > interface should not be direct in cpufunc.h. > - someone misnamed hlt() as halt(). BTW2, there are 1 or 2 direct uses of halt() per arch, and all seem to be wrong: - cpu_halt() uses halt() for amd64, i386 and pc98. It neither enables or disables interrupts. When it is called from ddb, enabling interrupts would be a bug. Otherwise, it might want to ensure that interrupts are enabled (to allow i/o to complete), but it is safer to ensure that they is disabled (the caller, which is normally shutdown_halt(), should have waited). - on arches that support apm (i386 and maybe pc98), apm_cpu_idle() uses halt(). It neither disables nor enables interrupts. Apparently they are always enabled already. But that seems to give races. But this seems to have no effect, since apm_cpu_idle() seems to be never used. It seems to have been last used in FreeBSD-2, where it is called from swtch.s. All references to apm were removed from swtch.s in 1997. The call was replaced by a call through the function pointer _hlt_vector (aout spelling). This always called a default which just executed the hlt instruction. _hlt_vector was not connected to apm. This later turned into cpu_idle() and the function pointer cpu_idle_hook that we have today. The hook was apparently never connected to apm. It is even misdescribed in its comment as being the ACPI idle hook. Perhaps ACPI is the only thing that uses it, but its declaration shouldn't say that. Bruce