Skip to contentSkip to conversation

mm-rmap-handle-anon_vma_prepare-common-case-inline.patch removed from -mm tree

merged [email protected] 1 participant 1 message Dec 14, 2016

lore
Share & tools
lore

[email protected]

author tree notice Applied
#0 lore raw

The patch titled
Subject: mm, rmap: handle anon_vma_prepare() common case inline
has been removed from the -mm tree. Its filename was
mm-rmap-handle-anon_vma_prepare-common-case-inline.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Vlastimil Babka <[email protected]>
Subject: mm, rmap: handle anon_vma_prepare() common case inline

anon_vma_prepare() is mostly a large "if (unlikely(...))" block, as the expected common case is that an anon_vma already exists. We could turn the condition around and return 0, but it also makes sense to do it inline and avoid a call for the common case.

Bloat-o-meter naturally shows that inlining the check has some code size costs:

add/remove: 1/1 grow/shrink: 4/0 up/down: 475/-373 (102)
function old new delta
__anon_vma_prepare - 359 +359

handle_mm_fault                             2744    2796     +52
hugetlb_cow                                 1146    1170     +24
hugetlb_fault                               2123    2145     +22
wp_page_copy                                1469    1487     +18

anon_vma_prepare 373 - -373

Checking the asm however confirms that the hot paths now avoid a call, which is moved away.

[[email protected]: coding-style fixes]
Cc "Kirill A. Shutemov" <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Konstantin Khlebnikov <[email protected]>
Cc Rik van Riel <[email protected]>

---

 include/linux/rmap.h |   10 +++++
 mm/rmap.c            |   73 ++++++++++++++++++++---------------------
 2 files changed, 45 insertions(+), 38 deletions(-)
include/linux/rmap.h renamed from include/linux/rmap.h~mm-rmap-handle-anon_vma_prepare-common-case-inline +9 -1
diff -puN include/linux/rmap.h~mm-rmap-handle-anon_vma_prepare-common-case-inline include/linux/rmap.h
@@ -137,11 +137,19 @@ static inline void anon_vma_unlock_read(
  * anon_vma helper functions.
  */
 void anon_vma_init(void);	/* create anon_vma_cachep */
-int  anon_vma_prepare(struct vm_area_struct *);
+int  __anon_vma_prepare(struct vm_area_struct *);
 void unlink_anon_vmas(struct vm_area_struct *);
 int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
 int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
 
+static inline int anon_vma_prepare(struct vm_area_struct *vma)
+{
+	if (likely(vma->anon_vma))
+		return 0;
+
+	return __anon_vma_prepare(vma);
+}
+
 static inline void anon_vma_merge(struct vm_area_struct *vma,
 				  struct vm_area_struct *next)
 {
mm/rmap.c renamed from mm/rmap.c~mm-rmap-handle-anon_vma_prepare-common-case-inline +27 -32

80 lines not on this page · raw message