public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Cc: mingo@elte.hu, jens.axboe@oracle.com, nickpiggin@yahoo.com.au,
	peterz@infradead.org, linux-kernel@vger.kernel.org,
	Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [PATCH] generic-ipi: make struct call_function_data lockless
Date: Mon, 27 Jul 2009 15:00:27 -0700	[thread overview]
Message-ID: <20090727150027.20d60f0a.akpm@linux-foundation.org> (raw)
In-Reply-To: <4A6983D8.8090805@cn.fujitsu.com>

On Fri, 24 Jul 2009 17:50:16 +0800
Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> wrote:

> This patch can remove spinlock from struct call_function_data, the 
> reasons are below:
> 
> 1: add a new interface for cpumask named cpumask_test_and_clear_cpu(),
>    it can atomically test and clear specific cpu, we can use it instead
>    of cpumask_test_cpu() and cpumask_clear_cpu() and no need data->lock
>    to protect those in generic_smp_call_function_interrupt().
> 
> 2: in smp_call_function_many(), after csd_lock() return, the current's
>    cfd_data is deleted from call_function list, so it not have race
>    between other cpus, then cfs_data is only used in
>    smp_call_function_many() that must disable preemption and not from
>    a hardware interrupthandler or from a bottom half handler to call,
>    only the correspond cpu can use it, so it not have race in current
>    cpu, no need cfs_data->lock to protect it.
> 
> 3: after 1 and 2, cfs_data->lock is only use to protect cfs_data->refs in
>    generic_smp_call_function_interrupt(), so we can define cfs_data->refs
>    to atomic_t, and no need cfs_data->lock any more.

Looks good to me.  One tiny cleanup:

--- a/kernel/smp.c~generic-ipi-make-struct-call_function_data-lockless-cleanup
+++ a/kernel/smp.c
@@ -193,7 +193,7 @@ void generic_smp_call_function_interrupt
 
 		data->csd.func(data->csd.info);
 
-		refs = atomic_sub_return(1, &data->refs);
+		refs = atomic_dec_return(&data->refs);
 		WARN_ON(refs < 0);
 		if (!refs) {
 			spin_lock(&call_function.lock);
_



  reply	other threads:[~2009-07-27 22:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-24  9:50 [PATCH] generic-ipi: make struct call_function_data lockless Xiao Guangrong
2009-07-27 22:00 ` Andrew Morton [this message]
2009-07-29  7:08 ` Jens Axboe
2009-07-29  7:53 ` [PATCH 1/3 -mm] generic-ipi: fix hotplug_cfd() Xiao Guangrong
2009-07-29  7:55   ` [PATCH 2/3 -mm] generic-ipi: cleanup for generic_smp_call_function_interrupt() Xiao Guangrong
2009-07-29  7:57   ` [PATCH 3/3 -mm] generic-ipi: fix the race between generic_smp_call_function_*() and hotplug_cfd() Xiao Guangrong
2009-07-29 23:31     ` Andrew Morton
2009-07-30  3:31       ` Xiao Guangrong
2009-07-30  6:50       ` Peter Zijlstra
2009-07-30  8:11         ` Xiao Guangrong
2009-07-30  8:23           ` Li Zefan
2009-07-29 23:27   ` [PATCH 1/3 -mm] generic-ipi: fix hotplug_cfd() Andrew Morton
2009-07-30  1:18     ` Li Zefan

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=20090727150027.20d60f0a.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nickpiggin@yahoo.com.au \
    --cc=peterz@infradead.org \
    --cc=rusty@rustcorp.com.au \
    --cc=xiaoguangrong@cn.fujitsu.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