linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Haifeng Xu <haifeng.xu@shopee.com>
Cc: mhocko@suse.com, hannes@cmpxchg.org, roman.gushchin@linux.dev,
	shakeelb@google.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm, vmpressure: remove redundant check in vmpressure()
Date: Wed, 19 Apr 2023 13:03:11 -0700	[thread overview]
Message-ID: <20230419130311.587b7273eca2512c07b32bd0@linux-foundation.org> (raw)
In-Reply-To: <20230419092007.186938-1-haifeng.xu@shopee.com>

On Wed, 19 Apr 2023 09:20:07 +0000 Haifeng Xu <haifeng.xu@shopee.com> wrote:

> There are three places, vmpressure_prio(), shrink_node_memcgs() and
> shrink_node(), which invoke vmpressure(). But only shrink_node_memcgs()
> sets tree to false and the memcg used in it is not NULL, so we don't
> check it again in vmpressure().
> 
> ...
>
> --- a/mm/vmpressure.c
> +++ b/mm/vmpressure.c
> @@ -284,7 +284,7 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, bool tree,
>  		enum vmpressure_levels level;
>  
>  		/* For now, no users for root-level efficiency */
> -		if (!memcg || mem_cgroup_is_root(memcg))
> +		if (mem_cgroup_is_root(memcg))
>  			return;
>  
>  		spin_lock(&vmpr->sr_lock);

try_to_free_pages()->
  do_try_to_free_pages()->
    vmpressure_prio()-> 
      vmpressure()->
        crash

what am I missing here?


It does appear that vmpressure() could be simplified with

	if (!memcg)
		memcg = root_mem_cgroup;

so the test you identified goes away and the memcg_to_vmpressure() call
becomes simpler.  But that's such a small change it doesn't seem worth
the effort.


  reply	other threads:[~2023-04-19 20:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-19  9:20 Haifeng Xu
2023-04-19 20:03 ` Andrew Morton [this message]
2023-04-20  2:25   ` Haifeng Xu

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=20230419130311.587b7273eca2512c07b32bd0@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=haifeng.xu@shopee.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeelb@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