public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Christoph Lameter <cl@linux.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: rcu: Avoid irq disable in rcu_cpu_kthread
Date: Mon, 9 Dec 2013 16:05:21 -0800	[thread overview]
Message-ID: <20131210000521.GH4208@linux.vnet.ibm.com> (raw)
In-Reply-To: <00000142c495b75b-c1878909-baf9-42a8-9ba7-62d216d806a7-000000@email.amazonses.com>

On Thu, Dec 05, 2013 at 09:06:55PM +0000, Christoph Lameter wrote:
> Once we have the per cpu patchset merged we could do the following [it
> even works without that patchset but the __this_cpu ops will not do
> preemption checks]. Would this work?

Looks plausible at first glance.  But are you really seeing performance
issues with this code?  It is only compiled into the kernel when you build
with CONFIG_RCU_BOOST=y -- are you actually using that for your workloads?

							Thanx, Paul

> Subject: rcu: Avoid irq disable in rcu_cpu_kthread
> 
> The use of this_cpu ops avoids numerous address calculations
> and allows to avoid the irq enable/disable sequence through a
> low latency non locking this_cpu_xchg.
> 
> Signed-off-by: Christoph Lameter <cl@linux.com>
> 
> Index: linux/kernel/rcu/tree_plugin.h
> ===================================================================
> --- linux.orig/kernel/rcu/tree_plugin.h	2013-12-03 11:32:23.322999660 -0600
> +++ linux/kernel/rcu/tree_plugin.h	2013-12-03 11:32:23.312999941 -0600
> @@ -1417,33 +1417,29 @@ static int rcu_cpu_kthread_should_run(un
>   */
>  static void rcu_cpu_kthread(unsigned int cpu)
>  {
> -	unsigned int *statusp = this_cpu_ptr(&rcu_cpu_kthread_status);
> -	char work, *workp = this_cpu_ptr(&rcu_cpu_has_work);
> +	char work;
>  	int spincnt;
> 
>  	for (spincnt = 0; spincnt < 10; spincnt++) {
>  		trace_rcu_utilization(TPS("Start CPU kthread@rcu_wait"));
>  		local_bh_disable();
> -		*statusp = RCU_KTHREAD_RUNNING;
> -		this_cpu_inc(rcu_cpu_kthread_loops);
> -		local_irq_disable();
> -		work = *workp;
> -		*workp = 0;
> -		local_irq_enable();
> +		__this_cpu_write(rcu_cpu_kthread_status, RCU_KTHREAD_RUNNING);
> +		__this_cpu_inc(rcu_cpu_kthread_loops);
> +		work = this_cpu_xchg(rcu_cpu_has_work, 0);
>  		if (work)
>  			rcu_kthread_do_work();
>  		local_bh_enable();
> -		if (*workp == 0) {
> +		if (__this_cpu_read(rcu_cpu_has_work) == 0) {
>  			trace_rcu_utilization(TPS("End CPU kthread@rcu_wait"));
> -			*statusp = RCU_KTHREAD_WAITING;
> +			__this_cpu_write(rcu_cpu_kthread_status, RCU_KTHREAD_WAITING);
>  			return;
>  		}
>  	}
> -	*statusp = RCU_KTHREAD_YIELDING;
> +	__this_cpu_write(rcu_cpu_kthread_status, RCU_KTHREAD_YIELDING);
>  	trace_rcu_utilization(TPS("Start CPU kthread@rcu_yield"));
>  	schedule_timeout_interruptible(2);
>  	trace_rcu_utilization(TPS("End CPU kthread@rcu_yield"));
> -	*statusp = RCU_KTHREAD_WAITING;
> +	__this_cpu_write(rcu_cpu_kthread_status, RCU_KTHREAD_WAITING);
>  }
> 
>  /*
> 


  reply	other threads:[~2013-12-10  0:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-05 21:06 rcu: Avoid irq disable in rcu_cpu_kthread Christoph Lameter
2013-12-10  0:05 ` Paul E. McKenney [this message]
2013-12-10 15:24   ` Christoph Lameter

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=20131210000521.GH4208@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=cl@linux.com \
    --cc=linux-kernel@vger.kernel.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