From: Andrew Morton <akpm@linux-foundation.org>
To: Christoph Lameter <clameter@sgi.com>
Cc: linux-mm@kvack.org
Subject: Re: Use ZVC counters to establish exact size of dirtyable pages
Date: Wed, 14 Feb 2007 14:24:32 -0800 [thread overview]
Message-ID: <20070214142432.a7e913fa.akpm@linux-foundation.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0702130933001.23798@schroedinger.engr.sgi.com>
On Tue, 13 Feb 2007 09:43:43 -0800 (PST)
Christoph Lameter <clameter@sgi.com> wrote:
> We can use the global ZVC counters to establish the exact size of the LRU
> and the free pages. This allows a more accurate determination of the dirty
> ratio.
>
> This patch will fix the broken ratio calculations if large amounts of
> memory are allocated to huge pags or other consumers that do not put the
> pages on to the LRU.
>
> Notes:
> - I did not add NR_SLAB_RECLAIMABLE to the calculation of the
> dirtyable pages. Those may be reclaimable but they are at this
> point not dirtyable. If NR_SLAB_RECLAIMABLE would be considered
> then a huge number of reclaimable pages would stop writeback
> from occurring.
>
> - This patch used to be in mm as the last one in a series of patches.
> It was removed when Linus updated the treatment of highmem because
> there was a conflict. I updated the patch to follow Linus' approach.
> This patch is neede to fulfill the claims made in the beginning of the
> patchset that is now in Linus' tree.
>
Let's get paranoid.
> --- linux-2.6.orig/mm/page-writeback.c 2007-02-12 09:15:22.000000000 -0800
> +++ linux-2.6/mm/page-writeback.c 2007-02-13 09:40:04.000000000 -0800
> @@ -119,6 +119,38 @@ static void background_writeout(unsigned
> * We make sure that the background writeout level is below the adjusted
> * clamping level.
> */
> +
> +static unsigned long highmem_dirtyable_memory(void)
> +{
> +#ifdef CONFIG_HIGHMEM
> + int node;
> + unsigned long x = 0;
> +
> + for_each_online_node(node) {
> + struct zone *z =
> + &NODE_DATA(node)->node_zones[ZONE_HIGHMEM];
> +
> + x += zone_page_state(z, NR_FREE_PAGES)
> + + zone_page_state(z, NR_INACTIVE)
> + + zone_page_state(z, NR_ACTIVE);
> + }
> + return x;
> +#else
> + return 0;
> +#endif
> +}
> +
> +static unsigned long determine_dirtyable_memory(void)
> +{
> + unsigned long x;
> +
> + x = global_page_state(NR_FREE_PAGES)
> + + global_page_state(NR_INACTIVE)
> + + global_page_state(NR_ACTIVE)
> + - highmem_dirtyable_memory();
> + return x;
> +}
Suppose a zone has ten dirty pages. All the remaining pages in the zone
are off being used for soundcard buffers and networking skbs.
The zone's ten dirty pages are temporarily off the LRU, being processed by
the vm scanner.
So we're now in the state where the zone has more dirty pages than it has
dirtyable memory(!).
This function will return zero. Which I think we'll happen to handle OK.
But this function can, I think, also return negative (ie: very large)
numbers. I don't think we handle that right.
> static void
> get_dirty_limits(long *pbackground, long *pdirty,
> struct address_space *mapping)
> @@ -128,17 +160,9 @@ get_dirty_limits(long *pbackground, long
> int unmapped_ratio;
> long background;
> long dirty;
> - unsigned long available_memory = vm_total_pages;
> + unsigned long available_memory = determine_dirtyable_memory();
> struct task_struct *tsk;
>
> -#ifdef CONFIG_HIGHMEM
> - /*
> - * We always exclude high memory from our count.
> - */
> - available_memory -= totalhigh_pages;
> -#endif
> -
> -
> unmapped_ratio = 100 - ((global_page_state(NR_FILE_MAPPED) +
> global_page_state(NR_ANON_PAGES)) * 100) /
> vm_total_pages;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2007-02-14 22:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-12 18:16 Christoph Lameter
2007-02-13 8:04 ` Andrew Morton
2007-02-13 17:43 ` Christoph Lameter
2007-02-13 18:03 ` Andrew Morton
2007-02-14 22:24 ` Andrew Morton [this message]
2007-02-14 22:41 ` Christoph Lameter
2007-02-14 22:49 ` Christoph Lameter
2007-02-14 23:19 ` Andrew Morton
2007-02-14 23:35 ` Christoph Lameter
2007-02-14 23:44 ` Andrew Morton
2007-02-15 0:00 ` Christoph Lameter
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=20070214142432.a7e913fa.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=clameter@sgi.com \
--cc=linux-mm@kvack.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