From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: paulmck@linux.vnet.ibm.com
Cc: Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] rcu: don't call rcu_preempt_note_context_switch() in rcu_check_callbacks()
Date: Thu, 01 Apr 2010 08:56:05 +0800 [thread overview]
Message-ID: <4BB3EF25.1040804@cn.fujitsu.com> (raw)
In-Reply-To: <20100331153656.GA4623@linux.vnet.ibm.com>
Paul E. McKenney wrote:
> On Tue, Mar 30, 2010 at 09:03:39AM -0700, Paul E. McKenney wrote:
>> On Tue, Mar 30, 2010 at 05:43:33PM +0800, Lai Jiangshan wrote:
>>> Paul E. McKenney wrote:
>>>> On Mon, Mar 29, 2010 at 10:47:59AM +0800, Lai Jiangshan wrote:
>>>>> Content-Type: text/plain; charset=UTF-8
>>>>> Content-Transfer-Encoding: 7bit
>>>>>
>>>>>
>>>>> Even though in user mode or idle mode, rcu_check_callbacks() is not
>>>>> context switch, so we don't call rcu_preempt_note_context_switch()
>>>>> in rcu_check_callbacks().
>>>>>
>>>>> Though there is no harm that calls rcu_preempt_note_context_switch()
>>>>> in rcu_check_callbacks(), but it is waste.
>>>>>
>>>>> rcu_check_callbacks()
>>>>> rcu_sched_qs()
>>>>> rcu_preempt_note_context_switch()
>>>>> Now, ->rcu_read_lock_nesting == 0, so we just calls
>>>>> rcu_preempt_qs(), but, rcu_preempt_check_callbacks()
>>>>> will call it again and set the ->rcu_read_unlock_special
>>>>> correct again.
>>>>>
>>>>> So let rcu_preempt_check_callbacks() handle things for us.
>>>> Nice!!!
>>>>
>>>> But how about naming the new function that invokes
>>>> rcu_preempt_note_context_switch() something like
>>>> rcu_sched_note_context_switch(), and then leaving the
>>>> name of rcu_sched_qs() the same (rather than changing
>>>> it to __rcu_sched_qs(), as below)?
>>>>
>>>> This way, the names clearly call out what the function
>>>> is doing.
>>>>
>>> If I understand right, it will become this:
>>>
>>> schedule() / run_ksoftirqd() / rcu_needs_cpu()
>>> rcu_sched_note_context_switch()
>>> rcu_sched_qs()
>>> rcu_preempt_note_context_switch()
>> Wow!!! That was a scare!!! I misread "run_ksoftirqd()" as
>> "do_softirq(). ;-)
>>
>> And I am not seeing a call to rcu_sched_qs() in rcu_needs_cpu()...
>>
>> Here is how I believe it needs to go:
>>
>> schedule():
>> rcu_sched_note_context_switch()
>> rcu_sched_qs()
>> rcu_preempt_note_context_switch()
>>
>> run_ksoftirqd():
>> rcu_sched_qs()
>>
>> rcu_check_callbacks():
>> rcu_sched_qs() [if idle etc.]
>> rcu_bh_qs() [if not in softirq]
>>
>> The reason we don't need rcu_bh_qs() from run_ksoftirqd() is that
>> __do_softirq() already calls rcu_bh_qs().
>>
>> Make sense, or am I missing something?
>
> And I was in fact missing something. The rcu_preempt_note_context_switch()
> function currently combines some work that needs to happen only at
> context-switch time with work that needs to happen all the time.
>
> At first glance, it appears that the big "if" statement in
> rcu_preempt_note_context_switch() need only happen for context switches.
> The remaining lines must happen unconditionally for context switches,
> and should be executed from rcu_check_callbacks() only if the current
> CPU is not in an RCU read-side critical section.
>
I think rcu_preempt_check_callbacks() will do this work better
in rcu_check_callbacks().
Thanks, Lai
next prev parent reply other threads:[~2010-04-01 0:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-29 2:47 [PATCH] rcu: don't call rcu_preempt_note_context_switch() in rcu_check_callbacks() Lai Jiangshan
2010-03-29 4:42 ` Paul E. McKenney
2010-03-30 9:43 ` Lai Jiangshan
2010-03-30 16:03 ` Paul E. McKenney
2010-03-31 15:36 ` Paul E. McKenney
2010-04-01 0:56 ` Lai Jiangshan [this message]
2010-04-01 1:17 ` Paul E. McKenney
2010-04-01 7:24 ` Lai Jiangshan
2010-04-02 0:53 ` Paul E. McKenney
2010-04-02 12:27 ` Lai Jiangshan
2010-04-02 15:25 ` Paul E. McKenney
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=4BB3EF25.1040804@cn.fujitsu.com \
--to=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulmck@linux.vnet.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.