Commit d22883d7 authored by Jason A. Harmening's avatar Jason A. Harmening
Browse files

Remove PCPU_INC

e4b8deb2 removed the last in-tree uses of PCPU_INC().  Its
potential benefit is also practically nonexistent.  Non-x86
platforms already implement it as PCPU_ADD(..., 1), and according
to [0] there are no recent x86 processors for which the 'inc'
instruction provides a performance benefit over the equivalent
memory-operand form of the 'add' instruction.  The only remaining
benefit of 'inc' is smaller instruction size, which in this case
is inconsequential given the limited number of per-CPU data consumers.

[0]: https://www.agner.org/optimize/instruction_tables.pdf

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D29308
parent f9693bef
...@@ -179,34 +179,6 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); ...@@ -179,34 +179,6 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
*__PCPU_PTR(name) += __val; \ *__PCPU_PTR(name) += __val; \
} while (0) } while (0)
/*
* Increments the value of the per-cpu counter name. The implementation
* must be atomic with respect to interrupts.
*/
#define __PCPU_INC(name) do { \
CTASSERT(sizeof(__pcpu_type(name)) == 1 || \
sizeof(__pcpu_type(name)) == 2 || \
sizeof(__pcpu_type(name)) == 4 || \
sizeof(__pcpu_type(name)) == 8); \
if (sizeof(__pcpu_type(name)) == 1) { \
__asm __volatile("incb %%gs:%0" \
: "=m" (*(__pcpu_type(name) *)(__pcpu_offset(name)))\
: "m" (*(__pcpu_type(name) *)(__pcpu_offset(name))));\
} else if (sizeof(__pcpu_type(name)) == 2) { \
__asm __volatile("incw %%gs:%0" \
: "=m" (*(__pcpu_type(name) *)(__pcpu_offset(name)))\
: "m" (*(__pcpu_type(name) *)(__pcpu_offset(name))));\
} else if (sizeof(__pcpu_type(name)) == 4) { \
__asm __volatile("incl %%gs:%0" \
: "=m" (*(__pcpu_type(name) *)(__pcpu_offset(name)))\
: "m" (*(__pcpu_type(name) *)(__pcpu_offset(name))));\
} else if (sizeof(__pcpu_type(name)) == 8) { \
__asm __volatile("incq %%gs:%0" \
: "=m" (*(__pcpu_type(name) *)(__pcpu_offset(name)))\
: "m" (*(__pcpu_type(name) *)(__pcpu_offset(name))));\
} \
} while (0)
/* /*
* Sets the value of the per-cpu variable name to value val. * Sets the value of the per-cpu variable name to value val.
*/ */
...@@ -239,7 +211,6 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); ...@@ -239,7 +211,6 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
#define PCPU_GET(member) __PCPU_GET(pc_ ## member) #define PCPU_GET(member) __PCPU_GET(pc_ ## member)
#define PCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val) #define PCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val)
#define PCPU_INC(member) __PCPU_INC(pc_ ## member)
#define PCPU_PTR(member) __PCPU_PTR(pc_ ## member) #define PCPU_PTR(member) __PCPU_PTR(pc_ ## member)
#define PCPU_SET(member, val) __PCPU_SET(pc_ ## member, val) #define PCPU_SET(member, val) __PCPU_SET(pc_ ## member, val)
......
...@@ -136,7 +136,6 @@ set_tls(void *tls) ...@@ -136,7 +136,6 @@ set_tls(void *tls)
#define PCPU_GET(member) (get_pcpu()->pc_ ## member) #define PCPU_GET(member) (get_pcpu()->pc_ ## member)
#define PCPU_ADD(member, value) (get_pcpu()->pc_ ## member += (value)) #define PCPU_ADD(member, value) (get_pcpu()->pc_ ## member += (value))
#define PCPU_INC(member) PCPU_ADD(member, 1)
#define PCPU_PTR(member) (&get_pcpu()->pc_ ## member) #define PCPU_PTR(member) (&get_pcpu()->pc_ ## member)
#define PCPU_SET(member,value) (get_pcpu()->pc_ ## member = (value)) #define PCPU_SET(member,value) (get_pcpu()->pc_ ## member = (value))
......
...@@ -73,7 +73,6 @@ get_curthread(void) ...@@ -73,7 +73,6 @@ get_curthread(void)
#define PCPU_GET(member) (pcpup->pc_ ## member) #define PCPU_GET(member) (pcpup->pc_ ## member)
#define PCPU_ADD(member, value) (pcpup->pc_ ## member += (value)) #define PCPU_ADD(member, value) (pcpup->pc_ ## member += (value))
#define PCPU_INC(member) PCPU_ADD(member, 1)
#define PCPU_PTR(member) (&pcpup->pc_ ## member) #define PCPU_PTR(member) (&pcpup->pc_ ## member)
#define PCPU_SET(member,value) (pcpup->pc_ ## member = (value)) #define PCPU_SET(member,value) (pcpup->pc_ ## member = (value))
......
...@@ -169,29 +169,6 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); ...@@ -169,29 +169,6 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
*__PCPU_PTR(name) += __val; \ *__PCPU_PTR(name) += __val; \
} while (0) } while (0)
/*
* Increments the value of the per-cpu counter name. The implementation
* must be atomic with respect to interrupts.
*/
#define __PCPU_INC(name) do { \
CTASSERT(sizeof(__pcpu_type(name)) == 1 || \
sizeof(__pcpu_type(name)) == 2 || \
sizeof(__pcpu_type(name)) == 4); \
if (sizeof(__pcpu_type(name)) == 1) { \
__asm __volatile("incb %%fs:%0" \
: "=m" (*(__pcpu_type(name) *)(__pcpu_offset(name)))\
: "m" (*(__pcpu_type(name) *)(__pcpu_offset(name))));\
} else if (sizeof(__pcpu_type(name)) == 2) { \
__asm __volatile("incw %%fs:%0" \
: "=m" (*(__pcpu_type(name) *)(__pcpu_offset(name)))\
: "m" (*(__pcpu_type(name) *)(__pcpu_offset(name))));\
} else if (sizeof(__pcpu_type(name)) == 4) { \
__asm __volatile("incl %%fs:%0" \
: "=m" (*(__pcpu_type(name) *)(__pcpu_offset(name)))\
: "m" (*(__pcpu_type(name) *)(__pcpu_offset(name))));\
} \
} while (0)
/* /*
* Sets the value of the per-cpu variable name to value val. * Sets the value of the per-cpu variable name to value val.
*/ */
...@@ -224,7 +201,6 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); ...@@ -224,7 +201,6 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
#define PCPU_GET(member) __PCPU_GET(pc_ ## member) #define PCPU_GET(member) __PCPU_GET(pc_ ## member)
#define PCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val) #define PCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val)
#define PCPU_INC(member) __PCPU_INC(pc_ ## member)
#define PCPU_PTR(member) __PCPU_PTR(pc_ ## member) #define PCPU_PTR(member) __PCPU_PTR(pc_ ## member)
#define PCPU_SET(member, val) __PCPU_SET(pc_ ## member, val) #define PCPU_SET(member, val) __PCPU_SET(pc_ ## member, val)
......
...@@ -83,7 +83,6 @@ extern struct pcpu *pcpup; ...@@ -83,7 +83,6 @@ extern struct pcpu *pcpup;
#define PCPU_ADD(member, value) (PCPUP->pc_ ## member += (value)) #define PCPU_ADD(member, value) (PCPUP->pc_ ## member += (value))
#define PCPU_GET(member) (PCPUP->pc_ ## member) #define PCPU_GET(member) (PCPUP->pc_ ## member)
#define PCPU_INC(member) PCPU_ADD(member, 1)
#define PCPU_PTR(member) (&PCPUP->pc_ ## member) #define PCPU_PTR(member) (&PCPUP->pc_ ## member)
#define PCPU_SET(member,value) (PCPUP->pc_ ## member = (value)) #define PCPU_SET(member,value) (PCPUP->pc_ ## member = (value))
#define PCPU_LAZY_INC(member) (++PCPUP->pc_ ## member) #define PCPU_LAZY_INC(member) (++PCPUP->pc_ ## member)
......
...@@ -168,7 +168,6 @@ __curthread(void) ...@@ -168,7 +168,6 @@ __curthread(void)
* with respect to preemption. * with respect to preemption.
*/ */
#define PCPU_ADD(member, value) (pcpup->pc_ ## member += (value)) #define PCPU_ADD(member, value) (pcpup->pc_ ## member += (value))
#define PCPU_INC(member) PCPU_ADD(member, 1)
#define PCPU_PTR(member) (&pcpup->pc_ ## member) #define PCPU_PTR(member) (&pcpup->pc_ ## member)
#define PCPU_SET(member,value) (pcpup->pc_ ## member = (value)) #define PCPU_SET(member,value) (pcpup->pc_ ## member = (value))
......
...@@ -79,7 +79,6 @@ get_curthread(void) ...@@ -79,7 +79,6 @@ get_curthread(void)
#define PCPU_GET(member) (get_pcpu()->pc_ ## member) #define PCPU_GET(member) (get_pcpu()->pc_ ## member)
#define PCPU_ADD(member, value) (get_pcpu()->pc_ ## member += (value)) #define PCPU_ADD(member, value) (get_pcpu()->pc_ ## member += (value))
#define PCPU_INC(member) PCPU_ADD(member, 1)
#define PCPU_PTR(member) (&get_pcpu()->pc_ ## member) #define PCPU_PTR(member) (&get_pcpu()->pc_ ## member)
#define PCPU_SET(member,value) (get_pcpu()->pc_ ## member = (value)) #define PCPU_SET(member,value) (get_pcpu()->pc_ ## member = (value))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment