All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] mm/vma: Use available wrappers when possible
@ 2020-02-17  5:03 ` Anshuman Khandual
  0 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-17  5:03 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Anshuman Khandual, linux-m68k, linux-mips, linuxppc-dev,
	linux-sh, kvm-ppc, linux-fsdevel, linux-arch

Apart from adding a VMA flag readable name for trace purpose, this series
does some open encoding replacements with availabe VMA specific wrappers.
This skips VM_HUGETLB check in vma_migratable() as its already being done
with another patch (https://patchwork.kernel.org/patch/11347831/) which
is yet to be merged.

This series applies on 5.6-rc2. This has been build tested on multiple
platforms, though boot and runtime testing was limited to arm64 and x86.

Cc: linux-kernel@vger.kernel.org
Cc: linux-m68k@lists.linux-m68k.org
Cc: linux-mips@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-sh@vger.kernel.org
Cc: kvm-ppc@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-mm@kvack.org

Anshuman Khandual (5):
  mm/vma: Add missing VMA flag readable name for VM_SYNC
  mm/vma: Make vma_is_accessible() available for general use
  mm/vma: Replace all remaining open encodings with is_vm_hugetlb_page()
  mm/vma: Replace all remaining open encodings with vma_set_anonymous()
  mm/vma: Replace all remaining open encodings with vma_is_anonymous()

 arch/csky/mm/fault.c              | 2 +-
 arch/m68k/mm/fault.c              | 2 +-
 arch/mips/mm/fault.c              | 2 +-
 arch/powerpc/kvm/e500_mmu_host.c  | 2 +-
 arch/powerpc/mm/fault.c           | 2 +-
 arch/sh/mm/fault.c                | 2 +-
 arch/x86/mm/fault.c               | 2 +-
 drivers/misc/mic/scif/scif_mmap.c | 2 +-
 fs/binfmt_elf.c                   | 2 +-
 include/asm-generic/tlb.h         | 2 +-
 include/linux/mm.h                | 5 +++++
 include/trace/events/mmflags.h    | 1 +
 kernel/events/core.c              | 3 ++-
 kernel/sched/fair.c               | 2 +-
 mm/gup.c                          | 5 +++--
 mm/memory.c                       | 5 -----
 mm/mempolicy.c                    | 3 +--
 17 files changed, 23 insertions(+), 21 deletions(-)

-- 
2.20.1


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

* [PATCH 0/5] mm/vma: Use available wrappers when possible
@ 2020-02-17  5:03 ` Anshuman Khandual
  0 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-17  5:03 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: linux-arch, linux-sh, Anshuman Khandual, linux-mips, kvm-ppc,
	linux-m68k, linux-fsdevel, linuxppc-dev

Apart from adding a VMA flag readable name for trace purpose, this series
does some open encoding replacements with availabe VMA specific wrappers.
This skips VM_HUGETLB check in vma_migratable() as its already being done
with another patch (https://patchwork.kernel.org/patch/11347831/) which
is yet to be merged.

This series applies on 5.6-rc2. This has been build tested on multiple
platforms, though boot and runtime testing was limited to arm64 and x86.

Cc: linux-kernel@vger.kernel.org
Cc: linux-m68k@lists.linux-m68k.org
Cc: linux-mips@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-sh@vger.kernel.org
Cc: kvm-ppc@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-mm@kvack.org

Anshuman Khandual (5):
  mm/vma: Add missing VMA flag readable name for VM_SYNC
  mm/vma: Make vma_is_accessible() available for general use
  mm/vma: Replace all remaining open encodings with is_vm_hugetlb_page()
  mm/vma: Replace all remaining open encodings with vma_set_anonymous()
  mm/vma: Replace all remaining open encodings with vma_is_anonymous()

 arch/csky/mm/fault.c              | 2 +-
 arch/m68k/mm/fault.c              | 2 +-
 arch/mips/mm/fault.c              | 2 +-
 arch/powerpc/kvm/e500_mmu_host.c  | 2 +-
 arch/powerpc/mm/fault.c           | 2 +-
 arch/sh/mm/fault.c                | 2 +-
 arch/x86/mm/fault.c               | 2 +-
 drivers/misc/mic/scif/scif_mmap.c | 2 +-
 fs/binfmt_elf.c                   | 2 +-
 include/asm-generic/tlb.h         | 2 +-
 include/linux/mm.h                | 5 +++++
 include/trace/events/mmflags.h    | 1 +
 kernel/events/core.c              | 3 ++-
 kernel/sched/fair.c               | 2 +-
 mm/gup.c                          | 5 +++--
 mm/memory.c                       | 5 -----
 mm/mempolicy.c                    | 3 +--
 17 files changed, 23 insertions(+), 21 deletions(-)

-- 
2.20.1


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

* [PATCH 1/5] mm/vma: Add missing VMA flag readable name for VM_SYNC
  2020-02-17  5:03 ` Anshuman Khandual
  (?)
  (?)
@ 2020-02-17  5:03 ` Anshuman Khandual
  -1 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-17  5:03 UTC (permalink / raw)
  To: linux-mm, linux-kernel; +Cc: Anshuman Khandual, Steven Rostedt, Ingo Molnar

This just adds the missing readable name for VM_SYNC.

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 include/trace/events/mmflags.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
index a1675d43777e..5fb752034386 100644
--- a/include/trace/events/mmflags.h
+++ b/include/trace/events/mmflags.h
@@ -154,6 +154,7 @@ IF_HAVE_PG_IDLE(PG_idle,		"idle"		)
 	{VM_ACCOUNT,			"account"	},		\
 	{VM_NORESERVE,			"noreserve"	},		\
 	{VM_HUGETLB,			"hugetlb"	},		\
+	{VM_SYNC,			"sync"		},		\
 	__VM_ARCH_SPECIFIC_1				,		\
 	{VM_WIPEONFORK,			"wipeonfork"	},		\
 	{VM_DONTDUMP,			"dontdump"	},		\
-- 
2.20.1


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

* [PATCH 2/5] mm/vma: Make vma_is_accessible() available for general use
  2020-02-17  5:03 ` Anshuman Khandual
  (?)
@ 2020-02-17  5:03   ` Anshuman Khandual
  -1 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-17  5:03 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Anshuman Khandual, Guo Ren, Geert Uytterhoeven, Ralf Baechle,
	Paul Burton, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Yoshinori Sato, Rich Felker, Dave Hansen,
	Andy Lutomirski, Peter Zijlstra, Thomas Gleixner, Ingo Molnar,
	Andrew Morton, Steven Rostedt, Mel Gorman, linux-m68k,
	linux-mips, linuxppc-dev, linux-sh

Lets move vma_is_accessible() helper to include/linux/mm.h which makes it
available for general use. While here, this replaces all remaining open
encodings for VMA access check with vma_is_accessible().

Cc: Guo Ren <guoren@kernel.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: linux-kernel@vger.kernel.org
Cc: linux-m68k@lists.linux-m68k.org
Cc: linux-mips@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-sh@vger.kernel.org
Cc: linux-mm@kvack.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 arch/csky/mm/fault.c    | 2 +-
 arch/m68k/mm/fault.c    | 2 +-
 arch/mips/mm/fault.c    | 2 +-
 arch/powerpc/mm/fault.c | 2 +-
 arch/sh/mm/fault.c      | 2 +-
 arch/x86/mm/fault.c     | 2 +-
 include/linux/mm.h      | 5 +++++
 kernel/sched/fair.c     | 2 +-
 mm/gup.c                | 2 +-
 mm/memory.c             | 5 -----
 mm/mempolicy.c          | 3 +--
 11 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/arch/csky/mm/fault.c b/arch/csky/mm/fault.c
index f76618b630f9..4b3511b8298d 100644
--- a/arch/csky/mm/fault.c
+++ b/arch/csky/mm/fault.c
@@ -137,7 +137,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
 		if (!(vma->vm_flags & VM_WRITE))
 			goto bad_area;
 	} else {
-		if (!(vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)))
+		if (!vma_is_accessible(vma))
 			goto bad_area;
 	}
 
diff --git a/arch/m68k/mm/fault.c b/arch/m68k/mm/fault.c
index e9b1d7585b43..d5131ec5d923 100644
--- a/arch/m68k/mm/fault.c
+++ b/arch/m68k/mm/fault.c
@@ -125,7 +125,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
 		case 1:		/* read, present */
 			goto acc_err;
 		case 0:		/* read, not present */
-			if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))
+			if (!vma_is_accessible(vma))
 				goto acc_err;
 	}
 
diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
index 1e8d00793784..5b9f947bfa32 100644
--- a/arch/mips/mm/fault.c
+++ b/arch/mips/mm/fault.c
@@ -142,7 +142,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,
 				goto bad_area;
 			}
 		} else {
-			if (!(vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)))
+			if (!vma_is_accessible(vma))
 				goto bad_area;
 		}
 	}
diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index 8db0507619e2..71a3658c516b 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -314,7 +314,7 @@ static bool access_error(bool is_write, bool is_exec,
 		return false;
 	}
 
-	if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
+	if (unlikely(!vma_is_accessible(vma)))
 		return true;
 	/*
 	 * We should ideally do the vma pkey access check here. But in the
diff --git a/arch/sh/mm/fault.c b/arch/sh/mm/fault.c
index 5f51456f4fc7..a8c4253f37d7 100644
--- a/arch/sh/mm/fault.c
+++ b/arch/sh/mm/fault.c
@@ -355,7 +355,7 @@ static inline int access_error(int error_code, struct vm_area_struct *vma)
 		return 1;
 
 	/* read, not present: */
-	if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
+	if (unlikely(!vma_is_accessible(vma)))
 		return 1;
 
 	return 0;
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index fa4ea09593ab..c461eaab0306 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1200,7 +1200,7 @@ access_error(unsigned long error_code, struct vm_area_struct *vma)
 		return 1;
 
 	/* read, not present: */
-	if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
+	if (unlikely(!vma_is_accessible(vma)))
 		return 1;
 
 	return 0;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 52269e56c514..b0e53ef13ff1 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -541,6 +541,11 @@ static inline bool vma_is_anonymous(struct vm_area_struct *vma)
 	return !vma->vm_ops;
 }
 
+static inline bool vma_is_accessible(struct vm_area_struct *vma)
+{
+	return vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC);
+}
+
 #ifdef CONFIG_SHMEM
 /*
  * The vma_is_shmem is not inline because it is used only by slow
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index fe4e0d775375..6ce54d57dd09 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2573,7 +2573,7 @@ static void task_numa_work(struct callback_head *work)
 		 * Skip inaccessible VMAs to avoid any confusion between
 		 * PROT_NONE and NUMA hinting ptes
 		 */
-		if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))
+		if (!vma_is_accessible(vma))
 			continue;
 
 		do {
diff --git a/mm/gup.c b/mm/gup.c
index 1b521e0ac1de..c8ffe2e61f03 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1171,7 +1171,7 @@ long populate_vma_page_range(struct vm_area_struct *vma,
 	 * We want mlock to succeed for regions that have any permissions
 	 * other than PROT_NONE.
 	 */
-	if (vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC))
+	if (vma_is_accessible(vma))
 		gup_flags |= FOLL_FORCE;
 
 	/*
diff --git a/mm/memory.c b/mm/memory.c
index 0bccc622e482..2f07747612b7 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3942,11 +3942,6 @@ static inline vm_fault_t wp_huge_pmd(struct vm_fault *vmf, pmd_t orig_pmd)
 	return VM_FAULT_FALLBACK;
 }
 
-static inline bool vma_is_accessible(struct vm_area_struct *vma)
-{
-	return vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE);
-}
-
 static vm_fault_t create_huge_pud(struct vm_fault *vmf)
 {
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 977c641f78cf..91c1ad6ab8ea 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -649,8 +649,7 @@ static int queue_pages_test_walk(unsigned long start, unsigned long end,
 
 	if (flags & MPOL_MF_LAZY) {
 		/* Similar to task_numa_work, skip inaccessible VMAs */
-		if (!is_vm_hugetlb_page(vma) &&
-			(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)) &&
+		if (!is_vm_hugetlb_page(vma) && vma_is_accessible(vma) &&
 			!(vma->vm_flags & VM_MIXEDMAP))
 			change_prot_numa(vma, start, endvma);
 		return 1;
-- 
2.20.1


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

* [PATCH 2/5] mm/vma: Make vma_is_accessible() available for general use
@ 2020-02-17  5:03   ` Anshuman Khandual
  0 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-17  5:03 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Rich Felker, linux-sh, Peter Zijlstra, Dave Hansen, Guo Ren,
	Yoshinori Sato, Ingo Molnar, Geert Uytterhoeven, Mel Gorman,
	Anshuman Khandual, Steven Rostedt, linux-m68k, Andy Lutomirski,
	Thomas Gleixner, Paul Burton, linux-mips, Ralf Baechle,
	Paul Mackerras, Andrew Morton, linuxppc-dev

Lets move vma_is_accessible() helper to include/linux/mm.h which makes it
available for general use. While here, this replaces all remaining open
encodings for VMA access check with vma_is_accessible().

Cc: Guo Ren <guoren@kernel.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: linux-kernel@vger.kernel.org
Cc: linux-m68k@lists.linux-m68k.org
Cc: linux-mips@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-sh@vger.kernel.org
Cc: linux-mm@kvack.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 arch/csky/mm/fault.c    | 2 +-
 arch/m68k/mm/fault.c    | 2 +-
 arch/mips/mm/fault.c    | 2 +-
 arch/powerpc/mm/fault.c | 2 +-
 arch/sh/mm/fault.c      | 2 +-
 arch/x86/mm/fault.c     | 2 +-
 include/linux/mm.h      | 5 +++++
 kernel/sched/fair.c     | 2 +-
 mm/gup.c                | 2 +-
 mm/memory.c             | 5 -----
 mm/mempolicy.c          | 3 +--
 11 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/arch/csky/mm/fault.c b/arch/csky/mm/fault.c
index f76618b630f9..4b3511b8298d 100644
--- a/arch/csky/mm/fault.c
+++ b/arch/csky/mm/fault.c
@@ -137,7 +137,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
 		if (!(vma->vm_flags & VM_WRITE))
 			goto bad_area;
 	} else {
-		if (!(vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)))
+		if (!vma_is_accessible(vma))
 			goto bad_area;
 	}
 
diff --git a/arch/m68k/mm/fault.c b/arch/m68k/mm/fault.c
index e9b1d7585b43..d5131ec5d923 100644
--- a/arch/m68k/mm/fault.c
+++ b/arch/m68k/mm/fault.c
@@ -125,7 +125,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
 		case 1:		/* read, present */
 			goto acc_err;
 		case 0:		/* read, not present */
-			if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))
+			if (!vma_is_accessible(vma))
 				goto acc_err;
 	}
 
diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
index 1e8d00793784..5b9f947bfa32 100644
--- a/arch/mips/mm/fault.c
+++ b/arch/mips/mm/fault.c
@@ -142,7 +142,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,
 				goto bad_area;
 			}
 		} else {
-			if (!(vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)))
+			if (!vma_is_accessible(vma))
 				goto bad_area;
 		}
 	}
diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index 8db0507619e2..71a3658c516b 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -314,7 +314,7 @@ static bool access_error(bool is_write, bool is_exec,
 		return false;
 	}
 
-	if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
+	if (unlikely(!vma_is_accessible(vma)))
 		return true;
 	/*
 	 * We should ideally do the vma pkey access check here. But in the
diff --git a/arch/sh/mm/fault.c b/arch/sh/mm/fault.c
index 5f51456f4fc7..a8c4253f37d7 100644
--- a/arch/sh/mm/fault.c
+++ b/arch/sh/mm/fault.c
@@ -355,7 +355,7 @@ static inline int access_error(int error_code, struct vm_area_struct *vma)
 		return 1;
 
 	/* read, not present: */
-	if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
+	if (unlikely(!vma_is_accessible(vma)))
 		return 1;
 
 	return 0;
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index fa4ea09593ab..c461eaab0306 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1200,7 +1200,7 @@ access_error(unsigned long error_code, struct vm_area_struct *vma)
 		return 1;
 
 	/* read, not present: */
-	if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
+	if (unlikely(!vma_is_accessible(vma)))
 		return 1;
 
 	return 0;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 52269e56c514..b0e53ef13ff1 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -541,6 +541,11 @@ static inline bool vma_is_anonymous(struct vm_area_struct *vma)
 	return !vma->vm_ops;
 }
 
+static inline bool vma_is_accessible(struct vm_area_struct *vma)
+{
+	return vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC);
+}
+
 #ifdef CONFIG_SHMEM
 /*
  * The vma_is_shmem is not inline because it is used only by slow
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index fe4e0d775375..6ce54d57dd09 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2573,7 +2573,7 @@ static void task_numa_work(struct callback_head *work)
 		 * Skip inaccessible VMAs to avoid any confusion between
 		 * PROT_NONE and NUMA hinting ptes
 		 */
-		if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))
+		if (!vma_is_accessible(vma))
 			continue;
 
 		do {
diff --git a/mm/gup.c b/mm/gup.c
index 1b521e0ac1de..c8ffe2e61f03 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1171,7 +1171,7 @@ long populate_vma_page_range(struct vm_area_struct *vma,
 	 * We want mlock to succeed for regions that have any permissions
 	 * other than PROT_NONE.
 	 */
-	if (vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC))
+	if (vma_is_accessible(vma))
 		gup_flags |= FOLL_FORCE;
 
 	/*
diff --git a/mm/memory.c b/mm/memory.c
index 0bccc622e482..2f07747612b7 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3942,11 +3942,6 @@ static inline vm_fault_t wp_huge_pmd(struct vm_fault *vmf, pmd_t orig_pmd)
 	return VM_FAULT_FALLBACK;
 }
 
-static inline bool vma_is_accessible(struct vm_area_struct *vma)
-{
-	return vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE);
-}
-
 static vm_fault_t create_huge_pud(struct vm_fault *vmf)
 {
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 977c641f78cf..91c1ad6ab8ea 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -649,8 +649,7 @@ static int queue_pages_test_walk(unsigned long start, unsigned long end,
 
 	if (flags & MPOL_MF_LAZY) {
 		/* Similar to task_numa_work, skip inaccessible VMAs */
-		if (!is_vm_hugetlb_page(vma) &&
-			(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)) &&
+		if (!is_vm_hugetlb_page(vma) && vma_is_accessible(vma) &&
 			!(vma->vm_flags & VM_MIXEDMAP))
 			change_prot_numa(vma, start, endvma);
 		return 1;
-- 
2.20.1


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

* [PATCH 3/5] mm/vma: Replace all remaining open encodings with is_vm_hugetlb_page()
  2020-02-17  5:03 ` Anshuman Khandual
  (?)
@ 2020-02-17  5:03   ` Anshuman Khandual
  -1 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-17  5:03 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Anshuman Khandual, Paul Mackerras, Benjamin Herrenschmidt,
	Michael Ellerman, Alexander Viro, Will Deacon, Aneesh Kumar K.V,
	Andrew Morton, Nick Piggin, Peter Zijlstra, Arnd Bergmann,
	Ingo Molnar, Arnaldo Carvalho de Melo, kvm-ppc, linuxppc-dev,
	linux-fsdevel, linux-arch

This replaces all remaining open encodings with is_vm_hugetlb_page().

Cc: Paul Mackerras <paulus@ozlabs.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Will Deacon <will@kernel.org>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Nick Piggin <npiggin@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: kvm-ppc@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-mm@kvack.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 arch/powerpc/kvm/e500_mmu_host.c | 2 +-
 fs/binfmt_elf.c                  | 2 +-
 include/asm-generic/tlb.h        | 2 +-
 kernel/events/core.c             | 3 ++-
 4 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c
index 425d13806645..3922575a1c31 100644
--- a/arch/powerpc/kvm/e500_mmu_host.c
+++ b/arch/powerpc/kvm/e500_mmu_host.c
@@ -422,7 +422,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
 				break;
 			}
 		} else if (vma && hva >= vma->vm_start &&
-			   (vma->vm_flags & VM_HUGETLB)) {
+			   (is_vm_hugetlb_page(vma))) {
 			unsigned long psize = vma_kernel_pagesize(vma);
 
 			tsize = (gtlbe->mas1 & MAS1_TSIZE_MASK) >>
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index f4713ea76e82..6bc97ede10ba 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1317,7 +1317,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
 	}
 
 	/* Hugetlb memory check */
-	if (vma->vm_flags & VM_HUGETLB) {
+	if (is_vm_hugetlb_page(vma)) {
 		if ((vma->vm_flags & VM_SHARED) && FILTER(HUGETLB_SHARED))
 			goto whole;
 		if (!(vma->vm_flags & VM_SHARED) && FILTER(HUGETLB_PRIVATE))
diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
index f391f6b500b4..d42c236d4965 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -398,7 +398,7 @@ tlb_update_vma_flags(struct mmu_gather *tlb, struct vm_area_struct *vma)
 	 * We rely on tlb_end_vma() to issue a flush, such that when we reset
 	 * these values the batch is empty.
 	 */
-	tlb->vma_huge = !!(vma->vm_flags & VM_HUGETLB);
+	tlb->vma_huge = is_vm_hugetlb_page(vma);
 	tlb->vma_exec = !!(vma->vm_flags & VM_EXEC);
 }
 
diff --git a/kernel/events/core.c b/kernel/events/core.c
index e453589da97c..eb0ee3c5f322 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -28,6 +28,7 @@
 #include <linux/export.h>
 #include <linux/vmalloc.h>
 #include <linux/hardirq.h>
+#include <linux/hugetlb_inline.h>
 #include <linux/rculist.h>
 #include <linux/uaccess.h>
 #include <linux/syscalls.h>
@@ -7693,7 +7694,7 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
 		flags |= MAP_EXECUTABLE;
 	if (vma->vm_flags & VM_LOCKED)
 		flags |= MAP_LOCKED;
-	if (vma->vm_flags & VM_HUGETLB)
+	if (is_vm_hugetlb_page(vma))
 		flags |= MAP_HUGETLB;
 
 	if (file) {
-- 
2.20.1


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

* [PATCH 3/5] mm/vma: Replace all remaining open encodings with is_vm_hugetlb_page()
@ 2020-02-17  5:03   ` Anshuman Khandual
  0 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-17  5:03 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: kvm-ppc, Aneesh Kumar K.V, linux-arch, Arnd Bergmann,
	Anshuman Khandual, Peter Zijlstra, linuxppc-dev, Nick Piggin,
	Arnaldo Carvalho de Melo, Ingo Molnar, Alexander Viro,
	linux-fsdevel, Andrew Morton, Will Deacon

This replaces all remaining open encodings with is_vm_hugetlb_page().

Cc: Paul Mackerras <paulus@ozlabs.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Will Deacon <will@kernel.org>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Nick Piggin <npiggin@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: kvm-ppc@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-mm@kvack.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 arch/powerpc/kvm/e500_mmu_host.c | 2 +-
 fs/binfmt_elf.c                  | 2 +-
 include/asm-generic/tlb.h        | 2 +-
 kernel/events/core.c             | 3 ++-
 4 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c
index 425d13806645..3922575a1c31 100644
--- a/arch/powerpc/kvm/e500_mmu_host.c
+++ b/arch/powerpc/kvm/e500_mmu_host.c
@@ -422,7 +422,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
 				break;
 			}
 		} else if (vma && hva >= vma->vm_start &&
-			   (vma->vm_flags & VM_HUGETLB)) {
+			   (is_vm_hugetlb_page(vma))) {
 			unsigned long psize = vma_kernel_pagesize(vma);
 
 			tsize = (gtlbe->mas1 & MAS1_TSIZE_MASK) >>
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index f4713ea76e82..6bc97ede10ba 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1317,7 +1317,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
 	}
 
 	/* Hugetlb memory check */
-	if (vma->vm_flags & VM_HUGETLB) {
+	if (is_vm_hugetlb_page(vma)) {
 		if ((vma->vm_flags & VM_SHARED) && FILTER(HUGETLB_SHARED))
 			goto whole;
 		if (!(vma->vm_flags & VM_SHARED) && FILTER(HUGETLB_PRIVATE))
diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
index f391f6b500b4..d42c236d4965 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -398,7 +398,7 @@ tlb_update_vma_flags(struct mmu_gather *tlb, struct vm_area_struct *vma)
 	 * We rely on tlb_end_vma() to issue a flush, such that when we reset
 	 * these values the batch is empty.
 	 */
-	tlb->vma_huge = !!(vma->vm_flags & VM_HUGETLB);
+	tlb->vma_huge = is_vm_hugetlb_page(vma);
 	tlb->vma_exec = !!(vma->vm_flags & VM_EXEC);
 }
 
diff --git a/kernel/events/core.c b/kernel/events/core.c
index e453589da97c..eb0ee3c5f322 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -28,6 +28,7 @@
 #include <linux/export.h>
 #include <linux/vmalloc.h>
 #include <linux/hardirq.h>
+#include <linux/hugetlb_inline.h>
 #include <linux/rculist.h>
 #include <linux/uaccess.h>
 #include <linux/syscalls.h>
@@ -7693,7 +7694,7 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
 		flags |= MAP_EXECUTABLE;
 	if (vma->vm_flags & VM_LOCKED)
 		flags |= MAP_LOCKED;
-	if (vma->vm_flags & VM_HUGETLB)
+	if (is_vm_hugetlb_page(vma))
 		flags |= MAP_HUGETLB;
 
 	if (file) {
-- 
2.20.1


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

* [PATCH 4/5] mm/vma: Replace all remaining open encodings with vma_set_anonymous()
  2020-02-17  5:03 ` Anshuman Khandual
                   ` (4 preceding siblings ...)
  (?)
@ 2020-02-17  5:03 ` Anshuman Khandual
  2020-02-17 10:27   ` Kirill A. Shutemov
  2020-03-18 10:24   ` Greg Kroah-Hartman
  -1 siblings, 2 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-17  5:03 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Anshuman Khandual, Sudeep Dutt, Ashutosh Dixit, Arnd Bergmann,
	Greg Kroah-Hartman, Thomas Gleixner, Kate Stewart,
	Allison Randal, Richard Fontana

This replaces all remaining open encodings with vma_set_anonymous().

Cc: Sudeep Dutt <sudeep.dutt@intel.com>
Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Allison Randal <allison@lohutok.net>
Cc: Richard Fontana <rfontana@redhat.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 drivers/misc/mic/scif/scif_mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/mic/scif/scif_mmap.c b/drivers/misc/mic/scif/scif_mmap.c
index a151d416f39c..1f0dec5df994 100644
--- a/drivers/misc/mic/scif/scif_mmap.c
+++ b/drivers/misc/mic/scif/scif_mmap.c
@@ -580,7 +580,7 @@ static void scif_munmap(struct vm_area_struct *vma)
 	 * The kernel probably zeroes these out but we still want
 	 * to clean up our own mess just in case.
 	 */
-	vma->vm_ops = NULL;
+	vma_set_anonymous(vma);
 	vma->vm_private_data = NULL;
 	kref_put(&vmapvt->ref, vma_pvt_release);
 	scif_delete_vma(ep, vma);
-- 
2.20.1


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

* [PATCH 5/5] mm/vma: Replace all remaining open encodings with vma_is_anonymous()
  2020-02-17  5:03 ` Anshuman Khandual
                   ` (5 preceding siblings ...)
  (?)
@ 2020-02-17  5:03 ` Anshuman Khandual
  -1 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-17  5:03 UTC (permalink / raw)
  To: linux-mm, linux-kernel; +Cc: Anshuman Khandual, Andrew Morton

This replaces all remaining open encodings with vma_is_anonymous().

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 mm/gup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/gup.c b/mm/gup.c
index c8ffe2e61f03..58c8cbfeded6 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -146,7 +146,8 @@ static struct page *no_page_table(struct vm_area_struct *vma,
 	 * But we can only make this optimization where a hole would surely
 	 * be zero-filled if handle_mm_fault() actually did handle it.
 	 */
-	if ((flags & FOLL_DUMP) && (!vma->vm_ops || !vma->vm_ops->fault))
+	if ((flags & FOLL_DUMP) &&
+			(vma_is_anonymous(vma) || !vma->vm_ops->fault))
 		return ERR_PTR(-EFAULT);
 	return NULL;
 }
-- 
2.20.1


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

* [PATCH 0/5] mm/vma: Use available wrappers when possible
@ 2020-02-17  5:03 ` Anshuman Khandual
  0 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-17  5:15 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Anshuman Khandual, linux-m68k, linux-mips, linuxppc-dev,
	linux-sh, kvm-ppc, linux-fsdevel, linux-arch

Apart from adding a VMA flag readable name for trace purpose, this series
does some open encoding replacements with availabe VMA specific wrappers.
This skips VM_HUGETLB check in vma_migratable() as its already being done
with another patch (https://patchwork.kernel.org/patch/11347831/) which
is yet to be merged.

This series applies on 5.6-rc2. This has been build tested on multiple
platforms, though boot and runtime testing was limited to arm64 and x86.

Cc: linux-kernel@vger.kernel.org
Cc: linux-m68k@lists.linux-m68k.org
Cc: linux-mips@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-sh@vger.kernel.org
Cc: kvm-ppc@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-mm@kvack.org

Anshuman Khandual (5):
  mm/vma: Add missing VMA flag readable name for VM_SYNC
  mm/vma: Make vma_is_accessible() available for general use
  mm/vma: Replace all remaining open encodings with is_vm_hugetlb_page()
  mm/vma: Replace all remaining open encodings with vma_set_anonymous()
  mm/vma: Replace all remaining open encodings with vma_is_anonymous()

 arch/csky/mm/fault.c              | 2 +-
 arch/m68k/mm/fault.c              | 2 +-
 arch/mips/mm/fault.c              | 2 +-
 arch/powerpc/kvm/e500_mmu_host.c  | 2 +-
 arch/powerpc/mm/fault.c           | 2 +-
 arch/sh/mm/fault.c                | 2 +-
 arch/x86/mm/fault.c               | 2 +-
 drivers/misc/mic/scif/scif_mmap.c | 2 +-
 fs/binfmt_elf.c                   | 2 +-
 include/asm-generic/tlb.h         | 2 +-
 include/linux/mm.h                | 5 +++++
 include/trace/events/mmflags.h    | 1 +
 kernel/events/core.c              | 3 ++-
 kernel/sched/fair.c               | 2 +-
 mm/gup.c                          | 5 +++--
 mm/memory.c                       | 5 -----
 mm/mempolicy.c                    | 3 +--
 17 files changed, 23 insertions(+), 21 deletions(-)

-- 
2.20.1

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

* [PATCH 2/5] mm/vma: Make vma_is_accessible() available for general use
@ 2020-02-17  5:03   ` Anshuman Khandual
  0 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-17  5:15 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Anshuman Khandual, Guo Ren, Geert Uytterhoeven, Ralf Baechle,
	Paul Burton, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Yoshinori Sato, Rich Felker, Dave Hansen,
	Andy Lutomirski, Peter Zijlstra, Thomas Gleixner, Ingo Molnar,
	Andrew Morton, Steven Rostedt, Mel Gorman, linux-m68k,
	linux-mips, linuxppc-dev, linux-sh

Lets move vma_is_accessible() helper to include/linux/mm.h which makes it
available for general use. While here, this replaces all remaining open
encodings for VMA access check with vma_is_accessible().

Cc: Guo Ren <guoren@kernel.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: linux-kernel@vger.kernel.org
Cc: linux-m68k@lists.linux-m68k.org
Cc: linux-mips@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-sh@vger.kernel.org
Cc: linux-mm@kvack.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 arch/csky/mm/fault.c    | 2 +-
 arch/m68k/mm/fault.c    | 2 +-
 arch/mips/mm/fault.c    | 2 +-
 arch/powerpc/mm/fault.c | 2 +-
 arch/sh/mm/fault.c      | 2 +-
 arch/x86/mm/fault.c     | 2 +-
 include/linux/mm.h      | 5 +++++
 kernel/sched/fair.c     | 2 +-
 mm/gup.c                | 2 +-
 mm/memory.c             | 5 -----
 mm/mempolicy.c          | 3 +--
 11 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/arch/csky/mm/fault.c b/arch/csky/mm/fault.c
index f76618b630f9..4b3511b8298d 100644
--- a/arch/csky/mm/fault.c
+++ b/arch/csky/mm/fault.c
@@ -137,7 +137,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
 		if (!(vma->vm_flags & VM_WRITE))
 			goto bad_area;
 	} else {
-		if (!(vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)))
+		if (!vma_is_accessible(vma))
 			goto bad_area;
 	}
 
diff --git a/arch/m68k/mm/fault.c b/arch/m68k/mm/fault.c
index e9b1d7585b43..d5131ec5d923 100644
--- a/arch/m68k/mm/fault.c
+++ b/arch/m68k/mm/fault.c
@@ -125,7 +125,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
 		case 1:		/* read, present */
 			goto acc_err;
 		case 0:		/* read, not present */
-			if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))
+			if (!vma_is_accessible(vma))
 				goto acc_err;
 	}
 
diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
index 1e8d00793784..5b9f947bfa32 100644
--- a/arch/mips/mm/fault.c
+++ b/arch/mips/mm/fault.c
@@ -142,7 +142,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,
 				goto bad_area;
 			}
 		} else {
-			if (!(vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)))
+			if (!vma_is_accessible(vma))
 				goto bad_area;
 		}
 	}
diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index 8db0507619e2..71a3658c516b 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -314,7 +314,7 @@ static bool access_error(bool is_write, bool is_exec,
 		return false;
 	}
 
-	if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
+	if (unlikely(!vma_is_accessible(vma)))
 		return true;
 	/*
 	 * We should ideally do the vma pkey access check here. But in the
diff --git a/arch/sh/mm/fault.c b/arch/sh/mm/fault.c
index 5f51456f4fc7..a8c4253f37d7 100644
--- a/arch/sh/mm/fault.c
+++ b/arch/sh/mm/fault.c
@@ -355,7 +355,7 @@ static inline int access_error(int error_code, struct vm_area_struct *vma)
 		return 1;
 
 	/* read, not present: */
-	if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
+	if (unlikely(!vma_is_accessible(vma)))
 		return 1;
 
 	return 0;
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index fa4ea09593ab..c461eaab0306 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1200,7 +1200,7 @@ access_error(unsigned long error_code, struct vm_area_struct *vma)
 		return 1;
 
 	/* read, not present: */
-	if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
+	if (unlikely(!vma_is_accessible(vma)))
 		return 1;
 
 	return 0;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 52269e56c514..b0e53ef13ff1 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -541,6 +541,11 @@ static inline bool vma_is_anonymous(struct vm_area_struct *vma)
 	return !vma->vm_ops;
 }
 
+static inline bool vma_is_accessible(struct vm_area_struct *vma)
+{
+	return vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC);
+}
+
 #ifdef CONFIG_SHMEM
 /*
  * The vma_is_shmem is not inline because it is used only by slow
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index fe4e0d775375..6ce54d57dd09 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2573,7 +2573,7 @@ static void task_numa_work(struct callback_head *work)
 		 * Skip inaccessible VMAs to avoid any confusion between
 		 * PROT_NONE and NUMA hinting ptes
 		 */
-		if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))
+		if (!vma_is_accessible(vma))
 			continue;
 
 		do {
diff --git a/mm/gup.c b/mm/gup.c
index 1b521e0ac1de..c8ffe2e61f03 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1171,7 +1171,7 @@ long populate_vma_page_range(struct vm_area_struct *vma,
 	 * We want mlock to succeed for regions that have any permissions
 	 * other than PROT_NONE.
 	 */
-	if (vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC))
+	if (vma_is_accessible(vma))
 		gup_flags |= FOLL_FORCE;
 
 	/*
diff --git a/mm/memory.c b/mm/memory.c
index 0bccc622e482..2f07747612b7 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3942,11 +3942,6 @@ static inline vm_fault_t wp_huge_pmd(struct vm_fault *vmf, pmd_t orig_pmd)
 	return VM_FAULT_FALLBACK;
 }
 
-static inline bool vma_is_accessible(struct vm_area_struct *vma)
-{
-	return vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE);
-}
-
 static vm_fault_t create_huge_pud(struct vm_fault *vmf)
 {
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 977c641f78cf..91c1ad6ab8ea 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -649,8 +649,7 @@ static int queue_pages_test_walk(unsigned long start, unsigned long end,
 
 	if (flags & MPOL_MF_LAZY) {
 		/* Similar to task_numa_work, skip inaccessible VMAs */
-		if (!is_vm_hugetlb_page(vma) &&
-			(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)) &&
+		if (!is_vm_hugetlb_page(vma) && vma_is_accessible(vma) &&
 			!(vma->vm_flags & VM_MIXEDMAP))
 			change_prot_numa(vma, start, endvma);
 		return 1;
-- 
2.20.1

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

* [PATCH 3/5] mm/vma: Replace all remaining open encodings with is_vm_hugetlb_page()
@ 2020-02-17  5:03   ` Anshuman Khandual
  0 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-17  5:15 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Anshuman Khandual, Paul Mackerras, Benjamin Herrenschmidt,
	Michael Ellerman, Alexander Viro, Will Deacon, Aneesh Kumar K.V,
	Andrew Morton, Nick Piggin, Peter Zijlstra, Arnd Bergmann,
	Ingo Molnar, Arnaldo Carvalho de Melo, kvm-ppc, linuxppc-dev,
	linux-fsdevel, linux-arch

This replaces all remaining open encodings with is_vm_hugetlb_page().

Cc: Paul Mackerras <paulus@ozlabs.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Will Deacon <will@kernel.org>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Nick Piggin <npiggin@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: kvm-ppc@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-mm@kvack.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 arch/powerpc/kvm/e500_mmu_host.c | 2 +-
 fs/binfmt_elf.c                  | 2 +-
 include/asm-generic/tlb.h        | 2 +-
 kernel/events/core.c             | 3 ++-
 4 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c
index 425d13806645..3922575a1c31 100644
--- a/arch/powerpc/kvm/e500_mmu_host.c
+++ b/arch/powerpc/kvm/e500_mmu_host.c
@@ -422,7 +422,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
 				break;
 			}
 		} else if (vma && hva >= vma->vm_start &&
-			   (vma->vm_flags & VM_HUGETLB)) {
+			   (is_vm_hugetlb_page(vma))) {
 			unsigned long psize = vma_kernel_pagesize(vma);
 
 			tsize = (gtlbe->mas1 & MAS1_TSIZE_MASK) >>
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index f4713ea76e82..6bc97ede10ba 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1317,7 +1317,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
 	}
 
 	/* Hugetlb memory check */
-	if (vma->vm_flags & VM_HUGETLB) {
+	if (is_vm_hugetlb_page(vma)) {
 		if ((vma->vm_flags & VM_SHARED) && FILTER(HUGETLB_SHARED))
 			goto whole;
 		if (!(vma->vm_flags & VM_SHARED) && FILTER(HUGETLB_PRIVATE))
diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
index f391f6b500b4..d42c236d4965 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -398,7 +398,7 @@ tlb_update_vma_flags(struct mmu_gather *tlb, struct vm_area_struct *vma)
 	 * We rely on tlb_end_vma() to issue a flush, such that when we reset
 	 * these values the batch is empty.
 	 */
-	tlb->vma_huge = !!(vma->vm_flags & VM_HUGETLB);
+	tlb->vma_huge = is_vm_hugetlb_page(vma);
 	tlb->vma_exec = !!(vma->vm_flags & VM_EXEC);
 }
 
diff --git a/kernel/events/core.c b/kernel/events/core.c
index e453589da97c..eb0ee3c5f322 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -28,6 +28,7 @@
 #include <linux/export.h>
 #include <linux/vmalloc.h>
 #include <linux/hardirq.h>
+#include <linux/hugetlb_inline.h>
 #include <linux/rculist.h>
 #include <linux/uaccess.h>
 #include <linux/syscalls.h>
@@ -7693,7 +7694,7 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
 		flags |= MAP_EXECUTABLE;
 	if (vma->vm_flags & VM_LOCKED)
 		flags |= MAP_LOCKED;
-	if (vma->vm_flags & VM_HUGETLB)
+	if (is_vm_hugetlb_page(vma))
 		flags |= MAP_HUGETLB;
 
 	if (file) {
-- 
2.20.1

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

* Re: [PATCH 2/5] mm/vma: Make vma_is_accessible() available for general use
  2020-02-17  5:03   ` Anshuman Khandual
  (?)
  (?)
@ 2020-02-17  7:36     ` Geert Uytterhoeven
  -1 siblings, 0 replies; 34+ messages in thread
From: Geert Uytterhoeven @ 2020-02-17  7:36 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: Linux MM, Linux Kernel Mailing List, Guo Ren, Ralf Baechle,
	Paul Burton, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Yoshinori Sato, Rich Felker, Dave Hansen,
	Andy Lutomirski, Peter Zijlstra, Thomas Gleixner, Ingo Molnar,
	Andrew Morton, Steven Rostedt, Mel Gorman, linux-m68k,
	linux-mips, linuxppc-dev, Linux-sh list

On Mon, Feb 17, 2020 at 6:04 AM Anshuman Khandual
<anshuman.khandual@arm.com> wrote:
> Lets move vma_is_accessible() helper to include/linux/mm.h which makes it
> available for general use. While here, this replaces all remaining open
> encodings for VMA access check with vma_is_accessible().
>
> Cc: Guo Ren <guoren@kernel.org>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Paul Burton <paulburton@kernel.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-m68k@lists.linux-m68k.org
> Cc: linux-mips@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-sh@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>

>  arch/m68k/mm/fault.c    | 2 +-

For m68k:
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 2/5] mm/vma: Make vma_is_accessible() available for general use
@ 2020-02-17  7:36     ` Geert Uytterhoeven
  0 siblings, 0 replies; 34+ messages in thread
From: Geert Uytterhoeven @ 2020-02-17  7:36 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: Linux MM, Linux Kernel Mailing List, Guo Ren, Ralf Baechle,
	Paul Burton, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Yoshinori Sato, Rich Felker, Dave Hansen,
	Andy Lutomirski, Peter Zijlstra, Thomas Gleixner, Ingo Molnar,
	Andrew Morton, Steven Rostedt, Mel Gorman, linux-m68k,
	linux-mips, linuxppc-dev, Linux-sh list

On Mon, Feb 17, 2020 at 6:04 AM Anshuman Khandual
<anshuman.khandual@arm.com> wrote:
> Lets move vma_is_accessible() helper to include/linux/mm.h which makes it
> available for general use. While here, this replaces all remaining open
> encodings for VMA access check with vma_is_accessible().
>
> Cc: Guo Ren <guoren@kernel.org>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Paul Burton <paulburton@kernel.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-m68k@lists.linux-m68k.org
> Cc: linux-mips@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-sh@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>

>  arch/m68k/mm/fault.c    | 2 +-

For m68k:
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 2/5] mm/vma: Make vma_is_accessible() available for general use
@ 2020-02-17  7:36     ` Geert Uytterhoeven
  0 siblings, 0 replies; 34+ messages in thread
From: Geert Uytterhoeven @ 2020-02-17  7:36 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: Linux MM, Linux Kernel Mailing List, Guo Ren, Ralf Baechle,
	Paul Burton, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Yoshinori Sato, Rich Felker, Dave Hansen,
	Andy Lutomirski, Peter Zijlstra, Thomas Gleixner, Ingo Molnar,
	Andrew Morton, Steven Rostedt, Mel Gorman, linux-m68k,
	linux-mips, linuxppc-dev, Linux-sh list

On Mon, Feb 17, 2020 at 6:04 AM Anshuman Khandual
<anshuman.khandual@arm.com> wrote:
> Lets move vma_is_accessible() helper to include/linux/mm.h which makes it
> available for general use. While here, this replaces all remaining open
> encodings for VMA access check with vma_is_accessible().
>
> Cc: Guo Ren <guoren@kernel.org>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Paul Burton <paulburton@kernel.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-m68k@lists.linux-m68k.org
> Cc: linux-mips@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-sh@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>

>  arch/m68k/mm/fault.c    | 2 +-

For m68k:
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds


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

* Re: [PATCH 2/5] mm/vma: Make vma_is_accessible() available for general use
@ 2020-02-17  7:36     ` Geert Uytterhoeven
  0 siblings, 0 replies; 34+ messages in thread
From: Geert Uytterhoeven @ 2020-02-17  7:36 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: Rich Felker, Linux-sh list, Peter Zijlstra, Dave Hansen,
	linux-mips, Linux MM, Guo Ren, Yoshinori Sato, Ingo Molnar,
	Mel Gorman, Steven Rostedt, linux-m68k, Andy Lutomirski,
	Thomas Gleixner, Paul Burton, Linux Kernel Mailing List,
	Ralf Baechle, Paul Mackerras, Andrew Morton, linuxppc-dev

On Mon, Feb 17, 2020 at 6:04 AM Anshuman Khandual
<anshuman.khandual@arm.com> wrote:
> Lets move vma_is_accessible() helper to include/linux/mm.h which makes it
> available for general use. While here, this replaces all remaining open
> encodings for VMA access check with vma_is_accessible().
>
> Cc: Guo Ren <guoren@kernel.org>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Paul Burton <paulburton@kernel.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-m68k@lists.linux-m68k.org
> Cc: linux-mips@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-sh@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>

>  arch/m68k/mm/fault.c    | 2 +-

For m68k:
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 3/5] mm/vma: Replace all remaining open encodings with is_vm_hugetlb_page()
  2020-02-17  5:03   ` Anshuman Khandual
  (?)
@ 2020-02-17  9:21     ` Anshuman Khandual
  -1 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-17  9:21 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Paul Mackerras, Benjamin Herrenschmidt, Michael Ellerman,
	Alexander Viro, Will Deacon, Aneesh Kumar K.V, Andrew Morton,
	Nick Piggin, Peter Zijlstra, Arnd Bergmann, Ingo Molnar,
	Arnaldo Carvalho de Melo, kvm-ppc, linuxppc-dev, linux-fsdevel,
	linux-arch

On 02/17/2020 10:33 AM, Anshuman Khandual wrote:
> This replaces all remaining open encodings with is_vm_hugetlb_page().
> 
> Cc: Paul Mackerras <paulus@ozlabs.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Alexander Viro <viro@zeniv.linux.org.uk>
> Cc: Will Deacon <will@kernel.org>
> Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Nick Piggin <npiggin@gmail.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: kvm-ppc@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-fsdevel@vger.kernel.org
> Cc: linux-arch@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
>  arch/powerpc/kvm/e500_mmu_host.c | 2 +-
>  fs/binfmt_elf.c                  | 2 +-
>  include/asm-generic/tlb.h        | 2 +-
>  kernel/events/core.c             | 3 ++-
>  4 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c
> index 425d13806645..3922575a1c31 100644
> --- a/arch/powerpc/kvm/e500_mmu_host.c
> +++ b/arch/powerpc/kvm/e500_mmu_host.c
> @@ -422,7 +422,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
>  				break;
>  			}
>  		} else if (vma && hva >= vma->vm_start &&
> -			   (vma->vm_flags & VM_HUGETLB)) {
> +			   (is_vm_hugetlb_page(vma))) {

Additional braces around is_vm_hugetlb_page() can be dropped here.

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

* Re: [PATCH 3/5] mm/vma: Replace all remaining open encodings with is_vm_hugetlb_page()
@ 2020-02-17  9:21     ` Anshuman Khandual
  0 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-17  9:21 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: kvm-ppc, linux-arch, Arnaldo Carvalho de Melo, Arnd Bergmann,
	linuxppc-dev, Nick Piggin, Peter Zijlstra, Ingo Molnar,
	Alexander Viro, Aneesh Kumar K.V, linux-fsdevel, Andrew Morton,
	Will Deacon

On 02/17/2020 10:33 AM, Anshuman Khandual wrote:
> This replaces all remaining open encodings with is_vm_hugetlb_page().
> 
> Cc: Paul Mackerras <paulus@ozlabs.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Alexander Viro <viro@zeniv.linux.org.uk>
> Cc: Will Deacon <will@kernel.org>
> Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Nick Piggin <npiggin@gmail.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: kvm-ppc@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-fsdevel@vger.kernel.org
> Cc: linux-arch@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
>  arch/powerpc/kvm/e500_mmu_host.c | 2 +-
>  fs/binfmt_elf.c                  | 2 +-
>  include/asm-generic/tlb.h        | 2 +-
>  kernel/events/core.c             | 3 ++-
>  4 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c
> index 425d13806645..3922575a1c31 100644
> --- a/arch/powerpc/kvm/e500_mmu_host.c
> +++ b/arch/powerpc/kvm/e500_mmu_host.c
> @@ -422,7 +422,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
>  				break;
>  			}
>  		} else if (vma && hva >= vma->vm_start &&
> -			   (vma->vm_flags & VM_HUGETLB)) {
> +			   (is_vm_hugetlb_page(vma))) {

Additional braces around is_vm_hugetlb_page() can be dropped here.

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

* Re: [PATCH 2/5] mm/vma: Make vma_is_accessible() available for general use
  2020-02-17  5:03   ` Anshuman Khandual
  (?)
@ 2020-02-17  9:28     ` Anshuman Khandual
  -1 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-17  9:28 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Guo Ren, Geert Uytterhoeven, Ralf Baechle, Paul Burton,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Yoshinori Sato, Rich Felker, Dave Hansen, Andy Lutomirski,
	Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Andrew Morton,
	Steven Rostedt, Mel Gorman, linux-m68k, linux-mips, linuxppc-dev,
	linux-sh


On 02/17/2020 10:33 AM, Anshuman Khandual wrote:
> Lets move vma_is_accessible() helper to include/linux/mm.h which makes it
> available for general use. While here, this replaces all remaining open
> encodings for VMA access check with vma_is_accessible().
> 
> Cc: Guo Ren <guoren@kernel.org>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Paul Burton <paulburton@kernel.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-m68k@lists.linux-m68k.org
> Cc: linux-mips@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-sh@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
>  arch/csky/mm/fault.c    | 2 +-
>  arch/m68k/mm/fault.c    | 2 +-
>  arch/mips/mm/fault.c    | 2 +-
>  arch/powerpc/mm/fault.c | 2 +-
>  arch/sh/mm/fault.c      | 2 +-
>  arch/x86/mm/fault.c     | 2 +-
>  include/linux/mm.h      | 5 +++++
>  kernel/sched/fair.c     | 2 +-
>  mm/gup.c                | 2 +-
>  mm/memory.c             | 5 -----
>  mm/mempolicy.c          | 3 +--
>  11 files changed, 14 insertions(+), 15 deletions(-)

There are couple of places in mm/mmap.c which could use vma_is_accessible()
as well. Probably missed them, as the order of the VMA flags were different.
Will fold the following changes next time around.

diff --git a/mm/mmap.c b/mm/mmap.c
index 6756b8bb0033..9b9bb4031fd4 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2338,8 +2338,7 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
                gap_addr = TASK_SIZE;
 
        next = vma->vm_next;
-       if (next && next->vm_start < gap_addr &&
-                       (next->vm_flags & (VM_WRITE|VM_READ|VM_EXEC))) {
+       if (next && next->vm_start < gap_addr && vma_is_accessible(next)) {
                if (!(next->vm_flags & VM_GROWSUP))
                        return -ENOMEM;
                /* Check that both stack segments have the same anon_vma? */
@@ -2420,7 +2419,7 @@ int expand_downwards(struct vm_area_struct *vma,
        prev = vma->vm_prev;
        /* Check that both stack segments have the same anon_vma? */
        if (prev && !(prev->vm_flags & VM_GROWSDOWN) &&
-                       (prev->vm_flags & (VM_WRITE|VM_READ|VM_EXEC))) {
+                       vma_is_accessible(prev)) {
                if (address - prev->vm_end < stack_guard_gap)
                        return -ENOMEM;
        }

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

* Re: [PATCH 2/5] mm/vma: Make vma_is_accessible() available for general use
@ 2020-02-17  9:28     ` Anshuman Khandual
  0 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-17  9:28 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Rich Felker, Yoshinori Sato, Paul Burton, linux-sh,
	Peter Zijlstra, Dave Hansen, linux-mips, Guo Ren, linuxppc-dev,
	linux-m68k, Ingo Molnar, Geert Uytterhoeven, Ralf Baechle,
	Andy Lutomirski, Paul Mackerras, Thomas Gleixner, Steven Rostedt,
	Andrew Morton, Mel Gorman


On 02/17/2020 10:33 AM, Anshuman Khandual wrote:
> Lets move vma_is_accessible() helper to include/linux/mm.h which makes it
> available for general use. While here, this replaces all remaining open
> encodings for VMA access check with vma_is_accessible().
> 
> Cc: Guo Ren <guoren@kernel.org>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Paul Burton <paulburton@kernel.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-m68k@lists.linux-m68k.org
> Cc: linux-mips@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-sh@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
>  arch/csky/mm/fault.c    | 2 +-
>  arch/m68k/mm/fault.c    | 2 +-
>  arch/mips/mm/fault.c    | 2 +-
>  arch/powerpc/mm/fault.c | 2 +-
>  arch/sh/mm/fault.c      | 2 +-
>  arch/x86/mm/fault.c     | 2 +-
>  include/linux/mm.h      | 5 +++++
>  kernel/sched/fair.c     | 2 +-
>  mm/gup.c                | 2 +-
>  mm/memory.c             | 5 -----
>  mm/mempolicy.c          | 3 +--
>  11 files changed, 14 insertions(+), 15 deletions(-)

There are couple of places in mm/mmap.c which could use vma_is_accessible()
as well. Probably missed them, as the order of the VMA flags were different.
Will fold the following changes next time around.

diff --git a/mm/mmap.c b/mm/mmap.c
index 6756b8bb0033..9b9bb4031fd4 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2338,8 +2338,7 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
                gap_addr = TASK_SIZE;
 
        next = vma->vm_next;
-       if (next && next->vm_start < gap_addr &&
-                       (next->vm_flags & (VM_WRITE|VM_READ|VM_EXEC))) {
+       if (next && next->vm_start < gap_addr && vma_is_accessible(next)) {
                if (!(next->vm_flags & VM_GROWSUP))
                        return -ENOMEM;
                /* Check that both stack segments have the same anon_vma? */
@@ -2420,7 +2419,7 @@ int expand_downwards(struct vm_area_struct *vma,
        prev = vma->vm_prev;
        /* Check that both stack segments have the same anon_vma? */
        if (prev && !(prev->vm_flags & VM_GROWSDOWN) &&
-                       (prev->vm_flags & (VM_WRITE|VM_READ|VM_EXEC))) {
+                       vma_is_accessible(prev)) {
                if (address - prev->vm_end < stack_guard_gap)
                        return -ENOMEM;
        }

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

* Re: [PATCH 3/5] mm/vma: Replace all remaining open encodings with is_vm_hugetlb_page()
@ 2020-02-17  9:21     ` Anshuman Khandual
  0 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-17  9:33 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Paul Mackerras, Benjamin Herrenschmidt, Michael Ellerman,
	Alexander Viro, Will Deacon, Aneesh Kumar K.V, Andrew Morton,
	Nick Piggin, Peter Zijlstra, Arnd Bergmann, Ingo Molnar,
	Arnaldo Carvalho de Melo, kvm-ppc, linuxppc-dev, linux-fsdevel,
	linux-arch

On 02/17/2020 10:33 AM, Anshuman Khandual wrote:
> This replaces all remaining open encodings with is_vm_hugetlb_page().
> 
> Cc: Paul Mackerras <paulus@ozlabs.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Alexander Viro <viro@zeniv.linux.org.uk>
> Cc: Will Deacon <will@kernel.org>
> Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Nick Piggin <npiggin@gmail.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: kvm-ppc@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-fsdevel@vger.kernel.org
> Cc: linux-arch@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
>  arch/powerpc/kvm/e500_mmu_host.c | 2 +-
>  fs/binfmt_elf.c                  | 2 +-
>  include/asm-generic/tlb.h        | 2 +-
>  kernel/events/core.c             | 3 ++-
>  4 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c
> index 425d13806645..3922575a1c31 100644
> --- a/arch/powerpc/kvm/e500_mmu_host.c
> +++ b/arch/powerpc/kvm/e500_mmu_host.c
> @@ -422,7 +422,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
>  				break;
>  			}
>  		} else if (vma && hva >= vma->vm_start &&
> -			   (vma->vm_flags & VM_HUGETLB)) {
> +			   (is_vm_hugetlb_page(vma))) {

Additional braces around is_vm_hugetlb_page() can be dropped here.

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

* Re: [PATCH 2/5] mm/vma: Make vma_is_accessible() available for general use
@ 2020-02-17  9:28     ` Anshuman Khandual
  0 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-17  9:40 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Guo Ren, Geert Uytterhoeven, Ralf Baechle, Paul Burton,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Yoshinori Sato, Rich Felker, Dave Hansen, Andy Lutomirski,
	Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Andrew Morton,
	Steven Rostedt, Mel Gorman, linux-m68k, linux-mips, linuxppc-dev,
	linux-sh


On 02/17/2020 10:33 AM, Anshuman Khandual wrote:
> Lets move vma_is_accessible() helper to include/linux/mm.h which makes it
> available for general use. While here, this replaces all remaining open
> encodings for VMA access check with vma_is_accessible().
> 
> Cc: Guo Ren <guoren@kernel.org>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Paul Burton <paulburton@kernel.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-m68k@lists.linux-m68k.org
> Cc: linux-mips@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-sh@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
>  arch/csky/mm/fault.c    | 2 +-
>  arch/m68k/mm/fault.c    | 2 +-
>  arch/mips/mm/fault.c    | 2 +-
>  arch/powerpc/mm/fault.c | 2 +-
>  arch/sh/mm/fault.c      | 2 +-
>  arch/x86/mm/fault.c     | 2 +-
>  include/linux/mm.h      | 5 +++++
>  kernel/sched/fair.c     | 2 +-
>  mm/gup.c                | 2 +-
>  mm/memory.c             | 5 -----
>  mm/mempolicy.c          | 3 +--
>  11 files changed, 14 insertions(+), 15 deletions(-)

There are couple of places in mm/mmap.c which could use vma_is_accessible()
as well. Probably missed them, as the order of the VMA flags were different.
Will fold the following changes next time around.

diff --git a/mm/mmap.c b/mm/mmap.c
index 6756b8bb0033..9b9bb4031fd4 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2338,8 +2338,7 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
                gap_addr = TASK_SIZE;
 
        next = vma->vm_next;
-       if (next && next->vm_start < gap_addr &&
-                       (next->vm_flags & (VM_WRITE|VM_READ|VM_EXEC))) {
+       if (next && next->vm_start < gap_addr && vma_is_accessible(next)) {
                if (!(next->vm_flags & VM_GROWSUP))
                        return -ENOMEM;
                /* Check that both stack segments have the same anon_vma? */
@@ -2420,7 +2419,7 @@ int expand_downwards(struct vm_area_struct *vma,
        prev = vma->vm_prev;
        /* Check that both stack segments have the same anon_vma? */
        if (prev && !(prev->vm_flags & VM_GROWSDOWN) &&
-                       (prev->vm_flags & (VM_WRITE|VM_READ|VM_EXEC))) {
+                       vma_is_accessible(prev)) {
                if (address - prev->vm_end < stack_guard_gap)
                        return -ENOMEM;
        }

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

* Re: [PATCH 4/5] mm/vma: Replace all remaining open encodings with vma_set_anonymous()
  2020-02-17  5:03 ` [PATCH 4/5] mm/vma: Replace all remaining open encodings with vma_set_anonymous() Anshuman Khandual
@ 2020-02-17 10:27   ` Kirill A. Shutemov
  2020-02-17 11:56     ` Anshuman Khandual
  2020-03-18 10:24   ` Greg Kroah-Hartman
  1 sibling, 1 reply; 34+ messages in thread
From: Kirill A. Shutemov @ 2020-02-17 10:27 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-mm, linux-kernel, Sudeep Dutt, Ashutosh Dixit,
	Arnd Bergmann, Greg Kroah-Hartman, Thomas Gleixner, Kate Stewart,
	Allison Randal, Richard Fontana

On Mon, Feb 17, 2020 at 10:33:52AM +0530, Anshuman Khandual wrote:
> This replaces all remaining open encodings with vma_set_anonymous().
> 
> Cc: Sudeep Dutt <sudeep.dutt@intel.com>
> Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Kate Stewart <kstewart@linuxfoundation.org>
> Cc: Allison Randal <allison@lohutok.net>
> Cc: Richard Fontana <rfontana@redhat.com>
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
>  drivers/misc/mic/scif/scif_mmap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/mic/scif/scif_mmap.c b/drivers/misc/mic/scif/scif_mmap.c
> index a151d416f39c..1f0dec5df994 100644
> --- a/drivers/misc/mic/scif/scif_mmap.c
> +++ b/drivers/misc/mic/scif/scif_mmap.c
> @@ -580,7 +580,7 @@ static void scif_munmap(struct vm_area_struct *vma)
>  	 * The kernel probably zeroes these out but we still want
>  	 * to clean up our own mess just in case.
>  	 */
> -	vma->vm_ops = NULL;
> +	vma_set_anonymous(vma);
>  	vma->vm_private_data = NULL;
>  	kref_put(&vmapvt->ref, vma_pvt_release);
>  	scif_delete_vma(ep, vma);

This is misleading. The VMA doesn't become anonymous here. This is undo of
the previously overwritten vm_ops. I think we should leave it opencodded.

-- 
 Kirill A. Shutemov

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

* Re: [PATCH 4/5] mm/vma: Replace all remaining open encodings with vma_set_anonymous()
  2020-02-17 10:27   ` Kirill A. Shutemov
@ 2020-02-17 11:56     ` Anshuman Khandual
  0 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-17 11:56 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: linux-mm, linux-kernel, Sudeep Dutt, Ashutosh Dixit,
	Arnd Bergmann, Greg Kroah-Hartman, Thomas Gleixner, Kate Stewart,
	Allison Randal, Richard Fontana



On 02/17/2020 03:57 PM, Kirill A. Shutemov wrote:
> On Mon, Feb 17, 2020 at 10:33:52AM +0530, Anshuman Khandual wrote:
>> This replaces all remaining open encodings with vma_set_anonymous().
>>
>> Cc: Sudeep Dutt <sudeep.dutt@intel.com>
>> Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
>> Cc: Arnd Bergmann <arnd@arndb.de>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: Kate Stewart <kstewart@linuxfoundation.org>
>> Cc: Allison Randal <allison@lohutok.net>
>> Cc: Richard Fontana <rfontana@redhat.com>
>> Cc: linux-kernel@vger.kernel.org
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>> ---
>>  drivers/misc/mic/scif/scif_mmap.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/misc/mic/scif/scif_mmap.c b/drivers/misc/mic/scif/scif_mmap.c
>> index a151d416f39c..1f0dec5df994 100644
>> --- a/drivers/misc/mic/scif/scif_mmap.c
>> +++ b/drivers/misc/mic/scif/scif_mmap.c
>> @@ -580,7 +580,7 @@ static void scif_munmap(struct vm_area_struct *vma)
>>  	 * The kernel probably zeroes these out but we still want
>>  	 * to clean up our own mess just in case.
>>  	 */
>> -	vma->vm_ops = NULL;
>> +	vma_set_anonymous(vma);
>>  	vma->vm_private_data = NULL;
>>  	kref_put(&vmapvt->ref, vma_pvt_release);
>>  	scif_delete_vma(ep, vma);
> 
> This is misleading. The VMA doesn't become anonymous here. This is undo of
> the previously overwritten vm_ops. I think we should leave it opencodded.

I was bit unsure about it as well, thanks for the clarification. Will drop it.

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

* Re: [PATCH 2/5] mm/vma: Make vma_is_accessible() available for general use
  2020-02-17  5:03   ` Anshuman Khandual
  (?)
  (?)
@ 2020-02-18  2:21     ` Guo Ren
  -1 siblings, 0 replies; 34+ messages in thread
From: Guo Ren @ 2020-02-18  2:21 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-mm, Linux Kernel Mailing List, Geert Uytterhoeven,
	Ralf Baechle, Paul Burton, Benjamin Herrenschmidt,
	Paul Mackerras, Michael Ellerman, Yoshinori Sato, Rich Felker,
	Dave Hansen, Andy Lutomirski, Peter Zijlstra, Thomas Gleixner,
	Ingo Molnar, Andrew Morton, Steven Rostedt, Mel Gorman,
	linux-m68k, linux-mips, linuxppc-dev, linux-sh

csky:

Acked-by: Guo Ren <guoren@kernel.org>


On Mon, Feb 17, 2020 at 1:04 PM Anshuman Khandual
<anshuman.khandual@arm.com> wrote:
>
> Lets move vma_is_accessible() helper to include/linux/mm.h which makes it
> available for general use. While here, this replaces all remaining open
> encodings for VMA access check with vma_is_accessible().
>
> Cc: Guo Ren <guoren@kernel.org>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Paul Burton <paulburton@kernel.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-m68k@lists.linux-m68k.org
> Cc: linux-mips@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-sh@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
>  arch/csky/mm/fault.c    | 2 +-
>  arch/m68k/mm/fault.c    | 2 +-
>  arch/mips/mm/fault.c    | 2 +-
>  arch/powerpc/mm/fault.c | 2 +-
>  arch/sh/mm/fault.c      | 2 +-
>  arch/x86/mm/fault.c     | 2 +-
>  include/linux/mm.h      | 5 +++++
>  kernel/sched/fair.c     | 2 +-
>  mm/gup.c                | 2 +-
>  mm/memory.c             | 5 -----
>  mm/mempolicy.c          | 3 +--
>  11 files changed, 14 insertions(+), 15 deletions(-)
>
> diff --git a/arch/csky/mm/fault.c b/arch/csky/mm/fault.c
> index f76618b630f9..4b3511b8298d 100644
> --- a/arch/csky/mm/fault.c
> +++ b/arch/csky/mm/fault.c
> @@ -137,7 +137,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
>                 if (!(vma->vm_flags & VM_WRITE))
>                         goto bad_area;
>         } else {
> -               if (!(vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)))
> +               if (!vma_is_accessible(vma))
>                         goto bad_area;
>         }
>
> diff --git a/arch/m68k/mm/fault.c b/arch/m68k/mm/fault.c
> index e9b1d7585b43..d5131ec5d923 100644
> --- a/arch/m68k/mm/fault.c
> +++ b/arch/m68k/mm/fault.c
> @@ -125,7 +125,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
>                 case 1:         /* read, present */
>                         goto acc_err;
>                 case 0:         /* read, not present */
> -                       if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))
> +                       if (!vma_is_accessible(vma))
>                                 goto acc_err;
>         }
>
> diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
> index 1e8d00793784..5b9f947bfa32 100644
> --- a/arch/mips/mm/fault.c
> +++ b/arch/mips/mm/fault.c
> @@ -142,7 +142,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,
>                                 goto bad_area;
>                         }
>                 } else {
> -                       if (!(vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)))
> +                       if (!vma_is_accessible(vma))
>                                 goto bad_area;
>                 }
>         }
> diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
> index 8db0507619e2..71a3658c516b 100644
> --- a/arch/powerpc/mm/fault.c
> +++ b/arch/powerpc/mm/fault.c
> @@ -314,7 +314,7 @@ static bool access_error(bool is_write, bool is_exec,
>                 return false;
>         }
>
> -       if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
> +       if (unlikely(!vma_is_accessible(vma)))
>                 return true;
>         /*
>          * We should ideally do the vma pkey access check here. But in the
> diff --git a/arch/sh/mm/fault.c b/arch/sh/mm/fault.c
> index 5f51456f4fc7..a8c4253f37d7 100644
> --- a/arch/sh/mm/fault.c
> +++ b/arch/sh/mm/fault.c
> @@ -355,7 +355,7 @@ static inline int access_error(int error_code, struct vm_area_struct *vma)
>                 return 1;
>
>         /* read, not present: */
> -       if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
> +       if (unlikely(!vma_is_accessible(vma)))
>                 return 1;
>
>         return 0;
> diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
> index fa4ea09593ab..c461eaab0306 100644
> --- a/arch/x86/mm/fault.c
> +++ b/arch/x86/mm/fault.c
> @@ -1200,7 +1200,7 @@ access_error(unsigned long error_code, struct vm_area_struct *vma)
>                 return 1;
>
>         /* read, not present: */
> -       if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
> +       if (unlikely(!vma_is_accessible(vma)))
>                 return 1;
>
>         return 0;
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 52269e56c514..b0e53ef13ff1 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -541,6 +541,11 @@ static inline bool vma_is_anonymous(struct vm_area_struct *vma)
>         return !vma->vm_ops;
>  }
>
> +static inline bool vma_is_accessible(struct vm_area_struct *vma)
> +{
> +       return vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC);
> +}
> +
>  #ifdef CONFIG_SHMEM
>  /*
>   * The vma_is_shmem is not inline because it is used only by slow
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index fe4e0d775375..6ce54d57dd09 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -2573,7 +2573,7 @@ static void task_numa_work(struct callback_head *work)
>                  * Skip inaccessible VMAs to avoid any confusion between
>                  * PROT_NONE and NUMA hinting ptes
>                  */
> -               if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))
> +               if (!vma_is_accessible(vma))
>                         continue;
>
>                 do {
> diff --git a/mm/gup.c b/mm/gup.c
> index 1b521e0ac1de..c8ffe2e61f03 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -1171,7 +1171,7 @@ long populate_vma_page_range(struct vm_area_struct *vma,
>          * We want mlock to succeed for regions that have any permissions
>          * other than PROT_NONE.
>          */
> -       if (vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC))
> +       if (vma_is_accessible(vma))
>                 gup_flags |= FOLL_FORCE;
>
>         /*
> diff --git a/mm/memory.c b/mm/memory.c
> index 0bccc622e482..2f07747612b7 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -3942,11 +3942,6 @@ static inline vm_fault_t wp_huge_pmd(struct vm_fault *vmf, pmd_t orig_pmd)
>         return VM_FAULT_FALLBACK;
>  }
>
> -static inline bool vma_is_accessible(struct vm_area_struct *vma)
> -{
> -       return vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE);
> -}
> -
>  static vm_fault_t create_huge_pud(struct vm_fault *vmf)
>  {
>  #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index 977c641f78cf..91c1ad6ab8ea 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -649,8 +649,7 @@ static int queue_pages_test_walk(unsigned long start, unsigned long end,
>
>         if (flags & MPOL_MF_LAZY) {
>                 /* Similar to task_numa_work, skip inaccessible VMAs */
> -               if (!is_vm_hugetlb_page(vma) &&
> -                       (vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)) &&
> +               if (!is_vm_hugetlb_page(vma) && vma_is_accessible(vma) &&
>                         !(vma->vm_flags & VM_MIXEDMAP))
>                         change_prot_numa(vma, start, endvma);
>                 return 1;
> --
> 2.20.1
>


-- 
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/

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

* Re: [PATCH 2/5] mm/vma: Make vma_is_accessible() available for general use
@ 2020-02-18  2:21     ` Guo Ren
  0 siblings, 0 replies; 34+ messages in thread
From: Guo Ren @ 2020-02-18  2:21 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-mm, Linux Kernel Mailing List, Geert Uytterhoeven,
	Ralf Baechle, Paul Burton, Benjamin Herrenschmidt,
	Paul Mackerras, Michael Ellerman, Yoshinori Sato, Rich Felker,
	Dave Hansen, Andy Lutomirski, Peter Zijlstra, Thomas Gleixner,
	Ingo Molnar, Andrew Morton, Steven Rostedt, Mel Gorman,
	linux-m68k, linux-mips, linuxppc-dev, linux-sh

csky:

Acked-by: Guo Ren <guoren@kernel.org>


On Mon, Feb 17, 2020 at 1:04 PM Anshuman Khandual
<anshuman.khandual@arm.com> wrote:
>
> Lets move vma_is_accessible() helper to include/linux/mm.h which makes it
> available for general use. While here, this replaces all remaining open
> encodings for VMA access check with vma_is_accessible().
>
> Cc: Guo Ren <guoren@kernel.org>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Paul Burton <paulburton@kernel.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-m68k@lists.linux-m68k.org
> Cc: linux-mips@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-sh@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
>  arch/csky/mm/fault.c    | 2 +-
>  arch/m68k/mm/fault.c    | 2 +-
>  arch/mips/mm/fault.c    | 2 +-
>  arch/powerpc/mm/fault.c | 2 +-
>  arch/sh/mm/fault.c      | 2 +-
>  arch/x86/mm/fault.c     | 2 +-
>  include/linux/mm.h      | 5 +++++
>  kernel/sched/fair.c     | 2 +-
>  mm/gup.c                | 2 +-
>  mm/memory.c             | 5 -----
>  mm/mempolicy.c          | 3 +--
>  11 files changed, 14 insertions(+), 15 deletions(-)
>
> diff --git a/arch/csky/mm/fault.c b/arch/csky/mm/fault.c
> index f76618b630f9..4b3511b8298d 100644
> --- a/arch/csky/mm/fault.c
> +++ b/arch/csky/mm/fault.c
> @@ -137,7 +137,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
>                 if (!(vma->vm_flags & VM_WRITE))
>                         goto bad_area;
>         } else {
> -               if (!(vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)))
> +               if (!vma_is_accessible(vma))
>                         goto bad_area;
>         }
>
> diff --git a/arch/m68k/mm/fault.c b/arch/m68k/mm/fault.c
> index e9b1d7585b43..d5131ec5d923 100644
> --- a/arch/m68k/mm/fault.c
> +++ b/arch/m68k/mm/fault.c
> @@ -125,7 +125,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
>                 case 1:         /* read, present */
>                         goto acc_err;
>                 case 0:         /* read, not present */
> -                       if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))
> +                       if (!vma_is_accessible(vma))
>                                 goto acc_err;
>         }
>
> diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
> index 1e8d00793784..5b9f947bfa32 100644
> --- a/arch/mips/mm/fault.c
> +++ b/arch/mips/mm/fault.c
> @@ -142,7 +142,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,
>                                 goto bad_area;
>                         }
>                 } else {
> -                       if (!(vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)))
> +                       if (!vma_is_accessible(vma))
>                                 goto bad_area;
>                 }
>         }
> diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
> index 8db0507619e2..71a3658c516b 100644
> --- a/arch/powerpc/mm/fault.c
> +++ b/arch/powerpc/mm/fault.c
> @@ -314,7 +314,7 @@ static bool access_error(bool is_write, bool is_exec,
>                 return false;
>         }
>
> -       if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
> +       if (unlikely(!vma_is_accessible(vma)))
>                 return true;
>         /*
>          * We should ideally do the vma pkey access check here. But in the
> diff --git a/arch/sh/mm/fault.c b/arch/sh/mm/fault.c
> index 5f51456f4fc7..a8c4253f37d7 100644
> --- a/arch/sh/mm/fault.c
> +++ b/arch/sh/mm/fault.c
> @@ -355,7 +355,7 @@ static inline int access_error(int error_code, struct vm_area_struct *vma)
>                 return 1;
>
>         /* read, not present: */
> -       if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
> +       if (unlikely(!vma_is_accessible(vma)))
>                 return 1;
>
>         return 0;
> diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
> index fa4ea09593ab..c461eaab0306 100644
> --- a/arch/x86/mm/fault.c
> +++ b/arch/x86/mm/fault.c
> @@ -1200,7 +1200,7 @@ access_error(unsigned long error_code, struct vm_area_struct *vma)
>                 return 1;
>
>         /* read, not present: */
> -       if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
> +       if (unlikely(!vma_is_accessible(vma)))
>                 return 1;
>
>         return 0;
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 52269e56c514..b0e53ef13ff1 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -541,6 +541,11 @@ static inline bool vma_is_anonymous(struct vm_area_struct *vma)
>         return !vma->vm_ops;
>  }
>
> +static inline bool vma_is_accessible(struct vm_area_struct *vma)
> +{
> +       return vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC);
> +}
> +
>  #ifdef CONFIG_SHMEM
>  /*
>   * The vma_is_shmem is not inline because it is used only by slow
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index fe4e0d775375..6ce54d57dd09 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -2573,7 +2573,7 @@ static void task_numa_work(struct callback_head *work)
>                  * Skip inaccessible VMAs to avoid any confusion between
>                  * PROT_NONE and NUMA hinting ptes
>                  */
> -               if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))
> +               if (!vma_is_accessible(vma))
>                         continue;
>
>                 do {
> diff --git a/mm/gup.c b/mm/gup.c
> index 1b521e0ac1de..c8ffe2e61f03 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -1171,7 +1171,7 @@ long populate_vma_page_range(struct vm_area_struct *vma,
>          * We want mlock to succeed for regions that have any permissions
>          * other than PROT_NONE.
>          */
> -       if (vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC))
> +       if (vma_is_accessible(vma))
>                 gup_flags |= FOLL_FORCE;
>
>         /*
> diff --git a/mm/memory.c b/mm/memory.c
> index 0bccc622e482..2f07747612b7 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -3942,11 +3942,6 @@ static inline vm_fault_t wp_huge_pmd(struct vm_fault *vmf, pmd_t orig_pmd)
>         return VM_FAULT_FALLBACK;
>  }
>
> -static inline bool vma_is_accessible(struct vm_area_struct *vma)
> -{
> -       return vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE);
> -}
> -
>  static vm_fault_t create_huge_pud(struct vm_fault *vmf)
>  {
>  #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index 977c641f78cf..91c1ad6ab8ea 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -649,8 +649,7 @@ static int queue_pages_test_walk(unsigned long start, unsigned long end,
>
>         if (flags & MPOL_MF_LAZY) {
>                 /* Similar to task_numa_work, skip inaccessible VMAs */
> -               if (!is_vm_hugetlb_page(vma) &&
> -                       (vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)) &&
> +               if (!is_vm_hugetlb_page(vma) && vma_is_accessible(vma) &&
>                         !(vma->vm_flags & VM_MIXEDMAP))
>                         change_prot_numa(vma, start, endvma);
>                 return 1;
> --
> 2.20.1
>


-- 
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/

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

* Re: [PATCH 2/5] mm/vma: Make vma_is_accessible() available for general use
@ 2020-02-18  2:21     ` Guo Ren
  0 siblings, 0 replies; 34+ messages in thread
From: Guo Ren @ 2020-02-18  2:21 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-mm, Linux Kernel Mailing List, Geert Uytterhoeven,
	Ralf Baechle, Paul Burton, Benjamin Herrenschmidt,
	Paul Mackerras, Michael Ellerman, Yoshinori Sato, Rich Felker,
	Dave Hansen, Andy Lutomirski, Peter Zijlstra, Thomas Gleixner,
	Ingo Molnar, Andrew Morton, Steven Rostedt, Mel Gorman,
	linux-m68k, linux-mips, linuxppc-dev, linux-sh

csky:

Acked-by: Guo Ren <guoren@kernel.org>


On Mon, Feb 17, 2020 at 1:04 PM Anshuman Khandual
<anshuman.khandual@arm.com> wrote:
>
> Lets move vma_is_accessible() helper to include/linux/mm.h which makes it
> available for general use. While here, this replaces all remaining open
> encodings for VMA access check with vma_is_accessible().
>
> Cc: Guo Ren <guoren@kernel.org>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Paul Burton <paulburton@kernel.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-m68k@lists.linux-m68k.org
> Cc: linux-mips@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-sh@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
>  arch/csky/mm/fault.c    | 2 +-
>  arch/m68k/mm/fault.c    | 2 +-
>  arch/mips/mm/fault.c    | 2 +-
>  arch/powerpc/mm/fault.c | 2 +-
>  arch/sh/mm/fault.c      | 2 +-
>  arch/x86/mm/fault.c     | 2 +-
>  include/linux/mm.h      | 5 +++++
>  kernel/sched/fair.c     | 2 +-
>  mm/gup.c                | 2 +-
>  mm/memory.c             | 5 -----
>  mm/mempolicy.c          | 3 +--
>  11 files changed, 14 insertions(+), 15 deletions(-)
>
> diff --git a/arch/csky/mm/fault.c b/arch/csky/mm/fault.c
> index f76618b630f9..4b3511b8298d 100644
> --- a/arch/csky/mm/fault.c
> +++ b/arch/csky/mm/fault.c
> @@ -137,7 +137,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
>                 if (!(vma->vm_flags & VM_WRITE))
>                         goto bad_area;
>         } else {
> -               if (!(vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)))
> +               if (!vma_is_accessible(vma))
>                         goto bad_area;
>         }
>
> diff --git a/arch/m68k/mm/fault.c b/arch/m68k/mm/fault.c
> index e9b1d7585b43..d5131ec5d923 100644
> --- a/arch/m68k/mm/fault.c
> +++ b/arch/m68k/mm/fault.c
> @@ -125,7 +125,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
>                 case 1:         /* read, present */
>                         goto acc_err;
>                 case 0:         /* read, not present */
> -                       if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))
> +                       if (!vma_is_accessible(vma))
>                                 goto acc_err;
>         }
>
> diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
> index 1e8d00793784..5b9f947bfa32 100644
> --- a/arch/mips/mm/fault.c
> +++ b/arch/mips/mm/fault.c
> @@ -142,7 +142,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,
>                                 goto bad_area;
>                         }
>                 } else {
> -                       if (!(vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)))
> +                       if (!vma_is_accessible(vma))
>                                 goto bad_area;
>                 }
>         }
> diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
> index 8db0507619e2..71a3658c516b 100644
> --- a/arch/powerpc/mm/fault.c
> +++ b/arch/powerpc/mm/fault.c
> @@ -314,7 +314,7 @@ static bool access_error(bool is_write, bool is_exec,
>                 return false;
>         }
>
> -       if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
> +       if (unlikely(!vma_is_accessible(vma)))
>                 return true;
>         /*
>          * We should ideally do the vma pkey access check here. But in the
> diff --git a/arch/sh/mm/fault.c b/arch/sh/mm/fault.c
> index 5f51456f4fc7..a8c4253f37d7 100644
> --- a/arch/sh/mm/fault.c
> +++ b/arch/sh/mm/fault.c
> @@ -355,7 +355,7 @@ static inline int access_error(int error_code, struct vm_area_struct *vma)
>                 return 1;
>
>         /* read, not present: */
> -       if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
> +       if (unlikely(!vma_is_accessible(vma)))
>                 return 1;
>
>         return 0;
> diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
> index fa4ea09593ab..c461eaab0306 100644
> --- a/arch/x86/mm/fault.c
> +++ b/arch/x86/mm/fault.c
> @@ -1200,7 +1200,7 @@ access_error(unsigned long error_code, struct vm_area_struct *vma)
>                 return 1;
>
>         /* read, not present: */
> -       if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
> +       if (unlikely(!vma_is_accessible(vma)))
>                 return 1;
>
>         return 0;
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 52269e56c514..b0e53ef13ff1 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -541,6 +541,11 @@ static inline bool vma_is_anonymous(struct vm_area_struct *vma)
>         return !vma->vm_ops;
>  }
>
> +static inline bool vma_is_accessible(struct vm_area_struct *vma)
> +{
> +       return vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC);
> +}
> +
>  #ifdef CONFIG_SHMEM
>  /*
>   * The vma_is_shmem is not inline because it is used only by slow
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index fe4e0d775375..6ce54d57dd09 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -2573,7 +2573,7 @@ static void task_numa_work(struct callback_head *work)
>                  * Skip inaccessible VMAs to avoid any confusion between
>                  * PROT_NONE and NUMA hinting ptes
>                  */
> -               if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))
> +               if (!vma_is_accessible(vma))
>                         continue;
>
>                 do {
> diff --git a/mm/gup.c b/mm/gup.c
> index 1b521e0ac1de..c8ffe2e61f03 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -1171,7 +1171,7 @@ long populate_vma_page_range(struct vm_area_struct *vma,
>          * We want mlock to succeed for regions that have any permissions
>          * other than PROT_NONE.
>          */
> -       if (vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC))
> +       if (vma_is_accessible(vma))
>                 gup_flags |= FOLL_FORCE;
>
>         /*
> diff --git a/mm/memory.c b/mm/memory.c
> index 0bccc622e482..2f07747612b7 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -3942,11 +3942,6 @@ static inline vm_fault_t wp_huge_pmd(struct vm_fault *vmf, pmd_t orig_pmd)
>         return VM_FAULT_FALLBACK;
>  }
>
> -static inline bool vma_is_accessible(struct vm_area_struct *vma)
> -{
> -       return vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE);
> -}
> -
>  static vm_fault_t create_huge_pud(struct vm_fault *vmf)
>  {
>  #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index 977c641f78cf..91c1ad6ab8ea 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -649,8 +649,7 @@ static int queue_pages_test_walk(unsigned long start, unsigned long end,
>
>         if (flags & MPOL_MF_LAZY) {
>                 /* Similar to task_numa_work, skip inaccessible VMAs */
> -               if (!is_vm_hugetlb_page(vma) &&
> -                       (vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)) &&
> +               if (!is_vm_hugetlb_page(vma) && vma_is_accessible(vma) &&
>                         !(vma->vm_flags & VM_MIXEDMAP))
>                         change_prot_numa(vma, start, endvma);
>                 return 1;
> --
> 2.20.1
>


-- 
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/


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

* Re: [PATCH 2/5] mm/vma: Make vma_is_accessible() available for general use
@ 2020-02-18  2:21     ` Guo Ren
  0 siblings, 0 replies; 34+ messages in thread
From: Guo Ren @ 2020-02-18  2:21 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: Rich Felker, linux-sh, Peter Zijlstra, Dave Hansen, linux-mips,
	linux-mm, Paul Mackerras, Yoshinori Sato, Ingo Molnar,
	Geert Uytterhoeven, Mel Gorman, Steven Rostedt, linux-m68k,
	Andy Lutomirski, Thomas Gleixner, Paul Burton,
	Linux Kernel Mailing List, Ralf Baechle, Andrew Morton,
	linuxppc-dev

csky:

Acked-by: Guo Ren <guoren@kernel.org>


On Mon, Feb 17, 2020 at 1:04 PM Anshuman Khandual
<anshuman.khandual@arm.com> wrote:
>
> Lets move vma_is_accessible() helper to include/linux/mm.h which makes it
> available for general use. While here, this replaces all remaining open
> encodings for VMA access check with vma_is_accessible().
>
> Cc: Guo Ren <guoren@kernel.org>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Paul Burton <paulburton@kernel.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-m68k@lists.linux-m68k.org
> Cc: linux-mips@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-sh@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
>  arch/csky/mm/fault.c    | 2 +-
>  arch/m68k/mm/fault.c    | 2 +-
>  arch/mips/mm/fault.c    | 2 +-
>  arch/powerpc/mm/fault.c | 2 +-
>  arch/sh/mm/fault.c      | 2 +-
>  arch/x86/mm/fault.c     | 2 +-
>  include/linux/mm.h      | 5 +++++
>  kernel/sched/fair.c     | 2 +-
>  mm/gup.c                | 2 +-
>  mm/memory.c             | 5 -----
>  mm/mempolicy.c          | 3 +--
>  11 files changed, 14 insertions(+), 15 deletions(-)
>
> diff --git a/arch/csky/mm/fault.c b/arch/csky/mm/fault.c
> index f76618b630f9..4b3511b8298d 100644
> --- a/arch/csky/mm/fault.c
> +++ b/arch/csky/mm/fault.c
> @@ -137,7 +137,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
>                 if (!(vma->vm_flags & VM_WRITE))
>                         goto bad_area;
>         } else {
> -               if (!(vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)))
> +               if (!vma_is_accessible(vma))
>                         goto bad_area;
>         }
>
> diff --git a/arch/m68k/mm/fault.c b/arch/m68k/mm/fault.c
> index e9b1d7585b43..d5131ec5d923 100644
> --- a/arch/m68k/mm/fault.c
> +++ b/arch/m68k/mm/fault.c
> @@ -125,7 +125,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
>                 case 1:         /* read, present */
>                         goto acc_err;
>                 case 0:         /* read, not present */
> -                       if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))
> +                       if (!vma_is_accessible(vma))
>                                 goto acc_err;
>         }
>
> diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
> index 1e8d00793784..5b9f947bfa32 100644
> --- a/arch/mips/mm/fault.c
> +++ b/arch/mips/mm/fault.c
> @@ -142,7 +142,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,
>                                 goto bad_area;
>                         }
>                 } else {
> -                       if (!(vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)))
> +                       if (!vma_is_accessible(vma))
>                                 goto bad_area;
>                 }
>         }
> diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
> index 8db0507619e2..71a3658c516b 100644
> --- a/arch/powerpc/mm/fault.c
> +++ b/arch/powerpc/mm/fault.c
> @@ -314,7 +314,7 @@ static bool access_error(bool is_write, bool is_exec,
>                 return false;
>         }
>
> -       if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
> +       if (unlikely(!vma_is_accessible(vma)))
>                 return true;
>         /*
>          * We should ideally do the vma pkey access check here. But in the
> diff --git a/arch/sh/mm/fault.c b/arch/sh/mm/fault.c
> index 5f51456f4fc7..a8c4253f37d7 100644
> --- a/arch/sh/mm/fault.c
> +++ b/arch/sh/mm/fault.c
> @@ -355,7 +355,7 @@ static inline int access_error(int error_code, struct vm_area_struct *vma)
>                 return 1;
>
>         /* read, not present: */
> -       if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
> +       if (unlikely(!vma_is_accessible(vma)))
>                 return 1;
>
>         return 0;
> diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
> index fa4ea09593ab..c461eaab0306 100644
> --- a/arch/x86/mm/fault.c
> +++ b/arch/x86/mm/fault.c
> @@ -1200,7 +1200,7 @@ access_error(unsigned long error_code, struct vm_area_struct *vma)
>                 return 1;
>
>         /* read, not present: */
> -       if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
> +       if (unlikely(!vma_is_accessible(vma)))
>                 return 1;
>
>         return 0;
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 52269e56c514..b0e53ef13ff1 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -541,6 +541,11 @@ static inline bool vma_is_anonymous(struct vm_area_struct *vma)
>         return !vma->vm_ops;
>  }
>
> +static inline bool vma_is_accessible(struct vm_area_struct *vma)
> +{
> +       return vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC);
> +}
> +
>  #ifdef CONFIG_SHMEM
>  /*
>   * The vma_is_shmem is not inline because it is used only by slow
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index fe4e0d775375..6ce54d57dd09 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -2573,7 +2573,7 @@ static void task_numa_work(struct callback_head *work)
>                  * Skip inaccessible VMAs to avoid any confusion between
>                  * PROT_NONE and NUMA hinting ptes
>                  */
> -               if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))
> +               if (!vma_is_accessible(vma))
>                         continue;
>
>                 do {
> diff --git a/mm/gup.c b/mm/gup.c
> index 1b521e0ac1de..c8ffe2e61f03 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -1171,7 +1171,7 @@ long populate_vma_page_range(struct vm_area_struct *vma,
>          * We want mlock to succeed for regions that have any permissions
>          * other than PROT_NONE.
>          */
> -       if (vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC))
> +       if (vma_is_accessible(vma))
>                 gup_flags |= FOLL_FORCE;
>
>         /*
> diff --git a/mm/memory.c b/mm/memory.c
> index 0bccc622e482..2f07747612b7 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -3942,11 +3942,6 @@ static inline vm_fault_t wp_huge_pmd(struct vm_fault *vmf, pmd_t orig_pmd)
>         return VM_FAULT_FALLBACK;
>  }
>
> -static inline bool vma_is_accessible(struct vm_area_struct *vma)
> -{
> -       return vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE);
> -}
> -
>  static vm_fault_t create_huge_pud(struct vm_fault *vmf)
>  {
>  #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index 977c641f78cf..91c1ad6ab8ea 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -649,8 +649,7 @@ static int queue_pages_test_walk(unsigned long start, unsigned long end,
>
>         if (flags & MPOL_MF_LAZY) {
>                 /* Similar to task_numa_work, skip inaccessible VMAs */
> -               if (!is_vm_hugetlb_page(vma) &&
> -                       (vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)) &&
> +               if (!is_vm_hugetlb_page(vma) && vma_is_accessible(vma) &&
>                         !(vma->vm_flags & VM_MIXEDMAP))
>                         change_prot_numa(vma, start, endvma);
>                 return 1;
> --
> 2.20.1
>


-- 
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/

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

* Re: [PATCH 3/5] mm/vma: Replace all remaining open encodings with is_vm_hugetlb_page()
  2020-02-17  5:03   ` Anshuman Khandual
@ 2020-02-19  1:14     ` kbuild test robot
  -1 siblings, 0 replies; 34+ messages in thread
From: kbuild test robot @ 2020-02-19  1:14 UTC (permalink / raw)
  To: Anshuman Khandual; +Cc: kbuild-all, linux-mm, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2566 bytes --]

Hi Anshuman,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mmotm/master]
[also build test ERROR on tip/perf/core m68k/for-next powerpc/next tip/sched/core char-misc/char-misc-testing linux/master linus/master tip/x86/mm asm-generic/master v5.6-rc2 next-20200218]
[cannot apply to kvm-ppc/kvm-ppc-next]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Anshuman-Khandual/mm-vma-Use-available-wrappers-when-possible/20200219-065223
base:   git://git.cmpxchg.org/linux-mmotm.git master
config: nds32-allnoconfig (attached as .config)
compiler: nds32le-linux-gcc (GCC) 9.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=9.2.0 make.cross ARCH=nds32 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from arch/nds32/include/asm/tlb.h:7,
                    from arch/nds32/mm/init.c:18:
   include/asm-generic/tlb.h: In function 'tlb_update_vma_flags':
>> include/asm-generic/tlb.h:382:18: error: implicit declaration of function 'is_vm_hugetlb_page' [-Werror=implicit-function-declaration]
     382 |  tlb->vma_huge = is_vm_hugetlb_page(vma);
         |                  ^~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +/is_vm_hugetlb_page +382 include/asm-generic/tlb.h

   367	
   368	static inline void
   369	tlb_update_vma_flags(struct mmu_gather *tlb, struct vm_area_struct *vma)
   370	{
   371		/*
   372		 * flush_tlb_range() implementations that look at VM_HUGETLB (tile,
   373		 * mips-4k) flush only large pages.
   374		 *
   375		 * flush_tlb_range() implementations that flush I-TLB also flush D-TLB
   376		 * (tile, xtensa, arm), so it's ok to just add VM_EXEC to an existing
   377		 * range.
   378		 *
   379		 * We rely on tlb_end_vma() to issue a flush, such that when we reset
   380		 * these values the batch is empty.
   381		 */
 > 382		tlb->vma_huge = is_vm_hugetlb_page(vma);
   383		tlb->vma_exec = !!(vma->vm_flags & VM_EXEC);
   384	}
   385	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 5273 bytes --]

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

* Re: [PATCH 3/5] mm/vma: Replace all remaining open encodings with is_vm_hugetlb_page()
@ 2020-02-19  1:14     ` kbuild test robot
  0 siblings, 0 replies; 34+ messages in thread
From: kbuild test robot @ 2020-02-19  1:14 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2627 bytes --]

Hi Anshuman,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mmotm/master]
[also build test ERROR on tip/perf/core m68k/for-next powerpc/next tip/sched/core char-misc/char-misc-testing linux/master linus/master tip/x86/mm asm-generic/master v5.6-rc2 next-20200218]
[cannot apply to kvm-ppc/kvm-ppc-next]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Anshuman-Khandual/mm-vma-Use-available-wrappers-when-possible/20200219-065223
base:   git://git.cmpxchg.org/linux-mmotm.git master
config: nds32-allnoconfig (attached as .config)
compiler: nds32le-linux-gcc (GCC) 9.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=9.2.0 make.cross ARCH=nds32 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from arch/nds32/include/asm/tlb.h:7,
                    from arch/nds32/mm/init.c:18:
   include/asm-generic/tlb.h: In function 'tlb_update_vma_flags':
>> include/asm-generic/tlb.h:382:18: error: implicit declaration of function 'is_vm_hugetlb_page' [-Werror=implicit-function-declaration]
     382 |  tlb->vma_huge = is_vm_hugetlb_page(vma);
         |                  ^~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +/is_vm_hugetlb_page +382 include/asm-generic/tlb.h

   367	
   368	static inline void
   369	tlb_update_vma_flags(struct mmu_gather *tlb, struct vm_area_struct *vma)
   370	{
   371		/*
   372		 * flush_tlb_range() implementations that look at VM_HUGETLB (tile,
   373		 * mips-4k) flush only large pages.
   374		 *
   375		 * flush_tlb_range() implementations that flush I-TLB also flush D-TLB
   376		 * (tile, xtensa, arm), so it's ok to just add VM_EXEC to an existing
   377		 * range.
   378		 *
   379		 * We rely on tlb_end_vma() to issue a flush, such that when we reset
   380		 * these values the batch is empty.
   381		 */
 > 382		tlb->vma_huge = is_vm_hugetlb_page(vma);
   383		tlb->vma_exec = !!(vma->vm_flags & VM_EXEC);
   384	}
   385	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 5273 bytes --]

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

* Re: [PATCH 3/5] mm/vma: Replace all remaining open encodings with is_vm_hugetlb_page()
  2020-02-19  1:14     ` kbuild test robot
@ 2020-02-24  2:21       ` Anshuman Khandual
  -1 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-24  2:21 UTC (permalink / raw)
  To: kbuild test robot; +Cc: kbuild-all, linux-mm, linux-kernel


On 02/19/2020 06:44 AM, kbuild test robot wrote:
> Hi Anshuman,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on mmotm/master]
> [also build test ERROR on tip/perf/core m68k/for-next powerpc/next tip/sched/core char-misc/char-misc-testing linux/master linus/master tip/x86/mm asm-generic/master v5.6-rc2 next-20200218]
> [cannot apply to kvm-ppc/kvm-ppc-next]
> [if your patch is applied to the wrong git tree, please drop us a note to help
> improve the system. BTW, we also suggest to use '--base' option to specify the
> base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
> 
> url:    https://github.com/0day-ci/linux/commits/Anshuman-Khandual/mm-vma-Use-available-wrappers-when-possible/20200219-065223
> base:   git://git.cmpxchg.org/linux-mmotm.git master
> config: nds32-allnoconfig (attached as .config)
> compiler: nds32le-linux-gcc (GCC) 9.2.0
> reproduce:
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # save the attached .config to linux build tree
>         GCC_VERSION=9.2.0 make.cross ARCH=nds32 
> 
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):
> 
>    In file included from arch/nds32/include/asm/tlb.h:7,
>                     from arch/nds32/mm/init.c:18:
>    include/asm-generic/tlb.h: In function 'tlb_update_vma_flags':
>>> include/asm-generic/tlb.h:382:18: error: implicit declaration of function 'is_vm_hugetlb_page' [-Werror=implicit-function-declaration]
>      382 |  tlb->vma_huge = is_vm_hugetlb_page(vma);
>          |                  ^~~~~~~~~~~~~~~~~~
>    cc1: some warnings being treated as errors

Though I am unable to reproduce this build failure [1], it seems like
explicitly adding <linux/hugetlb.h> or <linux/hugetlb_inline.h> header
will be sufficient.

[1] nds32 build failure (error while loading shared libraries)

/usr/lib/x86_64-linux-gnu/libfl.so.2: invalid ELF header

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

* Re: [PATCH 3/5] mm/vma: Replace all remaining open encodings with is_vm_hugetlb_page()
@ 2020-02-24  2:21       ` Anshuman Khandual
  0 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-02-24  2:21 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2130 bytes --]


On 02/19/2020 06:44 AM, kbuild test robot wrote:
> Hi Anshuman,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on mmotm/master]
> [also build test ERROR on tip/perf/core m68k/for-next powerpc/next tip/sched/core char-misc/char-misc-testing linux/master linus/master tip/x86/mm asm-generic/master v5.6-rc2 next-20200218]
> [cannot apply to kvm-ppc/kvm-ppc-next]
> [if your patch is applied to the wrong git tree, please drop us a note to help
> improve the system. BTW, we also suggest to use '--base' option to specify the
> base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
> 
> url:    https://github.com/0day-ci/linux/commits/Anshuman-Khandual/mm-vma-Use-available-wrappers-when-possible/20200219-065223
> base:   git://git.cmpxchg.org/linux-mmotm.git master
> config: nds32-allnoconfig (attached as .config)
> compiler: nds32le-linux-gcc (GCC) 9.2.0
> reproduce:
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # save the attached .config to linux build tree
>         GCC_VERSION=9.2.0 make.cross ARCH=nds32 
> 
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):
> 
>    In file included from arch/nds32/include/asm/tlb.h:7,
>                     from arch/nds32/mm/init.c:18:
>    include/asm-generic/tlb.h: In function 'tlb_update_vma_flags':
>>> include/asm-generic/tlb.h:382:18: error: implicit declaration of function 'is_vm_hugetlb_page' [-Werror=implicit-function-declaration]
>      382 |  tlb->vma_huge = is_vm_hugetlb_page(vma);
>          |                  ^~~~~~~~~~~~~~~~~~
>    cc1: some warnings being treated as errors

Though I am unable to reproduce this build failure [1], it seems like
explicitly adding <linux/hugetlb.h> or <linux/hugetlb_inline.h> header
will be sufficient.

[1] nds32 build failure (error while loading shared libraries)

/usr/lib/x86_64-linux-gnu/libfl.so.2: invalid ELF header

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

* Re: [PATCH 4/5] mm/vma: Replace all remaining open encodings with vma_set_anonymous()
  2020-02-17  5:03 ` [PATCH 4/5] mm/vma: Replace all remaining open encodings with vma_set_anonymous() Anshuman Khandual
  2020-02-17 10:27   ` Kirill A. Shutemov
@ 2020-03-18 10:24   ` Greg Kroah-Hartman
  2020-03-18 10:41     ` Anshuman Khandual
  1 sibling, 1 reply; 34+ messages in thread
From: Greg Kroah-Hartman @ 2020-03-18 10:24 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-mm, linux-kernel, Sudeep Dutt, Ashutosh Dixit,
	Arnd Bergmann, Thomas Gleixner, Kate Stewart, Allison Randal,
	Richard Fontana

On Mon, Feb 17, 2020 at 10:33:52AM +0530, Anshuman Khandual wrote:
> This replaces all remaining open encodings with vma_set_anonymous().
> 
> Cc: Sudeep Dutt <sudeep.dutt@intel.com>
> Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Kate Stewart <kstewart@linuxfoundation.org>
> Cc: Allison Randal <allison@lohutok.net>
> Cc: Richard Fontana <rfontana@redhat.com>
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
>  drivers/misc/mic/scif/scif_mmap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

The subject line does not match up with the file being modified here :(


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

* Re: [PATCH 4/5] mm/vma: Replace all remaining open encodings with vma_set_anonymous()
  2020-03-18 10:24   ` Greg Kroah-Hartman
@ 2020-03-18 10:41     ` Anshuman Khandual
  0 siblings, 0 replies; 34+ messages in thread
From: Anshuman Khandual @ 2020-03-18 10:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-mm, linux-kernel, Sudeep Dutt, Ashutosh Dixit,
	Arnd Bergmann, Thomas Gleixner, Kate Stewart, Allison Randal,
	Richard Fontana



On 03/18/2020 03:54 PM, Greg Kroah-Hartman wrote:
> On Mon, Feb 17, 2020 at 10:33:52AM +0530, Anshuman Khandual wrote:
>> This replaces all remaining open encodings with vma_set_anonymous().
>>
>> Cc: Sudeep Dutt <sudeep.dutt@intel.com>
>> Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
>> Cc: Arnd Bergmann <arnd@arndb.de>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: Kate Stewart <kstewart@linuxfoundation.org>
>> Cc: Allison Randal <allison@lohutok.net>
>> Cc: Richard Fontana <rfontana@redhat.com>
>> Cc: linux-kernel@vger.kernel.org
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>> ---
>>  drivers/misc/mic/scif/scif_mmap.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> The subject line does not match up with the file being modified here :(

Idea here was to primarily focus on the VMA modifying helpers instead,
hence the subject line. But I get your point and agree that it was bit
off the mark. Anyways, had already dropped this patch.

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

end of thread, other threads:[~2020-03-18 10:41 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-17  5:03 [PATCH 0/5] mm/vma: Use available wrappers when possible Anshuman Khandual
2020-02-17  5:15 ` Anshuman Khandual
2020-02-17  5:03 ` Anshuman Khandual
2020-02-17  5:03 ` [PATCH 1/5] mm/vma: Add missing VMA flag readable name for VM_SYNC Anshuman Khandual
2020-02-17  5:03 ` [PATCH 2/5] mm/vma: Make vma_is_accessible() available for general use Anshuman Khandual
2020-02-17  5:15   ` Anshuman Khandual
2020-02-17  5:03   ` Anshuman Khandual
2020-02-17  7:36   ` Geert Uytterhoeven
2020-02-17  7:36     ` Geert Uytterhoeven
2020-02-17  7:36     ` Geert Uytterhoeven
2020-02-17  7:36     ` Geert Uytterhoeven
2020-02-17  9:28   ` Anshuman Khandual
2020-02-17  9:40     ` Anshuman Khandual
2020-02-17  9:28     ` Anshuman Khandual
2020-02-18  2:21   ` Guo Ren
2020-02-18  2:21     ` Guo Ren
2020-02-18  2:21     ` Guo Ren
2020-02-18  2:21     ` Guo Ren
2020-02-17  5:03 ` [PATCH 3/5] mm/vma: Replace all remaining open encodings with is_vm_hugetlb_page() Anshuman Khandual
2020-02-17  5:15   ` Anshuman Khandual
2020-02-17  5:03   ` Anshuman Khandual
2020-02-17  9:21   ` Anshuman Khandual
2020-02-17  9:33     ` Anshuman Khandual
2020-02-17  9:21     ` Anshuman Khandual
2020-02-19  1:14   ` kbuild test robot
2020-02-19  1:14     ` kbuild test robot
2020-02-24  2:21     ` Anshuman Khandual
2020-02-24  2:21       ` Anshuman Khandual
2020-02-17  5:03 ` [PATCH 4/5] mm/vma: Replace all remaining open encodings with vma_set_anonymous() Anshuman Khandual
2020-02-17 10:27   ` Kirill A. Shutemov
2020-02-17 11:56     ` Anshuman Khandual
2020-03-18 10:24   ` Greg Kroah-Hartman
2020-03-18 10:41     ` Anshuman Khandual
2020-02-17  5:03 ` [PATCH 5/5] mm/vma: Replace all remaining open encodings with vma_is_anonymous() Anshuman Khandual

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.