diff options
author | alc <alc@FreeBSD.org> | 2007-03-11 05:54:29 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2007-03-11 05:54:29 +0000 |
commit | b03ddb707bfa75419cca3c62c43a52a0e43e11fe (patch) | |
tree | c82f4d045af3dd306e3ada863f05a02bf267342a /sys/i386 | |
parent | be15acebb297e61c62592db36b982bda336df47f (diff) | |
download | FreeBSD-src-b03ddb707bfa75419cca3c62c43a52a0e43e11fe.zip FreeBSD-src-b03ddb707bfa75419cca3c62c43a52a0e43e11fe.tar.gz |
Push down the implementation of PCPU_LAZY_INC() into the machine-dependent
header file. Reimplement PCPU_LAZY_INC() on amd64 and i386 making it
atomic with respect to interrupts.
Reviewed by: bde, jhb
Diffstat (limited to 'sys/i386')
-rw-r--r-- | sys/i386/include/pcpu.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sys/i386/include/pcpu.h b/sys/i386/include/pcpu.h index 1508d2c..e44eea1 100644 --- a/sys/i386/include/pcpu.h +++ b/sys/i386/include/pcpu.h @@ -62,6 +62,7 @@ extern struct pcpu *pcpup; #define PCPU_GET(member) (pcpup->pc_ ## member) +#define PCPU_LAZY_INC(member) (++pcpup->pc_ ## member) #define PCPU_PTR(member) (&pcpup->pc_ ## member) #define PCPU_SET(member, val) (pcpup->pc_ ## member = (val)) @@ -115,6 +116,29 @@ extern struct pcpu *pcpup; }) /* + * Increments the value of the per-cpu counter name. The implementation + * must be atomic with respect to interrupts. + */ +#define __PCPU_LAZY_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. */ #define __PCPU_SET(name, val) { \ @@ -136,6 +160,7 @@ extern struct pcpu *pcpup; } #define PCPU_GET(member) __PCPU_GET(pc_ ## member) +#define PCPU_LAZY_INC(member) __PCPU_LAZY_INC(pc_ ## member) #define PCPU_PTR(member) __PCPU_PTR(pc_ ## member) #define PCPU_SET(member, val) __PCPU_SET(pc_ ## member, val) |