From: Randy Dunlap <randy.dunlap@oracle.com>
To: Joe Perches <joe@perches.com>
Cc: linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org,
Dave Jones <davej@redhat.com>,
Greg Kroah-Hartman <gregkh@suse.de>,
"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>,
x86@vger.kernel.org, Len Brown <len.brown@intel.com>,
Mike Travis <travis@sgi.com>,
Rusty Russell <rusty@rustcorp.com.au>,
Thomas Gleixner <tglx@linutronix.de>,
Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Subject: Re: [PATCH 1/3] kernel.h: Add DO_ONCE statement expression macro
Date: Thu, 21 May 2009 16:27:42 -0700 [thread overview]
Message-ID: <4A15E36E.9080501@oracle.com> (raw)
In-Reply-To: <7b063fda0675875d51a5da49f59e89520d025eee.1242943463.git.joe@perches.com>
Joe Perches wrote:
> Add a DO_ONCE statement expression analogous to printk_once
> that executes any arbitrary statement exactly once.
>
> This will take the place of printk_once so that
> DO_ONCE(pr_<foo>) or any other statement performed
> a single time may be easily written.
>
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> include/linux/kernel.h | 12 ++++++++++++
> 1 files changed, 12 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 883cd44..a5520c9 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -637,6 +637,18 @@ static inline void ftrace_dump(void) { }
> #define swap(a, b) \
> do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
>
> +/*
> + * Do something once (analogous to WARN_ONCE() et al):
> + */
> +#define DO_ONCE(x...) ({ \
> + static bool __done = false; \
> + \
> + if (!__done) { \
> + x; \
> + __done = true; \
Hi Joe,
Since x is of arbitrary size & time duration, I think that x; should follow
__done = true;
instead of being before it, as was done in printk_once(). Otherwise there
could be a sizable window there x could be done more than once.
> + } \
> +})
> +
> /**
> * container_of - cast a member of a structure out to the containing structure
> * @ptr: the pointer to the member.
--
~Randy
LPC 2009, Sept. 23-25, Portland, Oregon
http://linuxplumbersconf.org/2009/
next prev parent reply other threads:[~2009-05-21 23:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-21 23:00 [PATCH 0/3] Introduce and use " Joe Perches
2009-05-21 23:00 ` [PATCH 1/3] kernel.h: Add " Joe Perches
2009-05-21 23:27 ` Randy Dunlap [this message]
2009-05-21 23:32 ` Joe Perches
2009-05-21 23:36 ` H. Peter Anvin
2009-05-21 23:41 ` Alan Cox
2009-05-22 0:27 ` Al Viro
2009-05-22 1:09 ` Joe Perches
2009-05-25 6:45 ` Rusty Russell
2009-05-26 2:42 ` Andrew Morton
2009-05-21 23:00 ` [PATCH 2/3] arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c: Use DO_ONCE & spelling fix Joe Perches
2009-05-21 23:26 ` Dave Jones
2009-05-21 23:34 ` Joe Perches
2009-05-21 23:47 ` Dave Jones
2009-05-21 23:52 ` Joe Perches
2009-05-21 23:00 ` [PATCH 3/3] kernel.h: Remove unused printk_once Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A15E36E.9080501@oracle.com \
--to=randy.dunlap@oracle.com \
--cc=cpufreq@vger.kernel.org \
--cc=davej@redhat.com \
--cc=gregkh@suse.de \
--cc=hpa@zytor.com \
--cc=joe@perches.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rusty@rustcorp.com.au \
--cc=tglx@linutronix.de \
--cc=travis@sgi.com \
--cc=venkatesh.pallipadi@intel.com \
--cc=x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome