arch/arm/mm/fault-armv.c | 3 ++- arch/arm/mm/flush.c | 3 ++- arch/nios2/mm/cacheflush.c | 3 ++- arch/parisc/kernel/cache.c | 4 ++- fs/dax.c | 3 ++- fs/hugetlbfs/inode.c | 10 +++---- fs/inode.c | 55 +++++++++++++++++++++++++++++++++++++- include/linux/fs.h | 40 +++++++++++++++++++++++++++ include/linux/mm.h | 33 +++++++++++++++++++++++ include/linux/mm_types.h | 1 + kernel/events/uprobes.c | 3 ++- mm/hugetlb.c | 7 +++-- mm/khugepaged.c | 6 +++-- mm/memory-failure.c | 8 +++--- mm/memory.c | 8 +++--- mm/mmap.c | 3 ++- mm/nommu.c | 11 +++++--- mm/pagewalk.c | 2 +- mm/rmap.c | 2 +- mm/vma.c | 36 +++++++++++++++++++------ mm/vma_init.c | 1 + 21 files changed, 204 insertions(+), 38 deletions(-)
In NUMA, there are maybe many NUMA nodes and many CPUs.
For example, a Hygon's server has 12 NUMA nodes, and 384 CPUs.
In the UnixBench tests, there is a test "execl" which tests
the execve system call.
When we test our server with "./Run -c 384 execl",
the test result is not good enough. The i_mmap locks contended heavily on
"libc.so" and "ld.so". For example, the i_mmap tree for "libc.so" can have
over 6000 VMAs, all the VMAs can be in different NUMA mode.
The insert/remove operations do not run quickly enough.
patch 1 & patch 2 are try to hide the direct access of i_mmap.
patch 3 splits the i_mmap into sibling trees, and we can get better
performance with this patch set:
we can get 77% performance improvement(10 times average)
Huang Shijie (3):
mm: use mapping_mapped to simplify the code
mm: use get_i_mmap_root to access the file's i_mmap
mm: split the file's i_mmap tree for NUMA
arch/arm/mm/fault-armv.c | 3 ++-
arch/arm/mm/flush.c | 3 ++-
arch/nios2/mm/cacheflush.c | 3 ++-
arch/parisc/kernel/cache.c | 4 ++-
fs/dax.c | 3 ++-
fs/hugetlbfs/inode.c | 10 +++----
fs/inode.c | 55 +++++++++++++++++++++++++++++++++++++-
include/linux/fs.h | 40 +++++++++++++++++++++++++++
include/linux/mm.h | 33 +++++++++++++++++++++++
include/linux/mm_types.h | 1 +
kernel/events/uprobes.c | 3 ++-
mm/hugetlb.c | 7 +++--
mm/khugepaged.c | 6 +++--
mm/memory-failure.c | 8 +++---
mm/memory.c | 8 +++---
mm/mmap.c | 3 ++-
mm/nommu.c | 11 +++++---
mm/pagewalk.c | 2 +-
mm/rmap.c | 2 +-
mm/vma.c | 36 +++++++++++++++++++------
mm/vma_init.c | 1 +
21 files changed, 204 insertions(+), 38 deletions(-)
--
2.43.0
On Mon, Apr 13, 2026 at 02:20:39PM +0800, Huang Shijie wrote: > In NUMA, there are maybe many NUMA nodes and many CPUs. > For example, a Hygon's server has 12 NUMA nodes, and 384 CPUs. > In the UnixBench tests, there is a test "execl" which tests > the execve system call. > > When we test our server with "./Run -c 384 execl", > the test result is not good enough. The i_mmap locks contended heavily on > "libc.so" and "ld.so". For example, the i_mmap tree for "libc.so" can have > over 6000 VMAs, all the VMAs can be in different NUMA mode. > The insert/remove operations do not run quickly enough. > > patch 1 & patch 2 are try to hide the direct access of i_mmap. > patch 3 splits the i_mmap into sibling trees, and we can get better > performance with this patch set: > we can get 77% performance improvement(10 times average) > To my reading you kept the lock as-is and only distributed the protected state. While I don't doubt the improvement, I'm confident should you take a look at the profile you are going to find this still does not scale with rwsem being one of the problems (there are other global locks, some of which have experimental patches for). Apart from that this does nothing to help high core systems which are all one node, which imo puts another question mark on this specific proposal. Of course one may question whether a RB tree is the right choice here, it may be the lock-protected cost can go way down with merely a better data structure. Regardless of that, for actual scalability, there will be no way around decentralazing locking around this and partitioning per some core count (not just by numa awareness). Decentralizing locking is definitely possible, but I have not looked into specifics of how problematic it is. Best case scenario it will merely with separate locks. Worst case scenario something needs a fully stabilized state for traversal, in that case another rw lock can be slapped around this, creating locking order read lock -> per-subset write lock -- this will suffer scalability due to the read locking, but it will still scale drastically better as apart from that there will be no serialization. In this setting the problematic consumer will write lock the new thing to stabilize the state. So my non-maintainer opinion is that the patchset is not worth it as it fails to address anything for significantly more common and already affected setups. Have you looked into splitting the lock?
On Mon, Apr 13, 2026 at 05:33:21PM +0200, Mateusz Guzik wrote:
> On Mon, Apr 13, 2026 at 02:20:39PM +0800, Huang Shijie wrote:
> > In NUMA, there are maybe many NUMA nodes and many CPUs.
> > For example, a Hygon's server has 12 NUMA nodes, and 384 CPUs.
> > In the UnixBench tests, there is a test "execl" which tests
> > the execve system call.
> >
> > When we test our server with "./Run -c 384 execl",
> > the test result is not good enough. The i_mmap locks contended heavily on
> > "libc.so" and "ld.so". For example, the i_mmap tree for "libc.so" can have
> > over 6000 VMAs, all the VMAs can be in different NUMA mode.
> > The insert/remove operations do not run quickly enough.
> >
> > patch 1 & patch 2 are try to hide the direct access of i_mmap.
> > patch 3 splits the i_mmap into sibling trees, and we can get better
> > performance with this patch set:
> > we can get 77% performance improvement(10 times average)
> >
>
> To my reading you kept the lock as-is and only distributed the protected
> state.
>
> While I don't doubt the improvement, I'm confident should you take a
> look at the profile you are going to find this still does not scale with
> rwsem being one of the problems (there are other global locks, some of
> which have experimental patches for).
>
> Apart from that this does nothing to help high core systems which are
> all one node, which imo puts another question mark on this specific
> proposal.
>
> Of course one may question whether a RB tree is the right choice here,
> it may be the lock-protected cost can go way down with merely a better
> data structure.
>
> Regardless of that, for actual scalability, there will be no way around
> decentralazing locking around this and partitioning per some core count
> (not just by numa awareness).
>
> Decentralizing locking is definitely possible, but I have not looked
> into specifics of how problematic it is. Best case scenario it will
> merely with separate locks. Worst case scenario something needs a fully
> stabilized state for traversal, in that case another rw lock can be
> slapped around this, creating locking order read lock -> per-subset
> write lock -- this will suffer scalability due to the read locking, but
> it will still scale drastically better as apart from that there will be
> no serialization. In this setting the problematic consumer will write
> lock the new thing to stabilize the state.
>
I thought over again.
I can change this patch set to support the non-NUMA case by:
1.) Still use one rw lock.
2.) For NUMA, keep the patch set as it is.
3.) For non-NUMA case, split the i_mmap tree to several subtrees.
For example, if a machine has 192 CPUs, split the 32 CPUs as a tree.
So extend the patch set to support both the NUMA and non-NUMA machines.
Thanks
Huang Shijie
BTW you're missing _a lot_ of CC's here, including the whole of mm/rmap.c maintainership. On Mon, Apr 20, 2026 at 10:10:19AM +0800, Huang Shijie wrote: > On Mon, Apr 13, 2026 at 05:33:21PM +0200, Mateusz Guzik wrote: > > On Mon, Apr 13, 2026 at 02:20:39PM +0800, Huang Shijie wrote: > > > In NUMA, there are maybe many NUMA nodes and many CPUs. > > > For example, a Hygon's server has 12 NUMA nodes, and 384 CPUs. > > > In the UnixBench tests, there is a test "execl" which tests > > > the execve system call. > > > > > > When we test our server with "./Run -c 384 execl", > > > the test result is not good enough. The i_mmap locks contended heavily on > > > "libc.so" and "ld.so". For example, the i_mmap tree for "libc.so" can have > > > over 6000 VMAs, all the VMAs can be in different NUMA mode. > > > The insert/remove operations do not run quickly enough. > > > > > > patch 1 & patch 2 are try to hide the direct access of i_mmap. > > > patch 3 splits the i_mmap into sibling trees, and we can get better > > > performance with this patch set: > > > we can get 77% performance improvement(10 times average) > > > > > > > To my reading you kept the lock as-is and only distributed the protected > > state. > > > > While I don't doubt the improvement, I'm confident should you take a > > look at the profile you are going to find this still does not scale with > > rwsem being one of the problems (there are other global locks, some of > > which have experimental patches for). > > > > Apart from that this does nothing to help high core systems which are > > all one node, which imo puts another question mark on this specific > > proposal. > > > > Of course one may question whether a RB tree is the right choice here, > > it may be the lock-protected cost can go way down with merely a better > > data structure. > > > > Regardless of that, for actual scalability, there will be no way around > > decentralazing locking around this and partitioning per some core count > > (not just by numa awareness). > > > > Decentralizing locking is definitely possible, but I have not looked > > into specifics of how problematic it is. Best case scenario it will > > merely with separate locks. Worst case scenario something needs a fully > > stabilized state for traversal, in that case another rw lock can be > > slapped around this, creating locking order read lock -> per-subset > > write lock -- this will suffer scalability due to the read locking, but > > it will still scale drastically better as apart from that there will be > > no serialization. In this setting the problematic consumer will write > > lock the new thing to stabilize the state. > > > I thought over again. > I can change this patch set to support the non-NUMA case by: > 1.) Still use one rw lock. No. This doesn't help anything. > 2.) For NUMA, keep the patch set as it is. Please no. No NUMA vs non-NUMA case. > 3.) For non-NUMA case, split the i_mmap tree to several subtrees. > For example, if a machine has 192 CPUs, split the 32 CPUs as a tree. If lock contention is the problem, I don't see how splitting the tree helps, unless it helps reduce lock hold time in a way that randomly helps your workload. But that's entirely random. > > So extend the patch set to support both the NUMA and non-NUMA machines. FYI I've discussed some concrete ideas for reworking file rmap with Mateusz. I'll be giving them a shot. Note that this needs to be done _carefully_, particularly as there are some hidden assumptions wrt forking that aren't very clear as to how they work[1]. [1] https://lore.kernel.org/all/bnukmnuxxuhdfeasjz33miemgr7w35c4aa6pqdmgupx7oxmeeb@gozgc3yxhcdd/ -- Pedro
On Mon, Apr 20, 2026 at 02:48:49PM +0100, Pedro Falcato wrote: > BTW you're missing _a lot_ of CC's here, including the whole of mm/rmap.c > maintainership. Thanks, my fault. > > On Mon, Apr 20, 2026 at 10:10:19AM +0800, Huang Shijie wrote: > > On Mon, Apr 13, 2026 at 05:33:21PM +0200, Mateusz Guzik wrote: > > > On Mon, Apr 13, 2026 at 02:20:39PM +0800, Huang Shijie wrote: > > > > In NUMA, there are maybe many NUMA nodes and many CPUs. > > > > For example, a Hygon's server has 12 NUMA nodes, and 384 CPUs. > > > > In the UnixBench tests, there is a test "execl" which tests > > > > the execve system call. > > > > > > > > When we test our server with "./Run -c 384 execl", > > > > the test result is not good enough. The i_mmap locks contended heavily on > > > > "libc.so" and "ld.so". For example, the i_mmap tree for "libc.so" can have > > > > over 6000 VMAs, all the VMAs can be in different NUMA mode. > > > > The insert/remove operations do not run quickly enough. > > > > > > > > patch 1 & patch 2 are try to hide the direct access of i_mmap. > > > > patch 3 splits the i_mmap into sibling trees, and we can get better > > > > performance with this patch set: > > > > we can get 77% performance improvement(10 times average) > > > > > > > > > > To my reading you kept the lock as-is and only distributed the protected > > > state. > > > > > > While I don't doubt the improvement, I'm confident should you take a > > > look at the profile you are going to find this still does not scale with > > > rwsem being one of the problems (there are other global locks, some of > > > which have experimental patches for). > > > > > > Apart from that this does nothing to help high core systems which are > > > all one node, which imo puts another question mark on this specific > > > proposal. > > > > > > Of course one may question whether a RB tree is the right choice here, > > > it may be the lock-protected cost can go way down with merely a better > > > data structure. > > > > > > Regardless of that, for actual scalability, there will be no way around > > > decentralazing locking around this and partitioning per some core count > > > (not just by numa awareness). > > > > > > Decentralizing locking is definitely possible, but I have not looked > > > into specifics of how problematic it is. Best case scenario it will > > > merely with separate locks. Worst case scenario something needs a fully > > > stabilized state for traversal, in that case another rw lock can be > > > slapped around this, creating locking order read lock -> per-subset > > > write lock -- this will suffer scalability due to the read locking, but > > > it will still scale drastically better as apart from that there will be > > > no serialization. In this setting the problematic consumer will write > > > lock the new thing to stabilize the state. > > > > > I thought over again. > > I can change this patch set to support the non-NUMA case by: > > 1.) Still use one rw lock. > > No. This doesn't help anything. > > > 2.) For NUMA, keep the patch set as it is. > > Please no. No NUMA vs non-NUMA case. > > > 3.) For non-NUMA case, split the i_mmap tree to several subtrees. > > For example, if a machine has 192 CPUs, split the 32 CPUs as a tree. > > If lock contention is the problem, I don't see how splitting the tree helps, > unless it helps reduce lock hold time in a way that randomly helps your workload. > But that's entirely random. We actually face two issues: 1.) the lock contention 2.) the lock hold time. IMHO, if we can reduce the lock hold time, we can ease the lock contention too. So this patch set is to reduce the lock hold time, which is much helpful in our NUMA server in UnixBench test. If we split the lock into small locks, we can also benefit from it. If you or Mateusz create the patch in future, I can test it on our server. I wonder if it can give us better performance then current patch set. Thanks Huang Shijie
On Mon, Apr 13, 2026 at 05:33:21PM +0200, Mateusz Guzik wrote: > On Mon, Apr 13, 2026 at 02:20:39PM +0800, Huang Shijie wrote: > > In NUMA, there are maybe many NUMA nodes and many CPUs. > > For example, a Hygon's server has 12 NUMA nodes, and 384 CPUs. > > In the UnixBench tests, there is a test "execl" which tests > > the execve system call. > > > > When we test our server with "./Run -c 384 execl", > > the test result is not good enough. The i_mmap locks contended heavily on > > "libc.so" and "ld.so". For example, the i_mmap tree for "libc.so" can have > > over 6000 VMAs, all the VMAs can be in different NUMA mode. > > The insert/remove operations do not run quickly enough. > > > > patch 1 & patch 2 are try to hide the direct access of i_mmap. > > patch 3 splits the i_mmap into sibling trees, and we can get better > > performance with this patch set: > > we can get 77% performance improvement(10 times average) > > > > To my reading you kept the lock as-is and only distributed the protected > state. > > While I don't doubt the improvement, I'm confident should you take a > look at the profile you are going to find this still does not scale with > rwsem being one of the problems (there are other global locks, some of > which have experimental patches for). > > Apart from that this does nothing to help high core systems which are > all one node, which imo puts another question mark on this specific > proposal. > > Of course one may question whether a RB tree is the right choice here, > it may be the lock-protected cost can go way down with merely a better > data structure. > > Regardless of that, for actual scalability, there will be no way around > decentralazing locking around this and partitioning per some core count > (not just by numa awareness). > > Decentralizing locking is definitely possible, but I have not looked > into specifics of how problematic it is. Best case scenario it will > merely with separate locks. Worst case scenario something needs a fully > stabilized state for traversal, in that case another rw lock can be > slapped around this, creating locking order read lock -> per-subset > write lock -- this will suffer scalability due to the read locking, but > it will still scale drastically better as apart from that there will be > no serialization. In this setting the problematic consumer will write > lock the new thing to stabilize the state. For your proposal in no-numa, I hope you can create a patch set for it. I can test it in our machine. Thanks Huang Shijie
On Mon, Apr 13, 2026 at 05:33:21PM +0200, Mateusz Guzik wrote:
> On Mon, Apr 13, 2026 at 02:20:39PM +0800, Huang Shijie wrote:
> > In NUMA, there are maybe many NUMA nodes and many CPUs.
> > For example, a Hygon's server has 12 NUMA nodes, and 384 CPUs.
> > In the UnixBench tests, there is a test "execl" which tests
> > the execve system call.
> >
> > When we test our server with "./Run -c 384 execl",
> > the test result is not good enough. The i_mmap locks contended heavily on
> > "libc.so" and "ld.so". For example, the i_mmap tree for "libc.so" can have
> > over 6000 VMAs, all the VMAs can be in different NUMA mode.
> > The insert/remove operations do not run quickly enough.
> >
> > patch 1 & patch 2 are try to hide the direct access of i_mmap.
> > patch 3 splits the i_mmap into sibling trees, and we can get better
> > performance with this patch set:
> > we can get 77% performance improvement(10 times average)
> >
>
> To my reading you kept the lock as-is and only distributed the protected
> state.
>
> While I don't doubt the improvement, I'm confident should you take a
> look at the profile you are going to find this still does not scale with
> rwsem being one of the problems (there are other global locks, some of
> which have experimental patches for).
IMHO, when the number of VMAs in the i_mmap is very large, only optimise the rwsem
lock does not help too much for our NUMA case.
In our NUMA server, the remote access could be the major issue.
>
> Apart from that this does nothing to help high core systems which are
> all one node, which imo puts another question mark on this specific
> proposal.
Yes, this patch set only focus on the NUMA case.
The one-node case should use the original i_mmap.
Maybe I can add a new config, CONFIG_SPILT_I_MMAP. The config is disabled
by default, and enabled when the NUMA node is not one.
>
> Of course one may question whether a RB tree is the right choice here,
> it may be the lock-protected cost can go way down with merely a better
> data structure.
>
> Regardless of that, for actual scalability, there will be no way around
> decentralazing locking around this and partitioning per some core count
> (not just by numa awareness).
>
> Decentralizing locking is definitely possible, but I have not looked
> into specifics of how problematic it is. Best case scenario it will
> merely with separate locks. Worst case scenario something needs a fully
> stabilized state for traversal, in that case another rw lock can be
Yes.
The traversal may need to hold many locks.
> slapped around this, creating locking order read lock -> per-subset
> write lock -- this will suffer scalability due to the read locking, but
> it will still scale drastically better as apart from that there will be
> no serialization. In this setting the problematic consumer will write
> lock the new thing to stabilize the state.
>
> So my non-maintainer opinion is that the patchset is not worth it as it
> fails to address anything for significantly more common and already
> affected setups.
This patch set is to reduce the remote access latency for insert/remove VMA
in NUMA.
>
> Have you looked into splitting the lock?
>
I ever tried.
But there are two disadvantages:
1.) The traversal may need to hold many locks which makes the
code very horrible.
2.) Even we split the locks. Each lock protects a tree, when the tree becomes
big enough, the VMA insert/remove will also become slow in NUMA.
The reason is that the tree has VMAs in different NUMA nodes.
Thanks
Huang Shijie
On Tue, Apr 14, 2026 at 11:11 AM Huang Shijie <huangsj@hygon.cn> wrote: > > On Mon, Apr 13, 2026 at 05:33:21PM +0200, Mateusz Guzik wrote: > > On Mon, Apr 13, 2026 at 02:20:39PM +0800, Huang Shijie wrote: > > > In NUMA, there are maybe many NUMA nodes and many CPUs. > > > For example, a Hygon's server has 12 NUMA nodes, and 384 CPUs. > > > In the UnixBench tests, there is a test "execl" which tests > > > the execve system call. > > > > > > When we test our server with "./Run -c 384 execl", > > > the test result is not good enough. The i_mmap locks contended heavily on > > > "libc.so" and "ld.so". For example, the i_mmap tree for "libc.so" can have > > > over 6000 VMAs, all the VMAs can be in different NUMA mode. > > > The insert/remove operations do not run quickly enough. > > > > > > patch 1 & patch 2 are try to hide the direct access of i_mmap. > > > patch 3 splits the i_mmap into sibling trees, and we can get better > > > performance with this patch set: > > > we can get 77% performance improvement(10 times average) > > > > > > > To my reading you kept the lock as-is and only distributed the protected > > state. > > > > While I don't doubt the improvement, I'm confident should you take a > > look at the profile you are going to find this still does not scale with > > rwsem being one of the problems (there are other global locks, some of > > which have experimental patches for). > IMHO, when the number of VMAs in the i_mmap is very large, only optimise the rwsem > lock does not help too much for our NUMA case. > > In our NUMA server, the remote access could be the major issue. > I'm confused how this is not supposed to help. You moved your data to be stored per-domain. With my proposal the lock itself will also get that treatment. Modulo the issue of what to do with code wanting to iterate the entire thing, this is blatantly faster. > > > > > Apart from that this does nothing to help high core systems which are > > all one node, which imo puts another question mark on this specific > > proposal. > Yes, this patch set only focus on the NUMA case. > The one-node case should use the original i_mmap. > > Maybe I can add a new config, CONFIG_SPILT_I_MMAP. The config is disabled > by default, and enabled when the NUMA node is not one. > > > > > Of course one may question whether a RB tree is the right choice here, > > it may be the lock-protected cost can go way down with merely a better > > data structure. > > > > Regardless of that, for actual scalability, there will be no way around > > decentralazing locking around this and partitioning per some core count > > (not just by numa awareness). > > > > Decentralizing locking is definitely possible, but I have not looked > > into specifics of how problematic it is. Best case scenario it will > > merely with separate locks. Worst case scenario something needs a fully > > stabilized state for traversal, in that case another rw lock can be > Yes. > > The traversal may need to hold many locks. > The very paragraph you partially quoted answers what to do in that case: wrap everything with a new rwsem taken for reading when adding/removing entries and taken for writing when iterating the entire thing. Then the iteration sticks to one lock. The new rw lock puts an upper ceiling on scalability of the thing, but it is way higher than the current state. Given the extra overhead associated with it one could consider sticking to one centralized state by default and switching to distributed state if there is enough contention. > > slapped around this, creating locking order read lock -> per-subset > > write lock -- this will suffer scalability due to the read locking, but > > it will still scale drastically better as apart from that there will be > > no serialization. In this setting the problematic consumer will write > > lock the new thing to stabilize the state. > > > > So my non-maintainer opinion is that the patchset is not worth it as it > > fails to address anything for significantly more common and already > > affected setups. > This patch set is to reduce the remote access latency for insert/remove VMA > in NUMA. > And I am saying the mmap semaphore is a significant problem already on high-core no-numa setups. Addressing scalability in that case would sort out the problem in your setup and to a significantly higher extent. > > > > Have you looked into splitting the lock? > > > I ever tried. > > But there are two disadvantages: > 1.) The traversal may need to hold many locks which makes the > code very horrible. > I already above this is avoidable. > 2.) Even we split the locks. Each lock protects a tree, when the tree becomes > big enough, the VMA insert/remove will also become slow in NUMA. > The reason is that the tree has VMAs in different NUMA nodes. > This is orthogonal to my proposal. In fact, if one is to pretend this is never a factor with your patch, I would like to point out it will remain not a factor if the per-numa struct gets its own lock.
On Thu, Apr 16, 2026 at 12:29:50PM +0200, Mateusz Guzik wrote: > On Tue, Apr 14, 2026 at 11:11 AM Huang Shijie <huangsj@hygon.cn> wrote: > > > > On Mon, Apr 13, 2026 at 05:33:21PM +0200, Mateusz Guzik wrote: > > > On Mon, Apr 13, 2026 at 02:20:39PM +0800, Huang Shijie wrote: > > > > In NUMA, there are maybe many NUMA nodes and many CPUs. > > > > For example, a Hygon's server has 12 NUMA nodes, and 384 CPUs. > > > > In the UnixBench tests, there is a test "execl" which tests > > > > the execve system call. > > > > > > > > When we test our server with "./Run -c 384 execl", > > > > the test result is not good enough. The i_mmap locks contended heavily on > > > > "libc.so" and "ld.so". For example, the i_mmap tree for "libc.so" can have > > > > over 6000 VMAs, all the VMAs can be in different NUMA mode. > > > > The insert/remove operations do not run quickly enough. > > > > > > > > patch 1 & patch 2 are try to hide the direct access of i_mmap. > > > > patch 3 splits the i_mmap into sibling trees, and we can get better > > > > performance with this patch set: > > > > we can get 77% performance improvement(10 times average) > > > > > > > > > > To my reading you kept the lock as-is and only distributed the protected > > > state. > > > > > > While I don't doubt the improvement, I'm confident should you take a > > > look at the profile you are going to find this still does not scale with > > > rwsem being one of the problems (there are other global locks, some of > > > which have experimental patches for). > > IMHO, when the number of VMAs in the i_mmap is very large, only optimise the rwsem > > lock does not help too much for our NUMA case. > > > > In our NUMA server, the remote access could be the major issue. > > > > I'm confused how this is not supposed to help. You moved your data to > be stored per-domain. With my proposal the lock itself will also get > that treatment. > > Modulo the issue of what to do with code wanting to iterate the entire > thing, this is blatantly faster. > I tested an old lock patch yesterday. It really helps a lot. The lock patch is from this link: https://lkml.org/lkml/2024/9/14/280 The test results: v7.0-rc5 + (lock patch) : improve about %60% v7.0-rc5 + (lock patch) + (this patch set) : improve about 130% > > > > > > > > Apart from that this does nothing to help high core systems which are > > > all one node, which imo puts another question mark on this specific > > > proposal. > > Yes, this patch set only focus on the NUMA case. > > The one-node case should use the original i_mmap. > > > > Maybe I can add a new config, CONFIG_SPILT_I_MMAP. The config is disabled > > by default, and enabled when the NUMA node is not one. > > > > > > > > Of course one may question whether a RB tree is the right choice here, > > > it may be the lock-protected cost can go way down with merely a better > > > data structure. > > > > > > Regardless of that, for actual scalability, there will be no way around > > > decentralazing locking around this and partitioning per some core count > > > (not just by numa awareness). > > > > > > Decentralizing locking is definitely possible, but I have not looked > > > into specifics of how problematic it is. Best case scenario it will > > > merely with separate locks. Worst case scenario something needs a fully > > > stabilized state for traversal, in that case another rw lock can be > > Yes. > > > > The traversal may need to hold many locks. > > > > The very paragraph you partially quoted answers what to do in that > case: wrap everything with a new rwsem taken for reading when > adding/removing entries and taken for writing when iterating the > entire thing. Then the iteration sticks to one lock. > > The new rw lock puts an upper ceiling on scalability of the thing, but > it is way higher than the current state. Could you tell me the patch about it? Is this lock patch merged ? or not? I can test it. > > Given the extra overhead associated with it one could consider > sticking to one centralized state by default and switching to > distributed state if there is enough contention. > > > > slapped around this, creating locking order read lock -> per-subset > > > write lock -- this will suffer scalability due to the read locking, but > > > it will still scale drastically better as apart from that there will be > > > no serialization. In this setting the problematic consumer will write > > > lock the new thing to stabilize the state. > > > > > > So my non-maintainer opinion is that the patchset is not worth it as it > > > fails to address anything for significantly more common and already > > > affected setups. > > This patch set is to reduce the remote access latency for insert/remove VMA > > in NUMA. > > > > And I am saying the mmap semaphore is a significant problem already on > high-core no-numa setups. Addressing scalability in that case would > sort out the problem in your setup and to a significantly higher > extent. I am afraid even the lock patch resolves the scalability high-core no-numa setups, we still need to split the i_mmap for NUMA. > > > > > > > Have you looked into splitting the lock? > > > > > I ever tried. > > > > But there are two disadvantages: > > 1.) The traversal may need to hold many locks which makes the > > code very horrible. > > > > I already above this is avoidable. > > > 2.) Even we split the locks. Each lock protects a tree, when the tree becomes > > big enough, the VMA insert/remove will also become slow in NUMA. > > The reason is that the tree has VMAs in different NUMA nodes. > > > > This is orthogonal to my proposal. In fact, if one is to pretend this > is never a factor with your patch, I would like to point out it will > remain not a factor if the per-numa struct gets its own lock. Yes. It is orthogonal to your proposal. Thanks Huang Shijie
© 2016 - 2026 Red Hat, Inc.