lkml.org 
[lkml]   [2010]   [Nov]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [thisops uV2 02/10] vmstat: Optimize zone counter modifications through the use of this cpu operations
* Christoph Lameter (cl@linux.com) wrote:
> We could do this with local cmpxchgs like in the following patch. This
> would avoid preemption disable and interrupt disable (at least on x86).
> Trouble is how do we make this fit for architectures that do not have
> cmpxchg?

All architectures should have a fallback nowadays, no ? This might involve
disabling interrupts around a cmpxchg emulation, which would make the slow path
disable/enable interrupts twice. Is it what you are concerned about ?

Thanks,

Matheu

>
>
> Index: linux-2.6/mm/vmstat.c
> ===================================================================
> --- linux-2.6.orig/mm/vmstat.c 2010-11-29 10:58:52.000000000 -0600
> +++ linux-2.6/mm/vmstat.c 2010-11-29 11:11:34.000000000 -0600
> @@ -169,18 +169,23 @@ void __mod_zone_page_state(struct zone *
> {
> struct per_cpu_pageset __percpu *pcp = zone->pageset;
> s8 __percpu *p = pcp->vm_stat_diff + item;
> - long x;
> - long t;
> + long o, n, t, z;
>
> - x = delta + __this_cpu_read(*p);
> + do {
> + z = 0;
> + t = this_cpu_read(pcp->stat_threshold);
> + o = this_cpu_read(*p);
> + n = delta + o;
> +
> + if (n > t || n < -t) {
> + /* Overflow must be added to zone counters */
> + z = n;
> + n = 0;
> + }
> + } while (o != n && this_cpu_cmpxchg(*p, o, n) != o);
>
> - t = __this_cpu_read(pcp->stat_threshold);
> -
> - if (unlikely(x > t || x < -t)) {
> - zone_page_state_add(x, zone, item);
> - x = 0;
> - }
> - __this_cpu_write(*p, x);
> + if (z)
> + zone_page_state_add(z, zone, item);
> }
> EXPORT_SYMBOL(__mod_zone_page_state);
>
> @@ -190,11 +195,7 @@ EXPORT_SYMBOL(__mod_zone_page_state);
> void mod_zone_page_state(struct zone *zone, enum zone_stat_item item,
> int delta)
> {
> - unsigned long flags;
> -
> - local_irq_save(flags);
> __mod_zone_page_state(zone, item, delta);
> - local_irq_restore(flags);
> }
> EXPORT_SYMBOL(mod_zone_page_state);
>
>

--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com


\
 
 \ /
  Last update: 2010-11-29 20:31    [W:0.084 / U:1.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site