public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* On "ratelimit: Use per ratelimit context locking"
@ 2009-12-20 11:39 Stefan Richter
  2009-12-28  9:53 ` Ingo Molnar
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Richter @ 2009-12-20 11:39 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel, Jay Fenlason

Hi Ingo,

in pre 2.6.33-rc1 commit 979f693d you wrote: "I'd like to use
printk_ratelimit() in atomic context, but that's not possible right now
due to the spinlock usage this commit introduced more than a year ago:
717115e: printk ratelimiting rewrite".¹,²

By not possible, do you mean it would be an outright bug to call
printk_ratelimit in atomic context prior to 979f693d, or merely a
performance issue?  If the former, under which circumstances would the
bug hit?

I'm asking because one of my commits actually introduced a
printk_ratelimit use in an interrupt handler shortly before 2.6.32 was
released.  In my testing, it didn't occur to me that there might be a
problem.

¹http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=979f693def9084a452846365dfde5dcb28366333
²http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=717115e1a5856b57af0f71e1df7149108294fc10
-- 
Stefan Richter
-=====-==--= ==-- =-=--
http://arcgraph.de/sr/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: On "ratelimit: Use per ratelimit context locking"
  2009-12-20 11:39 On "ratelimit: Use per ratelimit context locking" Stefan Richter
@ 2009-12-28  9:53 ` Ingo Molnar
  2009-12-29  1:56   ` Stefan Richter
  0 siblings, 1 reply; 3+ messages in thread
From: Ingo Molnar @ 2009-12-28  9:53 UTC (permalink / raw)
  To: Stefan Richter, Peter Zijlstra, Andrew Morton; +Cc: linux-kernel, Jay Fenlason


* Stefan Richter <stefanr@s5r6.in-berlin.de> wrote:

> Hi Ingo,
> 
> in pre 2.6.33-rc1 commit 979f693d you wrote: "I'd like to use
> printk_ratelimit() in atomic context, but that's not possible right now
> due to the spinlock usage this commit introduced more than a year ago:
> 717115e: printk ratelimiting rewrite".?,?
> 
> By not possible, do you mean it would be an outright bug to call
> printk_ratelimit in atomic context prior to 979f693d, or merely a
> performance issue?  If the former, under which circumstances would the
> bug hit?
> 
> I'm asking because one of my commits actually introduced a
> printk_ratelimit use in an interrupt handler shortly before 2.6.32 was
> released.  In my testing, it didn't occur to me that there might be a
> problem.
> 
> ?http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=979f693def9084a452846365dfde5dcb28366333
> ?http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=717115e1a5856b57af0f71e1df7149108294fc10

There used to be a global lock:

  static DEFINE_SPINLOCK(ratelimit_lock);

which is now per ratelimit context. The case i was after was to use the 
ratelimit state from NMI context. With NMIs we can lock up if an NMI hits when 
some other code uses the ratelimit code. It's a small but existing race 
window.

OTOH, IRQ context use of printk ratelimit was safe before (and after) this 
commit - so i think your code should be safe too.

Hope that helps,

	Ingo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: On "ratelimit: Use per ratelimit context locking"
  2009-12-28  9:53 ` Ingo Molnar
@ 2009-12-29  1:56   ` Stefan Richter
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Richter @ 2009-12-29  1:56 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Peter Zijlstra, Andrew Morton, linux-kernel, Jay Fenlason

Ingo Molnar wrote:
> There used to be a global lock:
> 
>   static DEFINE_SPINLOCK(ratelimit_lock);
> 
> which is now per ratelimit context. The case i was after was to use the 
> ratelimit state from NMI context. With NMIs we can lock up if an NMI hits when 
> some other code uses the ratelimit code. It's a small but existing race 
> window.

Ah, I see.

> OTOH, IRQ context use of printk ratelimit was safe before (and after) this 
> commit - so i think your code should be safe too.

Thanks for the explanation; that's reassuring.
-- 
Stefan Richter
-=====-==--= ==-- ===-=
http://arcgraph.de/sr/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-12-29  2:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-20 11:39 On "ratelimit: Use per ratelimit context locking" Stefan Richter
2009-12-28  9:53 ` Ingo Molnar
2009-12-29  1:56   ` Stefan Richter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox