[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
|
|
Subscribe / Log in / New account

Re: use of preempt_count instead of in_atomic() at leds-gpio.c

From:  Alan Stern <stern-AT-rowland.harvard.edu>
To:  Andrew Morton <akpm-AT-linux-foundation.org>
Subject:  Re: use of preempt_count instead of in_atomic() at leds-gpio.c
Date:  Fri, 21 Mar 2008 14:05:59 -0400 (EDT)
Message-ID:  <Pine.LNX.4.44L0.0803211343240.24421-100000@netrider.rowland.org>
Cc:  Jean Delvare <khali-AT-linux-fr.org>, Michael Buesch <mb-AT-bu3sch.de>, Henrique de Moraes Holschuh <hmh-AT-hmh.eng.br>, David Brownell <david-b-AT-pacbell.net>, Richard Purdie <rpurdie-AT-rpsys.net>, Kernel development list <linux-kernel-AT-vger.kernel.org>, Ingo Molnar <mingo-AT-elte.hu>, Geert Uytterhoeven <geert-AT-linux-m68k.org>, Jonathan Corbet <corbet-AT-lwn.net>
Archive‑link:  Article

On Fri, 21 Mar 2008, Andrew Morton wrote:

> On Fri, 21 Mar 2008 10:53:11 +0100 Jean Delvare <khali@linux-fr.org> wrote:
> 
> > On Thu, 20 Mar 2008 20:17:23 -0700, Andrew Morton wrote:
> > > in_atomic() is for core kernel use only.  (...)
> > 
> > Then why is it made available to drivers through <linux/hardirq.h>?
> 
> Because we suck.
> 
> > If
> > it's such a dangerous macro to call from drivers, it shouldn't be made
> > available, or at the very least there should be a big fat warning in
> > <linux/hardirq.h> that drivers aren't supposed to use it. This would
> > have avoided the 23 uses cases in drivers we have right now.
> 
> True.

There's also a section about in_atomic() in the Linux Device Drivers 
(3rd ed.) book which may have contributed to the confusion.  On p. 198:

	A function related to in_interrupt() is in_atomic().  Its 
	return value is nonzero whenever scheduling is not allowed;
	this includes hardware and software interrupt contexts as well
	as any time when a spinlock is held.  In the latter case, 
	current may be valid, but access to user space is forbidden, 
	since it can cause scheduling to happen.  Whenever you are
	using in_interrupt(), you should really consider whether 
	in_atomic() is what you actually mean.  Both functions are
	declared in <asm/hardirq.h>.

Alan Stern




to post comments


Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds