Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S263850AbTEWHJL (ORCPT ); Fri, 23 May 2003 03:09:11 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S263855AbTEWHJL (ORCPT ); Fri, 23 May 2003 03:09:11 -0400 Received: from thebsh.namesys.com ([212.16.7.65]:57791 "HELO thebsh.namesys.com") by vger.kernel.org with SMTP id S263850AbTEWHJJ (ORCPT ); Fri, 23 May 2003 03:09:09 -0400 From: Nikita Danilov MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16077.52259.718519.389903@laputa.namesys.com> Date: Fri, 23 May 2003 11:22:11 +0400 X-PGP-Fingerprint: 43CE 9384 5A1D CD75 5087 A876 A1AA 84D0 CCAA AC92 X-PGP-Key-ID: CCAAAC92 X-PGP-Key-At: http://wwwkeys.pgp.net:11371/pks/lookup?op=get&search=0xCCAAAC92 To: "Robert White" Cc: "Nick Piggin" , , "Rik van Riel" , "David Woodhouse" , , "William Lee Irwin III" , "Martin J. Bligh" , , Subject: Re: recursive spinlocks. Shoot. In-Reply-To: References: <3ECC4C3A.9000903@cyberone.com.au> X-Mailer: ed | telnet under Fuzzball OS, emulated on Emacs 21.5 (beta11) "cabbage" XEmacs Lucid X-Tom-Swifty: "The ASCII standard sucks," Tom said characteristically. Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1148 Lines: 57 Robert White writes: > This will, hopefully, be my out-comment on this thread. > [...] > > 4) All locks (spin or otherwise) should obviously be held for the shortest > amount of time reasonably possible which still produces the correct result. > > If this needs explaining... 8-) It surely does. Consider two loops: (1) spin_lock(&lock); list_for_each_entry(item, ...) { do something with item; } spin_unlock(&lock); versus (2) list_for_each_entry(item, ...) { spin_lock(&lock); do something with item; spin_unlock(&lock); } and suppose they both are equally correct. Now, in (2) total amount of time &lock is held is smaller than in (1), but (2) will usually perform worse on SMP, because: . spin_lock() is an optimization barrier . taking even un-contended spin lock is an expensive operation, because of the cache coherency issues. > [...] > > Rob. > Nikita. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/