linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Zhaoyang Huang <huangzhaoyang@gmail.com>
To: Yu Zhao <yuzhao@google.com>
Cc: "zhaoyang.huang" <zhaoyang.huang@unisoc.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	 linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	steve.kang@unisoc.com
Subject: Re: [PATCH] mm: throttle and inc min_seq when both page types reach MIN_NR_GENS
Date: Fri, 11 Oct 2024 16:02:37 +0800	[thread overview]
Message-ID: <CAGWkznGBWxVD0La5PArU1F2Q1Tqk40EGP1V0+jRiLNaxWy5zbg@mail.gmail.com> (raw)
In-Reply-To: <CAOUHufaiKFZ6LjoQ8SChK+m0-nPzT6RYpDfLHp69vn1OYm3qhQ@mail.gmail.com>

On Fri, Oct 11, 2024 at 12:37 AM Yu Zhao <yuzhao@google.com> wrote:
>
> On Wed, Oct 9, 2024 at 1:50 AM zhaoyang.huang <zhaoyang.huang@unisoc.com> wrote:
> >
> > From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> >
> > The test case of [1] leads to system hang which caused by a local
> > watchdog thread starved over 20s on a 5.5GB RAM ANDROID15(v6.6)
> > system. This commit solve the issue by have the reclaimer be throttled
> > and increase min_seq if both page types reach MIN_NR_GENS, which may
> > introduce a livelock of switching type with holding lruvec->lru_lock.
> >
> > [1]
> > launch below script 8 times simutanously which allocates 1GB virtual
> > memory and access it from user space by each thread.
> > $ costmem -c1024000 -b12800 -o0 &
> >
> > Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> > ---
> >  mm/vmscan.c | 16 ++++++++++++++--
> >  1 file changed, 14 insertions(+), 2 deletions(-)
> >
> > diff --git a/mm/vmscan.c b/mm/vmscan.c
> > index cfa839284b92..83e450d0ce3c 100644
> > --- a/mm/vmscan.c
> > +++ b/mm/vmscan.c
> > @@ -4384,11 +4384,23 @@ static int scan_folios(struct lruvec *lruvec, struct scan_control *sc,
> >         int remaining = MAX_LRU_BATCH;
> >         struct lru_gen_folio *lrugen = &lruvec->lrugen;
> >         struct mem_cgroup *memcg = lruvec_memcg(lruvec);
> > +       struct pglist_data *pgdat = lruvec_pgdat(lruvec);
> >
> >         VM_WARN_ON_ONCE(!list_empty(list));
> >
> > -       if (get_nr_gens(lruvec, type) == MIN_NR_GENS)
> > -               return 0;
> > +       if (get_nr_gens(lruvec, type) == MIN_NR_GENS) {
> > +               /*
> > +                * throttle for a while and then increase the min_seq since
> > +                * both page types reach the limit.
> > +                */
>
> Sorry but this isn't going to work because in try_to_inc_min_seq(), there is
>    `while (min_seq[type] + MIN_NR_GENS <= lrugen->max_seq) {`
> to prevent reclaimers from evicting hot memory -- they need to do aging first.
Thanks for heads up. What I thought was assuming there is a running
reclaimer will do the aging and the throttled reclaimers increase the
min_seq when scheduled back and move on. Or could we just drop the
lock and throttle for a while to avoid a livelock on 'type = !type'
with holding the lock?

>
> >
> > +               if (get_nr_gens(lruvec, !type) == MIN_NR_GENS) {
> > +                       spin_unlock_irq(&lruvec->lru_lock);
> > +                       reclaim_throttle(pgdat, VMSCAN_THROTTLE_ISOLATED);
> > +                       spin_lock_irq(&lruvec->lru_lock);
> > +                       try_to_inc_min_seq(lruvec, get_swappiness(lruvec, sc));
> > +               } else
> > +                       return 0;
> > +       }
> >
> >         gen = lru_gen_from_seq(lrugen->min_seq[type]);
> >
> > --
> > 2.25.1
> >


  reply	other threads:[~2024-10-11  8:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-09  7:49 zhaoyang.huang
2024-10-09 20:52 ` Andrew Morton
2024-10-10  1:28   ` Zhaoyang Huang
2024-10-10 16:37 ` Yu Zhao
2024-10-11  8:02   ` Zhaoyang Huang [this message]
2024-10-12  1:49     ` Zhaoyang Huang

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=CAGWkznGBWxVD0La5PArU1F2Q1Tqk40EGP1V0+jRiLNaxWy5zbg@mail.gmail.com \
    --to=huangzhaoyang@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=steve.kang@unisoc.com \
    --cc=yuzhao@google.com \
    --cc=zhaoyang.huang@unisoc.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