On Tue, Jun 22, 2010 at 10:00:54PM +0800, Peter Zijlstra wrote: > On Tue, 2010-06-22 at 21:52 +0800, Wu Fengguang wrote: > > #include <stdio.h> > > > > typedef struct { > > int counter; > > } atomic_t; > > > > static inline int atomic_dec_and_test(atomic_t *v) > > { > > unsigned char c; > > > > asm volatile("lock; decl %0; sete %1" > > : "+m" (v->counter), "=qm" (c) > > : : "memory"); > > return c != 0; > > } > > > > int main(void) > > { > > atomic_t i; > > > > i.counter = 100000000; > > > > for (; !atomic_dec_and_test(&i);) > > ; > > > > return 0; > > } > > This test utterly fails to stress the concurrency, you want to create > nr_cpus threads and then pound the global variable. Then compare it > against the per-cpu-counter variant. I mean to test an atomic value that is mainly visited by one single CPU. It sounds not reasonable for the IO completion IRQs to land randomly on every CPU in the system.. when the IOs are submitted mostly by a dedicated thread and to one single BDI (but yes, the BDI may be some "compound" device). Thanks, Fengguang -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html