From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S266170AbUGAQzG (ORCPT ); Thu, 1 Jul 2004 12:55:06 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S266132AbUGAQxd (ORCPT ); Thu, 1 Jul 2004 12:53:33 -0400 Received: from parcelfarce.linux.theplanet.co.uk ([195.92.249.252]:46801 "EHLO www.linux.org.uk") by vger.kernel.org with ESMTP id S266105AbUGAQw1 (ORCPT ); Thu, 1 Jul 2004 12:52:27 -0400 Message-ID: <40E4413B.5050000@pobox.com> Date: Thu, 01 Jul 2004 12:52:11 -0400 From: Jeff Garzik User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.6) Gecko/20040510 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Linus Torvalds CC: Alan Cox , Pavel Machek , vojtech@suse.cz, James Bottomley , Andrew Morton , Paul Jackson , Linux Kernel Mailing List , PARISC list Subject: Re: [parisc-linux] Re: [PATCH] Fix the cpumask rewrite References: <1088266111.1943.15.camel@mulgrave> <1088268405.1942.25.camel@mulgrave> <20040701131158.GP698@openzaurus.ucw.cz> <1088690821.4621.11.camel@localhost.localdomain> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Linus Torvalds wrote: > It _happens_ to be one on x86, so sadly it works on 99% of the machines > out there. And to avoid the extra (suprefluous) mb(), there are > > smp_mb__before_clear_bit() > smp_mb__after_clear_bit() > > that only works with "clear_bit()", on the assumption that the way you'd > do locking is: > > lock: > while (test_and_set_bit(..)) /* This is a memory barrier */ > while (test_bit(..)) > cpu_relax(); > > .. protected region .. > > unlock: > smp_mb__before_clear_bit(); > clear_bit(..); FWIW one of the major uses of bitops currently is e.g. in include/linux/netdevice.h, where bitops are used for atomic selection of code paths, but not spinning: static inline void netif_carrier_off(struct net_device *dev) { if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state)) linkwatch_fire_event(dev); }