From: Andrew Morton <akpm@linux-foundation.org>
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: linux-kernel@vger.kernel.org,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH] Fix uninitialized spinlock of printk_ratelimited()
Date: Wed, 19 May 2010 13:26:59 -0700 [thread overview]
Message-ID: <20100519132659.b787d17f.akpm@linux-foundation.org> (raw)
In-Reply-To: <87hbm7e6x9.fsf@devron.myhome.or.jp>
On Mon, 17 May 2010 08:57:38 +0900
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> wrote:
> ratelimit_state initialization of printk_ratelimited() seems
> broken. This fixes it by using DEFINE_RATELIMIT_STATE() to initialize
> spinlock properly.
>
> Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
> ---
>
> include/linux/kernel.h | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff -puN include/linux/kernel.h~printk_ratelimited-fix include/linux/kernel.h
> --- linux-2.6/include/linux/kernel.h~printk_ratelimited-fix 2010-05-17 03:37:33.000000000 +0900
> +++ linux-2.6-hirofumi/include/linux/kernel.h 2010-05-17 03:37:33.000000000 +0900
> @@ -420,14 +420,13 @@ static inline char *pack_hex_byte(char *
> * no local ratelimit_state used in the !PRINTK case
> */
> #ifdef CONFIG_PRINTK
> -#define printk_ratelimited(fmt, ...) ({ \
> - static struct ratelimit_state _rs = { \
> - .interval = DEFAULT_RATELIMIT_INTERVAL, \
> - .burst = DEFAULT_RATELIMIT_BURST, \
> - }; \
> - \
> - if (__ratelimit(&_rs)) \
> - printk(fmt, ##__VA_ARGS__); \
> +#define printk_ratelimited(fmt, ...) ({ \
> + static DEFINE_RATELIMIT_STATE(_rs, \
> + DEFAULT_RATELIMIT_INTERVAL, \
> + DEFAULT_RATELIMIT_BURST); \
> + \
> + if (__ratelimit(&_rs)) \
> + printk(fmt, ##__VA_ARGS__); \
> })
hm, yes, that spinlock will get the all-zeroes pattern.
It's been like this since December 2009. I'm a bit surprised that none
of our spinlock-debugging goodies picked this up. All the
CONFIG_DEBUG_SPINLOCK spinlock fields end up zeroed out also.
next prev parent reply other threads:[~2010-05-19 20:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-16 23:57 [PATCH] Fix uninitialized spinlock of printk_ratelimited() OGAWA Hirofumi
2010-05-19 20:26 ` Andrew Morton [this message]
2010-05-19 20:44 ` OGAWA Hirofumi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100519132659.b787d17f.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=a.p.zijlstra@chello.nl \
--cc=hirofumi@mail.parknet.co.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox