* Calling printk with locks held
@ 2011-06-02 20:43 Neil Baylis
2011-06-02 22:45 ` Mulyadi Santosa
2011-06-02 22:54 ` Dave Hylands
0 siblings, 2 replies; 3+ messages in thread
From: Neil Baylis @ 2011-06-02 20:43 UTC (permalink / raw)
To: kernelnewbies
I've just been told that it's not OK to call printk while holding a lock.
This came as a surprise to me, as I've written thousands of lines of code
that calls printk while holding multiple locks, and have not seen any
problem. The only explanation I was given was that it can deadlock.
Is this correct? I thought there were very few places where it was not safe
to call printk.
Neil Baylis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110602/5d2ee90a/attachment.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Calling printk with locks held
2011-06-02 20:43 Calling printk with locks held Neil Baylis
@ 2011-06-02 22:45 ` Mulyadi Santosa
2011-06-02 22:54 ` Dave Hylands
1 sibling, 0 replies; 3+ messages in thread
From: Mulyadi Santosa @ 2011-06-02 22:45 UTC (permalink / raw)
To: kernelnewbies
Hi...
On Fri, Jun 3, 2011 at 03:43, Neil Baylis <neil.baylis@gmail.com> wrote:
> I've just been told that it's not OK to call printk while holding a lock.
perhaps that is lock related to terminal?
> This came as a surprise to me, as I've written thousands of lines of code
> that calls printk while holding multiple locks, and have not seen any
> problem. The only explanation I was given was that it can deadlock.
> Is this correct? I thought there were very few places where it was not safe
> to call printk.
> Neil Baylis
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
--
regards,
Mulyadi Santosa
Freelance Linux trainer and consultant
blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Calling printk with locks held
2011-06-02 20:43 Calling printk with locks held Neil Baylis
2011-06-02 22:45 ` Mulyadi Santosa
@ 2011-06-02 22:54 ` Dave Hylands
1 sibling, 0 replies; 3+ messages in thread
From: Dave Hylands @ 2011-06-02 22:54 UTC (permalink / raw)
To: kernelnewbies
Hi Neil,
On Thu, Jun 2, 2011 at 1:43 PM, Neil Baylis <neil.baylis@gmail.com> wrote:
> I've just been told that it's not OK to call printk while holding a lock.
> This came as a surprise to me, as I've written thousands of lines of code
> that calls printk while holding multiple locks, and have not seen any
> problem. The only explanation I was given was that it can deadlock.
> Is this correct? I thought there were very few places where it was not safe
> to call printk.
In general I don't think that there's any issue with calling printk
with locks held. If the lock was held within the console driver using
to send the printk data you might have trouble. I know its fine (but
not recommended for performance reasons) to call printk from interrupt
context.
printk uses the "try" variant on its own locks and if it can't get
that lock then it just adds the data to its internal buffer and
doesn't try to output anything.
--
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-06-02 22:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-02 20:43 Calling printk with locks held Neil Baylis
2011-06-02 22:45 ` Mulyadi Santosa
2011-06-02 22:54 ` Dave Hylands
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).