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]
Message-ID: <20131015163559.2a25b8d9@gandalf.local.home>
Date:	Tue, 15 Oct 2013 16:35:59 -0400
From:	Steven Rostedt <rostedt@...dmis.org>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	"H. Peter Anvin" <hpa@...ux.intel.com>,
	Ingo Molnar <mingo@...nel.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Frederic Weisbecker <fweisbec@...il.com>,
	"Liu, Chuansheng" <chuansheng.liu@...el.com>,
	Borislav Petkov <bp@...en8.de>
Subject: Re: [PATCH] bug: Use xchg() to update WARN_ON_ONCE() static
 variable

On Tue, 15 Oct 2013 13:12:59 -0700
Andrew Morton <akpm@...ux-foundation.org> wrote:

 
> Also, we're now incurring an atomic op for every "call".  Presumably
> these calls are rare, but not necessarily - one can envisage uses of a
> generic ONCE() which are called at high frequency.  Should we avoid
> that with
> 
> #define ONCE() ({
> 	static int state;
> 	int ret;
> 
> 	if (likely(state))
> 		ret = 0;
> 	else
> 		ret = !xchg(&state, 1);
> 	ret;
> })

I was talking with Boris on IRC about having a shortcut if "state" is
already true. I argued against it, but that was just for the WARN()
operations because I rather add a LOCK xchg, then more branches to hot
paths.

But for a generic ONCE() function, I guess we would want the shortcut
as it may be used by something that gets hit all the time with a normal
kernel.

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

Powered by Openwall GNU/*/Linux Powered by OpenVZ