Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Yu Zhao <yuzhao@google.com>
Cc: stable@vger.kernel.org, "T.J. Mercier" <tjmercier@google.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 6.6.y 3/3] mm/mglru: fix ineffective protection calculation
Date: Tue, 30 Jul 2024 15:52:22 +0200	[thread overview]
Message-ID: <2024073016-spinach-salaried-fba0@gregkh> (raw)
In-Reply-To: <20240729074434.1223587-3-yuzhao@google.com>

On Mon, Jul 29, 2024 at 01:44:34AM -0600, Yu Zhao wrote:
> mem_cgroup_calculate_protection() is not stateless and should only be used
> as part of a top-down tree traversal.  shrink_one() traverses the per-node
> memcg LRU instead of the root_mem_cgroup tree, and therefore it should not
> call mem_cgroup_calculate_protection().
> 
> The existing misuse in shrink_one() can cause ineffective protection of
> sub-trees that are grandchildren of root_mem_cgroup.  Fix it by reusing
> lru_gen_age_node(), which already traverses the root_mem_cgroup tree, to
> calculate the protection.
> 
> Previously lru_gen_age_node() opportunistically skips the first pass,
> i.e., when scan_control->priority is DEF_PRIORITY.  On the second pass,
> lruvec_is_sizable() uses appropriate scan_control->priority, set by
> set_initial_priority() from lru_gen_shrink_node(), to decide whether a
> memcg is too small to reclaim from.
> 
> Now lru_gen_age_node() unconditionally traverses the root_mem_cgroup tree.
> So it should call set_initial_priority() upfront, to make sure
> lruvec_is_sizable() uses appropriate scan_control->priority on the first
> pass.  Otherwise, lruvec_is_reclaimable() can return false negatives and
> result in premature OOM kills when min_ttl_ms is used.
> 
> Link: https://lkml.kernel.org/r/20240712232956.1427127-1-yuzhao@google.com
> Fixes: e4dde56cd208 ("mm: multi-gen LRU: per-node lru_gen_folio lists")
> Signed-off-by: Yu Zhao <yuzhao@google.com>
> Reported-by: T.J. Mercier <tjmercier@google.com>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> (cherry picked from commit 30d77b7eef019fa4422980806e8b7cdc8674493e)
> ---
>  mm/vmscan.c | 83 ++++++++++++++++++++++++-----------------------------
>  1 file changed, 38 insertions(+), 45 deletions(-)

Now queued up, thanks.

greg k-h

  reply	other threads:[~2024-07-30 13:52 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 ` [PATCH 6.6.y 1/3] mm/mglru: fix div-by-zero in vmpressure_calc_level() Yu Zhao
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 [this message]
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=2024073016-spinach-salaried-fba0@gregkh \
    --to=greg@kroah.com \
    --cc=akpm@linux-foundation.org \
    --cc=stable@vger.kernel.org \
    --cc=tjmercier@google.com \
    --cc=yuzhao@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