From: Al Viro <viro@ZenIV.linux.org.uk>
To: "majun (F)" <majun258@huawei.com>
Cc: ebiederm@xmission.com, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org,
dhowells@redhat.com, Waiman.Long@hp.com, dingtianhong@huawei.com,
guohanjun@huawei.com, fanjinke1@huawei.com
Subject: Re: [PATCH] Change the spin_lock/unlock_irq interface in proc_alloc_inum() function
Date: Wed, 2 Mar 2016 17:29:54 +0000 [thread overview]
Message-ID: <20160302172954.GI17997@ZenIV.linux.org.uk> (raw)
In-Reply-To: <56D688FC.9020202@huawei.com>
On Wed, Mar 02, 2016 at 02:32:28PM +0800, majun (F) wrote:
> Sorry,I made a wrong example for this problem.
> I want to say this interface may change the irq status after this function
> be called.
It can't - either it's called with irqs enabled, in which case it returns
the same way, or it's called with irqs disabled, in which case it's a trouble
waiting to happen as soon as the allocation there (or in proc_mkdir(), etc.)
happens to block and failure to restore irq state is the least of your
concerns, because when you return from schedule() you *will* have irq enabled,
no matter what.
Take a look at __schedule():
...
local_irq_disable();
rcu_note_context_switch();
/*
* Make sure that signal_pending_state()->signal_pending() below
* can't be reordered with __set_current_state(TASK_INTERRUPTIBLE)
* done by the caller to avoid the race with signal_wake_up().
*/
smp_mb__before_spinlock();
raw_spin_lock(&rq->lock);
...
rq = context_switch(rq, prev, next); /* unlocks the rq */
and in context_switch() (right after switch_to()) we call finish_task_switch(),
which calls finish_lock_switch(), which does raw_spin_unlock_irq(&rq->lock),
which does local_irq_enable().
And no, it doesn't save the irq state anywhere - both disable and enable
are unconditional. schedule() always returns with irqs enabled.
Don't call blocking things with irqs disabled. If design of some of your
drivers depends on being able to do that, sorry, but it'll have to be changed.
next prev parent reply other threads:[~2016-03-02 17:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-02 2:47 [PATCH] Change the spin_lock/unlock_irq interface in proc_alloc_inum() function MaJun
2016-03-02 3:09 ` Al Viro
2016-03-02 6:32 ` majun (F)
2016-03-02 17:29 ` Al Viro [this message]
2016-03-02 17:57 ` Al Viro
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=20160302172954.GI17997@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=Waiman.Long@hp.com \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=dingtianhong@huawei.com \
--cc=ebiederm@xmission.com \
--cc=fanjinke1@huawei.com \
--cc=guohanjun@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=majun258@huawei.com \
/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