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: <4D827326.1040208@linux.intel.com>
Date:	Thu, 17 Mar 2011 13:46:30 -0700
From:	Darren Hart <dvhart@...ux.intel.com>
To:	Steven Rostedt <rostedt@...dmis.org>
CC:	linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...e.hu>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Peter Zijlstra <peterz@...radead.org>,
	Lai Jiangshan <laijs@...fujitsu.com>
Subject: Re: [PATCH 1/2] WARN_ON_SMP(): Allow use in if statements on UP



On 03/17/2011 12:21 PM, Steven Rostedt wrote:
> From: Steven Rostedt<srostedt@...hat.com>
>
> Both WARN_ON() and WARN_ON_SMP() should be able to be used in
> an if statement.
>
> 	if (WARN_ON_SMP(foo)) { ... }
>
> Because WARN_ON_SMP() is defined as a do { } while (0) on UP,
> it can not be used this way.
>
> Convert it to the same form that WARN_ON() is, even when
> CONFIG_SMP is off.
>
> Signed-off-by: Steven Rostedt<rostedt@...dmis.org>
> ---
>   include/asm-generic/bug.h |   28 +++++++++++++++++++++++++++-
>   1 files changed, 27 insertions(+), 1 deletions(-)
>
> diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
> index c2c9ba0..ac2f48a 100644
> --- a/include/asm-generic/bug.h
> +++ b/include/asm-generic/bug.h
> @@ -165,10 +165,36 @@ extern void warn_slowpath_null(const char *file, const int line);
>   #define WARN_ON_RATELIMIT(condition, state)			\
>   		WARN_ON((condition)&&  __ratelimit(state))
>
> +/*
> + * WARN_ON_SMP() is for cases that the warning is either
> + * meaningless for !SMP or may even cause failures.
> + * This is usually used for cases that we have
> + * WARN_ON(!spin_is_locked(&lock)) checks, as spin_is_locked()
> + * returns 0 for uniprocessor settings.
> + * It can be also be used with values that are only defined

Typo: can be also be

--
Darren

> + * on SMP:
> + *
> + * struct foo {
> + *  [...]
> + * #ifdef CONFIG_SMP
> + *	int bar;
> + * #endif
> + * };
> + *
> + * void func(struct foo *zoot)
> + * {
> + *	WARN_ON_SMP(!zoot->bar);
> + *
> + * For CONFIG_SMP, WARN_ON_SMP() should act the same as WARN_ON(),
> + * and should be a nop and return false for uniprocessor.
> + *
> + * if (WARN_ON_SMP(x)) returns true only when CONFIG_SMP is set
> + * and x is true.
> + */
>   #ifdef CONFIG_SMP
>   # define WARN_ON_SMP(x)			WARN_ON(x)
>   #else
> -# define WARN_ON_SMP(x)			do { } while (0)
> +# define WARN_ON_SMP(x)			({0;})
>   #endif
>
>   #endif
> -- 1.7.2.3

-- 
Darren Hart
Intel Open Source Technology Center
Yocto Project - Linux Kernel
--
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