lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJhHMCA-FbnXuxK9VT_ed2S_WPap_y+nnH5-a96ekPdyXRvtVQ@mail.gmail.com>
Date:	Wed, 23 Jul 2014 11:07:55 -0400
From:	Pranith Kumar <bobby.prani@...il.com>
To:	Paul McKenney <paulmck@...ux.vnet.ibm.com>
Cc:	Josh Triplett <josh@...htriplett.org>,
	Steven Rostedt <rostedt@...dmis.org>,
	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
	Lai Jiangshan <laijs@...fujitsu.com>,
	"open list:READ-COPY UPDATE..." <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 04/16] rcu: Remove redundant check for an online CPU

On Wed, Jul 23, 2014 at 10:14 AM, Paul E. McKenney
<paulmck@...ux.vnet.ibm.com> wrote:
> On Wed, Jul 23, 2014 at 10:01:14AM -0400, Pranith Kumar wrote:
>> On Wed, Jul 23, 2014 at 9:41 AM, Paul E. McKenney
>> <paulmck@...ux.vnet.ibm.com> wrote:
>> > On Wed, Jul 23, 2014 at 09:23:47AM -0400, Pranith Kumar wrote:
>> >> On Wed, Jul 23, 2014 at 8:09 AM, Paul E. McKenney
>> >> <paulmck@...ux.vnet.ibm.com> wrote:
>> >> > On Wed, Jul 23, 2014 at 01:09:41AM -0400, Pranith Kumar wrote:
>> >> >> rcu_prcess_callbacks() is the softirq handler for RCU which is raised from
>> >> >> invoke_rcu_core() which is called from __call_rcu_core().
>> >> >>
>> >> >> Each of these three functions checks if the cpu is online. We can remove the
>> >> >> redundant ones. This commit removes one of these redundant check.
>> >> >>
>> >> >> Signed-off-by: Pranith Kumar <bobby.prani@...il.com>
>> >> >
>> >> > Sorry, but no.  There can be a long delay between raise_softirq() and
>> >> > this function starting, particularly if ksoftirqd gets involved.  The
>> >> > CPU could easily go offline in the meantime.
>> >> >
>> >>
>> >> That makes sense. I guess one of the other two checks in
>> >> __call_rcu_core() or invoke_rcu_core() can go then?
>> >
>> > What would have to be the case for this suggested change to be safe?
>> > Does that condition in fact hold?
>> >
>>
>> The only scenario which is unsafe is when this thread is preempted and
>> scheduled on a dying CPU. In that case we should turn off interrupts.
>>
>> Actually, checking the code, I see that interrupts are turned off
>> already before we call _call_rcu_core(). So I am not sure such a case
>> will happen. On the other hand invoke_rcu_core() will be a one line
>> function which might as well be in-lined to avoid the double cpu
>> online check.
>>
>> What am I missing?
>
> I am not sure.  Perhaps the fact that __call_rcu_core() doesn't call
> invoke_rcu_core() unless the condition holds (which means that you
> cannnot remove the check from __call_rcu_core()) or maybe the fact that
> invoke_rcu_core() is called from many other places, which means that
> you might not be able to remove the check from invoke_rcu_core().
>

OK, since invoke_rcu_core() is being called from multiple places, we
cannot remove the check there.

But we can remove the check from __call_rcu_core(). Since we are going
to check again in invoke_rcu_core(), no? We will call
invoke_rcu_core() but we will return if the check if false.

The trade-off here is between a function call and an extra
smp_processor_id(). The only reason I am trying to do this is because
smp_processor_id() disables and enables interrupts which is costly and
we can avoid one such check.

-- 
Pranith
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ