From: Ashok Raj <ashok.raj@intel.com>
To: Shaohua Li <shaohua.li@intel.com>
Cc: Ashok Raj <ashok.raj@intel.com>, akpm <akpm@osdl.org>,
lkml <linux-kernel@vger.kernel.org>,
Zwane Mwaikambo <zwane@arm.linux.org.uk>,
Srivattsa Vaddagiri <vatsa@in.ibm.com>,
x86-64 <discuss@x86-64.org>,
Rusty Russell <rusty@rustycorp.com.au>, ak <ak@muc.de>
Subject: Re: [patch 4/5] try2: x86_64: Dont use broadcast shortcut to make it cpu hotplug safe.
Date: Tue, 7 Jun 2005 08:40:32 -0700 [thread overview]
Message-ID: <20050607084031.A26067@unix-os.sc.intel.com> (raw)
In-Reply-To: <1118128410.3949.3.camel@linux-hp.sh.intel.com>; from shaohua.li@intel.com on Tue, Jun 07, 2005 at 03:13:30PM +0800
On Tue, Jun 07, 2005 at 03:13:30PM +0800, Shaohua Li wrote:
> With the patch. smp_call_function still has race. It accesses
> cpu_online_map twice. First calculate online cpu counter and second,
> send the ipi, so it's not atomic. We should do something like this:
>
> Thanks,
> Shaohua
>
Correct, i though this was taken care earlier because i was holding call_lock
but i forgot that i just removed it based on zwane's feedback.
I re-introduced that with the comment so i dont forget the purpose.
attached patch should fix that by holding call_lock before setting, so
we exclude current upcomming cpu from on-going smp_call_function()
transactions.
x86_64-hold-call-lock-when-setting-online-map:
Need to hold call_lock when setting cpu_online_map for a new cpu.
__smp_call_function() reads num_cpus_online() to find out how many consumers
to wait. These counts are done at different times, and unless we keep
writes off cpu_online_map gaurded, these counts could be different. Worst
case a new cpu would also participate, this basically keeps the new cpu off
currently ongoing smp_call_functions().
Signed-off-by: Ashok Raj <ashok.raj@intel.com>
---------------------------------------------------
arch/x86_64/kernel/smp.c | 10 ++++++++++
arch/x86_64/kernel/smpboot.c | 12 ++++++++++++
include/asm-x86_64/smp.h | 2 ++
3 files changed, 24 insertions(+)
Index: linux-2.6.12-rc6-mm1/arch/x86_64/kernel/smp.c
===================================================================
--- linux-2.6.12-rc6-mm1.orig/arch/x86_64/kernel/smp.c
+++ linux-2.6.12-rc6-mm1/arch/x86_64/kernel/smp.c
@@ -283,6 +283,16 @@ struct call_data_struct {
static struct call_data_struct * call_data;
+void lock_ipi_call_lock(void)
+{
+ spin_lock_irq(&call_lock);
+}
+
+void unlock_ipi_call_lock(void)
+{
+ spin_unlock_irq(&call_lock);
+}
+
/*
* this function sends a 'generic call function' IPI to all other CPUs
* in the system.
Index: linux-2.6.12-rc6-mm1/arch/x86_64/kernel/smpboot.c
===================================================================
--- linux-2.6.12-rc6-mm1.orig/arch/x86_64/kernel/smpboot.c
+++ linux-2.6.12-rc6-mm1/arch/x86_64/kernel/smpboot.c
@@ -448,9 +448,21 @@ void __cpuinit start_secondary(void)
enable_APIC_timer();
/*
+ * We need to hold call_lock, so there is no inconsistency
+ * between the time smp_call_function() determines number of
+ * IPI receipients, and the time when the determination is made
+ * for which cpus receive the IPI in genapic_flat.c. Holding this
+ * lock helps us to not include this cpu in a currently in progress
+ * smp_call_function().
+ */
+ lock_ipi_call_lock();
+
+ /*
* Allow the master to continue.
*/
cpu_set(smp_processor_id(), cpu_online_map);
+ unlock_ipi_call_lock();
+
mb();
/* Wait for TSC sync to not schedule things before.
Index: linux-2.6.12-rc6-mm1/include/asm-x86_64/smp.h
===================================================================
--- linux-2.6.12-rc6-mm1.orig/include/asm-x86_64/smp.h
+++ linux-2.6.12-rc6-mm1/include/asm-x86_64/smp.h
@@ -43,6 +43,8 @@ extern cpumask_t cpu_callout_map;
extern void smp_alloc_memory(void);
extern volatile unsigned long smp_invalidate_needed;
extern int pic_mode;
+extern void lock_ipi_call_lock(void);
+extern void unlock_ipi_call_lock(void);
extern int smp_num_siblings;
extern void smp_flush_tlb(void);
extern void smp_message_irq(int cpl, void *dev_id, struct pt_regs *regs);
next prev parent reply other threads:[~2005-06-07 15:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-06 19:14 [patch 0/5] x86_64: try2: CPU hotplug patch series Ashok Raj
2005-06-06 19:14 ` [patch 1/5] try2: x86_64: Change init sections for CPU hotplug support Ashok Raj
2005-06-06 19:14 ` [patch 2/5] try2: x86_64: " Ashok Raj
2005-06-06 22:11 ` Andrew Morton
2005-06-06 22:43 ` Ashok Raj
2005-06-06 19:14 ` [patch 3/5] try2: x86_64: CPU hotplug sibling map cleanup Ashok Raj
2005-06-06 19:14 ` [patch 4/5] try2: x86_64: Dont use broadcast shortcut to make it cpu hotplug safe Ashok Raj
2005-06-06 22:13 ` Andrew Morton
2005-06-07 7:13 ` Shaohua Li
2005-06-07 12:05 ` Ashok Raj
2005-06-07 15:40 ` Ashok Raj [this message]
2005-06-06 19:14 ` [patch 5/5] try2: x86_64: Provide ability to choose using shortcuts for IPI in flat mode Ashok Raj
2005-06-06 22:14 ` Andrew Morton
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=20050607084031.A26067@unix-os.sc.intel.com \
--to=ashok.raj@intel.com \
--cc=ak@muc.de \
--cc=akpm@osdl.org \
--cc=discuss@x86-64.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustycorp.com.au \
--cc=shaohua.li@intel.com \
--cc=vatsa@in.ibm.com \
--cc=zwane@arm.linux.org.uk \
/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
all inboxes | Powered by JetHome®