From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A57D44210D for ; Mon, 6 Jul 2026 11:28:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.132 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783337304; cv=none; b=cK2C38jW46tlfCySmHQcN9+ACFG4t6ifYvw/rVJnvCAmpaRhXHpZL5Z/fo/tJS9OFHdMs/tsEzRPDn1LhqmgqD9IyUOE4wsqnHGdxvXvTAlSCF7MuH04V/WGJlUH7q9SH5E5K3Xx9d/PPb9vEiXMHcPkoZxJOcbdyCoVh3LmMX8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783337304; c=relaxed/simple; bh=ttscXhKtjPF53hisqOmk4dwcaEml3DFSrLU3Aig9/iQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=JKTQbWqINDW4R67yUiSC7y+Os0UveMvbi5Ntm1XGOb69Jy8BLlxfVM4NtN/rtstGqUKahzus5ucgGhVKxgbWKxdKuGSgnzA0A2ahKJKjYqZHVHj3W8v3hAXLKjmVnQ/3sUDLI69kt+V7zmW3lJQCeYVrYq89MxnbekozWLzR98w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=HhCr3efL; arc=none smtp.client-ip=115.124.30.132 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="HhCr3efL" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1783337292; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; bh=oKA2kC81pp4bhP84zmTGl4f9HCE5dXysfBVI/j2hjMs=; b=HhCr3efLPWWCAzDurfEZc7dEC9KsLhN7avi4npx1esjy2c3WmvIX6k4uSHuzEiSjfvXfzPXDEGPmq96+oeDzWyDpr6wwU/YTyp+QDsreRFYm5jnAfStQ9S8iWdYFo5wQRN7hO2xIq3t762z5Ho2hZDjIsB38xBIP8BNGmtP1qbw= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R481e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033045133197;MF=ying.huang@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0X6V0sRD_1783337279; Received: from DESKTOP-5N7EMDA(mailfrom:ying.huang@linux.alibaba.com fp:SMTPD_---0X6V0sRD_1783337279 cluster:ay36) by smtp.aliyun-inc.com; Mon, 06 Jul 2026 19:28:10 +0800 From: "Huang, Ying" To: Gregory Price Cc: Johannes Weiner , Andrew Morton , David Hildenbrand , Zi Yan , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Alistair Popple , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Neha Gholkar Subject: Re: [PATCH] mm: mempolicy: fix automatic numa balancing for shmem In-Reply-To: (Gregory Price's message of "Wed, 1 Jul 2026 11:33:38 -0400") References: <20260629163337.1264881-1-hannes@cmpxchg.org> <87h5mkz33h.fsf@DESKTOP-5N7EMDA> <877bnfynsr.fsf@DESKTOP-5N7EMDA> Date: Mon, 06 Jul 2026 19:27:57 +0800 Message-ID: <87y0fonyrm.fsf@DESKTOP-5N7EMDA> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Gregory Price writes: > On Wed, Jul 01, 2026 at 07:03:32PM +0800, Huang, Ying wrote: >> Gregory Price writes: >> >> > On Tue, Jun 30, 2026 at 07:20:50PM +0800, Huang, Ying wrote: >> >> Gregory Price writes: >> >> [snip] >> >> Anyway, it's convenient to use numactl to manage mempolicy. >> > > It can be, but there's also many footguns with task-wide policy. > > Something i found while seeing if i could make ZONE_NORMAL nodes more > reliably hotpluggable: > > diff --git a/lib/stackdepot.c b/lib/stackdepot.c > index dd2717ff94bf..9ceeb56574ef 100644 > --- a/lib/stackdepot.c > +++ b/lib/stackdepot.c > @@ -682,7 +682,15 @@ depot_stack_handle_t stack_depot_save_flags(unsigned long *entries, > * we won't be able to do that under the lock. > */ > if (unlikely(can_alloc && !READ_ONCE(new_pool))) { > - page = alloc_pages(gfp_nested_mask(alloc_flags), > + /* > + * The stack depot pool is a global, never-freed allocation. > + * Use alloc_pages_node() on the CPU-local node instead of > + * alloc_pages() so the pool does not inherit a transient task's > + * NUMA mempolicy (e.g. MPOL_BIND to a CPU-less/bound node), which > + * would strand this long-lived page on that node forever. > + */ > + page = alloc_pages_node(numa_node_id(), > + gfp_nested_mask(alloc_flags), > DEPOT_POOL_ORDER); > if (page) > prealloc = page_address(page); > > This is a global, permanently allocated, resource that inherits a task > mempolicy's placement because that task *happened* to be the first one > to touch it. > > There are many alloc_pages() calls (155 instances kernel-wide) that > inherit a task mempolicy when that's probably not what we want. > > alloc_pages() is called in: net/, lib/, kexec_core/, drivers/, arch/ > > you can imagine a task setting `set_mempolicy(INTERLEAVE, ALL)` and the > result is a bunch of random driver memory gets spread all over the place > along with the task's heap. Is that really what the caller wanted, or > did they just want userland data spread about? > > But at this point it's a 20 year old interface, not much we can do about > it without making *someone* sad :[ > > I considered proposing MPOL_F_MOVABLE_ONLY to mean (roughly) "userland > memory only" - and then slowly trying to migrate numactl to make this > the default. What is the right mempolicy for these random kernel allocations? If the pages are used privately by the task (not the case in your example, but is it possible?), is it OK to use the mempolicy of the task? If the pages are shared, what is the correct mempolicy? Will it be fixed? Or can we find a way to change the policy? [snip] --- Best Regards, Huang, Ying