All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>,
	Andi Kleen <andi@firstfloor.org>,
	"Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com>,
	Suresh Siddha <suresh.b.siddha@intel.com>,
	Jens Axboe <jens.axboe@oracle.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Rusty Russell <rusty@rustcorp.com.au>
Subject: [PATCH 1/2] smp_call_function: don't use lock in call_function_data
Date: Thu, 21 Aug 2008 17:29:48 -0700	[thread overview]
Message-ID: <48AE087C.4000408@goop.org> (raw)

There's no need for a lock in call_function_data, since it's only used
to decrement-and-test a counter.  Use an atomic instead.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
---
 kernel/smp.c |   17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

===================================================================
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -10,6 +10,7 @@
 #include <linux/rcupdate.h>
 #include <linux/rculist.h>
 #include <linux/smp.h>
+#include <asm/atomic.h>
 
 bool __read_mostly smp_single_ipi_queue = false;
 
@@ -37,8 +38,7 @@
 
 struct call_function_data {
 	struct call_single_data csd;
-	spinlock_t lock;
-	unsigned int refs;
+	atomic_t refs;
 	cpumask_t cpumask;
 	struct rcu_head rcu_head;
 };
@@ -125,21 +125,13 @@
 	 */
 	rcu_read_lock();
 	list_for_each_entry_rcu(data, &queue->list, csd.list) {
-		int refs;
-
 		if (!cpu_isset(cpu, data->cpumask))
 			continue;
 
 		data->csd.func(data->csd.info);
 
-		spin_lock(&data->lock);
 		cpu_clear(cpu, data->cpumask);
-		WARN_ON(data->refs == 0);
-		data->refs--;
-		refs = data->refs;
-		spin_unlock(&data->lock);
-
-		if (refs)
+		if (!atomic_dec_and_test(&data->refs))
 			continue;
 
 		spin_lock(&queue->lock);
@@ -379,10 +371,9 @@
 		slowpath = 1;
 	}
 
-	spin_lock_init(&data->lock);
 	data->csd.func = func;
 	data->csd.info = info;
-	data->refs = num_cpus;
+	atomic_set(&data->refs, num_cpus);
 	data->cpumask = mask;
 
 	spin_lock_irqsave(&queue->lock, flags);



             reply	other threads:[~2008-08-22  0:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-22  0:29 Jeremy Fitzhardinge [this message]
2008-08-22  0:36 ` [PATCH 1/2] smp_call_function: don't use lock in call_function_data Jeremy Fitzhardinge
2008-08-22  1:47 ` Nick Piggin

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=48AE087C.4000408@goop.org \
    --to=jeremy@goop.org \
    --cc=andi@firstfloor.org \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nickpiggin@yahoo.com.au \
    --cc=rusty@rustcorp.com.au \
    --cc=suresh.b.siddha@intel.com \
    --cc=venkatesh.pallipadi@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 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.