Messages in this thread | | | Date | Fri, 22 May 2009 00:41:27 +0100 | From | Alan Cox <> | Subject | Re: [PATCH 1/3] kernel.h: Add DO_ONCE statement expression macro |
| |
> Add a DO_ONCE statement expression analogous to printk_once > that executes any arbitrary statement exactly once.
Your implementation is racy. Its also hiding stuff in macro magic which is asking for accidents to happen.
The natural kernel way to write this is
if (!test_and_set_bit(....))
which is a lot more obvious than a magic macro, doesn't race and can use other bits in an existing set of flags and be used as a "do-once-for-this-object-instance" - which is almost always want you want.
Alan
| |