diff options
| author | Steve French <sfrench@us.ibm.com> | 2006-03-20 16:58:09 +0000 | 
|---|---|---|
| committer | Steve French <sfrench@us.ibm.com> | 2006-03-20 16:58:09 +0000 | 
| commit | fd4a0b92db6a57cba8d03efbe1cebf91f9124ce0 (patch) | |
| tree | 5886a08bfa1132058b06074f4666a36dc5ddd2a1 /mm/swap.c | |
| parent | 88274815f7477dc7550439413ab87c5ce4c5a623 (diff) | |
| parent | 7705a8792b0fc82fd7d4dd923724606bbfd9fb20 (diff) | |
Merge with /pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'mm/swap.c')
| -rw-r--r-- | mm/swap.c | 28 | 
1 files changed, 25 insertions, 3 deletions
| diff --git a/mm/swap.c b/mm/swap.c index cce3dda59c5..b524ea90bdd 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -393,7 +393,8 @@ void pagevec_strip(struct pagevec *pvec)  		struct page *page = pvec->pages[i];  		if (PagePrivate(page) && !TestSetPageLocked(page)) { -			try_to_release_page(page, 0); +			if (PagePrivate(page)) +				try_to_release_page(page, 0);  			unlock_page(page);  		}  	} @@ -489,13 +490,34 @@ void percpu_counter_mod(struct percpu_counter *fbc, long amount)  	if (count >= FBC_BATCH || count <= -FBC_BATCH) {  		spin_lock(&fbc->lock);  		fbc->count += count; +		*pcount = 0;  		spin_unlock(&fbc->lock); -		count = 0; +	} else { +		*pcount = count;  	} -	*pcount = count;  	put_cpu();  }  EXPORT_SYMBOL(percpu_counter_mod); + +/* + * Add up all the per-cpu counts, return the result.  This is a more accurate + * but much slower version of percpu_counter_read_positive() + */ +long percpu_counter_sum(struct percpu_counter *fbc) +{ +	long ret; +	int cpu; + +	spin_lock(&fbc->lock); +	ret = fbc->count; +	for_each_cpu(cpu) { +		long *pcount = per_cpu_ptr(fbc->counters, cpu); +		ret += *pcount; +	} +	spin_unlock(&fbc->lock); +	return ret < 0 ? 0 : ret; +} +EXPORT_SYMBOL(percpu_counter_sum);  #endif  /* | 
