From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [95.215.58.179]) (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 798E3372EE9 for ; Fri, 3 Apr 2026 07:40:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775202042; cv=none; b=eb4jefcjOi5uT1TQ4EpDcJ7hMXwGg6DSiBNivBPFa+YTqpOcciWwGsaL8JaMc3CA6lC5lW3zif0VabuxeGWdCJUkYttg375IpLLU8zh+IlVN2arNLHeJIdf5tr/AIxcB2UoC34ex9tPmAVqfCwWS+yQ2r38Y46evDE2KM7bLqG0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775202042; c=relaxed/simple; bh=jmleWKyLvZXleuLwVhk+lUcIOohAt8/Y8rYgpGVSQGY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DHp49wehUmw0ARoa/drxVKQW/MEMmENcTDMWtEDBIeretrUjDHD7HY51iBUjv3KznmlA/4Q9hW+Oni+vhjmDnO6lQO+WLoLVixylusw8WLEbNv6s0TKY5Qf7Luv49CC2WmXnw18E2EuMHyvtzPX1IIoyhBpRlOZ0kQjedQUhxsg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=vrmH/sJ1; arc=none smtp.client-ip=95.215.58.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="vrmH/sJ1" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1775202038; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Ln5XzWMFyTginHCaMgw8DBIoTgwuT8dHU7rE/Vwl3Rg=; b=vrmH/sJ195nnxnWxwc5peq/lAcTBTfLjp7Pra4SR4+bkQWxopN7e2Koq7r6wRcIZGaZKN4 6COnGKYwqHEyKqbgf7PmI+K2zOGAc68s/Fjcg+ZRrvGZshZbjS37udLq8dSKZEkvF7G1ly 93BRL71+pjphdSe2J2TKup50yvZtkHA= From: Hao Li To: vbabka@kernel.org, harry.yoo@oracle.com, akpm@linux-foundation.org Cc: cl@gentwo.org, rientjes@google.com, roman.gushchin@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hao Li Subject: [PATCH] slub: use N_NORMAL_MEMORY in can_free_to_pcs to handle remote frees Date: Fri, 3 Apr 2026 15:37:36 +0800 Message-ID: <20260403073958.8722-1-hao.li@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Memory hotplug now keeps N_NORMAL_MEMORY up to date correctly, so make can_free_to_pcs() use it. As a result, when freeing objects on memoryless nodes, or on nodes that have memory but only in ZONE_MOVABLE, the objects can be freed to the sheaf instead of going through the slow path. Signed-off-by: Hao Li --- Hi Vlastimil, this patch depends on a prerequisite patch[1] from a few days ago. I'm not sure how this should be handled. I wonder if Andrew might put them in the same tree. [1] https://lore.kernel.org/linux-mm/20260330035941.518186-1-hao.li@linux.dev/ --- mm/slub.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index fb2c5c57bc4e..4927407c9699 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -6022,14 +6022,15 @@ static __always_inline bool can_free_to_pcs(struct slab *slab) goto check_pfmemalloc; /* - * Freed object isn't from this cpu's node, but that node is memoryless. + * Freed object isn't from this cpu's node, but that node is memoryless + * or only has ZONE_MOVABLE memory, which slab cannot allocate from. * Proceed as it's better to cache remote objects than falling back to * the slowpath for everything. The allocation side can never obtain * a local object anyway, if none exist. We don't have numa_mem_id() to * point to the closest node as we would on a proper memoryless node * setup. */ - if (unlikely(!node_state(numa_node, N_MEMORY))) + if (unlikely(!node_state(numa_node, N_NORMAL_MEMORY))) goto check_pfmemalloc; #endif -- 2.50.1