linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Zhao Liu <zhao1.liu@intel.com>
To: Hao Li <hao.li@linux.dev>
Cc: Vlastimil Babka <vbabka@suse.cz>, Hao Li <haolee.swjtu@gmail.com>,
	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()
Date: Wed, 21 Jan 2026 21:17:56 +0800	[thread overview]
Message-ID: <aXDSBD09n7jYAX9i@intel.com> (raw)
In-Reply-To: <rey5elthflgiygw4lf5zqldlof6nd5b2mq5is7zbgec7zqvr7a@izbte4jmotrq>

> 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



      reply	other threads:[~2026-01-21 12:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-10  0:26 Hao Li
2025-12-15 14:30 ` Vlastimil Babka
2025-12-16  2:34   ` Hao Lee
2025-12-22 10:20   ` Harry Yoo
2026-01-05 15:58     ` Vlastimil Babka
2026-01-15 10:12   ` Zhao Liu
2026-01-15 16:19     ` Vlastimil Babka
2026-01-16  9:07       ` Zhao Liu
2026-01-16  9:11         ` Hao Li
2026-01-16  4:06     ` Hao Li
2026-01-16  9:16       ` Zhao Liu
2026-01-16  9:09         ` Hao Li
2026-01-19  6:07     ` Hao Li
2026-01-20  8:21       ` Zhao Liu
2026-01-21  3:15         ` Hao Li
2026-01-21 13:17           ` Zhao Liu [this message]

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=aXDSBD09n7jYAX9i@intel.com \
    --to=zhao1.liu@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@gentwo.org \
    --cc=hao.li@linux.dev \
    --cc=haolee.swjtu@gmail.com \
    --cc=harry.yoo@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=tim.c.chen@intel.com \
    --cc=vbabka@suse.cz \
    --cc=yu.c.chen@intel.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