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] [day] [month] [year] [list]
Message-Id: <20090525194221.8fd081c8.akpm@linux-foundation.org>
Date:	Mon, 25 May 2009 19:42:21 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
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

On Thu, 21 May 2009 16:00:22 -0700 Joe Perches <joe@...ches.com> wrote:

> +/*
> + * Do something once (analogous to WARN_ONCE() et al):
> + */
> +#define DO_ONCE(x...) ({			\
> +	static bool __done = false;		\
> +						\
> +	if (!__done) {				\
> +		x;				\
> +		__done = true;			\
> +	}					\
> +})

Every single call site for this macro will be mind-bogglingly ugly and
complex callers won't look like C at all.

It would be much better to replace

	DO_ONCE(code-sequence);

with
	if (ONCE()) {
		code-sequence;
	}

I think that's fairly natural and clear and will allow us to clean up a
large number of callsites many of which do the same thing in different
ways, some of them buggily.

And yeah, if this is to be core kernel infrastructure then the default
implementation shouldn't be racy on SMP/preempt.

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