All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Hongchen Zhang <zhanghongchen@loongson.cn>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/vmscan: don't scan adjust too much if current is not kswapd
Date: Wed, 14 Sep 2022 15:51:42 -0700	[thread overview]
Message-ID: <20220914155142.bf388515a39fb45bae987231@linux-foundation.org> (raw)
In-Reply-To: <20220914023318.549118-1-zhanghongchen@loongson.cn>

On Wed, 14 Sep 2022 10:33:18 +0800 Hongchen Zhang <zhanghongchen@loongson.cn> wrote:

> when a process falls into page fault and there is not enough free
> memory,it will do direct reclaim. At the same time,it is holding
> mmap_lock.So in case of multi-thread,it should exit from page fault
> ASAP.
> When reclaim memory,we do scan adjust between anon and file lru which
> may cost too much time and trigger hung task for other thread.So for a
> process which is not kswapd,it should just do a little scan adjust.

Well, that's a pretty nasty bug.  Before diving into a possible fix,
can you please tell us more about how this happens?  What sort of
machine, what sort of workload.  Can you suggest why others are not
experiencing this?

> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -3042,11 +3042,17 @@ static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc)
>  		nr[lru] = targets[lru] * (100 - percentage) / 100;
>  		nr[lru] -= min(nr[lru], nr_scanned);
>  
> +		if (!current_is_kswapd())
> +			nr[lru] = min(nr[lru], nr_to_reclaim);
> +
>  		lru += LRU_ACTIVE;
>  		nr_scanned = targets[lru] - nr[lru];
>  		nr[lru] = targets[lru] * (100 - percentage) / 100;
>  		nr[lru] -= min(nr[lru], nr_scanned);
>  
> +		if (!current_is_kswapd())
> +			nr[lru] = min(nr[lru], nr_to_reclaim);
> +
>  		scan_adjusted = true;
>  	}
>  	blk_finish_plug(&plug);

It would be better if these additions had code comments explaining why
they're there.  But let's more fully understand the problem before
altering your patch.


  reply	other threads:[~2022-09-14 22:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14  2:33 [PATCH] mm/vmscan: don't scan adjust too much if current is not kswapd Hongchen Zhang
2022-09-14 22:51 ` Andrew Morton [this message]
2022-09-14 23:02   ` Matthew Wilcox
2022-09-15  1:19   ` Hongchen Zhang
2022-09-15  7:28     ` Matthew Wilcox
2022-09-15  8:02       ` Hongchen Zhang
2022-09-15  9:00         ` Matthew Wilcox
2022-09-15  9:30           ` Hongchen Zhang
2022-09-16  0:57           ` Hongchen Zhang
2022-09-16  8:40             ` Matthew Wilcox
2022-09-16 10:19               ` Hongchen Zhang
2022-09-19 23:32                 ` Yosry Ahmed
2022-09-20  5:53                   ` Hongchen Zhang
2022-09-20  2:23                 ` Hongchen Zhang
2022-09-21  9:13                   ` Mel Gorman
2022-09-21 10:14                     ` Hongchen Zhang
2022-09-15 13:38         ` Feng Tang

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=20220914155142.bf388515a39fb45bae987231@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=zhanghongchen@loongson.cn \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.