linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Ryan Roberts <ryan.roberts@arm.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	David Hildenbrand <david@redhat.com>
Subject: Re: [PATCH] mm: memory: move mem_cgroup_charge() into alloc_anon_folio()
Date: Tue, 16 Jan 2024 14:51:13 +0000	[thread overview]
Message-ID: <ZaaX4Yi9JYBWrUEs@casper.infradead.org> (raw)
In-Reply-To: <2c24afdf-5103-4c1b-a649-2eeed185f3fb@arm.com>

On Tue, Jan 16, 2024 at 02:35:54PM +0000, Ryan Roberts wrote:
> On 16/01/2024 07:13, Kefeng Wang wrote:
> > In order to allocate as much as possible of large folio, move
> > the mem charge into alloc_anon_folio() and try the next order
> > if mem_cgroup_charge() fails, also we change the GFP_KERNEL
> > to gfp to be consistent with PMD THP.
> 
> I agree that changing gfp gives you consistency. But it's not entirely clear to
> me why THP should use one set of flags for this case, and since pages another.
> Why does this difference exist?

I think it needs to be spelled out much better in the changelog.  Here's
my attempt at explaining why we might want this change.

mem_cgroup_charge() uses the GFP flags in a fairly sophisticated way.
In addition to checking gfpflags_allow_blocking(), it pays attention to
__GFP_NORETRY and __GFP_RETRY_MAYFAIL to ensure that processes within
this memcg do not exceed their quotas.  Using the same GFP flags ensures
that we handle large anonymous folios correctly, including falling back
to smaller orders when there is plenty of memory available in the system
but this memcg is close to its limits.

... I remain not-an-expert in memcg and anonymous memory and welcome
improvements to that text.


  reply	other threads:[~2024-01-16 14:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-16  7:13 Kefeng Wang
2024-01-16 14:35 ` Ryan Roberts
2024-01-16 14:51   ` Matthew Wilcox [this message]
2024-01-16 15:07     ` Ryan Roberts
2024-01-17  1:34       ` Kefeng Wang
2024-01-16 21:26 ` kernel test robot
2024-01-17  1:02   ` Kefeng Wang
2024-01-16 23:41 ` kernel test robot

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=ZaaX4Yi9JYBWrUEs@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ryan.roberts@arm.com \
    --cc=wangkefeng.wang@huawei.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