From owner-freebsd-arch@FreeBSD.ORG Tue May 22 06:45:22 2007 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9A7E816A421; Tue, 22 May 2007 06:45:22 +0000 (UTC) (envelope-from bde@optusnet.com.au) Received: from mail08.syd.optusnet.com.au (mail08.syd.optusnet.com.au [211.29.132.189]) by mx1.freebsd.org (Postfix) with ESMTP id 3A74013C4AE; Tue, 22 May 2007 06:45:22 +0000 (UTC) (envelope-from bde@optusnet.com.au) Received: from besplex.bde.org (c211-30-216-190.carlnfd3.nsw.optusnet.com.au [211.30.216.190]) by mail08.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id l4M6jINU004740 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 May 2007 16:45:20 +1000 Date: Tue, 22 May 2007 16:45:19 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Attilio Rao In-Reply-To: <20070521225032.C57233@delplex.bde.org> Message-ID: <20070522162819.N5249@besplex.bde.org> References: <20070520155103.K632@10.0.0.1> <20070521113648.F86217@besplex.bde.org> <20070520213132.K632@10.0.0.1> <4651CAB8.8070007@FreeBSD.org> <4651CE2F.8080908@FreeBSD.org> <20070521022847.D679@10.0.0.1> <20070521195811.G56785@delplex.bde.org> <4651FCB5.7070604@FreeBSD.org> <20070521225032.C57233@delplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: arch@freebsd.org Subject: Re: sched_lock && thread_lock() X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 May 2007 06:45:22 -0000 On Tue, 22 May 2007, Bruce Evans wrote: > Bugs found while grepping for sched_locking of VMCNT fields: > - v_trap is supposed to be updated by PCPU_LAZY_INC(), but subr_trap.c > updates it by VMCNT_ADD(). The direct access used to be perfectly unlocked > and non-atomic, since it occurs immediately after releasing sched_lock > and just used "++". Now it is atomic and a micro-pessimization. > - v_trap's name is now hidden by the macro so grepping for it doesn't work. I'm still searching for a 1% performance loss in makeworld under UP that occurred just after the VMCNT changes. I've only found this harmless (?) bug so far: % Index: vnode_pager.c % =================================================================== % RCS file: /home/ncvs/src/sys/vm/vnode_pager.c,v % retrieving revision 1.232 % retrieving revision 1.233 % diff -u -2 -r1.232 -r1.233 % --- vnode_pager.c 14 Oct 2006 23:21:48 -0000 1.232 % +++ vnode_pager.c 18 May 2007 07:10:50 -0000 1.233 % @@ -910,6 +910,6 @@ % atomic_add_int(&runningbufspace, bp->b_runningbufspace); % % - cnt.v_vnodein++; % - cnt.v_vnodepgsin += count; ^^^^^ % + VMCNT_ADD(vnodein, 1); % + VMCNT_ADD(vnodepgsin, 1); ^ % % /* do the input */ Related API problem: v_vnodein and v_vnodepgsin are not used in the kernel except to increment them and to export them using sysctl, so they should be incremented using PCPY_LAZY_INC(). However, PCPU_LAZY_INC() can only do increments of 1. The increments of +1 also complicate searching for the regression. After removing `volatile', the VMCNT change should have no effect on the binary, but it has an effect since increments of 1 are replaced by "movl $1,%reg; addl %reg,mem" in i386 code, since the i386 atomic asms don't use incl and the "ir" constraint isn't working as intended (this is with gcc-3.4.6). The "ir" constraint should result in the "i" variant being chosen and generate "addl $1,mem". Bruce