From: greg@kroah.com (Greg KH)
To: kernelnewbies@lists.kernelnewbies.org
Subject: should drivers avoid the use of in_atomic()?
Date: Sun, 15 May 2011 12:41:05 -0700 [thread overview]
Message-ID: <20110515194105.GA26744@kroah.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1105151519020.27678@localhost6.localdomain6>
On Sun, May 15, 2011 at 03:22:10PM -0400, Robert P. J. Day wrote:
>
> perusing some timer-related kernel stuff and i ran across this in
> include/linux/hardirq.h:
>
> /*
> * Are we running in atomic context? WARNING: this macro cannot
> * always detect atomic context; in particular, it cannot know about
> * held spinlocks in non-preemptible kernels. Thus it should not be
> * used in the general case to determine whether sleeping is possible.
> * Do not use in_atomic() in driver code.
> */
> #define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != PREEMPT_INATOMIC_BASE)
>
> but a quick check shows a sprinkling of in_atomic() checks in the
> drivers/ directory. is that admonition overly strict? or what?
No, it's right, using it is wrong, but unfortunatly, it sometimes is the
best that we have to use. Fixing this in the drivers would be great to
do, feel free to add it to the kernel janitor's TODO list.
greg k-h
prev parent reply other threads:[~2011-05-15 19:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-15 19:22 should drivers avoid the use of in_atomic()? Robert P. J. Day
2011-05-15 19:41 ` Greg KH [this message]
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=20110515194105.GA26744@kroah.com \
--to=greg@kroah.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/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;
as well as URLs for NNTP newsgroup(s).