svn commit: r241690 - in stable/8/sys: kern sparc64/include sparc64/sparc64
Marius Strobl
marius at FreeBSD.org
Thu Oct 18 14:57:11 UTC 2012
Author: marius
Date: Thu Oct 18 14:57:11 2012
New Revision: 241690
URL: http://svn.freebsd.org/changeset/base/241690
Log:
MFC: r239864
- Unlike cache invalidation and TLB demapping IPIs, reading registers from
other CPUs doesn't require locking so get rid of it. As the latter is used
for the timecounter on certain machine models, using a spin lock in this
case can lead to a deadlock with the upcoming callout(9) rework.
- Merge r134227/r167250 from x86:
Avoid cross-IPI SMP deadlock by using the smp_ipi_mtx spin lock not only
for smp_rendezvous_cpus() but also for the MD cache invalidation and TLB
demapping IPIs.
- Mark some unused function arguments as such.
Modified:
stable/8/sys/kern/subr_witness.c
stable/8/sys/sparc64/include/smp.h
stable/8/sys/sparc64/sparc64/mp_machdep.c
stable/8/sys/sparc64/sparc64/tick.c
Directory Properties:
stable/8/sys/ (props changed)
stable/8/sys/kern/ (props changed)
stable/8/sys/sparc64/ (props changed)
Modified: stable/8/sys/kern/subr_witness.c
==============================================================================
--- stable/8/sys/kern/subr_witness.c Thu Oct 18 14:25:33 2012 (r241689)
+++ stable/8/sys/kern/subr_witness.c Thu Oct 18 14:57:11 2012 (r241690)
@@ -663,9 +663,6 @@ static struct witness_order_list_entry o
*/
{ "intrcnt", &lock_class_mtx_spin },
{ "icu", &lock_class_mtx_spin },
-#if defined(SMP) && defined(__sparc64__)
- { "ipi", &lock_class_mtx_spin },
-#endif
#ifdef __i386__
{ "allpmaps", &lock_class_mtx_spin },
{ "descriptor tables", &lock_class_mtx_spin },
Modified: stable/8/sys/sparc64/include/smp.h
==============================================================================
--- stable/8/sys/sparc64/include/smp.h Thu Oct 18 14:25:33 2012 (r241689)
+++ stable/8/sys/sparc64/include/smp.h Thu Oct 18 14:57:11 2012 (r241690)
@@ -107,7 +107,6 @@ extern cpu_ipi_single_t *cpu_ipi_single;
void mp_init(u_int cpu_impl);
-extern struct mtx ipi_mtx;
extern struct ipi_cache_args ipi_cache_args;
extern struct ipi_rd_args ipi_rd_args;
extern struct ipi_tlb_args ipi_tlb_args;
@@ -164,7 +163,7 @@ ipi_dcache_page_inval(void *func, vm_pad
return (NULL);
sched_pin();
ica = &ipi_cache_args;
- mtx_lock_spin(&ipi_mtx);
+ mtx_lock_spin(&smp_ipi_mtx);
ica->ica_mask = PCPU_GET(other_cpus);
ica->ica_pa = pa;
cpu_ipi_selected(ica->ica_mask, 0, (u_long)func, (u_long)ica);
@@ -180,7 +179,7 @@ ipi_icache_page_inval(void *func, vm_pad
return (NULL);
sched_pin();
ica = &ipi_cache_args;
- mtx_lock_spin(&ipi_mtx);
+ mtx_lock_spin(&smp_ipi_mtx);
ica->ica_mask = PCPU_GET(other_cpus);
ica->ica_pa = pa;
cpu_ipi_selected(ica->ica_mask, 0, (u_long)func, (u_long)ica);
@@ -196,7 +195,6 @@ ipi_rd(u_int cpu, void *func, u_long *va
return (NULL);
sched_pin();
ira = &ipi_rd_args;
- mtx_lock_spin(&ipi_mtx);
ira->ira_mask = 1 << cpu;
ira->ira_val = val;
cpu_ipi_single(cpu, 0, (u_long)func, (u_long)ira);
@@ -217,7 +215,7 @@ ipi_tlb_context_demap(struct pmap *pm)
return (NULL);
}
ita = &ipi_tlb_args;
- mtx_lock_spin(&ipi_mtx);
+ mtx_lock_spin(&smp_ipi_mtx);
ita->ita_mask = cpus;
ita->ita_pmap = pm;
cpu_ipi_selected(cpus, 0, (u_long)tl_ipi_tlb_context_demap,
@@ -239,7 +237,7 @@ ipi_tlb_page_demap(struct pmap *pm, vm_o
return (NULL);
}
ita = &ipi_tlb_args;
- mtx_lock_spin(&ipi_mtx);
+ mtx_lock_spin(&smp_ipi_mtx);
ita->ita_mask = cpus;
ita->ita_pmap = pm;
ita->ita_va = va;
@@ -261,7 +259,7 @@ ipi_tlb_range_demap(struct pmap *pm, vm_
return (NULL);
}
ita = &ipi_tlb_args;
- mtx_lock_spin(&ipi_mtx);
+ mtx_lock_spin(&smp_ipi_mtx);
ita->ita_mask = cpus;
ita->ita_pmap = pm;
ita->ita_start = start;
@@ -279,7 +277,19 @@ ipi_wait(void *cookie)
if ((mask = cookie) != NULL) {
while (*mask != 0)
;
- mtx_unlock_spin(&ipi_mtx);
+ mtx_unlock_spin(&smp_ipi_mtx);
+ sched_unpin();
+ }
+}
+
+static __inline void
+ipi_wait_unlocked(void *cookie)
+{
+ volatile cpumask_t *mask;
+
+ if ((mask = cookie) != NULL) {
+ while (*mask != 0)
+ ;
sched_unpin();
}
}
@@ -336,7 +346,13 @@ ipi_tlb_range_demap(struct pmap *pm __un
}
static __inline void
-ipi_wait(void *cookie)
+ipi_wait(void *cookie __unused)
+{
+
+}
+
+static __inline void
+ipi_wait_unlocked(void *cookie __unused)
{
}
Modified: stable/8/sys/sparc64/sparc64/mp_machdep.c
==============================================================================
--- stable/8/sys/sparc64/sparc64/mp_machdep.c Thu Oct 18 14:25:33 2012 (r241689)
+++ stable/8/sys/sparc64/sparc64/mp_machdep.c Thu Oct 18 14:57:11 2012 (r241690)
@@ -112,8 +112,6 @@ struct ipi_rd_args ipi_rd_args;
struct ipi_tlb_args ipi_tlb_args;
struct pcb stoppcbs[MAXCPU];
-struct mtx ipi_mtx;
-
cpu_ipi_selected_t *cpu_ipi_selected;
cpu_ipi_single_t *cpu_ipi_single;
@@ -283,8 +281,6 @@ void
cpu_mp_start(void)
{
- mtx_init(&ipi_mtx, "ipi", NULL, MTX_SPIN);
-
intr_setup(PIL_AST, cpu_ipi_ast, -1, NULL, NULL);
intr_setup(PIL_RENDEZVOUS, (ih_func_t *)smp_rendezvous_action,
-1, NULL, NULL);
@@ -498,13 +494,13 @@ cpu_mp_shutdown(void)
}
static void
-cpu_ipi_ast(struct trapframe *tf)
+cpu_ipi_ast(struct trapframe *tf __unused)
{
}
static void
-cpu_ipi_stop(struct trapframe *tf)
+cpu_ipi_stop(struct trapframe *tf __unused)
{
CTR2(KTR_SMP, "%s: stopped %d", __func__, curcpu);
Modified: stable/8/sys/sparc64/sparc64/tick.c
==============================================================================
--- stable/8/sys/sparc64/sparc64/tick.c Thu Oct 18 14:25:33 2012 (r241689)
+++ stable/8/sys/sparc64/sparc64/tick.c Thu Oct 18 14:57:11 2012 (r241690)
@@ -314,7 +314,7 @@ stick_get_timecount_mp(struct timecounte
if (curcpu == 0)
stick = rdstick();
else
- ipi_wait(ipi_rd(0, tl_ipi_stick_rd, &stick));
+ ipi_wait_unlocked(ipi_rd(0, tl_ipi_stick_rd, &stick));
sched_unpin();
return (stick);
}
@@ -328,7 +328,7 @@ tick_get_timecount_mp(struct timecounter
if (curcpu == 0)
tick = rd(tick);
else
- ipi_wait(ipi_rd(0, tl_ipi_tick_rd, &tick));
+ ipi_wait_unlocked(ipi_rd(0, tl_ipi_tick_rd, &tick));
sched_unpin();
return (tick);
}
More information about the svn-src-stable
mailing list