diff options
author | Christoph Lameter <clameter@sgi.com> | 2006-06-30 04:55:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-30 14:25:36 -0400 |
commit | f8891e5e1f93a128c3900f82035e8541357896a7 (patch) | |
tree | 97b078ac97970962b17c85d39fd64cb48dc01168 /drivers/parisc/led.c | |
parent | ca889e6c45e0b112cb2ca9d35afc66297519b5d5 (diff) |
[PATCH] Light weight event counters
The remaining counters in page_state after the zoned VM counter patches
have been applied are all just for show in /proc/vmstat. They have no
essential function for the VM.
We use a simple increment of per cpu variables. In order to avoid the most
severe races we disable preempt. Preempt does not prevent the race between
an increment and an interrupt handler incrementing the same statistics
counter. However, that race is exceedingly rare, we may only loose one
increment or so and there is no requirement (at least not in kernel) that
the vm event counters have to be accurate.
In the non preempt case this results in a simple increment for each
counter. For many architectures this will be reduced by the compiler to a
single instruction. This single instruction is atomic for i386 and x86_64.
And therefore even the rare race condition in an interrupt is avoided for
both architectures in most cases.
The patchset also adds an off switch for embedded systems that allows a
building of linux kernels without these counters.
The implementation of these counters is through inline code that hopefully
results in only a single instruction increment instruction being emitted
(i386, x86_64) or in the increment being hidden though instruction
concurrency (EPIC architectures such as ia64 can get that done).
Benefits:
- VM event counter operations usually reduce to a single inline instruction
on i386 and x86_64.
- No interrupt disable, only preempt disable for the preempt case.
Preempt disable can also be avoided by moving the counter into a spinlock.
- Handling is similar to zoned VM counters.
- Simple and easily extendable.
- Can be omitted to reduce memory use for embedded use.
References:
RFC http://marc.theaimsgroup.com/?l=linux-kernel&m=113512330605497&w=2
RFC http://marc.theaimsgroup.com/?l=linux-kernel&m=114988082814934&w=2
local_t http://marc.theaimsgroup.com/?l=linux-kernel&m=114991748606690&w=2
V2 http://marc.theaimsgroup.com/?t=115014808400007&r=1&w=2
V3 http://marc.theaimsgroup.com/?l=linux-kernel&m=115024767022346&w=2
V4 http://marc.theaimsgroup.com/?l=linux-kernel&m=115047968808926&w=2
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/parisc/led.c')
-rw-r--r-- | drivers/parisc/led.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c index 298f2ddb2c17..d7024c7483bd 100644 --- a/drivers/parisc/led.c +++ b/drivers/parisc/led.c | |||
@@ -411,16 +411,17 @@ static __inline__ int led_get_net_activity(void) | |||
411 | static __inline__ int led_get_diskio_activity(void) | 411 | static __inline__ int led_get_diskio_activity(void) |
412 | { | 412 | { |
413 | static unsigned long last_pgpgin, last_pgpgout; | 413 | static unsigned long last_pgpgin, last_pgpgout; |
414 | struct page_state pgstat; | 414 | unsigned long events[NR_VM_EVENT_ITEMS]; |
415 | int changed; | 415 | int changed; |
416 | 416 | ||
417 | get_full_page_state(&pgstat); /* get no of sectors in & out */ | 417 | all_vm_events(events); |
418 | 418 | ||
419 | /* Just use a very simple calculation here. Do not care about overflow, | 419 | /* Just use a very simple calculation here. Do not care about overflow, |
420 | since we only want to know if there was activity or not. */ | 420 | since we only want to know if there was activity or not. */ |
421 | changed = (pgstat.pgpgin != last_pgpgin) || (pgstat.pgpgout != last_pgpgout); | 421 | changed = (events[PGPGIN] != last_pgpgin) || |
422 | last_pgpgin = pgstat.pgpgin; | 422 | (events[PGPGOUT] != last_pgpgout); |
423 | last_pgpgout = pgstat.pgpgout; | 423 | last_pgpgin = events[PGPGIN]; |
424 | last_pgpgout = events[PGPGOUT]; | ||
424 | 425 | ||
425 | return (changed ? LED_DISK_IO : 0); | 426 | return (changed ? LED_DISK_IO : 0); |
426 | } | 427 | } |