From: Shakeel Butt <shakeel.butt@linux.dev>
To: Rik van Riel <riel@surriel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"Huang, Ying" <ying.huang@intel.com>,
Chris Li <chrisl@kernel.org>,
Ryan Roberts <ryan.roberts@arm.com>,
David Hildenbrand <david@redhat.com>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
kernel-team@meta.com
Subject: Re: [PATCH] mm: add maybe_lru_add_drain() that only drains when threshold is exceeded
Date: Wed, 18 Dec 2024 12:20:57 -0800 [thread overview]
Message-ID: <43o2dqigz6cap75h7y25jz6qbdzoinyq3ntxx4sm5cn3y4dddm@mwyjjygrxhmm> (raw)
In-Reply-To: <20241218115604.7e56bedb@fangorn>
On Wed, Dec 18, 2024 at 11:56:04AM -0500, Rik van Riel wrote:
[...]
>
> +static bool should_lru_add_drain(void)
> +{
> + struct cpu_fbatches *fbatches = this_cpu_ptr(&cpu_fbatches);
You will need either a local_lock or preempt_disable to access the per
cpu batches.
> + int pending = folio_batch_count(&fbatches->lru_add);
> + pending += folio_batch_count(&fbatches->lru_deactivate);
> + pending += folio_batch_count(&fbatches->lru_deactivate_file);
> + pending += folio_batch_count(&fbatches->lru_lazyfree);
> +
> + /* Don't bother draining unless we have several pages pending. */
> + return pending > SWAP_CLUSTER_MAX;
> +}
> +
> +void maybe_lru_add_drain(void)
Later it might also make sense to see if other users of lru_add_drain()
should be fine with maybe_lru_add_drain() as well.
> +{
> + if (should_lru_add_drain())
> + lru_add_drain();
> +}
> +
next prev parent reply other threads:[~2024-12-18 20:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-18 16:56 Rik van Riel
2024-12-18 20:20 ` Shakeel Butt [this message]
2024-12-19 3:13 ` Rik van Riel
2024-12-19 17:00 ` Shakeel Butt
2024-12-19 13:47 ` David Hildenbrand
2024-12-19 14:11 ` Rik van Riel
2024-12-19 17:23 ` David Hildenbrand
2024-12-19 17:50 ` Rik van Riel
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=43o2dqigz6cap75h7y25jz6qbdzoinyq3ntxx4sm5cn3y4dddm@mwyjjygrxhmm \
--to=shakeel.butt@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=chrisl@kernel.org \
--cc=david@redhat.com \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=riel@surriel.com \
--cc=ryan.roberts@arm.com \
--cc=willy@infradead.org \
--cc=ying.huang@intel.com \
/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