From: Stephen Lord <lord@sgi.com>
To: Andrew Morton <akpm@zip.com.au>
Cc: Andi Kleen <ak@suse.de>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] only irq-safe atomic ops
Date: Sat, 23 Feb 2002 16:10:42 -0600 [thread overview]
Message-ID: <3C781362.7070103@sgi.com> (raw)
In-Reply-To: <3C773C02.93C7753E@zip.com.au.suse.lists.linux.kernel> <1014444810.1003.53.camel@phantasy.suse.lists.linux.kernel> <3C773C02.93C7753E@zip.com.au.suse.lists.linux.kernel> <1014449389.1003.149.camel@phantasy.suse.lists.linux.kernel> <3C774AC8.5E0848A2@zip.com.au.suse.lists.linux.kernel> <3C77F503.1060005@sgi.com.suse.lists.linux.kernel> <3C77FB35.16844FE7@zip.com.au.suse.lists.linux.kernel>, Andrew Morton's message of "23 Feb 2002 21:36:17 +0100" <p73y9hjq5mw.fsf@oldwotan.suse.de> <3C78045C.668AB945@zip.com.au> <3C780702.9060109@sgi.com> <3C780CDA.FEAF9CB4@zip.com.au>
Andrew Morton wrote:
>Stephen Lord wrote:
>
>>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)) {
> preempt_disable();
> nr_dirty_pages[smp_processor_id()]++;
> if (nr_dirty_pages[smp_processor_id()] > 2,000,000) {
> fit_it_up();
> }
> preempt_enable();
> }
>
> void fix_it_up()
> {
> spin_lock(&global_counter_lock);
> global_counter += 1,000,000;
> nr_dirty_pages[smp_processor_id()] -= 1,000,000;
> spin_unlock(&global_counter_lock);
> }
>
> int approx_total_dirty_pages()
> {
> int ret;
>
> spin_lock(&global_counter_lock);
> ret = global_counter;
> for (all cpus) {
> ret += nr_dirty_pages[cpu];
> }
> spin_unlock(&global_counter_lock);
> 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.
>
>hmmm.
>
>-
>
As I was plumbing in a sink ;-) the thought also occurred that you could
have allocate
and free counters per cpu. The fix up code could do leveling between
them. Are you
sure you only want to look at the actual value infrequently though?
Every time you
put a page into delalloc state you need to do something similar to
balance_dirty(),
if you only poll the value periodically then it could get way out of
balance before
you noticed. It is very easy to dirty memory this way, cat /dev/zero >
xxxx runs
very quickly.
I would almost say you need to get a 'reservation' of a delalloc page
before you
grab the memory. There are extra memory costs associated with getting the
page out of this state, and if you do not hold threads back from
dirtying pages
you can end up in a situation where you cannot clean up again.
Steve
next prev parent reply other threads:[~2002-02-23 22:09 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1014444810.1003.53.camel@phantasy.suse.lists.linux.kernel>
[not found] ` <3C773C02.93C7753E@zip.com.au.suse.lists.linux.kernel>
[not found] ` <1014449389.1003.149.camel@phantasy.suse.lists.linux.kernel>
[not found] ` <3C774AC8.5E0848A2@zip.com.au.suse.lists.linux.kernel>
[not found] ` <3C77F503.1060005@sgi.com.suse.lists.linux.kernel>
[not found] ` <3C77FB35.16844FE7@zip.com.au.suse.lists.linux.kernel>
2002-02-23 20:56 ` [PATCH] only irq-safe atomic ops Andi Kleen
2002-02-23 21:06 ` Andrew Morton
2002-02-23 21:17 ` Stephen Lord
2002-02-23 21:42 ` Andrew Morton
2002-02-23 22:10 ` Stephen Lord [this message]
2002-02-23 22:34 ` Andrew Morton
2002-02-23 23:07 ` Mike Fedyk
2002-02-23 23:47 ` Andrew Morton
2002-02-25 13:02 ` Stephen Lord
2002-02-25 13:12 ` Jens Axboe
2002-02-25 13:18 ` Stephen Lord
2002-02-25 19:42 ` Andrew Morton
2002-02-25 19:45 ` Steve Lord
2002-02-25 20:05 ` Andrew Morton
2002-02-23 6:13 Robert Love
2002-02-23 6:51 ` Andrew Morton
2002-02-23 7:29 ` Robert Love
2002-02-23 7:54 ` Andrew Morton
2002-02-23 11:38 ` yodaiken
2002-02-23 18:20 ` Robert Love
2002-02-23 19:06 ` yodaiken
2002-02-23 21:57 ` Roman Zippel
2002-02-23 22:10 ` Andrew Morton
2002-02-23 22:23 ` yodaiken
2002-02-23 22:40 ` Andrew Morton
2002-02-23 22:48 ` yodaiken
2002-02-23 23:13 ` Robert Love
2002-02-23 23:45 ` Robert Love
2002-02-23 23:56 ` Andrew Morton
2002-02-24 1:05 ` yodaiken
2002-02-24 1:08 ` Robert Love
2002-02-23 22:00 ` John Levon
2002-02-23 22:43 ` yodaiken
2002-02-23 20:01 ` Stephen Lord
2002-02-23 20:27 ` Andrew Morton
2002-02-23 9:38 ` Russell King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3C781362.7070103@sgi.com \
--to=lord@sgi.com \
--cc=ak@suse.de \
--cc=akpm@zip.com.au \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox