From: Frederic Weisbecker <fweisbec@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Joe Perches <joe@perches.com>,
Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
"H. Peter Anvin" <hpa@zytor.com>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Liu Chuansheng <chuansheng.liu@intel.com>,
Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH 2/3] core: Convert printk_once to use DO_ONCE
Date: Wed, 16 Oct 2013 15:21:23 +0200 [thread overview]
Message-ID: <20131016132121.GA14938@localhost.localdomain> (raw)
In-Reply-To: <20131016085928.5b8f9d95@gandalf.local.home>
On Wed, Oct 16, 2013 at 08:59:28AM -0400, Steven Rostedt wrote:
> On Wed, 16 Oct 2013 13:53:56 +0200
> Frederic Weisbecker <fweisbec@gmail.com> wrote:
>
>
> > static int done;
> >
> > if (!done) {
> > trace_printk(something);
> > trace_printk(something else);
> > trace_dump_stack();
> > done = 1;
> > }
> >
> > Having a DO_ONCE() would help a lot I think.
> >
> > Now we can rename it to __DO_ONCE() and put a big fat comment to avoid it
> > to be misused.
>
> I wonder if we should make it just ONCE(), with no arguments that
> should go into an if statement.
>
>
> if (ONCE())
> do_this_function_once();
Or TRUE_ONCE() may be?
But what don't you like in DO_ONCE()? Its upside is that it consolidate the whole
call.
Also there is still the COND() part to handle. Note that COND things
need to return the condition as well.
Thanks.
>
>
> Where ONCE() is:
>
> ({
> static int __once;
> int __old_once = __once;
>
> __once = 1;
> __old_once;
> })
>
> Or the xchg version:
>
> ({
> static int __once;
>
> if (!__once)
> xchg(&__once, 1);
> else
> 1;
> })
>
> -- Steve
next prev parent reply other threads:[~2013-10-16 13:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-15 20:50 [RFC PATCH 0/3] headers: Consolidate once/cond style macros Frederic Weisbecker
2013-10-15 20:50 ` [PATCH 1/3] core: New macro to execute code only once Frederic Weisbecker
2013-10-15 20:50 ` [PATCH 2/3] core: Convert printk_once to use DO_ONCE Frederic Weisbecker
2013-10-15 21:00 ` Joe Perches
2013-10-15 21:12 ` Frederic Weisbecker
2013-10-15 21:24 ` Joe Perches
2013-10-16 11:53 ` Frederic Weisbecker
2013-10-16 12:59 ` Steven Rostedt
2013-10-16 13:21 ` Frederic Weisbecker [this message]
2013-10-15 20:50 ` [PATCH 3/3] bug: Convert warn macros to use once and cond helpers Frederic Weisbecker
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=20131016132121.GA14938@localhost.localdomain \
--to=fweisbec@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=chuansheng.liu@intel.com \
--cc=hpa@zytor.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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