public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Shaohua Li <shaohua.li@intel.com>
Cc: lkml <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH]rcu: avoid unnecessary thread wakeup
Date: Fri, 10 Jun 2011 09:38:42 -0700	[thread overview]
Message-ID: <20110610163842.GB2230@linux.vnet.ibm.com> (raw)
In-Reply-To: <1307692251.15392.91.camel@sli10-conroe>

On Fri, Jun 10, 2011 at 03:50:51PM +0800, Shaohua Li wrote:
> invoke_rcu_cpu_kthread could be called in the thread itself. In this case,
> we don't need call wakeup, which is just wasting CPU.
> 
> Signed-off-by: Shaohua Li <shaohua.li@intel.com>
> 
> diff --git a/kernel/rcutree.c b/kernel/rcutree.c
> index 89419ff..f9bd051 100644
> --- a/kernel/rcutree.c
> +++ b/kernel/rcutree.c
> @@ -1475,7 +1475,8 @@ static void invoke_rcu_cpu_kthread(void)
>  		local_irq_restore(flags);
>  		return;
>  	}
> -	wake_up_process(__this_cpu_read(rcu_cpu_kthread_task));
> +	if (current != __this_cpu_read(rcu_cpu_kthread_task))
> +		wake_up_process(__this_cpu_read(rcu_cpu_kthread_task));
>  	local_irq_restore(flags);
>  }

Excellent point, thank you!

But how about combining the tests, perhaps something like the
following?

Unless you have objections or spot problems with it (or it breaks during
testing), I will queue the patch below with your SOB, since I derived
it from your patch.

							Thanx, Paul

------------------------------------------------------------------------

diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index b4b254d..eda3986 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -1523,11 +1523,9 @@ static void invoke_rcu_cpu_kthread(void)
 
 	local_irq_save(flags);
 	__this_cpu_write(rcu_cpu_has_work, 1);
-	if (__this_cpu_read(rcu_cpu_kthread_task) == NULL) {
-		local_irq_restore(flags);
-		return;
-	}
-	wake_up_process(__this_cpu_read(rcu_cpu_kthread_task));
+	if (__this_cpu_read(rcu_cpu_kthread_task) != NULL &&
+	    current != __this_cpu_read(rcu_cpu_kthread_task))
+		wake_up_process(__this_cpu_read(rcu_cpu_kthread_task));
 	local_irq_restore(flags);
 }
 

  reply	other threads:[~2011-06-10 16:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-10  7:50 [PATCH]rcu: avoid unnecessary thread wakeup Shaohua Li
2011-06-10 16:38 ` Paul E. McKenney [this message]
2011-06-13  0:36   ` Shaohua Li

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=20110610163842.GB2230@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=shaohua.li@intel.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