Re: [parisc-linux] Re: [PATCH] Fix the cpumask rewrite
From: Jeff Garzik
Date: Thu Jul 01 2004 - 11:59:26 EST
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);
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/