Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102806803
D40647.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D40647.diff
View Options
diff --git a/sys/amd64/include/pcpu.h b/sys/amd64/include/pcpu.h
--- a/sys/amd64/include/pcpu.h
+++ b/sys/amd64/include/pcpu.h
@@ -113,18 +113,74 @@
#define MONITOR_STOPSTATE_RUNNING 0
#define MONITOR_STOPSTATE_STOPPED 1
-/*
- * Evaluates to the byte offset of the per-cpu variable name.
- */
-#define __pcpu_offset(name) \
- __offsetof(struct pcpu, name)
-
/*
* Evaluates to the type of the per-cpu variable name.
*/
#define __pcpu_type(name) \
__typeof(((struct pcpu *)0)->name)
+#ifdef __SEG_GS
+#define get_pcpu() __extension__ ({ \
+ static struct pcpu __seg_gs *__pc = 0; \
+ \
+ __pc->pc_prvspace; \
+})
+
+/*
+ * Evaluates to the address of the per-cpu variable name.
+ */
+#define __PCPU_PTR(name) __extension__ ({ \
+ struct pcpu *__pc = get_pcpu(); \
+ \
+ &__pc->name; \
+})
+
+/*
+ * Evaluates to the value of the per-cpu variable name.
+ */
+#define __PCPU_GET(name) __extension__ ({ \
+ static struct pcpu __seg_gs *__pc = 0; \
+ \
+ __pc->name; \
+})
+
+/*
+ * Adds the value to the per-cpu counter name. The implementation
+ * must be atomic with respect to interrupts.
+ */
+#define __PCPU_ADD(name, val) do { \
+ static struct pcpu __seg_gs *__pc = 0; \
+ __pcpu_type(name) __val; \
+ \
+ __val = (val); \
+ if (sizeof(__val) == 1 || sizeof(__val) == 2 || \
+ sizeof(__val) == 4 || sizeof(__val) == 8) { \
+ __pc->name += __val; \
+ } else \
+ *__PCPU_PTR(name) += __val; \
+} while (0)
+
+/*
+ * Sets the value of the per-cpu variable name to value val.
+ */
+#define __PCPU_SET(name, val) { \
+ static struct pcpu __seg_gs *__pc = 0; \
+ __pcpu_type(name) __val; \
+ \
+ __val = (val); \
+ if (sizeof(__val) == 1 || sizeof(__val) == 2 || \
+ sizeof(__val) == 4 || sizeof(__val) == 8) { \
+ __pc->name = __val; \
+ } else \
+ *__PCPU_PTR(name) = __val; \
+} while (0)
+#else /* !__SEG_GS */
+/*
+ * Evaluates to the byte offset of the per-cpu variable name.
+ */
+#define __pcpu_offset(name) \
+ __offsetof(struct pcpu, name)
+
/*
* Evaluates to the address of the per-cpu variable name.
*/
@@ -210,6 +266,7 @@
: "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace)))); \
__pc; \
})
+#endif /* !__SEG_GS */
#define PCPU_GET(member) __PCPU_GET(pc_ ## member)
#define PCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 18, 10:42 AM (21 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14696241
Default Alt Text
D40647.diff (2 KB)
Attached To
Mode
D40647: amd64: Use __seg_gs to implement per-CPU data accesses.
Attached
Detach File
Event Timeline
Log In to Comment