Re: [PATCH 1/3] kernel.h: Add DO_ONCE statement expression macro

From: Alan Cox
Date: Thu May 21 2009 - 19:41:32 EST


> 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
--
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/