* [PATCH V2 0/3] mm/vma: some more minor changes
@ 2020-02-27 5:56 Anshuman Khandual
2020-02-27 5:56 ` [PATCH V2 2/3] mm/vma: Make vma_is_foreign() available for general use Anshuman Khandual
0 siblings, 1 reply; 2+ messages in thread
From: Anshuman Khandual @ 2020-02-27 5:56 UTC (permalink / raw)
To: linux-mm
Cc: Anshuman Khandual, x86, linux-kernel, Ingo Molnar, Paul Mackerras,
Thomas Gleixner, linuxppc-dev, Andrew Morton, vbabka
The motivation here is to consolidate VMA flags and helpers in generic
memory header and reduce code duplication when ever applicable. If there
are other possible similar instances which might be missing here, please
do let me me know. I will be happy to incorporate them.
This series is based on v5.6-rc3. This series has been build tested on
multiple platforms but boot tested only on arm64 and x86.
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: x86@kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org
Changes in V2:
- Moved VM_NO_KHUGEPAGED after VM_SPECIAL with a comment per Vlastimil
- Renamed is_vma_temporary_stack() as vma_is_temporary_stack() per Vlastimil
Changes in V1: (https://patchwork.kernel.org/cover/11405177/)
Anshuman Khandual (3):
mm/vma: Move VM_NO_KHUGEPAGED into generic header
mm/vma: Make vma_is_foreign() available for general use
mm/vma: Make is_vma_temporary_stack() available for general use
arch/powerpc/mm/book3s64/pkeys.c | 12 ------------
arch/x86/include/asm/mmu_context.h | 15 ---------------
include/linux/huge_mm.h | 4 +---
include/linux/mm.h | 29 ++++++++++++++++++++++++++++-
mm/khugepaged.c | 4 +---
mm/mremap.c | 2 +-
mm/rmap.c | 16 +---------------
7 files changed, 32 insertions(+), 50 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH V2 2/3] mm/vma: Make vma_is_foreign() available for general use
2020-02-27 5:56 [PATCH V2 0/3] mm/vma: some more minor changes Anshuman Khandual
@ 2020-02-27 5:56 ` Anshuman Khandual
0 siblings, 0 replies; 2+ messages in thread
From: Anshuman Khandual @ 2020-02-27 5:56 UTC (permalink / raw)
To: linux-mm
Cc: Anshuman Khandual, x86, linux-kernel, Ingo Molnar, Paul Mackerras,
Thomas Gleixner, linuxppc-dev, Andrew Morton, vbabka
Idea of a foreign VMA with respect to the present context is very generic.
But currently there are two identical definitions for this in powerpc and
x86 platforms. Lets consolidate those redundant definitions while making
vma_is_foreign() available for general use later. This should not cause
any functional change.
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: x86@kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
arch/powerpc/mm/book3s64/pkeys.c | 12 ------------
arch/x86/include/asm/mmu_context.h | 15 ---------------
include/linux/mm.h | 11 +++++++++++
3 files changed, 11 insertions(+), 27 deletions(-)
diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c
index 59e0ebbd8036..07527f1ed108 100644
--- a/arch/powerpc/mm/book3s64/pkeys.c
+++ b/arch/powerpc/mm/book3s64/pkeys.c
@@ -381,18 +381,6 @@ bool arch_pte_access_permitted(u64 pte, bool write, bool execute)
* So do not enforce things if the VMA is not from the current mm, or if we are
* in a kernel thread.
*/
-static inline bool vma_is_foreign(struct vm_area_struct *vma)
-{
- if (!current->mm)
- return true;
-
- /* if it is not our ->mm, it has to be foreign */
- if (current->mm != vma->vm_mm)
- return true;
-
- return false;
-}
-
bool arch_vma_access_permitted(struct vm_area_struct *vma, bool write,
bool execute, bool foreign)
{
diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
index b538d9ddee9c..4e55370e48e8 100644
--- a/arch/x86/include/asm/mmu_context.h
+++ b/arch/x86/include/asm/mmu_context.h
@@ -213,21 +213,6 @@ static inline void arch_unmap(struct mm_struct *mm, unsigned long start,
* So do not enforce things if the VMA is not from the current
* mm, or if we are in a kernel thread.
*/
-static inline bool vma_is_foreign(struct vm_area_struct *vma)
-{
- if (!current->mm)
- return true;
- /*
- * Should PKRU be enforced on the access to this VMA? If
- * the VMA is from another process, then PKRU has no
- * relevance and should not be enforced.
- */
- if (current->mm != vma->vm_mm)
- return true;
-
- return false;
-}
-
static inline bool arch_vma_access_permitted(struct vm_area_struct *vma,
bool write, bool execute, bool foreign)
{
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 7cb7a5c564fb..c5d2fd889bdf 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -27,6 +27,7 @@
#include <linux/memremap.h>
#include <linux/overflow.h>
#include <linux/sizes.h>
+#include <linux/sched.h>
struct mempolicy;
struct anon_vma;
@@ -543,6 +544,16 @@ static inline bool vma_is_anonymous(struct vm_area_struct *vma)
return !vma->vm_ops;
}
+static inline bool vma_is_foreign(struct vm_area_struct *vma)
+{
+ if (!current->mm)
+ return true;
+
+ if (current->mm != vma->vm_mm)
+ return true;
+
+ return false;
+}
#ifdef CONFIG_SHMEM
/*
* The vma_is_shmem is not inline because it is used only by slow
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-02-27 6:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-27 5:56 [PATCH V2 0/3] mm/vma: some more minor changes Anshuman Khandual
2020-02-27 5:56 ` [PATCH V2 2/3] mm/vma: Make vma_is_foreign() available for general use Anshuman Khandual
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).