From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) (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 7BB991CEAC2 for ; Wed, 3 Jun 2026 04:27:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.189 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780460837; cv=none; b=LifLLPES5orCBEnijuXxSQ90tcl0cjstgpzkOTbi5yy50H2C5uf01gjC9E0sAHoDZK6GxrxbCIPJUYxK9ChfEf9yU/VHBT4/l6+jd3R+wB3Dw1CytF/c96kPDuJkGdD1trvHatNI/vG3W8wor1UOEh8dia5jePG2UCUfIg3W95o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780460837; c=relaxed/simple; bh=FNj5IlHdmYd1ufHHLZXcM5VBzB0cfemcz82J3YvFing=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YWaRSvWGEJTuy1uldWYV34XTbWOZ9g2kohaP1zNiBzlRoMyC1fAzC4Gi8Nh+YnlpkTIs9E0izwpLikAiGQhdLS9MdbEjybkO9WerIF1VP+IonkPjZfeWQNVydoV2ZQFAe1181GbDvnIFSi8EW/PJ9qyQxWNmNETHUu2M5TS1m94= 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=oqBR8AJW; arc=none smtp.client-ip=95.215.58.189 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="oqBR8AJW" Date: Wed, 3 Jun 2026 12:26:57 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1780460833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EHa5eVMR4HXRrhIH0Z/X3J8xy1NBtxqzlOfVAuzIev8=; b=oqBR8AJWKswu+TUBJI427l7tMXW46i5pJVFjhjvhm03A1vjbalG1LDflUcBusdBkf08nY6 AJL7vei+Q9OhyMld6u24rBVtnjyCuLKk6i5s8Q1STvlrLXOpcfJA0PwggLvGe5AjfkPw7L KGZ+C6ZLKPOwXjgKjaF660P7CRHFkDI= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Hao Li To: Harry Yoo Cc: vbabka@kernel.org, akpm@linux-foundation.org, cl@gentwo.org, rientjes@google.com, roman.gushchin@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm/slub: allocate sheaves on local memory nodes Message-ID: References: <20260601095706.106551-1-hao.li@linux.dev> <33506b25-ab2f-4f31-a380-7c0fe65567a3@kernel.org> 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=us-ascii Content-Disposition: inline In-Reply-To: <33506b25-ab2f-4f31-a380-7c0fe65567a3@kernel.org> X-Migadu-Flow: FLOW_OUT On Mon, Jun 01, 2026 at 08:28:16PM +0900, Harry Yoo wrote: > On 6/1/26 6:56 PM, Hao Li wrote: > > Sheaf structs are exchanged through node-local barns. Since barn structs > > are already allocated from their local NUMA node, this patch aims to > > allocate sheaf structs from their local memory nodes as well. > > > > To achieve this, the obvious choice would be using cpu_to_mem(). > > However, init_percpu_sheaves() and bootstrap_cache_sheaves() iterate > > through possible CPUs, whereas cpu_to_mem() is only initialized for > > online CPUs. Therefore, we cannot use cpu_to_mem() and instead need to > > use local_memory_node(cpu_to_node(cpu)), similar to what > > __build_all_zonelists() does. > > > > The primary goal of this patch is to improve NUMA node locality. > > Although the actual performance impact is minor, it still yields a ~1% > > improvement on a 192-core, 8-NUMA-node system when testing with the > > will-it-scale mmap test case. > > Oh, nice :) > > I have a question though... > > I wonder if would be better to handle this by e.g.) not returning empty > sheaves back to barn and freeing them if the node id doesn't match and > it's not a memoryless node. > > init_percpu_sheaves() and bootstrap_cache_sheaves() are not the only > places that can allocate sheaves from remote nodes; sheaves allocation > could fall back to other nodes and then SLUB could keep reusing those > sheaves from remote nodes even after memory is reclaimed. This is a good catch. In addition to the fallback mechanism, task migration between CPUs in __pcs_replace_empty_main() and __pcs_replace_full_main() can also mix up sheaf structs across different barns. So yeah, changing allocation locality is not a silver bullet. > > If this works well, we probably don't need to handle it in > init_percpu_sheaves() and bootstrap_cache_sheaves() at all as they will > eventually be freed, while covering the other case too? freeing the empty sheaf if the NUMA node mismatches instead of putting it back into the barn is indeed a good idea. I like it. But unfortunately, my testing didn't show a clear performance improvement, though there was no noticeable degradation either. :-( I also did some more testing on my patch too. Under CONFIG_PREEMPT_LAZY, the improvement is only about 0.5% (sometimes 1%). And when switching to CONFIG_PREEMPT, the patch doesn't seem to yield statistically significant benefits, likely because sheaves get mixed during task migration. So, perhaps the performance gain just isn't worth the extra complexity. It's a bit frustrating, but maybe we should just abandon this direction and keep things as they are... :( Thanks for the feedback anyway! -- Thanks, Hao