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:	Thu, 21 May 2009 16:27:42 -0700
From:	Randy Dunlap <randy.dunlap@...cle.com>
To:	Joe Perches <joe@...ches.com>
CC:	linux-kernel@...r.kernel.org, cpufreq@...r.kernel.org,
	Dave Jones <davej@...hat.com>,
	Greg Kroah-Hartman <gregkh@...e.de>,
	"H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...hat.com>,
	x86@...r.kernel.org, Len Brown <len.brown@...el.com>,
	Mike Travis <travis@....com>,
	Rusty Russell <rusty@...tcorp.com.au>,
	Thomas Gleixner <tglx@...utronix.de>,
	Venkatesh Pallipadi <venkatesh.pallipadi@...el.com>
Subject: Re: [PATCH 1/3] kernel.h: Add DO_ONCE statement expression macro

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@...ches.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/
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ