From: Rik van Riel <riel@surriel.com>
To: Shakeel Butt <shakeel.butt@linux.dev>
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 22:13:30 -0500 [thread overview]
Message-ID: <acb8c972fe569bf0fcfe65a1d806b135d007ef88.camel@surriel.com> (raw)
In-Reply-To: <43o2dqigz6cap75h7y25jz6qbdzoinyq3ntxx4sm5cn3y4dddm@mwyjjygrxhmm>
On Wed, 2024-12-18 at 12:20 -0800, Shakeel Butt wrote:
> 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.
>
Why is that? Can the per-cpu batches disappear on us
while we're trying to access them, without that
local_lock or preempt_disable?
I'm not trying to protect against accidentally reading
the wrong CPU's numbers, since we could be preempted
and migrated to another CPU immediately after returning
from should_lru_add_drain, but do want to keep things
safe against other potential issues.
> > + 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.
Agreed. I think there are a few other users where this
could make sense, including munmap.
--
All Rights Reversed.
next prev parent reply other threads:[~2024-12-19 3:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-18 16:56 [PATCH] mm: add maybe_lru_add_drain() that only drains when threshold is exceeded Rik van Riel
2024-12-18 20:20 ` Shakeel Butt
2024-12-19 3:13 ` Rik van Riel [this message]
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=acb8c972fe569bf0fcfe65a1d806b135d007ef88.camel@surriel.com \
--to=riel@surriel.com \
--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=ryan.roberts@arm.com \
--cc=shakeel.butt@linux.dev \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.