linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: DaeRo Lee <skseofh@gmail.com>
To: Mel Gorman <mgorman@techsingularity.net>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/vmscan.c: no need to double-check if free pages are under high-watermark
Date: Thu, 6 Jan 2022 21:03:34 +0900	[thread overview]
Message-ID: <CAATEi5=Cmt__5mQLcis5dO9ncc5nyQgiGD22UXtLsgJH5ZbwkA@mail.gmail.com> (raw)
In-Reply-To: <20220106094650.GX3366@techsingularity.net>

> > @@ -4355,7 +4355,7 @@ static enum zone_type kswapd_highest_zoneidx(pg_data_t *pgdat,
> >  static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_order,
> >                               unsigned int highest_zoneidx)
> >  {
> > -     long remaining = 0;
> > +     long remaining = ~0;
> >       DEFINE_WAIT(wait);
> >
> >       if (freezing(current) || kthread_should_stop())
>
> While this does avoid calling prepare_kswapd_sleep() twice if the pgdat
> is balanced on the first try, it then does not restore the vmstat
> thresholds and doesn't call schedul() for kswapd to go to sleep.

I intended not to call prepare_kswapd_sleep() twice when the pgdat is NOT
balanced on the first try:)

> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 700434db5735..40784693c840 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -4355,7 +4355,8 @@ static enum zone_type kswapd_highest_zoneidx(pg_data_t *pgdat,
>  static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_order,
>                                 unsigned int highest_zoneidx)
>  {
> -       long remaining = 0;
> +       long remaining;
> +       bool balanced;
>         DEFINE_WAIT(wait);
>
>         if (freezing(current) || kthread_should_stop())
> @@ -4370,7 +4371,8 @@ static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_o
>          * eligible zone balanced that it's also unlikely that compaction will
>          * succeed.
>          */
> -       if (prepare_kswapd_sleep(pgdat, reclaim_order, highest_zoneidx)) {
> +       balanced = prepare_kswapd_sleep(pgdat, reclaim_order, highest_zoneidx);
> +       if (balanced) {
>                 /*
>                  * Compaction records what page blocks it recently failed to
>                  * isolate pages from and skips them in the future scanning.
> @@ -4387,6 +4389,10 @@ static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_o
>
>                 remaining = schedule_timeout(HZ/10);
>
> +               /* Is pgdat balanced after a short sleep? */
> +               balanced = prepare_kswapd_sleep(pgdat, reclaim_order,
> +                                                       highest_zoneidx);
> +
>                 /*
>                  * If woken prematurely then reset kswapd_highest_zoneidx and
>                  * order. The values will either be from a wakeup request or
> @@ -4406,11 +4412,11 @@ static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_o
>         }
>
>         /*
> -        * After a short sleep, check if it was a premature sleep. If not, then
> -        * go fully to sleep until explicitly woken up.
> +        * If balanced to the high watermark, restore vmstat thresholds and
> +        * kswapd goes to sleep. If kswapd remains awake, account whether
> +        * the low or high watermark was hit quickly.
>          */
> -       if (!remaining &&
> -           prepare_kswapd_sleep(pgdat, reclaim_order, highest_zoneidx)) {
> +       if (balanced) {
>                 trace_mm_vmscan_kswapd_sleep(pgdat->node_id);
>
>                 /*

But, I think what you did is more readable and nice.
Thanks!

> > diff --git a/mm/vmscan.c b/mm/vmscan.c
> > index 700434db5735..1217ecec5bbb 100644
> > --- a/mm/vmscan.c
> > +++ b/mm/vmscan.c
> > @@ -4331,7 +4331,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int highest_zoneidx)
> >       /*
> >        * Return the order kswapd stopped reclaiming at as
> >        * prepare_kswapd_sleep() takes it into account. If another caller
> > -      * entered the allocator slow path while kswapd was awake, order will
> > +      * entered the allqocator slow path while kswapd was awake, order will
> >        * remain at the higher level.
> >        */
> >       return sc.order;
>
> This hunk just adds a typo, drop it.

Sorry about that;;


  reply	other threads:[~2022-01-06 12:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-02  3:31 [PATCH] mm/vmscan.c: no need to double-check if free pages are under high-watermark skseofh
2022-01-06  0:17 ` Andrew Morton
2022-01-06  9:46 ` Mel Gorman
2022-01-06 12:03   ` DaeRo Lee [this message]
2022-01-06 12:57     ` Mel Gorman
2022-03-26 15:50       ` Wei Yang
2022-04-07 13:56         ` Mel Gorman

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='CAATEi5=Cmt__5mQLcis5dO9ncc5nyQgiGD22UXtLsgJH5ZbwkA@mail.gmail.com' \
    --to=skseofh@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    /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).