From owner-svn-src-all@FreeBSD.ORG Tue Jan 26 15:37:54 2010 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 A1706106568D; Tue, 26 Jan 2010 15:37:54 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 70FCD8FC08; Tue, 26 Jan 2010 15:37:54 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 0893746B2A; Tue, 26 Jan 2010 10:37:54 -0500 (EST) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPA id 38C428A01F; Tue, 26 Jan 2010 10:37:53 -0500 (EST) From: John Baldwin To: Attilio Rao Date: Tue, 26 Jan 2010 09:43:38 -0500 User-Agent: KMail/1.12.1 (FreeBSD/7.2-CBSD-20100120; KDE/4.3.1; amd64; ; ) References: <201001231554.o0NFsMbx049837@svn.freebsd.org> <201001251456.32459.jhb@freebsd.org> <3bbf2fe11001260058i65604619l664bd0e49c1dbbd@mail.gmail.com> In-Reply-To: <3bbf2fe11001260058i65604619l664bd0e49c1dbbd@mail.gmail.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201001260943.38609.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Tue, 26 Jan 2010 10:37:53 -0500 (EST) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Warner Losh Subject: Re: svn commit: r202889 - head/sys/kern 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: Tue, 26 Jan 2010 15:37:54 -0000 On Tuesday 26 January 2010 3:58:45 am Attilio Rao wrote: > Finally, I really don't think the BLOCK_SPIN() performance improvement > you suggest should really make a difference (assuming how rarely it > should happen) because, please note, that the cmpxchg is necessary as > we need to enforce a memory barrier when doing the check in anyway (so > the first case should be however an atomic_cmpset_X_Y()). Note that Intel specifically mentions in the app note that introduced 'pause' that one should not sit in a spin loop that bangs on cmpxchg due to the extra cache contention it causes. Also, I did not say to remove the cmpxchg, but to only do it if a 'cmp' indicates it should work. We already do this now for mtx_lock_spin() in C with something like this: while (!atomic_cmpset_acq_ptr(...)) { while (m->mtx_lock != MTX_UNOWNED) { cpu_spinwait(); } } The idea is to do "cheap" compares that do not require an exclusive hold on the cache line until you have a reason to think that the cmpxchg will "work". > Last thinking: it is not a very good idea cpu_switch() is made > conditional in regard of schedulers, but there is not an easy way to > do that as long as the safe points for releasing blocked_lock happens > within cpu_switch(). I think that is one of the reasons why some > people (maybe you or Jeff) pushed for having cpu_switch() made in C. Would the complicated version of BLOCK_SWITCH() work ok for the sched_4bsd and ULE/UP case and just devolve into normally not spinning? -- John Baldwin