Skip to contentSkip to conversation

fork: Use helper function mapping_allow_writable() in dup_mmap()

PATCH In review Miaohe Lin 3 participants 3 messages Sep 13, 2020 – Sep 15, 2020

Subsystems (3)
lore
Share & tools
lore

Miaohe Lin

author
#0 lore raw

PATCH 1/1 fork: Use helper function mapping_allow_writable() in dup_mmap()

Use helper function mapping_allow_writable() to atomic_inc i_mmap_writable.

---
 kernel/fork.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/fork.c +1 -1
index 4b328aecabb2..a0586716e327 100644
@@ -558,7 +558,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
 				atomic_dec(&inode->i_writecount);
 			i_mmap_lock_write(mapping);
 			if (tmp->vm_flags & VM_SHARED)
-				atomic_inc(&mapping->i_mmap_writable);
+				mapping_allow_writable(mapping);
 			flush_dcache_mmap_lock(mapping);
 			/* insert tmp into the share list, just after mpnt */
 			vma_interval_tree_insert_after(tmp, mpnt,
Signature · 1 line
2.19.1
#1 lore raw
Quoted 2 lines · Miaohe Lin

Use helper function mapping_allow_writable() to atomic_inc i_mmap_writable.

Why?

Quoted 18 lines
---
 kernel/fork.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/fork.c +1 -1
index 4b328aecabb2..a0586716e327 100644
@@ -558,7 +558,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
 				atomic_dec(&inode->i_writecount);
 			i_mmap_lock_write(mapping);
 			if (tmp->vm_flags & VM_SHARED)
-				atomic_inc(&mapping->i_mmap_writable);
+				mapping_allow_writable(mapping);
 			flush_dcache_mmap_lock(mapping);
 			/* insert tmp into the share list, just after mpnt */
 			vma_interval_tree_insert_after(tmp, mpnt,
#2 lore raw
In reply to Miaohe Lin
Quoted 4 lines · Miaohe Lin

Use helper function mapping_allow_writable() to atomic_inc i_mmap_writable.

---

Hey Miaohe,

Thanks for the patch!
Per se there's nothing against using a proper helper when it exists. But it has already been pointed out that this needs a proper commit message with more rationale. But I'm otherwise happy to take this.

Thanks!
Christian