diff options
author | attilio <attilio@FreeBSD.org> | 2007-06-04 21:38:48 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2007-06-04 21:38:48 +0000 |
commit | e333d0ff0eb23a5f94f36fd95b4bbcfda3ccbc8f (patch) | |
tree | a35bbd71798a97fd11a5f264ff97c562de001111 /sys/i386 | |
parent | 771efb08f5bfaf22da0498ae91647fdecb3cc6bb (diff) | |
download | FreeBSD-src-e333d0ff0eb23a5f94f36fd95b4bbcfda3ccbc8f.zip FreeBSD-src-e333d0ff0eb23a5f94f36fd95b4bbcfda3ccbc8f.tar.gz |
Rework the PCPU_* (MD) interface:
- Rename PCPU_LAZY_INC into PCPU_INC
- Add the PCPU_ADD interface which just does an add on the pcpu member
given a specific value.
Note that for most architectures PCPU_INC and PCPU_ADD are not safe.
This is a point that needs some discussions/work in the next days.
Reviewed by: alc, bde
Approved by: jeff (mentor)
Diffstat (limited to 'sys/i386')
-rw-r--r-- | sys/i386/i386/intr_machdep.c | 4 | ||||
-rw-r--r-- | sys/i386/i386/trap.c | 6 | ||||
-rw-r--r-- | sys/i386/include/pcpu.h | 29 |
3 files changed, 31 insertions, 8 deletions
diff --git a/sys/i386/i386/intr_machdep.c b/sys/i386/i386/intr_machdep.c index 65e67e2..a07ee77 100644 --- a/sys/i386/i386/intr_machdep.c +++ b/sys/i386/i386/intr_machdep.c @@ -241,7 +241,7 @@ intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame) * processed too. */ (*isrc->is_count)++; - PCPU_LAZY_INC(cnt.v_intr); + PCPU_INC(cnt.v_intr); ie = isrc->is_event; @@ -312,7 +312,7 @@ intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame) * processed too. */ (*isrc->is_count)++; - PCPU_LAZY_INC(cnt.v_intr); + PCPU_INC(cnt.v_intr); ie = isrc->is_event; diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index 83fe391..e44e427 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -181,7 +181,7 @@ trap(struct trapframe *frame) static int lastalert = 0; #endif - PCPU_LAZY_INC(cnt.v_trap); + PCPU_INC(cnt.v_trap); type = frame->tf_trapno; #ifdef SMP @@ -922,10 +922,10 @@ syscall(struct trapframe *frame) ksiginfo_t ksi; /* - * note: PCPU_LAZY_INC() can only be used if we can afford + * note: PCPU_INC() can only be used if we can afford * occassional inaccuracy in the count. */ - PCPU_LAZY_INC(cnt.v_syscall); + PCPU_INC(cnt.v_syscall); #ifdef DIAGNOSTIC if (ISPL(frame->tf_cs) != SEL_UPL) { diff --git a/sys/i386/include/pcpu.h b/sys/i386/include/pcpu.h index e44eea1..67cb530 100644 --- a/sys/i386/include/pcpu.h +++ b/sys/i386/include/pcpu.h @@ -62,7 +62,8 @@ extern struct pcpu *pcpup; #define PCPU_GET(member) (pcpup->pc_ ## member) -#define PCPU_LAZY_INC(member) (++pcpup->pc_ ## member) +#define PCPU_ADD(member, val) (pcpu->pc_ ## member += (val)) +#define PCPU_INC(member) PCPU_ADD(member, 1) #define PCPU_PTR(member) (&pcpup->pc_ ## member) #define PCPU_SET(member, val) (pcpup->pc_ ## member = (val)) @@ -116,10 +117,31 @@ extern struct pcpu *pcpup; }) /* + * Adds a value of the per-cpu counter name. The implementation + * must be atomic with respect to interrupts. + */ +#define __PCPU_ADD(name, val) do { \ + __pcpu_type(name) __val; \ + struct __s { \ + u_char __b[MIN(sizeof(__pcpu_type(name)), 4)]; \ + } __s; \ + \ + __val = (val); \ + if (sizeof(__val) == 1 || sizeof(__val) == 2 || \ + sizeof(__val) == 4) { \ + __s = *(struct __s *)(void *)&__val; \ + __asm __volatile("add %1,%%fs:%0" \ + : "=m" (*(struct __s *)(__pcpu_offset(name))) \ + : "r" (__s)); \ + } else \ + *__PCPU_PTR(name) += __val; \ +} while (0) + +/* * Increments the value of the per-cpu counter name. The implementation * must be atomic with respect to interrupts. */ -#define __PCPU_LAZY_INC(name) do { \ +#define __PCPU_INC(name) do { \ CTASSERT(sizeof(__pcpu_type(name)) == 1 || \ sizeof(__pcpu_type(name)) == 2 || \ sizeof(__pcpu_type(name)) == 4); \ @@ -160,7 +182,8 @@ extern struct pcpu *pcpup; } #define PCPU_GET(member) __PCPU_GET(pc_ ## member) -#define PCPU_LAZY_INC(member) __PCPU_LAZY_INC(pc_ ## member) +#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_SET(member, val) __PCPU_SET(pc_ ## member, val) |