From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Andrew Morton <akpm@linux-foundation.org>,
Jiexun Wang <wangjiexun@tinylab.org>
Cc: brauner@kernel.org, falcon@tinylab.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
tangjinyu@tinylab.org
Subject: Re: [PATCH v2 1/1] mm/madvise: add cond_resched() in madvise_cold_or_pageout_pte_range()
Date: Fri, 26 Jan 2024 12:12:38 +0900 [thread overview]
Message-ID: <20240126031238.GA329333@google.com> (raw)
In-Reply-To: <20230921174101.8e6271422a857af5414ce0a0@linux-foundation.org>
On (23/09/21 17:41), Andrew Morton wrote:
> > Currently the madvise_cold_or_pageout_pte_range() function exhibits
> > significant latency under memory pressure, which can be effectively
> > reduced by adding cond_resched() within the loop.
> >
> > When the batch_count reaches SWAP_CLUSTER_MAX, we reschedule
> > the task to ensure fairness and avoid long lock holding times.
> >
> > ...
> >
> > --- a/mm/madvise.c
> > +++ b/mm/madvise.c
> > @@ -354,6 +354,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
> > struct folio *folio = NULL;
> > LIST_HEAD(folio_list);
> > bool pageout_anon_only_filter;
> > + unsigned int batch_count = 0;
> >
> > if (fatal_signal_pending(current))
> > return -EINTR;
> > @@ -433,6 +434,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
> > regular_folio:
> > #endif
> > tlb_change_page_size(tlb, PAGE_SIZE);
> > +restart:
> > start_pte = pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
>
> The handling of start_pte looks OK.
>
> > if (!start_pte)
> > return 0;
> > @@ -441,6 +443,15 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
> > for (; addr < end; pte++, addr += PAGE_SIZE) {
> > ptent = ptep_get(pte);
> >
> > + if (++batch_count == SWAP_CLUSTER_MAX) {
> > + batch_count = 0;
> > + if (need_resched()) {
> > + pte_unmap_unlock(start_pte, ptl);
Shouldn't it leave lazy MMU mode here?
---
diff --git a/mm/madvise.c b/mm/madvise.c
index 0f222d464254..127f0c7b69ac 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -451,6 +451,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
if (++batch_count == SWAP_CLUSTER_MAX) {
batch_count = 0;
if (need_resched()) {
+ arch_leave_lazy_mmu_mode();
pte_unmap_unlock(start_pte, ptl);
cond_resched();
goto restart;
next prev parent reply other threads:[~2024-01-26 3:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-21 12:02 [PATCH v2 0/1] mm/madvise: add cond_resched() in madvise_cold_or_pageout_pte_range() Jiexun Wang
[not found] ` <85363861af65fac66c7a98c251906afc0d9c8098.1695291046.git.wangjiexun@tinylab.org>
2023-09-22 0:41 ` [PATCH v2 1/1] " Andrew Morton
2024-01-26 3:12 ` Sergey Senozhatsky [this message]
2024-01-26 3:25 ` [PATCH] mm/madvise: don't forget to leave lazy MMU mode " Sergey Senozhatsky
2024-01-26 6:53 ` Andrew Morton
2024-01-26 7:00 ` Sergey Senozhatsky
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=20240126031238.GA329333@google.com \
--to=senozhatsky@chromium.org \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=falcon@tinylab.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=tangjinyu@tinylab.org \
--cc=wangjiexun@tinylab.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).