diff options
author | Paul Mackerras <paulus@samba.org> | 2006-03-08 22:32:05 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-03-08 22:32:05 -0500 |
commit | 516450179454de9e689e0a53ed8f34b896e8651c (patch) | |
tree | 78eae2f77de6cd39b18c7393fc5854456fc3fb1f /mm/swap.c | |
parent | 6749c5507388f3fc3719f57a54b540ee83f6661a (diff) | |
parent | 0d514f040ac6629311974889d5b96bcf21c6461a (diff) |
Merge ../linux-2.6
Diffstat (limited to 'mm/swap.c')
-rw-r--r-- | mm/swap.c | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -489,13 +489,34 @@ void percpu_counter_mod(struct percpu_counter *fbc, long amount) | |||
489 | if (count >= FBC_BATCH || count <= -FBC_BATCH) { | 489 | if (count >= FBC_BATCH || count <= -FBC_BATCH) { |
490 | spin_lock(&fbc->lock); | 490 | spin_lock(&fbc->lock); |
491 | fbc->count += count; | 491 | fbc->count += count; |
492 | *pcount = 0; | ||
492 | spin_unlock(&fbc->lock); | 493 | spin_unlock(&fbc->lock); |
493 | count = 0; | 494 | } else { |
495 | *pcount = count; | ||
494 | } | 496 | } |
495 | *pcount = count; | ||
496 | put_cpu(); | 497 | put_cpu(); |
497 | } | 498 | } |
498 | EXPORT_SYMBOL(percpu_counter_mod); | 499 | EXPORT_SYMBOL(percpu_counter_mod); |
500 | |||
501 | /* | ||
502 | * Add up all the per-cpu counts, return the result. This is a more accurate | ||
503 | * but much slower version of percpu_counter_read_positive() | ||
504 | */ | ||
505 | long percpu_counter_sum(struct percpu_counter *fbc) | ||
506 | { | ||
507 | long ret; | ||
508 | int cpu; | ||
509 | |||
510 | spin_lock(&fbc->lock); | ||
511 | ret = fbc->count; | ||
512 | for_each_cpu(cpu) { | ||
513 | long *pcount = per_cpu_ptr(fbc->counters, cpu); | ||
514 | ret += *pcount; | ||
515 | } | ||
516 | spin_unlock(&fbc->lock); | ||
517 | return ret < 0 ? 0 : ret; | ||
518 | } | ||
519 | EXPORT_SYMBOL(percpu_counter_sum); | ||
499 | #endif | 520 | #endif |
500 | 521 | ||
501 | /* | 522 | /* |