Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153081408
D56507.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D56507.diff
View Options
diff --git a/lib/libsys/membarrier.2 b/lib/libsys/membarrier.2
--- a/lib/libsys/membarrier.2
+++ b/lib/libsys/membarrier.2
@@ -83,6 +83,8 @@
Register the process to receive
.Dv MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE
memory barriers.
+.It Dv MEMBARRIER_CMD_GET_REGISTRATIONS
+Return the bitmask of the currently registered receive barriers.
.El
.Pp
The following
@@ -106,6 +108,10 @@
is
.Dv MEMBARRIER_CMD_QUERY
a bitmask of supported commands is returned.
+For the
+.Dv MEMBARRIER_CMD_GET_REGISTRATIONS
+command, a bitmask of the registrations for the current process
+is returned.
Otherwise, on success,
.Nm
returns 0.
diff --git a/sys/kern/kern_membarrier.c b/sys/kern/kern_membarrier.c
--- a/sys/kern/kern_membarrier.c
+++ b/sys/kern/kern_membarrier.c
@@ -51,7 +51,8 @@
MEMBARRIER_CMD_PRIVATE_EXPEDITED | \
MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED | \
MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE | \
- MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE)
+ MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE | \
+ MEMBARRIER_CMD_GET_REGISTRATIONS)
static void
membarrier_action_seqcst(void *arg __unused)
@@ -120,7 +121,7 @@
struct thread *td1;
cpuset_t cs;
uint64_t *swt;
- int c, error;
+ int c, error, f, res;
bool first;
if (flags != 0 || (cmd & ~MEMBARRIER_SUPPORTED_CMDS) != 0)
@@ -133,6 +134,7 @@
p = td->td_proc;
error = 0;
+ f = atomic_load_int(&td->td_proc->p_flag2);
switch (cmd) {
case MEMBARRIER_CMD_GLOBAL:
@@ -155,7 +157,7 @@
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 +173,7 @@
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 +181,7 @@
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 +190,7 @@
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 +198,7 @@
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 {
/*
@@ -217,13 +219,26 @@
break;
case MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE:
- if ((p->p_flag2 & P2_MEMBAR_PRIVE_SYNCORE) == 0) {
+ if ((f & P2_MEMBAR_PRIVE_SYNCORE) == 0) {
PROC_LOCK(p);
p->p_flag2 |= P2_MEMBAR_PRIVE_SYNCORE;
PROC_UNLOCK(p);
}
break;
+ case MEMBARRIER_CMD_GET_REGISTRATIONS:
+ res = 0;
+ if ((f & P2_MEMBAR_GLOBE) != 0)
+ res |= MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED;
+ if ((f & P2_MEMBAR_PRIVE) != 0)
+ res |= MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED;
+ if ((f & P2_MEMBAR_PRIVE_SYNCORE) != 0) {
+ res |=
+ MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE;
+ }
+ td->td_retval[0] = res;
+ break;
+
default:
error = EINVAL;
break;
diff --git a/sys/sys/membarrier.h b/sys/sys/membarrier.h
--- a/sys/sys/membarrier.h
+++ b/sys/sys/membarrier.h
@@ -55,6 +55,9 @@
*/
MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ = 0x00000080,
MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ = 0x00000100,
+
+ /* Return the bitmask of current registrations. */
+ MEMBARRIER_CMD_GET_REGISTRATIONS = 0x00000200,
};
enum membarrier_cmd_flag {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Apr 20, 12:25 AM (4 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31811835
Default Alt Text
D56507.diff (3 KB)
Attached To
Mode
D56507: membarrier(2): implement the MEMBARRIER_CMD_GET_REGISTRATIONS command
Attached
Detach File
Event Timeline
Log In to Comment