Date: Mon, 27 Apr 2026 01:29:44 +0000 Message-ID: <69eebc08.2695f.43727b7c@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/15 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=fad4e7b656b86befd5995fc4704c68e57a96caa6 commit fad4e7b656b86befd5995fc4704c68e57a96caa6 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2026-04-18 18:42:56 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2026-04-27 01:28:59 +0000 membarrier(2): use atomic for lockless read of curproc->p_flag2 (cherry picked from commit 950fd59955e10429c1325c327f0141a7e97fcfe5) --- sys/kern/kern_membarrier.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sys/kern/kern_membarrier.c b/sys/kern/kern_membarrier.c index f0660bd7360e..6d210a1b1783 100644 --- a/sys/kern/kern_membarrier.c +++ b/sys/kern/kern_membarrier.c @@ -120,7 +120,7 @@ kern_membarrier(struct thread *td, int cmd, unsigned flags, int cpu_id) struct thread *td1; cpuset_t cs; uint64_t *swt; - int c, error; + int c, error, f; bool first; if (flags != 0 || (cmd & ~MEMBARRIER_SUPPORTED_CMDS) != 0) @@ -133,6 +133,7 @@ kern_membarrier(struct thread *td, int cmd, unsigned flags, int cpu_id) p = td->td_proc; error = 0; + f = atomic_load_int(&td->td_proc->p_flag2); switch (cmd) { case MEMBARRIER_CMD_GLOBAL: @@ -155,7 +156,7 @@ kern_membarrier(struct thread *td, int cmd, unsigned flags, int cpu_id) break; case MEMBARRIER_CMD_GLOBAL_EXPEDITED: - if ((td->td_proc->p_flag2 & P2_MEMBAR_GLOBE) == 0) { + if ((f & P2_MEMBAR_GLOBE) == 0) { error = EPERM; } else { CPU_ZERO(&cs); @@ -171,7 +172,7 @@ kern_membarrier(struct thread *td, int cmd, unsigned flags, int cpu_id) break; case MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED: - if ((p->p_flag2 & P2_MEMBAR_GLOBE) == 0) { + if ((f & P2_MEMBAR_GLOBE) == 0) { PROC_LOCK(p); p->p_flag2 |= P2_MEMBAR_GLOBE; PROC_UNLOCK(p); @@ -179,7 +180,7 @@ kern_membarrier(struct thread *td, int cmd, unsigned flags, int cpu_id) break; case MEMBARRIER_CMD_PRIVATE_EXPEDITED: - if ((td->td_proc->p_flag2 & P2_MEMBAR_PRIVE) == 0) { + if ((f & P2_MEMBAR_PRIVE) == 0) { error = EPERM; } else { pmap_active_cpus(vmspace_pmap(p->p_vmspace), &cs); @@ -188,7 +189,7 @@ kern_membarrier(struct thread *td, int cmd, unsigned flags, int cpu_id) break; case MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED: - if ((p->p_flag2 & P2_MEMBAR_PRIVE) == 0) { + if ((f & P2_MEMBAR_PRIVE) == 0) { PROC_LOCK(p); p->p_flag2 |= P2_MEMBAR_PRIVE; PROC_UNLOCK(p); @@ -196,7 +197,7 @@ kern_membarrier(struct thread *td, int cmd, unsigned flags, int cpu_id) break; case MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE: - if ((td->td_proc->p_flag2 & P2_MEMBAR_PRIVE_SYNCORE) == 0) { + if ((f & P2_MEMBAR_PRIVE_SYNCORE) == 0) { error = EPERM; } else { /*home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69eebc08.2695f.43727b7c>
