The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Huang, Ying" <ying.huang@linux.alibaba.com>
To: Gregory Price <gourry@gourry.net>
Cc: linux-mm@kvack.org,  linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org,  kernel-team@meta.com,
	willy@infradead.org,  jack@suse.cz,  akpm@linux-foundation.org,
	david@kernel.org,  ziy@nvidia.com,  matthew.brost@intel.com,
	joshua.hahnjy@gmail.com,  rakie.kim@sk.com,  byungchul@sk.com,
	apopple@nvidia.com,  Johannes Weiner <hannes@cmpxchg.org>
Subject: Re: [PATCH 0/2] mm: don't apply task mempolicy to unmovable kernel allocations
Date: Thu, 09 Jul 2026 19:09:29 +0800	[thread overview]
Message-ID: <87echco1w6.fsf@DESKTOP-5N7EMDA> (raw)
In-Reply-To: <20260701222112.2820098-1-gourry@gourry.net> (Gregory Price's message of "Wed, 1 Jul 2026 18:21:10 -0400")

Gregory Price <gourry@gourry.net> writes:

> This series stops a task's NUMA mempolicy from steering incidental,
> global kernel allocations that have no real relationship to the task.
>
> VMA-less allocations (alloc_pages(), folio_alloc(), vmalloc(), slab
> refils) - fall back to the current task's mempolicy as their only
> placement hint.
>
> This sweeps in kernel memory that is not the task's:
>   - unaccounted slab
>   - kernel page tables
>   - driver GFP_KERNEL buffers
>   - one-off global structures
>   - etc
>
> On a uniform multi-socket system this is not implicitly harmful.
> On a tiered-memory system a task's interleave/bind can push these
> incidental allocations onto slower tiers and cause regressions.
>
> The memory may outlive the task, or be shared by others, yet a single
> task's policy dictated where it landed.  
>
> The fix is to only follow the task policy for allocations that are
> plausibly the task's:
>
>   - movable allocations (mostly user data), and
>   - allocations explicitly tied to the task via __GFP_ACCOUNT.
>
> Everything else (unmovable and unaccounted) prefers node-local.
>
> Cpuset still enforces any hard confinements (ALLOC_CPUSET), and
> fallback allocations may still cause spillage, but this at least
> prevents interleave policies from making poor placements.
>
> Patch 1 makes page-cache placement explicit in filemap to retain
> existing behavior (pagecache and metadata still end up following
> the task mempolicy).  Since the metadata can be significant on
> some systems, retaining this behavior will ensure there are no
> surprises for existing users.
>
> If we want to change this behavior, this patch is droppable.
>
> Patch 2 adds the alloc_task_policy() filter for bare allocations.
>
> Test 1: Page cache follows the task policy (unchanged)
> ======
> A process running on node0 but bound to node1:
>    (numactl --cpunodebind=0 --membind=1) writes a 1.2G file.
>
>   membind=1 (non-local):  FilePages  node0 +0MB     node1 +1200MB
>   membind=0 (control):    FilePages  node0 +1200MB  node1 +0MB 
>
>
> Test 2: Incidental kernel allocations no longer follow it (changed)
> ======
> Added a debugfs interface to do movable and kernel allocations:
>
>  w/ --cpunodebind=0
>  numactl ... --membind=1      echo 100000 > .../alloc_kernel
>  numactl ... --membind=1      echo 100000 > .../alloc_movable
>  numactl ... --interleave=all echo 100000 > .../alloc_kernel
>
>                        GFP_KERNEL          GFP_HIGHUSER_MOVABLE
> membind=1    base:     node1 (follows)     node1
>              patched:  node0 (local)       node1 (follows)
>
> interleave   base:     50/50 (follows)     50/50
>              patched:  node0 (local)       50/50 (follows)
>
> Movable (user) allocations are unaffected in every case.
>
> The unmovable unaccounted kernel allocations stop following the
> task policy and place node-local. With no policy set, both place
> node-local as before.

Personally, I think this should be the right thing to do theoretically.
However, you may need to find some practical issues that this resolves.

> Suggested-by: Johannes Weiner <hannes@cmpxchg.org>
>
> Gregory Price (2):
>   mm/filemap: place page-cache folios via an explicit mempolicy
>   mm/mempolicy: skip task mempolicy for unmovable unaccounted kernel
>     allocations
>
>  mm/filemap.c   |  5 ++++-
>  mm/mempolicy.c | 40 ++++++++++++++++++++++++++++------------
>  2 files changed, 32 insertions(+), 13 deletions(-)

---
Best Regards,
Huang, Ying

  parent reply	other threads:[~2026-07-09 11:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01 22:21 [PATCH 0/2] mm: don't apply task mempolicy to unmovable kernel allocations Gregory Price
2026-07-01 22:21 ` [PATCH 1/2] mm/filemap: place page-cache folios via an explicit mempolicy Gregory Price
2026-07-01 22:21 ` [PATCH 2/2] mm/mempolicy: skip task mempolicy for unmovable unaccounted kernel allocations Gregory Price
2026-07-09 11:09 ` Huang, Ying [this message]
2026-07-09 17:32   ` [PATCH 0/2] mm: don't apply task mempolicy to unmovable " Gregory Price

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=87echco1w6.fsf@DESKTOP-5N7EMDA \
    --to=ying.huang@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=byungchul@sk.com \
    --cc=david@kernel.org \
    --cc=gourry@gourry.net \
    --cc=hannes@cmpxchg.org \
    --cc=jack@suse.cz \
    --cc=joshua.hahnjy@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=matthew.brost@intel.com \
    --cc=rakie.kim@sk.com \
    --cc=willy@infradead.org \
    --cc=ziy@nvidia.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