Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Jul 2015 22:56:47 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r285771 - head/sys/kern
Message-ID:  <201507212256.t6LMul0x097990@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Tue Jul 21 22:56:46 2015
New Revision: 285771
URL: https://svnweb.freebsd.org/changeset/base/285771

Log:
  The smp_rendezvous_cpus() function should ensure that all accesses
  done by the functions called on other CPUs, are visible to the caller.
  Pair otherwise useless acquire on smp_rv_waiters[3] with a release add
  to ensure synchronized with relation, which guarantees visibility.
  
  Reviewed by:	alc
  Sponsored by:	The FreeBSD Foundation
  MFC after:	3 weeks

Modified:
  head/sys/kern/subr_smp.c

Modified: head/sys/kern/subr_smp.c
==============================================================================
--- head/sys/kern/subr_smp.c	Tue Jul 21 21:46:24 2015	(r285770)
+++ head/sys/kern/subr_smp.c	Tue Jul 21 22:56:46 2015	(r285771)
@@ -455,8 +455,13 @@ smp_rendezvous_action(void)
 	 * This means that no member of smp_rv_* pseudo-structure will be
 	 * accessed by this target CPU after this point; in particular,
 	 * memory pointed by smp_rv_func_arg.
+	 *
+	 * The release semantic ensures that all accesses performed by
+	 * the current CPU are visible when smp_rendezvous_cpus()
+	 * returns, by synchronizing with the
+	 * atomic_load_acq_int(&smp_rv_waiters[3]).
 	 */
-	atomic_add_int(&smp_rv_waiters[3], 1);
+	atomic_add_rel_int(&smp_rv_waiters[3], 1);
 
 	td->td_critnest--;
 	KASSERT(owepreempt == td->td_owepreempt,
@@ -522,6 +527,11 @@ smp_rendezvous_cpus(cpuset_t map,
 	 * CPUs to finish the rendezvous, so that smp_rv_*
 	 * pseudo-structure and the arg are guaranteed to not
 	 * be in use.
+	 *
+	 * Load acquire synchronizes with the release add in
+	 * smp_rendezvous_action(), which ensures that our caller sees
+	 * all memory actions done by the called functions on other
+	 * CPUs.
 	 */
 	while (atomic_load_acq_int(&smp_rv_waiters[3]) < ncpus)
 		cpu_spinwait();



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507212256.t6LMul0x097990>