Skip to contentSkip to conversation

mm/vma: avoid redundant file rmap tree re-insert on new_below=0 split

PATCH In review Pan Deng 3 participants 7 messages Sep 24 – Sep 29

Subsystems (4)
lore
Share & tools
lore

Pan Deng

author
#0 lore raw

PATCH 1/1 mm/vma: avoid redundant file rmap tree re-insert on new_below=0 split

Splitting a file-backed VMA removes it from the mapping's i_mmap interval tree and re-inserts it, two O(log n) walks with rebalancing, all inside the i_mmap_rwsem write-side critical section. For a file mapped by many processes that lock is a single serialization point, so the cost translates into reduced exec throughput.

While the re-insert is needed whenever the sort key changes, it is not for a new_below=0 split: there the new VMA takes the upper half and only the original VMA's vm_end shrinks, so vma_start_pgoff(), the sort key of the interval tree, stays constant and the VMA is already in the correct position.

This change skips the re-insert for that case. vma_prepare() no longer removes vp->vma from the tree; instead vma_complete() detects that case and only recomputes shared.rb_subtree_last up the ancestor chain. Everything else keeps the remove + re-insert path.

The case is detected by comparing vma_start_pgoff(vp->insert) against vma_start_pgoff(vp->vma): only a new_below=0 split leaves the former greater. __split_vma() adjusts pgoff via vma_add_pgoff(new, linear_page_delta(vma, addr)), and linear_page_delta() is (addr - vm_start) >> PAGE_SHIFT with addr strictly inside the VMA, so the delta is at least one page and the new VMA's pgoff is strictly greater. For new_below=1 the two are initially equal and vp->vma's pgoff then increases, so the comparison is false both before and after the caller's endpoint updates, and the original path is taken.

Inferring the case this way keeps the change small: struct vma_prepare gains no field and no caller changes.

Moving the remove() out of vma_prepare() leaves vp->vma in the tree with a possibly stale sort key across the caller's endpoint updates, so vma_complete() re-keys it *before* inserting vp->adj_next: otherwise that key-driven descent could place adj_next in the wrong subtree.

Measured on v7.3-rc4, on a 2-socket 192C/384T system running UnixBench execl (384 concurrent execve of the same binary), dropping the redundant remove + re-insert yields ~14% higher throughput by shortening the i_mmap_rwsem write-side critical section during the file VMA splits that execve performs on the shared libraries.

---
 include/linux/mm.h                |  1 +
 mm/interval_tree.c                | 13 ++++++++
 mm/vma.c                          | 54 +++++++++++++++++++++++++++++--
 mm/vma.h                          |  1 +
 tools/testing/vma/include/stubs.h |  4 +++
 5 files changed, 71 insertions(+), 2 deletions(-)
include/linux/mm.h +1 -0
index dd09c438fa23..baf489343f86 100644
@@ -4181,6 +4181,7 @@ void mapping_rmap_tree_insert_after(struct vm_area_struct *vma,
 				    struct address_space *mapping);
 void mapping_rmap_tree_remove(struct vm_area_struct *vma,
 			      struct address_space *mapping);
+void mapping_rmap_tree_propagate(struct vm_area_struct *vma);
 struct vm_area_struct *
 mapping_rmap_tree_iter_first(struct address_space *mapping,
 			     pgoff_t pgoff_start, pgoff_t pgoff_last);
mm/interval_tree.c +13 -0
index 7bbbf15cfbf0..3b81c990aab2 100644
@@ -64,6 +64,19 @@ void mapping_rmap_tree_remove(struct vm_area_struct *vma,
 	__mapping_rmap_tree_remove(vma, &mapping->i_mmap);
 }
 
+/*
+ * Recompute shared.rb_subtree_last for vma and its ancestors, for a vma whose
+ * interval changed but whose vma_start_pgoff() (the tree's sort key) did not.
+ * The NULL stop node makes the walk run up to the root, though it ends early
+ * once the recomputed value stops changing.
+ *
+ * Wrapper because INTERVAL_TREE_DEFINE() above declares the callbacks static.
+ */
+void mapping_rmap_tree_propagate(struct vm_area_struct *vma)
+{
+	__mapping_rmap_tree_augment.propagate(&vma->shared.rb, NULL);
+}
+
 struct vm_area_struct *
 mapping_rmap_tree_iter_first(struct address_space *mapping,
 			     pgoff_t pgoff_start, pgoff_t pgoff_last)
mm/vma.c +52 -2

72 lines not on this page · raw message

mm/vma.h +1 -0
index 024fabe63560..3f791e4d13f6 100644
@@ -23,6 +23,7 @@ struct vma_prepare {
 	struct file *file;
 	struct address_space *mapping;
 	struct anon_vma *anon_vma;
+	/* Set by __split_vma() only; see vma_split_keeps_rmap_key(). */
 	struct vm_area_struct *insert;
 	struct vm_area_struct *remove;
 	struct vm_area_struct *remove2;
tools/testing/vma/include/stubs.h +4 -0
index d6136e19a8af..3b5184aeee54 100644
@@ -267,6 +267,10 @@ static inline void mapping_rmap_tree_remove(struct vm_area_struct *vma,
 {
 }
 
+static inline void mapping_rmap_tree_propagate(struct vm_area_struct *vma)
+{
+}
+
 static inline void flush_dcache_mmap_unlock(struct address_space *mapping)
 {
 }
Signature · 1 line
2.43.5
#1 lore raw

Sorry this patch feels like AI schlopp.

Please read https://docs.kernel.org/process/generated-content.html
especially:

If tools permit you to generate a contribution automatically, expect additional scrutiny in proportion to how much of it was generated.

As with the output of any tooling, the result may be incorrect or inappropriate. You are expected to understand and to be able to defend everything you submit. If you are unable to do so, then do not submit the resulting changes.

If you do so anyway, maintainers are entitled to reject your series without detailed review.

You are changing a very subtle and fragile part of the kernel, and you seem to be an absolute newcomer to mm.

In general we expect newcomers to mm to do smaller work and gradually work their way up towards larger changes.

I think it's best to treat this as a report rather than a patch, and for a member of the core team to take this over. I'll take a look.

Thanks!

(Review for below as reference only).

Quoted 12 lines · Pan Deng

Splitting a file-backed VMA removes it from the mapping's i_mmap interval tree and re-inserts it, two O(log n) walks with rebalancing, all inside the i_mmap_rwsem write-side critical section. For a file mapped by many processes that lock is a single serialization point, so the cost translates into reduced exec throughput.

While the re-insert is needed whenever the sort key changes, it is not for a new_below=0 split: there the new VMA takes the upper half and only the original VMA's vm_end shrinks, so vma_start_pgoff(), the sort key of the interval tree, stays constant and the VMA is already in the correct position.

Quoted 4 lines

This change skips the re-insert for that case. vma_prepare() no longer removes vp->vma from the tree; instead vma_complete() detects that case and only recomputes shared.rb_subtree_last up the ancestor chain. Everything else keeps the remove + re-insert path.

This could really do with a diagram and a simple explanation.

In general you should rewrite the entire commit message yourself and not use the LLM output at all.

Quoted 10 lines

The case is detected by comparing vma_start_pgoff(vp->insert) against vma_start_pgoff(vp->vma): only a new_below=0 split leaves the former greater. __split_vma() adjusts pgoff via vma_add_pgoff(new, linear_page_delta(vma, addr)), and linear_page_delta() is (addr - vm_start) >> PAGE_SHIFT with addr strictly inside the VMA, so the delta is at least one page and the new VMA's pgoff is strictly greater. For new_below=1 the two are initially equal and vp->vma's pgoff then increases, so the comparison is false both before and after the caller's endpoint updates, and the original path is taken.

This is useless description of the code in English, it's not telling me anything useful at all. Human beings don't have a large 'stack' with which to hold things in our minds.

Write with humans in mind please :)

Quoted 3 lines

Inferring the case this way keeps the change small: struct vma_prepare gains no field and no caller changes.

I don't understand what inferring the case means? I think this can be dropped.

Quoted 3 lines

Moving the remove() out of vma_prepare() leaves vp->vma in the tree with a possibly stale sort key across the caller's endpoint updates, so

I mean what?

What does a 'possibly stale sort key' mean? And what does 'across the caller's endpoint updates' mean? Which caller? What's an endpoint? What updates?

Quoted 2 lines

vma_complete() re-keys it *before* inserting vp->adj_next: otherwise that key-driven descent could place adj_next in the wrong subtree.

Re-keys what? WHat does re-key mean?

What you're saying here really makes me nervous. You're changing a very sensitive part of the kernel and talking about intentionally leaving stale state around.

This patch cannot possibly be considered for upstream until I fully understand exactly what this means and that you understand what you're doing.

Quoted 6 lines

Measured on v7.3-rc4, on a 2-socket 192C/384T system running UnixBench execl (384 concurrent execve of the same binary), dropping the redundant remove + re-insert yields ~14% higher throughput by shortening the i_mmap_rwsem write-side critical section during the file VMA splits that execve performs on the shared libraries.

This is really unconvincing I'm sorry. Real numbers please with statistical evidence to back them.

Additionally I notice you have not made one comment referring to locking anywhere.

This part of the kernel has VERY subtle and sensitive locking requirements. I am not convinced you understand this, either.

Quoted 2 lines

This patch feels like a hack. You are creating a whole new set of very fragile assumptions that have to be maintained throughout.

Again as above, a member of the core team should take this over.

Quoted 4 lines

Please don't do this.

Upstream is not interested in private reviews. Review tags upstream are based on review done in _public_.

Quoted 1 line
Assisted-by LLM

Thank you for acking.

Quoted 25 lines
---
 include/linux/mm.h                |  1 +
 mm/interval_tree.c                | 13 ++++++++
 mm/vma.c                          | 54 +++++++++++++++++++++++++++++--
 mm/vma.h                          |  1 +
 tools/testing/vma/include/stubs.h |  4 +++
 5 files changed, 71 insertions(+), 2 deletions(-)
include/linux/mm.h +1 -0
index dd09c438fa23..baf489343f86 100644
@@ -4181,6 +4181,7 @@ void mapping_rmap_tree_insert_after(struct vm_area_struct *vma,
 				    struct address_space *mapping);
 void mapping_rmap_tree_remove(struct vm_area_struct *vma,
 			      struct address_space *mapping);
+void mapping_rmap_tree_propagate(struct vm_area_struct *vma);
 struct vm_area_struct *
 mapping_rmap_tree_iter_first(struct address_space *mapping,
 			     pgoff_t pgoff_start, pgoff_t pgoff_last);
mm/interval_tree.c +0 -0
index 7bbbf15cfbf0..3b81c990aab2 100644

mm/interval_tree.c void mapping_rmap_tree_remove(struct vm_area_struct *vma, · line 71

Quoted 8 lines
mm/interval_tree.c +5 -0
@@ -64,6 +64,19 @@ void mapping_rmap_tree_remove(struct vm_area_struct *vma,
 	__mapping_rmap_tree_remove(vma, &mapping->i_mmap);
 }
 
+/*
+ * Recompute shared.rb_subtree_last for vma and its ancestors, for a vma whose
+ * interval changed but whose vma_start_pgoff() (the tree's sort key) did not.
+ * The NULL stop node makes the walk run up to the root, though it ends early
+ * once the recomputed value stops changing.

Again this is a bunch of unnecesary text that is explaining implementation details and very typical of LLM comments.

mm/interval_tree.c void mapping_rmap_tree_remove(struct vm_area_struct *vma, · line 73

Quoted 2 lines
mm/interval_tree.c +2 -0
+ *
+ * Wrapper because INTERVAL_TREE_DEFINE() above declares the callbacks static.

This is completely useless. Don't write comments like this please.

Having written a lot of LLM-assisted code now in my build speedup series I understand that responsible use of an LLM involves a _lot_ of human work checking and auditing and ensuring understanding.

Please do make sure you do this part, it is not optional.

mm/interval_tree.c void mapping_rmap_tree_remove(struct vm_area_struct *vma, · line 77

Quoted 4 lines
mm/interval_tree.c +4 -0
+ */
+void mapping_rmap_tree_propagate(struct vm_area_struct *vma)
+{
+	__mapping_rmap_tree_augment.propagate(&vma->shared.rb, NULL);

Is it safe to arbitrarily perform a 'propagate' at any time within the interval tree?

I didn't notice any comment about locks or when this can or cannot be done?

Quoted 10 lines
mm/interval_tree.c +2 -0
+}
+
 struct vm_area_struct *
 mapping_rmap_tree_iter_first(struct address_space *mapping,
 			     pgoff_t pgoff_start, pgoff_t pgoff_last)
mm/vma.c +0 -0
index f29abb30956b..e1dbfd5094cd 100644

mm/vma.c static void vma_prepare(struct vma_prepare *vp) · line 368

Quoted 4 lines
mm/vma.c +0 -1
@@ -365,11 +365,43 @@ static void vma_prepare(struct vma_prepare *vp)
 
 	if (vp->file) {
 		flush_dcache_mmap_lock(vp->mapping);
-		mapping_rmap_tree_remove(vp->vma, vp->mapping);

vma_prepare() is called before performing the work that actually performs the underlying operation ON THE ASSUMPTION that the VMA is correctly removed from the tree.

So this would require some strong set of requirements to establish that it is safe.

mm/vma.c static void vma_prepare(struct vma_prepare *vp) · line 368

Quoted 1 line
mm/vma.c +1 -0
+		/* vp->vma is re-keyed by vma_complete(), if it needs to be. */

What does re-key me? Please don't invent new terminology :)

Quoted 7 lines
mm/vma.c +3 -0
 		if (vp->adj_next)
 			mapping_rmap_tree_remove(vp->adj_next, vp->mapping);
 	}
+}
 
+/*
+ * vma_split_keeps_rmap_key() - Check if vp->vma keeps its file rmap tree key

mm/vma.c static void vma_prepare(struct vma_prepare *vp) · line 385

Quoted 10 lines
mm/vma.c +10 -0
+ * @vp: The vma_prepare struct
+ *
+ * True only for a new_below=0 __split_vma(): the new VMA takes the upper half,
+ * so its vma_start_pgoff() is strictly greater, while vp->vma's (its key in the
+ * file rmap interval tree) is unchanged and its tree position still correct, so
+ * only shared.rb_subtree_last has to be recomputed.
+ *
+ * Relies on vp->insert being assigned by __split_vma() only; the check below
+ * catches a second assignment site whose VMA does not abut vp->vma.
+ */

Not a kdoc, you're writing implementation details in the comment, this feels like noise.

mm/vma.c static void vma_prepare(struct vma_prepare *vp) · line 386

Quoted 1 line
mm/vma.c +1 -0
+static bool vma_split_keeps_rmap_key(const struct vma_prepare *vp)

This doesn't seem to be differentiating against file? There's nothing here about file.

And 'keeps rmap key'? What key? What do you mean?

mm/vma.c static void vma_prepare(struct vma_prepare *vp) · line 394

Quoted 8 lines
mm/vma.c +8 -0
+{
+	if (!vp->insert ||
+	    vma_start_pgoff(vp->insert) <= vma_start_pgoff(vp->vma))
+		return false;
+
+	/*
+	 * Today only a new_below=0 __split_vma() reaches here, where the new
+	 * VMA abuts vp->vma at the split point once the caller has updated

'abuts' :) this is not helpful to non-native speakers and is rather an obscure turn of phrase for native speakers, even.

mm/vma.c static void vma_prepare(struct vma_prepare *vp) · line 398

Quoted 4 lines
mm/vma.c +4 -0
+	 * vp->vma->vm_end.  If a future vp->insert user ever violates that,
+	 * fall back to the safe remove + re-insert instead of trusting the
+	 * fast path.
+	 */

Sorry this is just another horrible LLM-generated comment.

And it's totally unacceptable to write 'rules' into comments like this or to say 'if a future xxx'.

mm/vma.c static void vma_prepare(struct vma_prepare *vp) · line 402

Quoted 4 lines
mm/vma.c +4 -0
+	if (vp->insert->vm_start != vp->vma->vm_end) {
+		VM_WARN_ON_ONCE(1);
+		return false;
+	}

This is not good :) we musn't set traps for ourselves like this.

Quoted 6 lines
mm/vma.c +2 -0
+
+	return true;
 }
 
 /*

mm/vma.c static void vma_complete(struct vma_prepare *vp, struct vma_iterator *vmi, · line 423

Quoted 8 lines
mm/vma.c +5 -0
@@ -384,9 +416,27 @@ static void vma_complete(struct vma_prepare *vp, struct vma_iterator *vmi,
 			 struct mm_struct *mm)
 {
 	if (vp->file) {
+		if (vma_split_keeps_rmap_key(vp)) {
+			/*
+			 * Split paths go through init_vma_prep(), which
+			 * passes a NULL vmg, so vp->adj_next is never set.
+			 */

No, you don't make assumptions like this in the code that can explode later.

mm/vma.c static void vma_complete(struct vma_prepare *vp, struct vma_iterator *vmi, · line 434

Quoted 11 lines
mm/vma.c +11 -0
+			VM_WARN_ON_ONCE(vp->adj_next);
+			mapping_rmap_tree_propagate(vp->vma);
+		} else {
+			/*
+			 * Re-key vp->vma *before* the insert of vp->adj_next
+			 * below, so that the latter descends a valid
+			 * search tree: vp->vma is the only node left in
+			 * the tree that may carry a stale sort key
+			 * (vp->adj_next itself was removed in
+			 * vma_prepare()).
+			 */

This is not great, it doesn't explain anything.

mm/vma.c static void vma_complete(struct vma_prepare *vp, struct vma_iterator *vmi, · line 436

Quoted 2 lines
mm/vma.c +2 -0
+			mapping_rmap_tree_remove(vp->vma, vp->mapping);
+			mapping_rmap_tree_insert(vp->vma, vp->mapping);

'Re-key'?

Quoted 12 lines
mm/vma.c +1 -1
+		}
 		if (vp->adj_next)
 			mapping_rmap_tree_insert(vp->adj_next, vp->mapping);
-		mapping_rmap_tree_insert(vp->vma, vp->mapping);
 		flush_dcache_mmap_unlock(vp->mapping);
 	}
 
mm/vma.h +0 -0
index 024fabe63560..3f791e4d13f6 100644

mm/vma.h struct vma_prepare { · line 27

Quoted 5 lines
mm/vma.h +1 -0
@@ -23,6 +23,7 @@ struct vma_prepare {
 	struct file *file;
 	struct address_space *mapping;
 	struct anon_vma *anon_vma;
+	/* Set by __split_vma() only; see vma_split_keeps_rmap_key(). */
 	struct vm_area_struct *insert;

Again feels like adding a fragile assumption.

Quoted 18 lines
mm/vma.h +0 -0
 	struct vm_area_struct *remove;
 	struct vm_area_struct *remove2;
tools/testing/vma/include/stubs.h +4 -1
index d6136e19a8af..3b5184aeee54 100644
@@ -267,6 +267,10 @@ static inline void mapping_rmap_tree_remove(struct vm_area_struct *vma,
 {
 }
 
+static inline void mapping_rmap_tree_propagate(struct vm_area_struct *vma)
+{
+}
+
 static inline void flush_dcache_mmap_unlock(struct address_space *mapping)
 {
 }
--
Quoted 2 lines

2.43.5

--
Cheers, Lorenzo

reviewer
#2 lore raw
Quoted 9 lines · Lorenzo Stoakes (ARM)
Quoted 4 lines

This change skips the re-insert for that case. vma_prepare() no longer removes vp->vma from the tree; instead vma_complete() detects that case and only recomputes shared.rb_subtree_last up the ancestor chain. Everything else keeps the remove + re-insert path.

This could really do with a diagram and a simple explanation.

In general you should rewrite the entire commit message yourself and not use the LLM output at all.

+1 on this. Even with the Assisted-by, this needs to be understandable by hoomans.

Quoted 40 lines
Quoted 11 lines

The case is detected by comparing vma_start_pgoff(vp->insert) against vma_start_pgoff(vp->vma): only a new_below=0 split leaves the former greater. __split_vma() adjusts pgoff via vma_add_pgoff(new, linear_page_delta(vma, addr)), and linear_page_delta() is (addr - vm_start) >> PAGE_SHIFT with addr strictly inside the VMA, so the delta is at least one page and the new VMA's pgoff is strictly greater. For new_below=1 the two are initially equal and vp->vma's pgoff then increases, so the comparison is false both before and after the caller's endpoint updates, and the original path is taken.

This is useless description of the code in English, it's not telling me anything useful at all. Human beings don't have a large 'stack' with which to hold things in our minds.

Write with humans in mind please :)

Quoted 3 lines

Inferring the case this way keeps the change small: struct vma_prepare gains no field and no caller changes.

I don't understand what inferring the case means? I think this can be dropped.

Quoted 3 lines

Moving the remove() out of vma_prepare() leaves vp->vma in the tree with a possibly stale sort key across the caller's endpoint updates, so

I mean what?

What does a 'possibly stale sort key' mean? And what does 'across the caller's endpoint updates' mean? Which caller? What's an endpoint? What updates?

Quoted 2 lines

vma_complete() re-keys it *before* inserting vp->adj_next: otherwise that key-driven descent could place adj_next in the wrong subtree.

Re-keys what? WHat does re-key mean?

Quoted 14 lines

What you're saying here really makes me nervous. You're changing a very sensitive part of the kernel and talking about intentionally leaving stale state around.

This patch cannot possibly be considered for upstream until I fully understand exactly what this means and that you understand what you're doing.

Quoted 6 lines

Measured on v7.3-rc4, on a 2-socket 192C/384T system running UnixBench execl (384 concurrent execve of the same binary), dropping the redundant remove + re-insert yields ~14% higher throughput by shortening the i_mmap_rwsem write-side critical section during the file VMA splits that execve performs on the shared libraries.

For what it's worth, I'm vaguely accepting of a similar change, but this needs to be _really_ well commented out, and ideally in file rmap code, _not_ spaghetti'd in VMAs. The interval tree is complicated and some bits are not very intuitive. This needs to be robust. Not LLM'd into existence.

This also reminds me that I should reboot the sharded file rmap effort...

Quoted 23 lines

This is really unconvincing I'm sorry. Real numbers please with statistical evidence to back them.

Additionally I notice you have not made one comment referring to locking anywhere.

This part of the kernel has VERY subtle and sensitive locking requirements. I am not convinced you understand this, either.

Quoted 2 lines

This patch feels like a hack. You are creating a whole new set of very fragile assumptions that have to be maintained throughout.

Again as above, a member of the core team should take this over.

Quoted 4 lines
Quoted 4 lines

Please don't do this.

Upstream is not interested in private reviews. Review tags upstream are based on review done in _public_.

Yeah, this too. It's just noise.

Signature · 1 line
Pedro
#3 lore raw
Quoted 6 lines · Pedro Falcato
Quoted 5 lines · Lorenzo Stoakes (ARM)
Quoted 4 lines

This change skips the re-insert for that case. vma_prepare() no longer removes vp->vma from the tree; instead vma_complete() detects that case and only recomputes shared.rb_subtree_last up the ancestor chain. Everything else keeps the remove + re-insert path.

Quoted 7 lines
Quoted 4 lines

This could really do with a diagram and a simple explanation.

In general you should rewrite the entire commit message yourself and not use the LLM output at all.

+1 on this. Even with the Assisted-by, this needs to be understandable by hoomans.

Yes.

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

Measured on v7.3-rc4, on a 2-socket 192C/384T system running UnixBench execl (384 concurrent execve of the same binary), dropping the redundant remove + re-insert yields ~14% higher throughput by shortening the i_mmap_rwsem write-side critical section during the file VMA splits that execve performs on the shared libraries.

Quoted 6 lines

For what it's worth, I'm vaguely accepting of a similar change, but this needs to be _really_ well commented out, and ideally in file rmap code, _not_ spaghetti'd in VMAs. The interval tree is complicated and some bits are not very intuitive. This needs to be robust. Not LLM'd into existence.

This also reminds me that I should reboot the sharded file rmap effort...

Indeed, which is why I'm treating this as a report rather than a patch.

A member of the core team can do the actual work.

Quoted 24 lines
Quoted 24 lines

This is really unconvincing I'm sorry. Real numbers please with statistical evidence to back them.

Additionally I notice you have not made one comment referring to locking anywhere.

This part of the kernel has VERY subtle and sensitive locking requirements. I am not convinced you understand this, either.

Quoted 2 lines

This patch feels like a hack. You are creating a whole new set of very fragile assumptions that have to be maintained throughout.

Again as above, a member of the core team should take this over.

Quoted 4 lines
Quoted 6 lines
Quoted 4 lines

Please don't do this.

Upstream is not interested in private reviews. Review tags upstream are based on review done in _public_.

Yeah, this too. It's just noise.

Yes!

Quoted 3 lines

--
Pedro

--
Cheers, Lorenzo

author
#4 lore raw
Quoted 43 lines

-----Original Message-----
From: Lorenzo Stoakes (ARM) <[email protected]>
Sent: Saturday, September 26, 2026 12:09 AM
To: Pedro Falcato <[email protected]>
Cc: Deng, Pan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; Li, Tianyou <[email protected]>; Guo, Wangyang <[email protected]>; Zhou, Zhiguo <[email protected]>; Tim Chen <[email protected]>
Subject: Re: [PATCH] mm/vma: avoid redundant file rmap tree re-insert on new_below=0 split

Quoted 3 lines · Pedro Falcato
Quoted 2 lines · Lorenzo Stoakes (ARM)
Quoted 2 lines

This change skips the re-insert for that case. vma_prepare() no longer removes vp->vma from the tree; instead vma_complete() detects that case

and

Quoted 10 lines
Quoted 7 lines
Quoted 2 lines

only recomputes shared.rb_subtree_last up the ancestor chain. Everything else keeps the remove + re-insert path.

This could really do with a diagram and a simple explanation.

In general you should rewrite the entire commit message yourself and not use the LLM output at all.

+1 on this. Even with the Assisted-by, this needs to be understandable by hoomans.

Yes.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Measured on v7.3-rc4, on a 2-socket 192C/384T system running

UnixBench

Quoted 10 lines
Quoted 4 lines
Quoted 4 lines

execl (384 concurrent execve of the same binary), dropping the redundant remove + re-insert yields ~14% higher throughput by shortening the i_mmap_rwsem write-side critical section during the file VMA splits that execve performs on the shared libraries.

For what it's worth, I'm vaguely accepting of a similar change, but this needs to be _really_ well commented out, and ideally in file rmap code, _not_ spaghetti'd in VMAs. The interval tree is complicated and some bits are not very intuitive. This needs to be robust. Not LLM'd into existence.

Quoted 5 lines
Quoted 1 line

This also reminds me that I should reboot the sharded file rmap effort...

Indeed, which is why I'm treating this as a report rather than a patch.

A member of the core team can do the actual work.

Thanks everyone for your patience and time to review this patch.

You're right that I should not use the LLM output for commit message. As a non-native speaker, I used it to generate commit message and comments to make it read more natively, unfortunately it had an opposite effect. I'm writing by myself, from now on :)

I just saw Lorenzo has picked over this work in https://lore.kernel.org/all/[email protected]/. I've read through the new patch, which extends the scope to anonymous and covers merge and shrink scenario, more complete than I just sent, it is great. I fully agree that it is a very subtle and fragile part of the kernel, I did spend time and struggled with the patch, very appreciate your help.

One last thing, and please read it as a question rather than a request. I read submitting-patches.rst, and it says "Reported-by" tag is intended for bugs. While I wasn't reporting a bug, so would you consider "Suggested-by" instead (or even "co-developed-by") if you feel that describes it better? I'm fine with which tag you think is accurate, and I'm not trying to reopen the decision to take the work over. Again, very appreciate your review and looking forward to your help in the future.

Best Regards
Pan

#5 lore raw
Quoted 47 lines · Pan
Quoted 47 lines

-----Original Message-----
From: Lorenzo Stoakes (ARM) <[email protected]>
Sent: Saturday, September 26, 2026 12:09 AM
To: Pedro Falcato <[email protected]>
Cc: Deng, Pan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; Li, Tianyou <[email protected]>; Guo, Wangyang <[email protected]>; Zhou, Zhiguo <[email protected]>; Tim Chen <[email protected]>
Subject: Re: [PATCH] mm/vma: avoid redundant file rmap tree re-insert on new_below=0 split

Quoted 3 lines · Pedro Falcato
Quoted 2 lines · Lorenzo Stoakes (ARM)
Quoted 2 lines

This change skips the re-insert for that case. vma_prepare() no longer removes vp->vma from the tree; instead vma_complete() detects that case

and

Quoted 10 lines
Quoted 7 lines
Quoted 2 lines

only recomputes shared.rb_subtree_last up the ancestor chain. Everything else keeps the remove + re-insert path.

This could really do with a diagram and a simple explanation.

In general you should rewrite the entire commit message yourself and not use the LLM output at all.

+1 on this. Even with the Assisted-by, this needs to be understandable by hoomans.

Yes.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Measured on v7.3-rc4, on a 2-socket 192C/384T system running

UnixBench

Quoted 11 lines
Quoted 4 lines
Quoted 4 lines

execl (384 concurrent execve of the same binary), dropping the redundant remove + re-insert yields ~14% higher throughput by shortening the i_mmap_rwsem write-side critical section during the file VMA splits that execve performs on the shared libraries.

For what it's worth, I'm vaguely accepting of a similar change, but this needs to be _really_ well commented out, and ideally in file rmap code, _not_ spaghetti'd in VMAs. The interval tree is complicated and some bits are not very intuitive. This needs to be robust. Not LLM'd into existence.

This also reminds me that I should reboot the sharded file rmap effort...

Indeed, which is why I'm treating this as a report rather than a patch.

Quoted 7 lines
Quoted 1 line

A member of the core team can do the actual work.

Thanks everyone for your patience and time to review this patch.

You're right that I should not use the LLM output for commit message. As a non-native speaker, I used it to generate commit message and comments to make it read more natively, unfortunately it had an opposite effect. I'm writing by myself, from now on :)

I just saw Lorenzo has picked over this work in https://lore.kernel.org/all/[email protected]/. I've read through the new patch, which extends the scope to anonymous and covers merge and shrink scenario, more complete than I just sent, it is great. I fully agree that it is a very subtle and fragile part of the kernel, I did spend time and struggled with the patch, very appreciate your help.

Thanks :) and thank you for your understanding.

If you are able to test that locally with whatever workloads you've been using and report back there that'd be helpful? Thanks.

Quoted 2 lines

One last thing, and please read it as a question rather than a request. I read submitting-patches.rst, and it says "Reported-by" tag is intended for bugs. While I wasn't reporting a bug, so would you consider "Suggested-by" instead (or even "co-developed-by") if you feel that describes it better? I'm fine with which tag you think is accurate, and I'm not trying to reopen the decision to take the work over. Again, very appreciate your review and looking forward to your help in the future.

Yeah it's not quite the right match, but often the resultant final patch is quite substantially different than that submitted, and Suggested-by generally implies:

Person X: 'hey I want to do ...'
Person Y: 'have you thought of doing it using <great idea>' Person X: 'oh yeah great thanks will respin with that!'

Whereas in this case where it seems it's end-to-end LLM, none of that really matches.

And if any tags are to be given then Reported-by, Closes is closest.

However, since you're explicitly asking for it and the idea itself is nice, I'll ask Andrew to switch it out :)

(One small note - please wrap your lines to ~75 chars in emails makes life easier!)

Quoted 3 lines

Best Regards
Pan

--
Cheers, Lorenzo

author
#6 lore raw
Quoted 9 lines
Quoted 2 lines

I just saw Lorenzo has picked over this work in

https://lore.kernel.org/all/20260925-speed-up-inplace-rmap-v1-1-
[email protected]/. I've read through the new patch, which extends the scope to anonymous and covers merge and shrink scenario, more complete than I just sent, it is great. I fully agree that it is a very subtle and fragile part of the kernel, I did spend time and struggled with the patch, very appreciate your help.

Quoted 4 lines

Thanks :) and thank you for your understanding.

If you are able to test that locally with whatever workloads you've been using and report back there that'd be helpful? Thanks.

Reported back in that thread.

Quoted 13 lines
Quoted 2 lines

One last thing, and please read it as a question rather than a request. I read

submitting-patches.rst, and it says "Reported-by" tag is intended for bugs. While I wasn't reporting a bug, so would you consider "Suggested-by" instead (or even "co-developed-by") if you feel that describes it better? I'm fine with which tag you think is accurate, and I'm not trying to reopen the decision to take the work over. Again, very appreciate your review and looking forward to your help in the future.

Yeah it's not quite the right match, but often the resultant final patch is quite substantially different than that submitted, and Suggested-by generally implies:

Quoted 6 lines

Person X: 'hey I want to do ...'
Person Y: 'have you thought of doing it using <great idea>' Person X: 'oh yeah great thanks will respin with that!'

Whereas in this case where it seems it's end-to-end LLM, none of that really matches.

Oh, it is not end-to-end LLM, actually a lot of human intelligence is involved :)

Quoted 4 lines

And if any tags are to be given then Reported-by, Closes is closest.

However, since you're explicitly asking for it and the idea itself is nice, I'll ask Andrew to switch it out :)

Thanks a lot!

Quoted 2 lines

(One small note - please wrap your lines to ~75 chars in emails makes life easier!)

Got it, will do!

Best Regards