Commit f98bf5ff authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] percpu: balance_dirty_pages ratelimit counters

Convert balance_dirty_pages_ratelimited() to use percpu storage
for the ratelimiting counters.
parent 4524ea04
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/backing-dev.h> #include <linux/backing-dev.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/mpage.h> #include <linux/mpage.h>
#include <linux/percpu.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/smp.h> #include <linux/smp.h>
...@@ -182,9 +183,7 @@ EXPORT_SYMBOL_GPL(balance_dirty_pages); ...@@ -182,9 +183,7 @@ EXPORT_SYMBOL_GPL(balance_dirty_pages);
*/ */
void balance_dirty_pages_ratelimited(struct address_space *mapping) void balance_dirty_pages_ratelimited(struct address_space *mapping)
{ {
static struct rate_limit_struct { static DEFINE_PER_CPU(int, ratelimits) = 0;
int count;
} ____cacheline_aligned_in_smp ratelimits[NR_CPUS];
int cpu; int cpu;
long ratelimit; long ratelimit;
...@@ -193,8 +192,8 @@ void balance_dirty_pages_ratelimited(struct address_space *mapping) ...@@ -193,8 +192,8 @@ void balance_dirty_pages_ratelimited(struct address_space *mapping)
ratelimit = 8; ratelimit = 8;
cpu = get_cpu(); cpu = get_cpu();
if (ratelimits[cpu].count++ >= ratelimit) { if (per_cpu(ratelimits, cpu)++ >= ratelimit) {
ratelimits[cpu].count = 0; per_cpu(ratelimits, cpu) = 0;
put_cpu(); put_cpu();
balance_dirty_pages(mapping); balance_dirty_pages(mapping);
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment