[lkml]   [2002]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] only irq-safe atomic ops
Stephen Lord wrote:
> ...
> >If we needed exact reader-accounting for the number of dirty pages in the
> >machine then we'd need a ton of new locking in fun places like __free_pte(),
> >and that still doesn't account for pages which are only pte-dirty, and it's
> >not obvious what we'd do with reader-exact dirty page info anyway?
> >
> >
> You do want to avoid a leak in one direction or the other, the os would
> start to think it
> had lots of dirty pages, but not be able to find them, or think there is
> no shortage
> when in fact there was.

Oh absolutely. Even a one-page-per-hour leak would be catastrophic.

But there is a problem. If CPUA is always setting pages dirty,
and CPUB is always setting them clean, CPUA's counter will eventually
overflow, and CPUB's will underflow. Drat.

One fix for this would be special-case over- and under-flow handling:

if (TestSetPageDirty(page)) {
if (nr_dirty_pages[smp_processor_id()] > 2,000,000) {

void fix_it_up()
global_counter += 1,000,000;
nr_dirty_pages[smp_processor_id()] -= 1,000,000;

int approx_total_dirty_pages()
int ret;

ret = global_counter;
for (all cpus) {
ret += nr_dirty_pages[cpu];
return ret;

Or something like that.

Then again, maybe the underflows and overflows don't matter, because the
sum of all counters is always correct. Unless there's a counter roll-over
during the summation. No. Even then it's OK.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:24    [W:0.024 / U:22.512 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site