From: Yu Zhao <yuzhao@google.com>
To: stable@vger.kernel.org
Cc: Yu Zhao <yuzhao@google.com>, Wei Xu <weixugc@google.com>,
Alexander Motin <mav@ixsystems.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 6.6.y 1/3] mm/mglru: fix div-by-zero in vmpressure_calc_level()
Date: Mon, 29 Jul 2024 01:44:32 -0600 [thread overview]
Message-ID: <20240729074434.1223587-1-yuzhao@google.com> (raw)
In-Reply-To: <2024072912-during-vitalize-fe0c@gregkh>
evict_folios() uses a second pass to reclaim folios that have gone through
page writeback and become clean before it finishes the first pass, since
folio_rotate_reclaimable() cannot handle those folios due to the
isolation.
The second pass tries to avoid potential double counting by deducting
scan_control->nr_scanned. However, this can result in underflow of
nr_scanned, under a condition where shrink_folio_list() does not increment
nr_scanned, i.e., when folio_trylock() fails.
The underflow can cause the divisor, i.e., scale=scanned+reclaimed in
vmpressure_calc_level(), to become zero, resulting in the following crash:
[exception RIP: vmpressure_work_fn+101]
process_one_work at ffffffffa3313f2b
Since scan_control->nr_scanned has no established semantics, the potential
double counting has minimal risks. Therefore, fix the problem by not
deducting scan_control->nr_scanned in evict_folios().
Link: https://lkml.kernel.org/r/20240711191957.939105-1-yuzhao@google.com
Fixes: 359a5e1416ca ("mm: multi-gen LRU: retry folios written back while isolated")
Reported-by: Wei Xu <weixugc@google.com>
Signed-off-by: Yu Zhao <yuzhao@google.com>
Cc: Alexander Motin <mav@ixsystems.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 8b671fe1a879923ecfb72dda6caf01460dd885ef)
---
mm/vmscan.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index e9d4c1f6d7bb..0fea816d9946 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -5226,7 +5226,6 @@ static int evict_folios(struct lruvec *lruvec, struct scan_control *sc, int swap
/* retry folios that may have missed folio_rotate_reclaimable() */
list_move(&folio->lru, &clean);
- sc->nr_scanned -= folio_nr_pages(folio);
}
spin_lock_irq(&lruvec->lru_lock);
--
2.46.0.rc1.232.g9752f9e123-goog
next prev parent reply other threads:[~2024-07-29 7:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-29 7:20 FAILED: patch "[PATCH] mm/mglru: fix ineffective protection calculation" failed to apply to 6.6-stable tree gregkh
2024-07-29 7:44 ` Yu Zhao [this message]
2024-07-29 7:44 ` [PATCH 6.6.y 2/3] mm/mglru: fix overshooting shrinker memory Yu Zhao
2024-07-29 7:44 ` [PATCH 6.6.y 3/3] mm/mglru: fix ineffective protection calculation Yu Zhao
2024-07-30 13:52 ` Greg KH
2024-07-29 16:52 ` [PATCH 6.6.y] " T.J. Mercier
2024-07-29 17:06 ` T.J. Mercier
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=20240729074434.1223587-1-yuzhao@google.com \
--to=yuzhao@google.com \
--cc=akpm@linux-foundation.org \
--cc=mav@ixsystems.com \
--cc=stable@vger.kernel.org \
--cc=weixugc@google.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