mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] mm/mmap: not necessary to check mapping separately
@ 2020-09-13 13:36 Wei Yang
  2020-09-13 13:36 ` [PATCH 2/2] mm/mmap: check on file instead of the rb_root_cached of its address_space Wei Yang
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Yang @ 2020-09-13 13:36 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, Wei Yang

*root* with type of struct rb_root_cached is an element of *mapping*
with type of struct address_space. This implies when we have a valid
*root* it must be a part of valid *mapping*.

So we can merge these two checks together to make the code more easy to
read and to save some cpu cycles.

Signed-off-by: Wei Yang <richard.weiyang@linux.alibaba.com>
---
 mm/mmap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index 1922e6fce9e7..30b155098606 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -895,10 +895,9 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
 			anon_vma_interval_tree_post_update_vma(next);
 		anon_vma_unlock_write(anon_vma);
 	}
-	if (mapping)
-		i_mmap_unlock_write(mapping);
 
 	if (root) {
+		i_mmap_unlock_write(mapping);
 		uprobe_mmap(vma);
 
 		if (adjust_next)
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-13 13:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-13 13:36 [PATCH 1/2] mm/mmap: not necessary to check mapping separately Wei Yang
2020-09-13 13:36 ` [PATCH 2/2] mm/mmap: check on file instead of the rb_root_cached of its address_space Wei Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®