Merge tag 'riscv-for-linus-6.9-mw2' of git://git.kernel.org/pub/scm/linux/kernel...
[sfrench/cifs-2.6.git] / kernel / sched / core.c
index d44efa0d06112a8b4f022fe450aa7725987dca9b..7019a40457a6dafd14803896d3cb68a1e26bb2d4 100644 (file)
@@ -6647,7 +6647,9 @@ static void __sched notrace __schedule(unsigned int sched_mode)
         *     if (signal_pending_state())          if (p->state & @state)
         *
         * Also, the membarrier system call requires a full memory barrier
-        * after coming from user-space, before storing to rq->curr.
+        * after coming from user-space, before storing to rq->curr; this
+        * barrier matches a full barrier in the proximity of the membarrier
+        * system call exit.
         */
        rq_lock(rq, &rf);
        smp_mb__after_spinlock();
@@ -6718,12 +6720,20 @@ static void __sched notrace __schedule(unsigned int sched_mode)
                 *
                 * Here are the schemes providing that barrier on the
                 * various architectures:
-                * - mm ? switch_mm() : mmdrop() for x86, s390, sparc, PowerPC.
-                *   switch_mm() rely on membarrier_arch_switch_mm() on PowerPC.
+                * - mm ? switch_mm() : mmdrop() for x86, s390, sparc, PowerPC,
+                *   RISC-V.  switch_mm() relies on membarrier_arch_switch_mm()
+                *   on PowerPC and on RISC-V.
                 * - finish_lock_switch() for weakly-ordered
                 *   architectures where spin_unlock is a full barrier,
                 * - switch_to() for arm64 (weakly-ordered, spin_unlock
                 *   is a RELEASE barrier),
+                *
+                * The barrier matches a full barrier in the proximity of
+                * the membarrier system call entry.
+                *
+                * On RISC-V, this barrier pairing is also needed for the
+                * SYNC_CORE command when switching between processes, cf.
+                * the inline comments in membarrier_arch_switch_mm().
                 */
                ++*switch_count;