From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 C094448C3EB for ; Wed, 21 Jan 2026 12:52:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768999950; cv=none; b=acV6KJ//uLRSj+rfQt9pgSDVmemVZyZF5HZlRFYgRxqgLmo6Dfrbn058szqQJtCvXlAvofXhjP7UTEPL5/XBtatsEzxOnal2si3BksyjjB+nooHds3dTHBICKOS32iW8oFapST9AysoSYUgVrDxQHnXExP1tQVgcgvAFcys/CIM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768999950; c=relaxed/simple; bh=93qVCOReLolQAzWDuV7FilpZk3VhIeJNRhIl5LgLvD4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FZCdwRhza/7bl8CH4POtQAVAq2KKuk6UnBB3+TVnc05+Udnw2TBR5xgSFmrn/sPiCi8COFQRQYHB1nMxwyu4/eJMcUtHQoT6ywiAOMFva/GFTNU5iB2uG1NypytVrHQSUaNuYpI4oFfMTWa7RgSfWwQmOptD8T/gLNKAupp+Cj4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=SpIs2ZzC; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SpIs2ZzC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1768999949; x=1800535949; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=93qVCOReLolQAzWDuV7FilpZk3VhIeJNRhIl5LgLvD4=; b=SpIs2ZzCU4eaTyuDimv0HZ5YQ2RD2Hh0CefNm1nL1dD4Wzo9HWERX52V RXR8u3X+XjAghnq2fEScQiCvIo+wUGRSyoVSh23RfdVoDoTn0KDxkO+gc okqsii/T/qWmZcttKh4yAN82XWVXhdho/2Ga1Eh5ccO86jFUfoPIGDEOf 53E4892Vb3ebVnxUJguDiK0qbFqhj5cXOLrih9ZLSadKFb/J36jQWbtQA fs3WT3bN8LeMKPBgol4RzK8WyylmXMbLfrP7MAExAi6olZb1DfbjFqphh RlAkYOZQZwkFxdPdRdHbQIyjjjbgFdTzsliNPRYUMjRh/zaIyHade6dPt A==; X-CSE-ConnectionGUID: zuRotRxPTq68A9vqm5QrvQ== X-CSE-MsgGUID: MTeV5YHJSZW6pSko6+ucwA== X-IronPort-AV: E=McAfee;i="6800,10657,11677"; a="69242540" X-IronPort-AV: E=Sophos;i="6.21,242,1763452800"; d="scan'208";a="69242540" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jan 2026 04:52:28 -0800 X-CSE-ConnectionGUID: 7urcOYczRA2ACdjtwuqQDA== X-CSE-MsgGUID: uG1TQmSuTnyH84e42KJ33w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,242,1763452800"; d="scan'208";a="206506618" Received: from liuzhao-optiplex-7080.sh.intel.com (HELO localhost) ([10.239.160.39]) by orviesa008.jf.intel.com with ESMTP; 21 Jan 2026 04:52:25 -0800 Date: Wed, 21 Jan 2026 21:17:56 +0800 From: Zhao Liu To: Hao Li Cc: Vlastimil Babka , Hao Li , akpm@linux-foundation.org, harry.yoo@oracle.com, cl@gentwo.org, rientjes@google.com, roman.gushchin@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, tim.c.chen@intel.com, yu.c.chen@intel.com Subject: Re: [PATCH v2] slub: keep empty main sheaf as spare in __pcs_replace_empty_main() Message-ID: References: <20251210002629.34448-1-haoli.tcs@gmail.com> <3ozekmmsscrarwoa7vcytwjn5rxsiyxjrcsirlu3bhmlwtdxzn@s7a6rcxnqadc> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: > Thanks again for your thorough testing and detailed feedback - I really > appreciate your help. You're welcome and thanks for your patinece! > > It seems like this is a GNR machine - maybe SNC could be enabled. > > Actually, my cpu is AMD EPYC 96-Core Processor. SNC is disabled, and > there's only one NUMA node per socket. That's interesting. > > For lkp, smt parameter is disabled. I tried with smt=1 locally, the > > difference between "with fix" & "w/o fix" is not significate. Maybe smt > > parameter could be set as 0. > > Just to confirm: do you mean that on your machine, when smt=1, the performance > difference between "with fix" and "without fix" is not significant - regardless > of whether it's a gain or regression? Thanks. Yes, that's what I found on my machine. Given that you're using an AMD machine, performance differences arise due to hardware difference :). > > On another machine (2 sockets with SNC3 enabled - 6 NUMA nodes), there's > > the similar regression happening when tasks fill up a socket and then > > there're more get_partial_node(). > > From a theoretical standpoint, it seems like having more nodes should reduce > lock contention, not increase it... > > By the way, I wanted to confirm one thing: in your earlier perf data, I noticed > that the sampling ratio of native_queued_spin_lock_slowpath and get_partial_node > slightly increased with the patch. Does this suggest that the lock contention > you're observing mainly comes from kmem_cache_node->list_lock rather than > node_barn->lock? Yes, I think so. > If possible, could you help confirm this using "perf report -g" to see where the > contention is coming from? No problem, - 42.82% 42.82% mmap2_processes [kernel.vmlinux] [k] native_queued_spin_lock_slowpath ▒ - 42.17% __mmap ▒ - 42.17% entry_SYSCALL_64_after_hwframe ▒ - do_syscall_64 ▒ - 42.16% ksys_mmap_pgoff ▒ - 42.16% vm_mmap_pgoff ▒ - 42.15% do_mmap ▒ - 42.14% __mmap_region ▒ - 42.09% __mmap_new_vma ▒ - 41.59% mas_preallocate ▒ - 41.59% kmem_cache_alloc_noprof ▒ - 41.58% __pcs_replace_empty_main ▒ - 40.38% __kmem_cache_alloc_bulk ▒ - 40.38% ___slab_alloc ▒ - 28.62% get_any_partial ▒ - 28.61% get_partial_node ▒ + 28.25% _raw_spin_lock_irqsave ▒ - 11.76% get_partial_node ▒ + 11.66% _raw_spin_lock_irqsave ▒ - 1.00% barn_replace_empty_sheaf ▒ + 0.95% _raw_spin_lock_irqsave ▒ + 0.65% __munmap > > Back to my previous test, I'm guessing that with this fix, under extreme > > conditions of massive mmap usage, each CPU now stores an empty spare sheaf > > locally. Previously, each CPU's spare sheaf was NULL. So memory pressure > > increases with more spare sheaves locally. > > I'm not quite sure about this point - my intuition is that this shouldn't > consume a significant amount of memory. > > > And in that extreme scenario, > > cross-socket remote NUMA access incurs significant overhead — which is why > > regression occurs here. > > This part I haven't fully figured out yet - still looking into it. This part is hard to say; it could also be due to certain differences in the hardware itself so that your machine didn't meet. > > However, testing from 1 task to max tasks (nr_tasks = nr_logical_cpus) > > shows overall significant improvements in most scenarios. Regressions > > only occur at the specific topology boundaries described above. > > It does look like there's some underlying factor at play, triggering a > performance tipping point. Though I haven't yet figured out the exact pattern. For details, on my machines, test where nr_task ranges from 0, 1, 4, 8 all the way up to max_cpus, and I plot the score curves with and without the fix to observe how the fix behaves under different conditions. > > I believe the cases with performance gains are more common. So I think > > the regression is a corner case. If it does indeed impact certain > > workloads in the future, we may need to reconsider optimization at that > > time. It can now be used as a reference. > > Agreed — this seems to be a corner case, and your test results have been really > helpful as a reference. Thanks again for the great support and insightful > discussion. It's been a pleasure communicating with you. :) Thanks, Zhao