From: Andi Kleen <ak@linux.intel.com>
To: Chunsheng Luo <luochunsheng@ustc.edu>
Cc: gregkh@linuxfoundation.org, rafael@kernel.org,
akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH] meminfo: provide estimated per-node's available memory
Date: Fri, 09 Feb 2024 01:56:03 -0800 [thread overview]
Message-ID: <87fry2t0zw.fsf@linux.intel.com> (raw)
In-Reply-To: <20240204083414.107799-1-luochunsheng@ustc.edu> (Chunsheng Luo's message of "Sun, 4 Feb 2024 03:34:14 -0500")
Chunsheng Luo <luochunsheng@ustc.edu> writes:
> + available = sum_zone_node_page_state(nid, NR_FREE_PAGES) - pgdat->totalreserve_pages;
> +
> + /*
> + * Not all the page cache can be freed, otherwise the system will
> + * start swapping or thrashing. Assume at least half of the page
> + * cache, or the low watermark worth of cache, needs to stay.
> + */
> + pagecache = node_page_state(pgdat, NR_ACTIVE_FILE) +
> + node_page_state(pgdat, NR_INACTIVE_FILE);
> + pagecache -= min(pagecache / 2, wmark_low);
The magic number 2 should be a define (or maybe even a tunable). Similar
below. It seems quite arbitrary, but I don't have a better solution
either. Maybe could handle dirty differently, but nothing stands out here
> + node_page_state(pgdat, NR_KERNEL_MISC_RECLAIMABLE);
> + reclaimable -= min(reclaimable / 2, wmark_low);
> + available += reclaimable;
> +
> + if (available < 0)
> + available = 0;
That would be a bug? Perhaps add a WARN_ON
With those changes:
Reviewed-by: Andi Kleen <ak@linux.intel.com>
-Andi
prev parent reply other threads:[~2024-02-09 9:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-04 8:34 [PATCH] meminfo: provide estimated per-node's available memory Chunsheng Luo
2024-02-09 9:56 ` Andi Kleen [this message]
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=87fry2t0zw.fsf@linux.intel.com \
--to=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luochunsheng@ustc.edu \
--cc=rafael@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;
as well as URLs for NNTP newsgroup(s).