lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 16 Oct 2013 08:59:28 -0400
From:	Steven Rostedt <rostedt@...dmis.org>
To:	Frederic Weisbecker <fweisbec@...il.com>
Cc:	Joe Perches <joe@...ches.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	LKML <linux-kernel@...r.kernel.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	"H. Peter Anvin" <hpa@...or.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Liu Chuansheng <chuansheng.liu@...el.com>,
	Ingo Molnar <mingo@...nel.org>
Subject: Re: [PATCH 2/3] core: Convert printk_once to use DO_ONCE

On Wed, 16 Oct 2013 13:53:56 +0200
Frederic Weisbecker <fweisbec@...il.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();


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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists