Skip to contentSkip to conversation

Use asm-generic for mmu_context no-op functions

PATCH Superseded Nicholas Piggin 13 participants 50 messages Aug 26, 2020 – Oct 27, 2020

Subsystems (22)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
author reviewer
#5 lore raw

PATCH v2 2/23 alpha: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
Cc Richard Henderson <[email protected]>
Cc Ivan Kokshaysky <[email protected]>
Cc Matt Turner <[email protected]>
---
 arch/alpha/include/asm/mmu_context.h | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
arch/alpha/include/asm/mmu_context.h +4 -8
index 6d7d9bc1b4b8..4eea7c616992 100644
@@ -214,8 +214,6 @@ ev4_activate_mm(struct mm_struct *prev_mm, struct mm_struct *next_mm)
 	tbiap();
 }
 
-#define deactivate_mm(tsk,mm)	do { } while (0)
-
 #ifdef CONFIG_ALPHA_GENERIC
 # define switch_mm(a,b,c)	alpha_mv.mv_switch_mm((a),(b),(c))
 # define activate_mm(x,y)	alpha_mv.mv_activate_mm((x),(y))
@@ -229,6 +227,7 @@ ev4_activate_mm(struct mm_struct *prev_mm, struct mm_struct *next_mm)
 # endif
 #endif
 
+#define init_new_context init_new_context
 static inline int
 init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 {
@@ -242,12 +241,7 @@ init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 	return 0;
 }
 
-extern inline void
-destroy_context(struct mm_struct *mm)
-{
-	/* Nothing to do.  */
-}
-
+#define enter_lazy_tlb enter_lazy_tlb
 static inline void
 enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
 {
@@ -255,6 +249,8 @@ enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
 	  = ((unsigned long)mm->pgd - IDENT_ADDR) >> PAGE_SHIFT;
 }
 
+#include <asm-generic/mmu_context.h>
+
 #ifdef __MMU_EXTERN_INLINE
 #undef __EXTERN_INLINE
 #undef __MMU_EXTERN_INLINE
Signature · 1 line
2.23.0
author reviewer
#17 lore raw

PATCH v2 7/23 hexagon: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
---
 arch/hexagon/include/asm/mmu_context.h | 33 ++++----------------------
 1 file changed, 5 insertions(+), 28 deletions(-)
arch/hexagon/include/asm/mmu_context.h +5 -28
index cdc4adc0300a..81947764c47d 100644
@@ -15,39 +15,13 @@
 #include <asm/pgalloc.h>
 #include <asm/mem-layout.h>
 
-static inline void destroy_context(struct mm_struct *mm)
-{
-}
-
 /*
  * VM port hides all TLB management, so "lazy TLB" isn't very
  * meaningful.  Even for ports to architectures with visble TLBs,
  * this is almost invariably a null function.
+ *
+ * mm->context is set up by pgd_alloc, so no init_new_context required.
  */
-static inline void enter_lazy_tlb(struct mm_struct *mm,
-	struct task_struct *tsk)
-{
-}
-
-/*
- * Architecture-specific actions, if any, for memory map deactivation.
- */
-static inline void deactivate_mm(struct task_struct *tsk,
-	struct mm_struct *mm)
-{
-}
-
-/**
- * init_new_context - initialize context related info for new mm_struct instance
- * @tsk: pointer to a task struct
- * @mm: pointer to a new mm struct
- */
-static inline int init_new_context(struct task_struct *tsk,
-					struct mm_struct *mm)
-{
-	/* mm->context is set up by pgd_alloc */
-	return 0;
-}
 
 /*
  *  Switch active mm context
@@ -74,6 +48,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
 /*
  *  Activate new memory map for task
  */
+#define activate_mm activate_mm
 static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
 {
 	unsigned long flags;
@@ -86,4 +61,6 @@ static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
 /*  Generic hooks for arch_dup_mmap and arch_exit_mmap  */
 #include <asm-generic/mm_hooks.h>
 
+#include <asm-generic/mmu_context.h>
+
 #endif
Signature · 1 line
2.23.0
author reviewer
#18 lore raw

PATCH v2 8/23 ia64: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
---
 arch/ia64/include/asm/mmu_context.h | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)
arch/ia64/include/asm/mmu_context.h +4 -13
index 2da0e2eb036b..87a0d5bc11ef 100644
@@ -49,11 +49,6 @@ DECLARE_PER_CPU(u8, ia64_need_tlb_flush);
 extern void mmu_context_init (void);
 extern void wrap_mmu_context (struct mm_struct *mm);
 
-static inline void
-enter_lazy_tlb (struct mm_struct *mm, struct task_struct *tsk)
-{
-}
-
 /*
  * When the context counter wraps around all TLBs need to be flushed because
  * an old context number might have been reused. This is signalled by the
@@ -116,6 +111,7 @@ get_mmu_context (struct mm_struct *mm)
  * Initialize context number to some sane value.  MM is guaranteed to be a
  * brand-new address-space, so no TLB flushing is needed, ever.
  */
+#define init_new_context init_new_context
 static inline int
 init_new_context (struct task_struct *p, struct mm_struct *mm)
 {
@@ -123,12 +119,6 @@ init_new_context (struct task_struct *p, struct mm_struct *mm)
 	return 0;
 }
 
-static inline void
-destroy_context (struct mm_struct *mm)
-{
-	/* Nothing to do.  */
-}
-
 static inline void
 reload_context (nv_mm_context_t context)
 {
@@ -178,11 +168,10 @@ activate_context (struct mm_struct *mm)
 	} while (unlikely(context != mm->context));
 }
 
-#define deactivate_mm(tsk,mm)	do { } while (0)
-
 /*
  * Switch from address space PREV to address space NEXT.
  */
+#define activate_mm activate_mm
 static inline void
 activate_mm (struct mm_struct *prev, struct mm_struct *next)
 {
@@ -196,5 +185,7 @@ activate_mm (struct mm_struct *prev, struct mm_struct *next)
 
 #define switch_mm(prev_mm,next_mm,next_task)	activate_mm(prev_mm, next_mm)
 
+#include <asm-generic/mmu_context.h>
+
 # endif /* ! __ASSEMBLY__ */
 #endif /* _ASM_IA64_MMU_CONTEXT_H */
Signature · 1 line
2.23.0
author reviewer
#33 lore raw

PATCH v2 14/23 openrisc: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
Cc Jonas Bonn <[email protected]>
Cc Stefan Kristiansson <[email protected]>
Cc Stafford Horne <[email protected]>
Cc openrisc at lists.librecores.org
---
 arch/openrisc/include/asm/mmu_context.h | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
arch/openrisc/include/asm/mmu_context.h +3 -5
index ced577542e29..a6702384c77d 100644
@@ -17,13 +17,13 @@
 
 #include <asm-generic/mm_hooks.h>
 
+#define init_new_context init_new_context
 extern int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
+#define destroy_context destroy_context
 extern void destroy_context(struct mm_struct *mm);
 extern void switch_mm(struct mm_struct *prev, struct mm_struct *next,
 		      struct task_struct *tsk);
 
-#define deactivate_mm(tsk, mm)	do { } while (0)
-
 #define activate_mm(prev, next) switch_mm((prev), (next), NULL)
 
 /* current active pgd - this is similar to other processors pgd
@@ -32,8 +32,6 @@ extern void switch_mm(struct mm_struct *prev, struct mm_struct *next,
 
 extern volatile pgd_t *current_pgd[]; /* defined in arch/openrisc/mm/fault.c */
 
-static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
-{
-}
+#include <asm-generic/mmu_context.h>
 
 #endif
Signature · 1 line
2.23.0
author reviewer
#40 lore raw

PATCH v2 18/23 s390: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
Cc Heiko Carstens <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Christian Borntraeger <[email protected]>
---
 arch/s390/include/asm/mmu_context.h | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
arch/s390/include/asm/mmu_context.h +4 -5
index c9f3d8a52756..66f9cf0a07e3 100644
@@ -15,6 +15,7 @@
 #include <asm/ctl_reg.h>
 #include <asm-generic/mm_hooks.h>
 
+#define init_new_context init_new_context
 static inline int init_new_context(struct task_struct *tsk,
 				   struct mm_struct *mm)
 {
@@ -69,8 +70,6 @@ static inline int init_new_context(struct task_struct *tsk,
 	return 0;
 }
 
-#define destroy_context(mm)             do { } while (0)
-
 static inline void set_user_asce(struct mm_struct *mm)
 {
 	S390_lowcore.user_asce = mm->context.asce;
@@ -125,9 +124,7 @@ static inline void finish_arch_post_lock_switch(void)
 	set_fs(current->thread.mm_segment);
 }
 
-#define enter_lazy_tlb(mm,tsk)	do { } while (0)
-#define deactivate_mm(tsk,mm)	do { } while (0)
-
+#define activate_mm activate_mm
 static inline void activate_mm(struct mm_struct *prev,
                                struct mm_struct *next)
 {
@@ -136,4 +133,6 @@ static inline void activate_mm(struct mm_struct *prev,
 	set_user_asce(next);
 }
 
+#include <asm-generic/mmu_context.h>
+
 #endif /* __S390_MMU_CONTEXT_H */
Signature · 1 line
2.23.0
author reviewer
#41 lore raw

PATCH v2 19/23 sh: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
---
 arch/sh/include/asm/mmu_context.h    | 5 ++---
 arch/sh/include/asm/mmu_context_32.h | 9 ---------
 2 files changed, 2 insertions(+), 12 deletions(-)
arch/sh/include/asm/mmu_context.h +2 -3
index 461b1304580b..78eef4e7d5df 100644
@@ -84,6 +84,7 @@ static inline void get_mmu_context(struct mm_struct *mm, unsigned int cpu)
  * Initialize the context related info for a new mm_struct
  * instance.
  */
+#define init_new_context init_new_context
 static inline int init_new_context(struct task_struct *tsk,
 				   struct mm_struct *mm)
 {
@@ -120,9 +121,7 @@ static inline void switch_mm(struct mm_struct *prev,
 			activate_context(next, cpu);
 }
 
-#define activate_mm(prev, next)		switch_mm((prev),(next),NULL)
-#define deactivate_mm(tsk,mm)		do { } while (0)
-#define enter_lazy_tlb(mm,tsk)		do { } while (0)
+#include <asm-generic/mmu_context.h>
 
 #else
 
arch/sh/include/asm/mmu_context_32.h +0 -9
index 71bf12ef1f65..bc5034fa6249 100644
@@ -2,15 +2,6 @@
 #ifndef __ASM_SH_MMU_CONTEXT_32_H
 #define __ASM_SH_MMU_CONTEXT_32_H
 
-/*
- * Destroy context related info for an mm_struct that is about
- * to be put to rest.
- */
-static inline void destroy_context(struct mm_struct *mm)
-{
-	/* Do nothing */
-}
-
 #ifdef CONFIG_CPU_HAS_PTEAEX
 static inline void set_asid(unsigned long asid)
 {
Signature · 1 line
2.23.0
author reviewer
#42 lore raw

PATCH v2 20/23 sparc: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
---
 arch/sparc/include/asm/mmu_context_32.h | 10 ++++------
 arch/sparc/include/asm/mmu_context_64.h | 10 +++++-----
 2 files changed, 9 insertions(+), 11 deletions(-)
arch/sparc/include/asm/mmu_context_32.h +4 -6
index 7ddcb8badf70..509043f81560 100644
@@ -6,13 +6,10 @@
 
 #include <asm-generic/mm_hooks.h>
 
-static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
-{
-}
-
 /* Initialize a new mmu context.  This is invoked when a new
  * address space instance (unique or shared) is instantiated.
  */
+#define init_new_context init_new_context
 int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
 
 /* Destroy a dead context.  This occurs when mmput drops the
@@ -20,17 +17,18 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
  * all the page tables have been flushed.  Our job is to destroy
  * any remaining processor-specific state.
  */
+#define destroy_context destroy_context
 void destroy_context(struct mm_struct *mm);
 
 /* Switch the current MM context. */
 void switch_mm(struct mm_struct *old_mm, struct mm_struct *mm,
 	       struct task_struct *tsk);
 
-#define deactivate_mm(tsk,mm)	do { } while (0)
-
 /* Activate a new MM instance for the current task. */
 #define activate_mm(active_mm, mm) switch_mm((active_mm), (mm), NULL)
 
+#include <asm-generic/mmu_context.h>
+
 #endif /* !(__ASSEMBLY__) */
 
 #endif /* !(__SPARC_MMU_CONTEXT_H) */
arch/sparc/include/asm/mmu_context_64.h +5 -5
index 312fcee8df2b..7a8380c63aab 100644
@@ -16,17 +16,16 @@
 #include <asm-generic/mm_hooks.h>
 #include <asm/percpu.h>
 
-static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
-{
-}
-
 extern spinlock_t ctx_alloc_lock;
 extern unsigned long tlb_context_cache;
 extern unsigned long mmu_context_bmap[];
 
 DECLARE_PER_CPU(struct mm_struct *, per_cpu_secondary_mm);
 void get_new_mmu_context(struct mm_struct *mm);
+
+#define init_new_context init_new_context
 int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
+#define destroy_context destroy_context
 void destroy_context(struct mm_struct *mm);
 
 void __tsb_context_switch(unsigned long pgd_pa,
@@ -136,7 +135,6 @@ static inline void switch_mm(struct mm_struct *old_mm, struct mm_struct *mm, str
 	spin_unlock_irqrestore(&mm->context.lock, flags);
 }
 
-#define deactivate_mm(tsk,mm)	do { } while (0)
 #define activate_mm(active_mm, mm) switch_mm(active_mm, mm, NULL)
 
 #define  __HAVE_ARCH_START_CONTEXT_SWITCH
@@ -187,6 +185,8 @@ static inline void finish_arch_post_lock_switch(void)
 	}
 }
 
+#include <asm-generic/mmu_context.h>
+
 #endif /* !(__ASSEMBLY__) */
 
 #endif /* !(__SPARC64_MMU_CONTEXT_H) */
Signature · 1 line
2.23.0
author reviewer
#43 lore raw

PATCH v2 21/23 um: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
Cc Jeff Dike <[email protected]>
Cc Richard Weinberger <[email protected]>
Cc Anton Ivanov <[email protected]>
---
 arch/um/include/asm/mmu_context.h | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
arch/um/include/asm/mmu_context.h +5 -7
index 17ddd4edf875..f8a100770691 100644
@@ -37,10 +37,9 @@ static inline bool arch_vma_access_permitted(struct vm_area_struct *vma,
  * end asm-generic/mm_hooks.h functions
  */
 
-#define deactivate_mm(tsk,mm)	do { } while (0)
-
 extern void force_flush_all(void);
 
+#define activate_mm activate_mm
 static inline void activate_mm(struct mm_struct *old, struct mm_struct *new)
 {
 	/*
@@ -66,13 +65,12 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
 	}
 }
 
-static inline void enter_lazy_tlb(struct mm_struct *mm, 
-				  struct task_struct *tsk)
-{
-}
-
+#define init_new_context init_new_context
 extern int init_new_context(struct task_struct *task, struct mm_struct *mm);
 
+#define destroy_context destroy_context
 extern void destroy_context(struct mm_struct *mm);
 
+#include <asm-generic/mmu_context.h>
+
 #endif
Signature · 1 line
2.23.0

Nicholas Piggin

author reviewer
#0 lore raw

v2 cover Use asm-generic for mmu_context no-op functions

It would be nice to be able to modify mmu_context functions or add a hook without updating all architectures, many of which will be no-ops.

The motivation for this series is a change to lazy mmu handling, but this series stands on its own as a good cleanup whether or not we end up making that change.

Arnd, is this something you could take through your asm-generic tree? (assuming arch maintainers are okay with it)

Thanks,
Nick

Since v1:
- Added acks and feedback from various people.
- Fixed a nommu build error caught by ktp.
- Dropped unicore32.

Nicholas Piggin (23):
asm-generic: add generic MMU versions of mmu context functions
alpha: use asm-generic/mmu_context.h for no-op implementations
arc: use asm-generic/mmu_context.h for no-op implementations
arm: use asm-generic/mmu_context.h for no-op implementations
arm64: use asm-generic/mmu_context.h for no-op implementations
csky: use asm-generic/mmu_context.h for no-op implementations
hexagon: use asm-generic/mmu_context.h for no-op implementations
ia64: use asm-generic/mmu_context.h for no-op implementations
m68k: use asm-generic/mmu_context.h for no-op implementations
microblaze: use asm-generic/mmu_context.h for no-op implementations
mips: use asm-generic/mmu_context.h for no-op implementations
nds32: use asm-generic/mmu_context.h for no-op implementations
nios2: use asm-generic/mmu_context.h for no-op implementations
openrisc: use asm-generic/mmu_context.h for no-op implementations
parisc: use asm-generic/mmu_context.h for no-op implementations
powerpc: use asm-generic/mmu_context.h for no-op implementations
riscv: use asm-generic/mmu_context.h for no-op implementations
s390: use asm-generic/mmu_context.h for no-op implementations
sh: use asm-generic/mmu_context.h for no-op implementations
sparc: use asm-generic/mmu_context.h for no-op implementations
um: use asm-generic/mmu_context.h for no-op implementations
x86: use asm-generic/mmu_context.h for no-op implementations
xtensa: use asm-generic/mmu_context.h for no-op implementations

 arch/alpha/include/asm/mmu_context.h         | 12 ++---
 arch/arc/include/asm/mmu_context.h           | 17 +++---
 arch/arm/include/asm/mmu_context.h           | 26 ++-------
 arch/arm64/include/asm/mmu_context.h         |  9 ++--
 arch/csky/include/asm/mmu_context.h          |  8 ++-
 arch/hexagon/include/asm/mmu_context.h       | 33 ++----------
 arch/ia64/include/asm/mmu_context.h          | 17 ++----
 arch/m68k/include/asm/mmu_context.h          | 47 +++-------------
 arch/microblaze/include/asm/mmu_context.h    |  2 +-
 arch/microblaze/include/asm/mmu_context_mm.h |  8 +--
 arch/microblaze/include/asm/processor.h      |  3 --
 arch/mips/include/asm/mmu_context.h          | 11 ++--
 arch/nds32/include/asm/mmu_context.h         | 10 +---
 arch/nios2/include/asm/mmu_context.h         | 21 ++------
 arch/openrisc/include/asm/mmu_context.h      |  8 ++-
 arch/parisc/include/asm/mmu_context.h        | 12 ++---
 arch/powerpc/include/asm/mmu_context.h       | 22 +++-----
 arch/riscv/include/asm/mmu_context.h         | 22 +-------
 arch/s390/include/asm/mmu_context.h          |  9 ++--
 arch/sh/include/asm/mmu_context.h            |  7 ++-
 arch/sh/include/asm/mmu_context_32.h         |  9 ----
 arch/sparc/include/asm/mmu_context_32.h      | 10 ++--
 arch/sparc/include/asm/mmu_context_64.h      | 10 ++--
 arch/um/include/asm/mmu_context.h            | 12 ++---
 arch/x86/include/asm/mmu_context.h           |  6 +++
 arch/xtensa/include/asm/mmu_context.h        | 11 ++--
 arch/xtensa/include/asm/nommu_context.h      | 26 +--------
 include/asm-generic/mmu_context.h            | 57 +++++++++++++++-----
 include/asm-generic/nommu_context.h          | 19 +++++++
 29 files changed, 166 insertions(+), 298 deletions(-)
 create mode 100644 include/asm-generic/nommu_context.h
Signature · 1 line
2.23.0
author reviewer
#1 lore raw

PATCH v2 1/23 asm-generic: add generic MMU versions of mmu context functions

Many of these are no-ops on many architectures, so extend mmu_context.h to cover MMU and NOMMU, and split the NOMMU bits out to nommu_context.h

---
 arch/microblaze/include/asm/mmu_context.h |  2 +-
 arch/sh/include/asm/mmu_context.h         |  2 +-
 include/asm-generic/mmu_context.h         | 57 +++++++++++++++++------
 include/asm-generic/nommu_context.h       | 19 ++++++++
 4 files changed, 64 insertions(+), 16 deletions(-)
 create mode 100644 include/asm-generic/nommu_context.h
arch/microblaze/include/asm/mmu_context.h +1 -1
index f74f9da07fdc..34004efb3def 100644
@@ -2,5 +2,5 @@
 #ifdef CONFIG_MMU
 # include <asm/mmu_context_mm.h>
 #else
-# include <asm-generic/mmu_context.h>
+# include <asm-generic/nommu_context.h>
 #endif
arch/sh/include/asm/mmu_context.h +1 -1
index f664e51e8a15..461b1304580b 100644
@@ -133,7 +133,7 @@ static inline void switch_mm(struct mm_struct *prev,
 #define set_TTB(pgd)			do { } while (0)
 #define get_TTB()			(0)
 
-#include <asm-generic/mmu_context.h>
+#include <asm-generic/nommu_context.h>
 
 #endif /* CONFIG_MMU */
 
include/asm-generic/mmu_context.h +43 -14

87 lines not on this page · raw message

include/asm-generic/nommu_context.h new file +19 -0
new file mode 100644
index 000000000000..4f916f9e16cd
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_GENERIC_NOMMU_H
+#define __ASM_GENERIC_NOMMU_H
+
+/*
+ * Generic hooks for NOMMU architectures, which do not need to do
+ * anything special here.
+ */
+#include <asm-generic/mm_hooks.h>
+
+static inline void switch_mm(struct mm_struct *prev,
+			struct mm_struct *next,
+			struct task_struct *tsk)
+{
+}
+
+#include <asm-generic/mmu_context.h>
+
+#endif /* __ASM_GENERIC_NOMMU_H */
Signature · 1 line
2.23.0
author reviewer
#6 lore raw

PATCH v2 3/23 arc: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
---
 arch/arc/include/asm/mmu_context.h | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
arch/arc/include/asm/mmu_context.h +9 -8
index 3a5e6a5b9ed6..df164066e172 100644
@@ -102,6 +102,7 @@ static inline void get_new_mmu_context(struct mm_struct *mm)
  * Initialize the context related info for a new mm_struct
  * instance.
  */
+#define init_new_context init_new_context
 static inline int
 init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 {
@@ -113,6 +114,7 @@ init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 	return 0;
 }
 
+#define destroy_context destroy_context
 static inline void destroy_context(struct mm_struct *mm)
 {
 	unsigned long flags;
@@ -153,13 +155,13 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
 }
 
 /*
- * Called at the time of execve() to get a new ASID
- * Note the subtlety here: get_new_mmu_context() behaves differently here
- * vs. in switch_mm(). Here it always returns a new ASID, because mm has
- * an unallocated "initial" value, while in latter, it moves to a new ASID,
- * only if it was unallocated
+ * activate_mm defaults (in asm-generic) to switch_mm and is called at the
+ * time of execve() to get a new ASID Note the subtlety here:
+ * get_new_mmu_context() behaves differently here vs. in switch_mm(). Here
+ * it always returns a new ASID, because mm has an unallocated "initial"
+ * value, while in latter, it moves to a new ASID, only if it was
+ * unallocated
  */
-#define activate_mm(prev, next)		switch_mm(prev, next, NULL)
 
 /* it seemed that deactivate_mm( ) is a reasonable place to do book-keeping
  * for retiring-mm. However destroy_context( ) still needs to do that because
@@ -168,8 +170,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
  * there is a good chance that task gets sched-out/in, making it's ASID valid
  * again (this teased me for a whole day).
  */
-#define deactivate_mm(tsk, mm)   do { } while (0)
 
-#define enter_lazy_tlb(mm, tsk)
+#include <asm-generic/mmu_context.h>
 
 #endif /* __ASM_ARC_MMU_CONTEXT_H */
Signature · 1 line
2.23.0
author reviewer
#7 lore raw

PATCH v2 4/23 arm: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
---
 arch/arm/include/asm/mmu_context.h | 26 +++-----------------------
 1 file changed, 3 insertions(+), 23 deletions(-)
arch/arm/include/asm/mmu_context.h +3 -23
index f99ed524fe41..84e58956fcab 100644
@@ -26,6 +26,8 @@ void __check_vmalloc_seq(struct mm_struct *mm);
 #ifdef CONFIG_CPU_HAS_ASID
 
 void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk);
+
+#define init_new_context init_new_context
 static inline int
 init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 {
@@ -92,32 +94,10 @@ static inline void finish_arch_post_lock_switch(void)
 
 #endif	/* CONFIG_MMU */
 
-static inline int
-init_new_context(struct task_struct *tsk, struct mm_struct *mm)
-{
-	return 0;
-}
-
-
 #endif	/* CONFIG_CPU_HAS_ASID */
 
-#define destroy_context(mm)		do { } while(0)
 #define activate_mm(prev,next)		switch_mm(prev, next, NULL)
 
-/*
- * This is called when "tsk" is about to enter lazy TLB mode.
- *
- * mm:  describes the currently active mm context
- * tsk: task which is entering lazy tlb
- * cpu: cpu number which is entering lazy tlb
- *
- * tsk->mm will be NULL
- */
-static inline void
-enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
-{
-}
-
 /*
  * This is the actual mm switch as far as the scheduler
  * is concerned.  No registers are touched.  We avoid
@@ -149,6 +129,6 @@ switch_mm(struct mm_struct *prev, struct mm_struct *next,
 #endif
 }
 
-#define deactivate_mm(tsk,mm)	do { } while (0)
+#include <asm-generic/mmu_context.h>
 
 #endif
Signature · 1 line
2.23.0
author reviewer
#8 lore raw

PATCH v2 5/23 arm64: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
---
 arch/arm64/include/asm/mmu_context.h | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
arch/arm64/include/asm/mmu_context.h +4 -5
index f2d7537d6f83..765e8a0f88c9 100644
@@ -174,8 +174,7 @@ static inline void cpu_replace_ttbr1(pgd_t *pgdp)
  * Setting a reserved TTBR0 or EPD0 would work, but it all gets ugly when you
  * take CPU migration into account.
  */
-#define destroy_context(mm)		do { } while(0)
-void check_and_switch_context(struct mm_struct *mm);
+void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
 
 #define init_new_context(tsk,mm)	({ atomic64_set(&(mm)->context.id, 0); 0; })
 
@@ -202,6 +201,7 @@ static inline void update_saved_ttbr0(struct task_struct *tsk,
 }
 #endif
 
+#define enter_lazy_tlb enter_lazy_tlb
 static inline void
 enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
 {
@@ -242,12 +242,11 @@ switch_mm(struct mm_struct *prev, struct mm_struct *next,
 	update_saved_ttbr0(tsk, next);
 }
 
-#define deactivate_mm(tsk,mm)	do { } while (0)
-#define activate_mm(prev,next)	switch_mm(prev, next, current)
-
 void verify_cpu_asid_bits(void);
 void post_ttbr_update_workaround(void);
 
+#include <asm-generic/mmu_context.h>
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /* !__ASM_MMU_CONTEXT_H */
Signature · 1 line
2.23.0
author reviewer
#16 lore raw

PATCH v2 6/23 csky: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
---
 arch/csky/include/asm/mmu_context.h | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
arch/csky/include/asm/mmu_context.h +3 -5
index abdf1f1cb6ec..b227d29393a8 100644
@@ -24,11 +24,6 @@
 #define cpu_asid(mm)		(atomic64_read(&mm->context.asid) & ASID_MASK)
 
 #define init_new_context(tsk,mm)	({ atomic64_set(&(mm)->context.asid, 0); 0; })
-#define activate_mm(prev,next)		switch_mm(prev, next, current)
-
-#define destroy_context(mm)		do {} while (0)
-#define enter_lazy_tlb(mm, tsk)		do {} while (0)
-#define deactivate_mm(tsk, mm)		do {} while (0)
 
 void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
 
@@ -46,4 +41,7 @@ switch_mm(struct mm_struct *prev, struct mm_struct *next,
 
 	flush_icache_deferred(next);
 }
+
+#include <asm-generic/mmu_context.h>
+
 #endif /* __ASM_CSKY_MMU_CONTEXT_H */
Signature · 1 line
2.23.0
author reviewer
#19 lore raw

PATCH v2 9/23 m68k: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
---
 arch/m68k/include/asm/mmu_context.h | 47 +++++------------------------
 1 file changed, 8 insertions(+), 39 deletions(-)
arch/m68k/include/asm/mmu_context.h +8 -39
index 993fd7e37069..012e92204c1b 100644
@@ -5,10 +5,6 @@
 #include <asm-generic/mm_hooks.h>
 #include <linux/mm_types.h>
 
-static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
-{
-}
-
 #ifdef CONFIG_MMU
 
 #if defined(CONFIG_COLDFIRE)
@@ -58,6 +54,7 @@ static inline void get_mmu_context(struct mm_struct *mm)
 /*
  * We're finished using the context for an address space.
  */
+#define destroy_context destroy_context
 static inline void destroy_context(struct mm_struct *mm)
 {
 	if (mm->context != NO_CONTEXT) {
@@ -79,19 +76,6 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
 	set_context(tsk->mm->context, next->pgd);
 }
 
-/*
- * After we have set current->mm to a new value, this activates
- * the context for the new mm so we see the new mappings.
- */
-static inline void activate_mm(struct mm_struct *active_mm,
-	struct mm_struct *mm)
-{
-	get_mmu_context(mm);
-	set_context(mm->context, mm->pgd);
-}
-
-#define deactivate_mm(tsk, mm) do { } while (0)
-
 #define prepare_arch_switch(next) load_ksp_mmu(next)
 
 static inline void load_ksp_mmu(struct task_struct *task)
@@ -176,6 +160,7 @@ extern unsigned long get_free_context(struct mm_struct *mm);
 extern void clear_context(unsigned long context);
 
 /* set the context for a new task to unmapped */
+#define init_new_context init_new_context
 static inline int init_new_context(struct task_struct *tsk,
 				   struct mm_struct *mm)
 {
@@ -210,8 +195,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
 	activate_context(tsk->mm);
 }
 
-#define deactivate_mm(tsk, mm)	do { } while (0)
-
+#define activate_mm activate_mm
 static inline void activate_mm(struct mm_struct *prev_mm,
 			       struct mm_struct *next_mm)
 {
@@ -224,6 +208,7 @@ static inline void activate_mm(struct mm_struct *prev_mm,
 #include <asm/page.h>
 #include <asm/cacheflush.h>
 
+#define init_new_context init_new_context
 static inline int init_new_context(struct task_struct *tsk,
 				   struct mm_struct *mm)
 {
@@ -231,8 +216,6 @@ static inline int init_new_context(struct task_struct *tsk,
 	return 0;
 }
 
-#define destroy_context(mm)		do { } while(0)
-
 static inline void switch_mm_0230(struct mm_struct *mm)
 {
 	unsigned long crp[2] = {
@@ -300,8 +283,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, str
 	}
 }
 
-#define deactivate_mm(tsk,mm)	do { } while (0)
-
+#define activate_mm activate_mm
 static inline void activate_mm(struct mm_struct *prev_mm,
 			       struct mm_struct *next_mm)
 {
@@ -315,24 +297,11 @@ static inline void activate_mm(struct mm_struct *prev_mm,
 
 #endif
 
-#else /* !CONFIG_MMU */
+#include <asm-generic/mmu_context.h>
 
-static inline int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
-{
-	return 0;
-}
-
-
-static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk)
-{
-}
-
-#define destroy_context(mm)	do { } while (0)
-#define deactivate_mm(tsk,mm)	do { } while (0)
+#else /* !CONFIG_MMU */
 
-static inline void activate_mm(struct mm_struct *prev_mm, struct mm_struct *next_mm)
-{
-}
+#include <asm-generic/nommu_context.h>
 
 #endif /* CONFIG_MMU */
 #endif /* __M68K_MMU_CONTEXT_H */
Signature · 1 line
2.23.0
author reviewer
#24 lore raw

PATCH v2 10/23 microblaze: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
---
 arch/microblaze/include/asm/mmu_context_mm.h | 8 ++++----
 arch/microblaze/include/asm/processor.h      | 3 ---
 2 files changed, 4 insertions(+), 7 deletions(-)
arch/microblaze/include/asm/mmu_context_mm.h +4 -4
index a1c7dd48454c..c2c77f708455 100644
@@ -33,10 +33,6 @@
    to represent all kernel pages as shared among all contexts.
  */
 
-static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
-{
-}
-
 # define NO_CONTEXT	256
 # define LAST_CONTEXT	255
 # define FIRST_CONTEXT	1
@@ -105,6 +101,7 @@ static inline void get_mmu_context(struct mm_struct *mm)
 /*
  * We're finished using the context for an address space.
  */
+#define destroy_context destroy_context
 static inline void destroy_context(struct mm_struct *mm)
 {
 	if (mm->context != NO_CONTEXT) {
@@ -126,6 +123,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
  * After we have set current->mm to a new value, this activates
  * the context for the new mm so we see the new mappings.
  */
+#define activate_mm activate_mm
 static inline void activate_mm(struct mm_struct *active_mm,
 			struct mm_struct *mm)
 {
@@ -136,5 +134,7 @@ static inline void activate_mm(struct mm_struct *active_mm,
 
 extern void mmu_context_init(void);
 
+#include <asm-generic/mmu_context.h>
+
 # endif /* __KERNEL__ */
 #endif /* _ASM_MICROBLAZE_MMU_CONTEXT_H */
arch/microblaze/include/asm/processor.h +0 -3
index 1ff5a82b76b6..616211871a6e 100644
@@ -122,9 +122,6 @@ unsigned long get_wchan(struct task_struct *p);
 #  define KSTK_EIP(task)	(task_pc(task))
 #  define KSTK_ESP(task)	(task_sp(task))
 
-/* FIXME */
-#  define deactivate_mm(tsk, mm)	do { } while (0)
-
 #  define STACK_TOP	TASK_SIZE
 #  define STACK_TOP_MAX	STACK_TOP
 
Signature · 1 line
2.23.0
author reviewer
#29 lore raw

PATCH v2 11/23 mips: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
---
 arch/mips/include/asm/mmu_context.h | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
arch/mips/include/asm/mmu_context.h +4 -7
index cddead91acd4..ed9f2d748f63 100644
@@ -124,10 +124,6 @@ static inline void set_cpu_context(unsigned int cpu,
 #define cpu_asid(cpu, mm) \
 	(cpu_context((cpu), (mm)) & cpu_asid_mask(&cpu_data[cpu]))
 
-static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
-{
-}
-
 extern void get_new_mmu_context(struct mm_struct *mm);
 extern void check_mmu_context(struct mm_struct *mm);
 extern void check_switch_mmu_context(struct mm_struct *mm);
@@ -136,6 +132,7 @@ extern void check_switch_mmu_context(struct mm_struct *mm);
  * Initialize the context related info for a new mm_struct
  * instance.
  */
+#define init_new_context init_new_context
 static inline int
 init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 {
@@ -180,14 +177,12 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
  * Destroy context related info for an mm_struct that is about
  * to be put to rest.
  */
+#define destroy_context destroy_context
 static inline void destroy_context(struct mm_struct *mm)
 {
 	dsemul_mm_cleanup(mm);
 }
 
-#define activate_mm(prev, next)	switch_mm(prev, next, current)
-#define deactivate_mm(tsk, mm)	do { } while (0)
-
 static inline void
 drop_mmu_context(struct mm_struct *mm)
 {
@@ -237,4 +232,6 @@ drop_mmu_context(struct mm_struct *mm)
 	local_irq_restore(flags);
 }
 
+#include <asm-generic/mmu_context.h>
+
 #endif /* _ASM_MMU_CONTEXT_H */
Signature · 1 line
2.23.0
author reviewer
#30 lore raw

PATCH v2 12/23 nds32: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
Cc Nick Hu <[email protected]>
Cc Greentime Hu <[email protected]>
Cc Vincent Chen <[email protected]>
---
 arch/nds32/include/asm/mmu_context.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/nds32/include/asm/mmu_context.h +2 -8
index b8fd3d189fdc..c651bc8cacdc 100644
@@ -9,6 +9,7 @@
 #include <asm/proc-fns.h>
 #include <asm-generic/mm_hooks.h>
 
+#define init_new_context init_new_context
 static inline int
 init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 {
@@ -16,8 +17,6 @@ init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 	return 0;
 }
 
-#define destroy_context(mm)	do { } while(0)
-
 #define CID_BITS	9
 extern spinlock_t cid_lock;
 extern unsigned int cpu_last_cid;
@@ -47,10 +46,6 @@ static inline void check_context(struct mm_struct *mm)
 		__new_context(mm);
 }
 
-static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
-{
-}
-
 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
 			     struct task_struct *tsk)
 {
@@ -62,7 +57,6 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
 	}
 }
 
-#define deactivate_mm(tsk,mm)	do { } while (0)
-#define activate_mm(prev,next)	switch_mm(prev, next, NULL)
+#include <asm-generic/mmu_context.h>
 
 #endif
Signature · 1 line
2.23.0
author reviewer
#32 lore raw

PATCH v2 13/23 nios2: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
---
 arch/nios2/include/asm/mmu_context.h | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)
arch/nios2/include/asm/mmu_context.h +4 -17
index 78ab3dacf579..4f99ed09b5a7 100644
@@ -26,16 +26,13 @@ extern unsigned long get_pid_from_context(mm_context_t *ctx);
  */
 extern pgd_t *pgd_current;
 
-static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
-{
-}
-
 /*
  * Initialize the context related info for a new mm_struct instance.
  *
  * Set all new contexts to 0, that way the generation will never match
  * the currently running generation when this context is switched in.
  */
+#define init_new_context init_new_context
 static inline int init_new_context(struct task_struct *tsk,
 					struct mm_struct *mm)
 {
@@ -43,26 +40,16 @@ static inline int init_new_context(struct task_struct *tsk,
 	return 0;
 }
 
-/*
- * Destroy context related info for an mm_struct that is about
- * to be put to rest.
- */
-static inline void destroy_context(struct mm_struct *mm)
-{
-}
-
 void switch_mm(struct mm_struct *prev, struct mm_struct *next,
 		struct task_struct *tsk);
 
-static inline void deactivate_mm(struct task_struct *tsk,
-				struct mm_struct *mm)
-{
-}
-
 /*
  * After we have set current->mm to a new value, this activates
  * the context for the new mm so we see the new mappings.
  */
+#define activate_mm activate_mm
 void activate_mm(struct mm_struct *prev, struct mm_struct *next);
 
+#include <asm-generic/mmu_context.h>
+
 #endif /* _ASM_NIOS2_MMU_CONTEXT_H */
Signature · 1 line
2.23.0
author reviewer
#34 lore raw

PATCH v2 15/23 parisc: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
Cc "James E.J. Bottomley" <[email protected]>
Cc Helge Deller <[email protected]>
---
 arch/parisc/include/asm/mmu_context.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
arch/parisc/include/asm/mmu_context.h +6 -6
index cb5f2f730421..46f8c22c5977 100644
@@ -7,16 +7,13 @@
 #include <linux/atomic.h>
 #include <asm-generic/mm_hooks.h>
 
-static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
-{
-}
-
 /* on PA-RISC, we actually have enough contexts to justify an allocator
  * for them.  prumpf */
 
 extern unsigned long alloc_sid(void);
 extern void free_sid(unsigned long);
 
+#define init_new_context init_new_context
 static inline int
 init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 {
@@ -26,6 +23,7 @@ init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 	return 0;
 }
 
+#define destroy_context destroy_context
 static inline void
 destroy_context(struct mm_struct *mm)
 {
@@ -71,8 +69,7 @@ static inline void switch_mm(struct mm_struct *prev,
 }
 #define switch_mm_irqs_off switch_mm_irqs_off
 
-#define deactivate_mm(tsk,mm)	do { } while (0)
-
+#define activate_mm activate_mm
 static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
 {
 	/*
@@ -90,4 +87,7 @@ static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
 
 	switch_mm(prev,next,current);
 }
+
+#include <asm-generic/mmu_context.h>
+
 #endif
Signature · 1 line
2.23.0
author reviewer
#36 lore raw

PATCH v2 16/23 powerpc: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
Cc Michael Ellerman <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Paul Mackerras <[email protected]>
---
 arch/powerpc/include/asm/mmu_context.h | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)
arch/powerpc/include/asm/mmu_context.h +7 -15
index 7f3658a97384..bc22e247ab55 100644
@@ -14,7 +14,9 @@
 /*
  * Most if the context management is out of line
  */
+#define init_new_context init_new_context
 extern int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
+#define destroy_context destroy_context
 extern void destroy_context(struct mm_struct *mm);
 #ifdef CONFIG_SPAPR_TCE_IOMMU
 struct mm_iommu_table_group_mem_t;
@@ -235,27 +237,15 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
 }
 #define switch_mm_irqs_off switch_mm_irqs_off
 
-
-#define deactivate_mm(tsk,mm)	do { } while (0)
-
-/*
- * After we have set current->mm to a new value, this activates
- * the context for the new mm so we see the new mappings.
- */
-static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
-{
-	switch_mm(prev, next, current);
-}
-
-/* We don't currently use enter_lazy_tlb() for anything */
+#ifdef CONFIG_PPC_BOOK3E_64
+#define enter_lazy_tlb enter_lazy_tlb
 static inline void enter_lazy_tlb(struct mm_struct *mm,
 				  struct task_struct *tsk)
 {
 	/* 64-bit Book3E keeps track of current PGD in the PACA */
-#ifdef CONFIG_PPC_BOOK3E_64
 	get_paca()->pgd = NULL;
-#endif
 }
+#endif
 
 extern void arch_exit_mmap(struct mm_struct *mm);
 
@@ -298,5 +288,7 @@ static inline int arch_dup_mmap(struct mm_struct *oldmm,
 	return 0;
 }
 
+#include <asm-generic/mmu_context.h>
+
 #endif /* __KERNEL__ */
 #endif /* __ASM_POWERPC_MMU_CONTEXT_H */
Signature · 1 line
2.23.0
author reviewer
#38 lore raw

PATCH v2 17/23 riscv: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
---
 arch/riscv/include/asm/mmu_context.h | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)
arch/riscv/include/asm/mmu_context.h +2 -20
index 67c463812e2d..250defa06f3a 100644
@@ -13,34 +13,16 @@
 #include <linux/mm.h>
 #include <linux/sched.h>
 
-static inline void enter_lazy_tlb(struct mm_struct *mm,
-	struct task_struct *task)
-{
-}
-
-/* Initialize context-related info for a new mm_struct */
-static inline int init_new_context(struct task_struct *task,
-	struct mm_struct *mm)
-{
-	return 0;
-}
-
-static inline void destroy_context(struct mm_struct *mm)
-{
-}
-
 void switch_mm(struct mm_struct *prev, struct mm_struct *next,
 	struct task_struct *task);
 
+#define activate_mm activate_mm
 static inline void activate_mm(struct mm_struct *prev,
 			       struct mm_struct *next)
 {
 	switch_mm(prev, next, NULL);
 }
 
-static inline void deactivate_mm(struct task_struct *task,
-	struct mm_struct *mm)
-{
-}
+#include <asm-generic/mmu_context.h>
 
 #endif /* _ASM_RISCV_MMU_CONTEXT_H */
Signature · 1 line
2.23.0
author reviewer
#44 lore raw

PATCH v2 22/23 x86: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
---
 arch/x86/include/asm/mmu_context.h | 6 ++++++
 1 file changed, 6 insertions(+)
arch/x86/include/asm/mmu_context.h +6 -0
index d98016b83755..36afcbea6a9f 100644
@@ -91,12 +91,14 @@ static inline void switch_ldt(struct mm_struct *prev, struct mm_struct *next)
 }
 #endif
 
+#define enter_lazy_tlb enter_lazy_tlb
 extern void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk);
 
 /*
  * Init a new mm.  Used on mm copies, like at fork()
  * and on mm's that are brand-new, like at execve().
  */
+#define init_new_context init_new_context
 static inline int init_new_context(struct task_struct *tsk,
 				   struct mm_struct *mm)
 {
@@ -116,6 +118,8 @@ static inline int init_new_context(struct task_struct *tsk,
 	init_new_context_ldt(mm);
 	return 0;
 }
+
+#define destroy_context destroy_context
 static inline void destroy_context(struct mm_struct *mm)
 {
 	destroy_context_ldt(mm);
@@ -214,4 +218,6 @@ static inline bool arch_vma_access_permitted(struct vm_area_struct *vma,
 
 unsigned long __get_current_cr3_fast(void);
 
+#include <asm-generic/mmu_context.h>
+
 #endif /* _ASM_X86_MMU_CONTEXT_H */
Signature · 1 line
2.23.0
author reviewer
#45 lore raw

PATCH v2 23/23 xtensa: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
---
 arch/xtensa/include/asm/mmu_context.h   | 11 +++--------
 arch/xtensa/include/asm/nommu_context.h | 26 +------------------------
 2 files changed, 4 insertions(+), 33 deletions(-)
arch/xtensa/include/asm/mmu_context.h +3 -8
index 74923ef3b228..e337ba9686e9 100644
@@ -111,6 +111,7 @@ static inline void activate_context(struct mm_struct *mm, unsigned int cpu)
  * to -1 says the process has never run on any core.
  */
 
+#define init_new_context init_new_context
 static inline int init_new_context(struct task_struct *tsk,
 		struct mm_struct *mm)
 {
@@ -136,24 +137,18 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
 		activate_context(next, cpu);
 }
 
-#define activate_mm(prev, next)	switch_mm((prev), (next), NULL)
-#define deactivate_mm(tsk, mm)	do { } while (0)
-
 /*
  * Destroy context related info for an mm_struct that is about
  * to be put to rest.
  */
+#define destroy_context destroy_context
 static inline void destroy_context(struct mm_struct *mm)
 {
 	invalidate_page_directory();
 }
 
 
-static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
-{
-	/* Nothing to do. */
-
-}
+#include <asm-generic/mmu_context.h>
 
 #endif /* CONFIG_MMU */
 #endif /* _XTENSA_MMU_CONTEXT_H */
arch/xtensa/include/asm/nommu_context.h +1 -25
index 37251b2ef871..7c9d1918dc41 100644
@@ -7,28 +7,4 @@ static inline void init_kio(void)
 {
 }
 
-static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
-{
-}
-
-static inline int init_new_context(struct task_struct *tsk,struct mm_struct *mm)
-{
-	return 0;
-}
-
-static inline void destroy_context(struct mm_struct *mm)
-{
-}
-
-static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
-{
-}
-
-static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
-				struct task_struct *tsk)
-{
-}
-
-static inline void deactivate_mm(struct task_struct *tsk, struct mm_struct *mm)
-{
-}
+#include <asm-generic/nommu_context.h>
Signature · 1 line
2.23.0
author reviewer
#10 lore raw

Re: [PATCH v2 05/23] arm64: use asm-generic/mmu_context.h for no-op implementations

Excerpts from Catalin Marinas's message of August 27, 2020 1:25 am:

Quoted 8 lines · Nicholas Piggin
Quoted 4 lines

Thank you, I see I stupidly mis-rebased this patch too :( Sorry I'll fix that.

Thanks,
Nick

#2 lore raw

Re: [PATCH v2 01/23] asm-generic: add generic MMU versions of mmu context functions

In reply to Nicholas Piggin
I love your patch! Yet something to improve:

Hi Nicholas,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on asm-generic/master sparc-next/master xtensa/for_next v5.9-rc2 next-20200826] [cannot apply to sparc/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Nicholas-Piggin/Use-asm-generic-for-mmu_context-no-op-functions/20200826-225632
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2ac69819ba9e3d8d550bb5d2d2df74848e556812
config: c6x-allyesconfig (attached as .config)
compiler: c6x-elf-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
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
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=c6x

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from ./arch/c6x/include/generated/asm/mmu_context.h:1,

                    from kernel/fork.c:101:
   include/asm-generic/mmu_context.h: In function 'activate_mm':
>> include/asm-generic/mmu_context.h:59:2: error: implicit declaration of function 'switch_mm' [-Werror=implicit-function-declaration]
      59 |  switch_mm(prev_mm, next_mm, current);
         |  ^~~~~~~~~
   kernel/fork.c: At top level:
   kernel/fork.c:160:13: warning: no previous prototype for 'arch_release_task_struct' [-Wmissing-prototypes]
     160 | void __weak arch_release_task_struct(struct task_struct *tsk)
         |             ^~~~~~~~~~~~~~~~~~~~~~~~
   kernel/fork.c:743:20: warning: no previous prototype for 'arch_task_cache_init' [-Wmissing-prototypes]
     743 | void __init __weak arch_task_cache_init(void) { }
         |                    ^~~~~~~~~~~~~~~~~~~~

kernel/fork.c:834:12: warning: no previous prototype for 'arch_dup_task_struct' [-Wmissing-prototypes]
834 | int __weak arch_dup_task_struct(struct task_struct *dst,
| ^~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
--
In file included from ./arch/c6x/include/generated/asm/mmu_context.h:1,

                    from kernel/exit.c:69:
   include/asm-generic/mmu_context.h: In function 'activate_mm':
>> include/asm-generic/mmu_context.h:59:2: error: implicit declaration of function 'switch_mm' [-Werror=implicit-function-declaration]
      59 |  switch_mm(prev_mm, next_mm, current);
         |  ^~~~~~~~~
   kernel/exit.c: At top level:
   kernel/exit.c:1754:13: warning: no previous prototype for 'abort' [-Wmissing-prototypes]
    1754 | __weak void abort(void)
         |             ^~~~~

cc1: some warnings being treated as errors
--
In file included from ./arch/c6x/include/generated/asm/mmu_context.h:1,
from include/linux/mmu_context.h:5,
from kernel/kthread.c:12:
include/asm-generic/mmu_context.h: In function 'activate_mm':

>> include/asm-generic/mmu_context.h:59:2: error: implicit declaration of function 'switch_mm' [-Werror=implicit-function-declaration]
      59 |  switch_mm(prev_mm, next_mm, current);
         |  ^~~~~~~~~

cc1: some warnings being treated as errors
--
In file included from ./arch/c6x/include/generated/asm/mmu_context.h:1,
from include/linux/mmu_context.h:5,
from kernel/sched/sched.h:54,
from kernel/sched/rt.c:6:
include/asm-generic/mmu_context.h: In function 'activate_mm':

>> include/asm-generic/mmu_context.h:59:2: error: implicit declaration of function 'switch_mm' [-Werror=implicit-function-declaration]
      59 |  switch_mm(prev_mm, next_mm, current);
         |  ^~~~~~~~~

kernel/sched/rt.c: At top level:
kernel/sched/rt.c:668:6: warning: no previous prototype for 'sched_rt_bandwidth_account' [-Wmissing-prototypes]
668 | bool sched_rt_bandwidth_account(struct rt_rq *rt_rq)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

# https://github.com/0day-ci/linux/commit/96f6fa7969b31878ea85427182e4d9201ab3f592
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Nicholas-Piggin/Use-asm-generic-for-mmu_context-no-op-functions/20200826-225632 git checkout 96f6fa7969b31878ea85427182e4d9201ab3f592
vim +/switch_mm +59 include/asm-generic/mmu_context.h

    49	
    50	/**
    51	 * activate_mm - called after exec switches the current task to a new mm, to switch to it
    52	 * @prev_mm: previous mm of this task
    53	 * @next_mm: new mm
    54	 */
    55	#ifndef activate_mm
    56	static inline void activate_mm(struct mm_struct *prev_mm,
    57				       struct mm_struct *next_mm)
    58	{
  > 59		switch_mm(prev_mm, next_mm, current);
    60	}
    61	#endif
    62	

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

#13 lore raw

Re: [PATCH v2 05/23] arm64: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
I love your patch! Yet something to improve:

Hi Nicholas,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.9-rc2 next-20200826]
[cannot apply to sparc/master asm-generic/master sparc-next/master xtensa/for_next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Nicholas-Piggin/Use-asm-generic-for-mmu_context-no-op-functions/20200826-225632
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2ac69819ba9e3d8d550bb5d2d2df74848e556812
config: arm64-randconfig-r013-20200826 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
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
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm64

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from arch/arm64/kernel/process.c:54:
arch/arm64/include/asm/mmu_context.h: In function '__switch_mm':

>> arch/arm64/include/asm/mmu_context.h:226:2: error: too few arguments to function 'check_and_switch_context'
     226 |  check_and_switch_context(next);
         |  ^~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/mmu_context.h:177:6: note: declared here
     177 | void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
         |      ^~~~~~~~~~~~~~~~~~~~~~~~

arch/arm64/kernel/process.c: At top level:
arch/arm64/kernel/process.c:260:6: warning: no previous prototype for '__show_regs' [-Wmissing-prototypes]
260 | void __show_regs(struct pt_regs *regs)
| ^~~~~~~~~~~
arch/arm64/kernel/process.c:352:5: warning: no previous prototype for 'arch_dup_task_struct' [-Wmissing-prototypes]
352 | int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
| ^~~~~~~~~~~~~~~~~~~~
arch/arm64/kernel/process.c:554:41: warning: no previous prototype for '__switch_to' [-Wmissing-prototypes]
554 | __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev,
| ^~~~~~~~~~~
arch/arm64/kernel/process.c:692:25: warning: no previous prototype for 'arm64_preempt_schedule_irq' [-Wmissing-prototypes]
692 | asmlinkage void __sched arm64_preempt_schedule_irq(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
--
In file included from arch/arm64/include/asm/efi.h:10,

                    from arch/arm64/kernel/setup.c:50:
   arch/arm64/include/asm/mmu_context.h: In function '__switch_mm':
>> arch/arm64/include/asm/mmu_context.h:226:2: error: too few arguments to function 'check_and_switch_context'
     226 |  check_and_switch_context(next);
         |  ^~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/mmu_context.h:177:6: note: declared here
     177 | void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
         |      ^~~~~~~~~~~~~~~~~~~~~~~~
--
   In file included from arch/arm64/kernel/cpu_errata.c:111:
   arch/arm64/include/asm/mmu_context.h: In function '__switch_mm':
>> arch/arm64/include/asm/mmu_context.h:226:2: error: too few arguments to function 'check_and_switch_context'
     226 |  check_and_switch_context(next);
         |  ^~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/mmu_context.h:177:6: note: declared here
     177 | void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
         |      ^~~~~~~~~~~~~~~~~~~~~~~~

arch/arm64/kernel/cpu_errata.c: At top level:
arch/arm64/kernel/cpu_errata.c:295:13: warning: no previous prototype for 'arm64_update_smccc_conduit' [-Wmissing-prototypes]
295 | void __init arm64_update_smccc_conduit(struct alt_instr *alt,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
arch/arm64/kernel/cpu_errata.c:317:13: warning: no previous prototype for 'arm64_enable_wa2_handling' [-Wmissing-prototypes]
317 | void __init arm64_enable_wa2_handling(struct alt_instr *alt,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
--
In file included from arch/arm64/include/asm/kvm_mmu.h:90,

                    from arch/arm64/kernel/smp.c:43:
   arch/arm64/include/asm/mmu_context.h: In function '__switch_mm':
>> arch/arm64/include/asm/mmu_context.h:226:2: error: too few arguments to function 'check_and_switch_context'
     226 |  check_and_switch_context(next);
         |  ^~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/mmu_context.h:177:6: note: declared here
     177 | void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
         |      ^~~~~~~~~~~~~~~~~~~~~~~~

arch/arm64/kernel/smp.c: At top level:
arch/arm64/kernel/smp.c:842:6: warning: no previous prototype for 'arch_irq_work_raise' [-Wmissing-prototypes]
842 | void arch_irq_work_raise(void)
| ^~~~~~~~~~~~~~~~~~~
arch/arm64/kernel/smp.c:863:6: warning: no previous prototype for 'panic_smp_self_stop' [-Wmissing-prototypes]
863 | void panic_smp_self_stop(void)
| ^~~~~~~~~~~~~~~~~~~
--
In file included from arch/arm64/kernel/suspend.c:14:
arch/arm64/include/asm/mmu_context.h: In function '__switch_mm':

>> arch/arm64/include/asm/mmu_context.h:226:2: error: too few arguments to function 'check_and_switch_context'
     226 |  check_and_switch_context(next);
         |  ^~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/mmu_context.h:177:6: note: declared here
     177 | void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
         |      ^~~~~~~~~~~~~~~~~~~~~~~~

arch/arm64/kernel/suspend.c: At top level:
arch/arm64/kernel/suspend.c:32:13: warning: no previous prototype for 'cpu_suspend_set_dbg_restorer' [-Wmissing-prototypes]
32 | void __init cpu_suspend_set_dbg_restorer(int (*hw_bp_restore)(unsigned int))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
In file included from arch/arm64/kernel/machine_kexec.c:21:
arch/arm64/include/asm/mmu_context.h: In function '__switch_mm':

>> arch/arm64/include/asm/mmu_context.h:226:2: error: too few arguments to function 'check_and_switch_context'
     226 |  check_and_switch_context(next);
         |  ^~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/mmu_context.h:177:6: note: declared here
     177 | void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
         |      ^~~~~~~~~~~~~~~~~~~~~~~~

arch/arm64/kernel/machine_kexec.c: At top level:
arch/arm64/kernel/machine_kexec.c:250:6: warning: no previous prototype for 'machine_crash_shutdown' [-Wmissing-prototypes]
250 | void machine_crash_shutdown(struct pt_regs *regs)
| ^~~~~~~~~~~~~~~~~~~~~~
--
In file included from arch/arm64/mm/context.c:16:
arch/arm64/include/asm/mmu_context.h: In function '__switch_mm':

>> arch/arm64/include/asm/mmu_context.h:226:2: error: too few arguments to function 'check_and_switch_context'
     226 |  check_and_switch_context(next);
         |  ^~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/mmu_context.h:177:6: note: declared here
     177 | void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
         |      ^~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/mm/context.c: At top level:
>> arch/arm64/mm/context.c:201:6: error: conflicting types for 'check_and_switch_context'
     201 | void check_and_switch_context(struct mm_struct *mm)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~
   In file included from arch/arm64/mm/context.c:16:
   arch/arm64/include/asm/mmu_context.h:177:6: note: previous declaration of 'check_and_switch_context' was here
     177 | void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
         |      ^~~~~~~~~~~~~~~~~~~~~~~~

# https://github.com/0day-ci/linux/commit/b7168fc5046fd65223bdc51ef411e157939433b6
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Nicholas-Piggin/Use-asm-generic-for-mmu_context-no-op-functions/20200826-225632 git checkout b7168fc5046fd65223bdc51ef411e157939433b6
vim +/check_and_switch_context +226 arch/arm64/include/asm/mmu_context.h

d96cc49bff5a77 Will Deacon     2017-12-06  214  
39bc88e5e38e9b Catalin Marinas 2016-09-02  215  static inline void __switch_mm(struct mm_struct *next)
39bc88e5e38e9b Catalin Marinas 2016-09-02  216  {
e53f21bce4d35a Catalin Marinas 2015-03-23  217  	/*
e53f21bce4d35a Catalin Marinas 2015-03-23  218  	 * init_mm.pgd does not contain any user mappings and it is always
e53f21bce4d35a Catalin Marinas 2015-03-23  219  	 * active for kernel addresses in TTBR1. Just set the reserved TTBR0.
e53f21bce4d35a Catalin Marinas 2015-03-23  220  	 */
e53f21bce4d35a Catalin Marinas 2015-03-23  221  	if (next == &init_mm) {
e53f21bce4d35a Catalin Marinas 2015-03-23  222  		cpu_set_reserved_ttbr0();
e53f21bce4d35a Catalin Marinas 2015-03-23  223  		return;
e53f21bce4d35a Catalin Marinas 2015-03-23  224  	}
e53f21bce4d35a Catalin Marinas 2015-03-23  225  

c4885bbb3afee8 Pingfan Liu 2020-07-10 @226 check_and_switch_context(next);
b3901d54dc4f73 Catalin Marinas 2012-03-05 227 }
b3901d54dc4f73 Catalin Marinas 2012-03-05 228

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

#14 lore raw

Re: [PATCH v2 05/23] arm64: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
I love your patch! Yet something to improve:

Hi Nicholas,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.9-rc2 next-20200826]
[cannot apply to sparc/master asm-generic/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Nicholas-Piggin/Use-asm-generic-for-mmu_context-no-op-functions/20200826-225632
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2ac69819ba9e3d8d550bb5d2d2df74848e556812
config: arm64-randconfig-r002-20200826 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 7cfcecece0e0430937cf529ce74d3a071a4dedc6)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from arch/arm64/kernel/process.c:54:

>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   arch/arm64/kernel/process.c:260:6: warning: no previous prototype for function '__show_regs' [-Wmissing-prototypes]
   void __show_regs(struct pt_regs *regs)
        ^
   arch/arm64/kernel/process.c:260:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __show_regs(struct pt_regs *regs)
   ^
   static 
   arch/arm64/kernel/process.c:352:5: warning: no previous prototype for function 'arch_dup_task_struct' [-Wmissing-prototypes]
   int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
       ^
   arch/arm64/kernel/process.c:352:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
   ^
   static 
   arch/arm64/kernel/process.c:554:41: warning: no previous prototype for function '__switch_to' [-Wmissing-prototypes]
   __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev,
                                           ^
   arch/arm64/kernel/process.c:554:21: note: declare 'static' if the function is not intended to be used outside of this translation unit
   __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev,
                       ^
                       static 
   arch/arm64/kernel/process.c:692:25: warning: no previous prototype for function 'arm64_preempt_schedule_irq' [-Wmissing-prototypes]
   asmlinkage void __sched arm64_preempt_schedule_irq(void)
                           ^
   arch/arm64/kernel/process.c:692:12: note: declare 'static' if the function is not intended to be used outside of this translation unit
   asmlinkage void __sched arm64_preempt_schedule_irq(void)
              ^
              static 

4 warnings and 1 error generated.
--
In file included from arch/arm64/kernel/setup.c:50:
In file included from arch/arm64/include/asm/efi.h:10:

>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   1 error generated.
--
   In file included from arch/arm64/kernel/cpu_errata.c:111:
>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   arch/arm64/kernel/cpu_errata.c:295:13: warning: no previous prototype for function 'arm64_update_smccc_conduit' [-Wmissing-prototypes]
   void __init arm64_update_smccc_conduit(struct alt_instr *alt,
               ^
   arch/arm64/kernel/cpu_errata.c:295:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __init arm64_update_smccc_conduit(struct alt_instr *alt,
   ^
   static 
   arch/arm64/kernel/cpu_errata.c:317:13: warning: no previous prototype for function 'arm64_enable_wa2_handling' [-Wmissing-prototypes]
   void __init arm64_enable_wa2_handling(struct alt_instr *alt,
               ^
   arch/arm64/kernel/cpu_errata.c:317:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __init arm64_enable_wa2_handling(struct alt_instr *alt,
   ^
   static 
   arch/arm64/kernel/cpu_errata.c:747:3: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
                   ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 4),
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:506:2: note: expanded from macro 'ERRATA_MIDR_REV_RANGE'
           ERRATA_MIDR_RANGE(m, var, r_min, var, r_max)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:498:2: note: expanded from macro 'ERRATA_MIDR_RANGE'
           CAP_MIDR_RANGE(model, v_min, r_min, v_max, r_max)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:486:13: note: expanded from macro 'CAP_MIDR_RANGE'
           .matches = is_affected_midr_range,                      \
                      ^~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:746:14: note: previous initialization is here
                   .matches = is_affected_midr_range,
                              ^~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:753:3: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
                   ERRATA_MIDR_REV(MIDR_BRAHMA_B53, 0, 0),
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:510:2: note: expanded from macro 'ERRATA_MIDR_REV'
           ERRATA_MIDR_RANGE(model, var, rev, var, rev)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:498:2: note: expanded from macro 'ERRATA_MIDR_RANGE'
           CAP_MIDR_RANGE(model, v_min, r_min, v_max, r_max)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:486:13: note: expanded from macro 'CAP_MIDR_RANGE'
           .matches = is_affected_midr_range,                      \
                      ^~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:752:14: note: previous initialization is here
                   .matches = is_affected_midr_range,
                              ^~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:913:11: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
                   .type = (ARM64_CPUCAP_SCOPE_LOCAL_CPU |
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:912:3: note: previous initialization is here
                   ERRATA_MIDR_RANGE_LIST(erratum_1418040_list),
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:519:10: note: expanded from macro 'ERRATA_MIDR_RANGE_LIST'
           .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,                 \
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

arch/arm64/include/asm/cpufeature.h:258:2: note: expanded from macro 'ARM64_CPUCAP_LOCAL_CPU_ERRATUM'
(ARM64_CPUCAP_SCOPE_LOCAL_CPU | ARM64_CPUCAP_OPTIONAL_FOR_LATE_CPU) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 warnings and 1 error generated.
--
In file included from arch/arm64/kernel/smp.c:43:
In file included from arch/arm64/include/asm/kvm_mmu.h:90:

>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   arch/arm64/kernel/smp.c:842:6: warning: no previous prototype for function 'arch_irq_work_raise' [-Wmissing-prototypes]
   void arch_irq_work_raise(void)
        ^
   arch/arm64/kernel/smp.c:842:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void arch_irq_work_raise(void)
   ^
   static 
   arch/arm64/kernel/smp.c:863:6: warning: no previous prototype for function 'panic_smp_self_stop' [-Wmissing-prototypes]
   void panic_smp_self_stop(void)
        ^
   arch/arm64/kernel/smp.c:863:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void panic_smp_self_stop(void)
   ^
   static 
   arch/arm64/kernel/smp.c:1067:5: warning: no previous prototype for function 'setup_profiling_timer' [-Wmissing-prototypes]
   int setup_profiling_timer(unsigned int multiplier)
       ^

arch/arm64/kernel/smp.c:1067:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int setup_profiling_timer(unsigned int multiplier)
^
static
3 warnings and 1 error generated.
--
In file included from arch/arm64/kernel/suspend.c:14:

>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   arch/arm64/kernel/suspend.c:32:13: warning: no previous prototype for function 'cpu_suspend_set_dbg_restorer' [-Wmissing-prototypes]
   void __init cpu_suspend_set_dbg_restorer(int (*hw_bp_restore)(unsigned int))
               ^

arch/arm64/kernel/suspend.c:32:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void __init cpu_suspend_set_dbg_restorer(int (*hw_bp_restore)(unsigned int))
^
static
1 warning and 1 error generated.
--
In file included from arch/arm64/kernel/machine_kexec.c:21:

>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   arch/arm64/kernel/machine_kexec.c:250:6: warning: no previous prototype for function 'machine_crash_shutdown' [-Wmissing-prototypes]
   void machine_crash_shutdown(struct pt_regs *regs)
        ^

arch/arm64/kernel/machine_kexec.c:250:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void machine_crash_shutdown(struct pt_regs *regs)
^
static
1 warning and 1 error generated.
--
In file included from arch/arm64/mm/mmu.c:35:

>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   arch/arm64/mm/mmu.c:1135:6: warning: no previous prototype for function 'vmemmap_free' [-Wmissing-prototypes]
   void vmemmap_free(unsigned long start, unsigned long end,
        ^

arch/arm64/mm/mmu.c:1135:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void vmemmap_free(unsigned long start, unsigned long end,
^
static
1 warning and 1 error generated.
--
In file included from arch/arm64/mm/context.c:16:

>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   arch/arm64/mm/context.c:201:6: error: conflicting types for 'check_and_switch_context'
   void check_and_switch_context(struct mm_struct *mm)
        ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: previous declaration is here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^

2 errors generated.
--
In file included from arch/arm64/kvm/va_layout.c:13:
In file included from arch/arm64/include/asm/kvm_mmu.h:90:

>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   arch/arm64/kvm/va_layout.c:137:6: warning: no previous prototype for function 'kvm_patch_vector_branch' [-Wmissing-prototypes]
   void kvm_patch_vector_branch(struct alt_instr *alt,
        ^

arch/arm64/kvm/va_layout.c:137:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void kvm_patch_vector_branch(struct alt_instr *alt,
^
static
1 warning and 1 error generated.
--
In file included from arch/arm64/kvm/handle_exit.c:19:
In file included from arch/arm64/include/asm/kvm_mmu.h:90:

>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   arch/arm64/kvm/handle_exit.c:178:21: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
           [ESR_ELx_EC_WFx]        = kvm_handle_wfx,
                                     ^~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:177:27: note: previous initialization is here
           [0 ... ESR_ELx_EC_MAX]  = kvm_handle_unknown_ec,
                                     ^~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:179:25: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
           [ESR_ELx_EC_CP15_32]    = kvm_handle_cp15_32,
                                     ^~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:177:27: note: previous initialization is here
           [0 ... ESR_ELx_EC_MAX]  = kvm_handle_unknown_ec,
                                     ^~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:180:25: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
           [ESR_ELx_EC_CP15_64]    = kvm_handle_cp15_64,
                                     ^~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:177:27: note: previous initialization is here
           [0 ... ESR_ELx_EC_MAX]  = kvm_handle_unknown_ec,
                                     ^~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:181:25: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
           [ESR_ELx_EC_CP14_MR]    = kvm_handle_cp14_32,
                                     ^~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:177:27: note: previous initialization is here
           [0 ... ESR_ELx_EC_MAX]  = kvm_handle_unknown_ec,
                                     ^~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:182:25: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
           [ESR_ELx_EC_CP14_LS]    = kvm_handle_cp14_load_store,
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:177:27: note: previous initialization is here
           [0 ... ESR_ELx_EC_MAX]  = kvm_handle_unknown_ec,
                                     ^~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:183:25: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
           [ESR_ELx_EC_CP14_64]    = kvm_handle_cp14_64,
                                     ^~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:177:27: note: previous initialization is here
           [0 ... ESR_ELx_EC_MAX]  = kvm_handle_unknown_ec,
                                     ^~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:184:23: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
           [ESR_ELx_EC_HVC32]      = handle_hvc,
                                     ^~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:177:27: note: previous initialization is here
           [0 ... ESR_ELx_EC_MAX]  = kvm_handle_unknown_ec,
                                     ^~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:185:23: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
           [ESR_ELx_EC_SMC32]      = handle_smc,
                                     ^~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:177:27: note: previous initialization is here
           [0 ... ESR_ELx_EC_MAX]  = kvm_handle_unknown_ec,
                                     ^~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:186:23: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
           [ESR_ELx_EC_HVC64]      = handle_hvc,
                                     ^~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:177:27: note: previous initialization is here
           [0 ... ESR_ELx_EC_MAX]  = kvm_handle_unknown_ec,
                                     ^~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:187:23: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
           [ESR_ELx_EC_SMC64]      = handle_smc,
                                     ^~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:177:27: note: previous initialization is here
           [0 ... ESR_ELx_EC_MAX]  = kvm_handle_unknown_ec,
                                     ^~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:188:23: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
           [ESR_ELx_EC_SYS64]      = kvm_handle_sys_reg,
                                     ^~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:177:27: note: previous initialization is here
           [0 ... ESR_ELx_EC_MAX]  = kvm_handle_unknown_ec,
                                     ^~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:189:21: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
           [ESR_ELx_EC_SVE]        = handle_sve,
                                     ^~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:177:27: note: previous initialization is here
           [0 ... ESR_ELx_EC_MAX]  = kvm_handle_unknown_ec,
                                     ^~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:190:26: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
           [ESR_ELx_EC_IABT_LOW]   = kvm_handle_guest_abort,
                                     ^~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:177:27: note: previous initialization is here
           [0 ... ESR_ELx_EC_MAX]  = kvm_handle_unknown_ec,
                                     ^~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:191:26: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
           [ESR_ELx_EC_DABT_LOW]   = kvm_handle_guest_abort,
                                     ^~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:177:27: note: previous initialization is here
           [0 ... ESR_ELx_EC_MAX]  = kvm_handle_unknown_ec,
                                     ^~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:192:28: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
           [ESR_ELx_EC_SOFTSTP_LOW]= kvm_handle_guest_debug,
                                     ^~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:177:27: note: previous initialization is here
           [0 ... ESR_ELx_EC_MAX]  = kvm_handle_unknown_ec,
                                     ^~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:193:28: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
           [ESR_ELx_EC_WATCHPT_LOW]= kvm_handle_guest_debug,
                                     ^~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kvm/handle_exit.c:177:27: note: previous initialization is here
           [0 ... ESR_ELx_EC_MAX]  = kvm_handle_unknown_ec,

# https://github.com/0day-ci/linux/commit/b7168fc5046fd65223bdc51ef411e157939433b6
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Nicholas-Piggin/Use-asm-generic-for-mmu_context-no-op-functions/20200826-225632 git checkout b7168fc5046fd65223bdc51ef411e157939433b6
vim +226 arch/arm64/include/asm/mmu_context.h

d96cc49bff5a77 Will Deacon     2017-12-06  214  
39bc88e5e38e9b Catalin Marinas 2016-09-02  215  static inline void __switch_mm(struct mm_struct *next)
39bc88e5e38e9b Catalin Marinas 2016-09-02  216  {
e53f21bce4d35a Catalin Marinas 2015-03-23  217  	/*
e53f21bce4d35a Catalin Marinas 2015-03-23  218  	 * init_mm.pgd does not contain any user mappings and it is always
e53f21bce4d35a Catalin Marinas 2015-03-23  219  	 * active for kernel addresses in TTBR1. Just set the reserved TTBR0.
e53f21bce4d35a Catalin Marinas 2015-03-23  220  	 */
e53f21bce4d35a Catalin Marinas 2015-03-23  221  	if (next == &init_mm) {
e53f21bce4d35a Catalin Marinas 2015-03-23  222  		cpu_set_reserved_ttbr0();
e53f21bce4d35a Catalin Marinas 2015-03-23  223  		return;
e53f21bce4d35a Catalin Marinas 2015-03-23  224  	}
e53f21bce4d35a Catalin Marinas 2015-03-23  225  

c4885bbb3afee8 Pingfan Liu 2020-07-10 @226 check_and_switch_context(next);
b3901d54dc4f73 Catalin Marinas 2012-03-05 227 }
b3901d54dc4f73 Catalin Marinas 2012-03-05 228

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

maintainer
#46 lore raw
In reply to Nicholas Piggin
Quoted 10 lines · Nicholas Piggin

It would be nice to be able to modify mmu_context functions or add a hook without updating all architectures, many of which will be no-ops.

The motivation for this series is a change to lazy mmu handling, but this series stands on its own as a good cleanup whether or not we end up making that change.

Arnd, is this something you could take through your asm-generic tree? (assuming arch maintainers are okay with it)

Yes, I can definitely take this. The patches all look good to me, so feel free to add "Acked-by: Arnd Bergmann <[email protected]" if you like (not really needed if I merge them later though) and send me a pull request once you feel you have collected enough Ack from others.

Arnd

#15 lore raw

Re: [PATCH v2 05/23] arm64: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
I love your patch! Yet something to improve:

Hi Nicholas,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.9-rc2 next-20200826]
[cannot apply to sparc/master asm-generic/master sparc-next/master xtensa/for_next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Nicholas-Piggin/Use-asm-generic-for-mmu_context-no-op-functions/20200826-225632
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2ac69819ba9e3d8d550bb5d2d2df74848e556812
config: arm64-randconfig-r036-20200826 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 7cfcecece0e0430937cf529ce74d3a071a4dedc6)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from arch/arm64/mm/mmu.c:35:

>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   1 error generated.
--
   In file included from arch/arm64/mm/context.c:16:
>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
>> arch/arm64/mm/context.c:201:6: error: conflicting types for 'check_and_switch_context'
   void check_and_switch_context(struct mm_struct *mm)
        ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: previous declaration is here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   2 errors generated.
--
   In file included from arch/arm64/kernel/process.c:54:
>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   arch/arm64/kernel/process.c:260:6: warning: no previous prototype for function '__show_regs' [-Wmissing-prototypes]
   void __show_regs(struct pt_regs *regs)
        ^
   arch/arm64/kernel/process.c:260:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __show_regs(struct pt_regs *regs)
   ^
   static 
   arch/arm64/kernel/process.c:352:5: warning: no previous prototype for function 'arch_dup_task_struct' [-Wmissing-prototypes]
   int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
       ^
   arch/arm64/kernel/process.c:352:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
   ^
   static 
   arch/arm64/kernel/process.c:554:41: warning: no previous prototype for function '__switch_to' [-Wmissing-prototypes]
   __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev,
                                           ^
   arch/arm64/kernel/process.c:554:21: note: declare 'static' if the function is not intended to be used outside of this translation unit
   __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev,
                       ^
                       static 
   arch/arm64/kernel/process.c:692:25: warning: no previous prototype for function 'arm64_preempt_schedule_irq' [-Wmissing-prototypes]
   asmlinkage void __sched arm64_preempt_schedule_irq(void)
                           ^
   arch/arm64/kernel/process.c:692:12: note: declare 'static' if the function is not intended to be used outside of this translation unit
   asmlinkage void __sched arm64_preempt_schedule_irq(void)
              ^
              static 
   4 warnings and 1 error generated.
--
   In file included from arch/arm64/kernel/cpu_errata.c:111:
>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   arch/arm64/kernel/cpu_errata.c:295:13: warning: no previous prototype for function 'arm64_update_smccc_conduit' [-Wmissing-prototypes]
   void __init arm64_update_smccc_conduit(struct alt_instr *alt,
               ^
   arch/arm64/kernel/cpu_errata.c:295:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __init arm64_update_smccc_conduit(struct alt_instr *alt,
   ^
   static 
   arch/arm64/kernel/cpu_errata.c:317:13: warning: no previous prototype for function 'arm64_enable_wa2_handling' [-Wmissing-prototypes]
   void __init arm64_enable_wa2_handling(struct alt_instr *alt,
               ^
   arch/arm64/kernel/cpu_errata.c:317:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __init arm64_enable_wa2_handling(struct alt_instr *alt,
   ^
   static 
   arch/arm64/kernel/cpu_errata.c:747:3: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
                   ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A53, 0, 0, 4),
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:506:2: note: expanded from macro 'ERRATA_MIDR_REV_RANGE'
           ERRATA_MIDR_RANGE(m, var, r_min, var, r_max)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:498:2: note: expanded from macro 'ERRATA_MIDR_RANGE'
           CAP_MIDR_RANGE(model, v_min, r_min, v_max, r_max)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:486:13: note: expanded from macro 'CAP_MIDR_RANGE'
           .matches = is_affected_midr_range,                      \
                      ^~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:746:14: note: previous initialization is here
                   .matches = is_affected_midr_range,
                              ^~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:753:3: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
                   ERRATA_MIDR_REV(MIDR_BRAHMA_B53, 0, 0),
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:510:2: note: expanded from macro 'ERRATA_MIDR_REV'
           ERRATA_MIDR_RANGE(model, var, rev, var, rev)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:498:2: note: expanded from macro 'ERRATA_MIDR_RANGE'
           CAP_MIDR_RANGE(model, v_min, r_min, v_max, r_max)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:486:13: note: expanded from macro 'CAP_MIDR_RANGE'
           .matches = is_affected_midr_range,                      \
                      ^~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:752:14: note: previous initialization is here
                   .matches = is_affected_midr_range,
                              ^~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:938:14: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
                   .matches = needs_tx2_tvm_workaround,
                              ^~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:937:3: note: previous initialization is here
                   ERRATA_MIDR_RANGE_LIST(tx2_family_cpus),
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:520:2: note: expanded from macro 'ERRATA_MIDR_RANGE_LIST'
           CAP_MIDR_RANGE_LIST(midr_list)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/kernel/cpu_errata.c:501:13: note: expanded from macro 'CAP_MIDR_RANGE_LIST'
           .matches = is_affected_midr_range_list,                 \
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~

5 warnings and 1 error generated.
--
In file included from arch/arm64/kernel/smp.c:43:
In file included from arch/arm64/include/asm/kvm_mmu.h:90:

>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   arch/arm64/kernel/smp.c:842:6: warning: no previous prototype for function 'arch_irq_work_raise' [-Wmissing-prototypes]
   void arch_irq_work_raise(void)
        ^
   arch/arm64/kernel/smp.c:842:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void arch_irq_work_raise(void)
   ^
   static 
   arch/arm64/kernel/smp.c:863:6: warning: no previous prototype for function 'panic_smp_self_stop' [-Wmissing-prototypes]
   void panic_smp_self_stop(void)
        ^

arch/arm64/kernel/smp.c:863:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void panic_smp_self_stop(void)
^
static
2 warnings and 1 error generated.
--
In file included from arch/arm64/kernel/suspend.c:14:

>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   arch/arm64/kernel/suspend.c:32:13: warning: no previous prototype for function 'cpu_suspend_set_dbg_restorer' [-Wmissing-prototypes]
   void __init cpu_suspend_set_dbg_restorer(int (*hw_bp_restore)(unsigned int))
               ^

arch/arm64/kernel/suspend.c:32:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void __init cpu_suspend_set_dbg_restorer(int (*hw_bp_restore)(unsigned int))
^
static
1 warning and 1 error generated.
--
In file included from arch/arm64/kernel/machine_kexec.c:21:

>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   arch/arm64/kernel/machine_kexec.c:250:6: warning: no previous prototype for function 'machine_crash_shutdown' [-Wmissing-prototypes]
   void machine_crash_shutdown(struct pt_regs *regs)
        ^

arch/arm64/kernel/machine_kexec.c:250:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void machine_crash_shutdown(struct pt_regs *regs)
^
static
1 warning and 1 error generated.
--
In file included from kernel/fork.c:101:

>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   kernel/fork.c:743:20: warning: no previous prototype for function 'arch_task_cache_init' [-Wmissing-prototypes]
   void __init __weak arch_task_cache_init(void) { }
                      ^
   kernel/fork.c:743:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __init __weak arch_task_cache_init(void) { }
   ^
   static 
   kernel/fork.c:834:12: warning: no previous prototype for function 'arch_dup_task_struct' [-Wmissing-prototypes]
   int __weak arch_dup_task_struct(struct task_struct *dst,
              ^

kernel/fork.c:834:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int __weak arch_dup_task_struct(struct task_struct *dst,
^
static
2 warnings and 1 error generated.
--
In file included from kernel/sched/core.c:13:
In file included from kernel/sched/sched.h:54:
In file included from include/linux/mmu_context.h:5:

>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   kernel/sched/core.c:2380:6: warning: no previous prototype for function 'sched_set_stop_task' [-Wmissing-prototypes]
   void sched_set_stop_task(int cpu, struct task_struct *stop)
        ^
   kernel/sched/core.c:2380:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void sched_set_stop_task(int cpu, struct task_struct *stop)
   ^
   static 
   kernel/sched/core.c:4635:35: warning: no previous prototype for function 'schedule_user' [-Wmissing-prototypes]
   asmlinkage __visible void __sched schedule_user(void)
                                     ^
   kernel/sched/core.c:4635:22: note: declare 'static' if the function is not intended to be used outside of this translation unit
   asmlinkage __visible void __sched schedule_user(void)
                        ^
                        static 

2 warnings and 1 error generated.
--
In file included from kernel/sched/fair.c:23:
In file included from kernel/sched/sched.h:54:
In file included from include/linux/mmu_context.h:5:

>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   kernel/sched/fair.c:5364:6: warning: no previous prototype for function 'init_cfs_bandwidth' [-Wmissing-prototypes]
   void init_cfs_bandwidth(struct cfs_bandwidth *cfs_b) {}
        ^
   kernel/sched/fair.c:5364:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void init_cfs_bandwidth(struct cfs_bandwidth *cfs_b) {}
   ^
   static 
   kernel/sched/fair.c:11108:6: warning: no previous prototype for function 'free_fair_sched_group' [-Wmissing-prototypes]
   void free_fair_sched_group(struct task_group *tg) { }
        ^
   kernel/sched/fair.c:11108:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void free_fair_sched_group(struct task_group *tg) { }
   ^
   static 
   kernel/sched/fair.c:11110:5: warning: no previous prototype for function 'alloc_fair_sched_group' [-Wmissing-prototypes]
   int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent)
       ^
   kernel/sched/fair.c:11110:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent)
   ^
   static 
   kernel/sched/fair.c:11115:6: warning: no previous prototype for function 'online_fair_sched_group' [-Wmissing-prototypes]
   void online_fair_sched_group(struct task_group *tg) { }
        ^
   kernel/sched/fair.c:11115:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void online_fair_sched_group(struct task_group *tg) { }
   ^
   static 
   kernel/sched/fair.c:11117:6: warning: no previous prototype for function 'unregister_fair_sched_group' [-Wmissing-prototypes]
   void unregister_fair_sched_group(struct task_group *tg) { }
        ^

kernel/sched/fair.c:11117:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void unregister_fair_sched_group(struct task_group *tg) { }
^
static
5 warnings and 1 error generated.
--
In file included from kernel/sched/rt.c:6:
In file included from kernel/sched/sched.h:54:
In file included from include/linux/mmu_context.h:5:

>> arch/arm64/include/asm/mmu_context.h:226:31: error: too few arguments to function call, expected 2, have 1
           check_and_switch_context(next);
           ~~~~~~~~~~~~~~~~~~~~~~~~     ^
   arch/arm64/include/asm/mmu_context.h:177:6: note: 'check_and_switch_context' declared here
   void check_and_switch_context(struct mm_struct *mm, unsigned int cpu);
        ^
   kernel/sched/rt.c:253:6: warning: no previous prototype for function 'free_rt_sched_group' [-Wmissing-prototypes]
   void free_rt_sched_group(struct task_group *tg) { }
        ^
   kernel/sched/rt.c:253:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void free_rt_sched_group(struct task_group *tg) { }
   ^
   static 
   kernel/sched/rt.c:255:5: warning: no previous prototype for function 'alloc_rt_sched_group' [-Wmissing-prototypes]
   int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent)
       ^
   kernel/sched/rt.c:255:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent)
   ^
   static 
   kernel/sched/rt.c:668:6: warning: no previous prototype for function 'sched_rt_bandwidth_account' [-Wmissing-prototypes]
   bool sched_rt_bandwidth_account(struct rt_rq *rt_rq)
        ^

kernel/sched/rt.c:668:1: note: declare 'static' if the function is not intended to be used outside of this translation unit bool sched_rt_bandwidth_account(struct rt_rq *rt_rq)
^
static
3 warnings and 1 error generated.

# https://github.com/0day-ci/linux/commit/b7168fc5046fd65223bdc51ef411e157939433b6
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Nicholas-Piggin/Use-asm-generic-for-mmu_context-no-op-functions/20200826-225632 git checkout b7168fc5046fd65223bdc51ef411e157939433b6
vim +226 arch/arm64/include/asm/mmu_context.h

d96cc49bff5a77 Will Deacon     2017-12-06  214  
39bc88e5e38e9b Catalin Marinas 2016-09-02  215  static inline void __switch_mm(struct mm_struct *next)
39bc88e5e38e9b Catalin Marinas 2016-09-02  216  {
e53f21bce4d35a Catalin Marinas 2015-03-23  217  	/*
e53f21bce4d35a Catalin Marinas 2015-03-23  218  	 * init_mm.pgd does not contain any user mappings and it is always
e53f21bce4d35a Catalin Marinas 2015-03-23  219  	 * active for kernel addresses in TTBR1. Just set the reserved TTBR0.
e53f21bce4d35a Catalin Marinas 2015-03-23  220  	 */
e53f21bce4d35a Catalin Marinas 2015-03-23  221  	if (next == &init_mm) {
e53f21bce4d35a Catalin Marinas 2015-03-23  222  		cpu_set_reserved_ttbr0();
e53f21bce4d35a Catalin Marinas 2015-03-23  223  		return;
e53f21bce4d35a Catalin Marinas 2015-03-23  224  	}
e53f21bce4d35a Catalin Marinas 2015-03-23  225  

c4885bbb3afee8 Pingfan Liu 2020-07-10 @226 check_and_switch_context(next);
b3901d54dc4f73 Catalin Marinas 2012-03-05 227 }
b3901d54dc4f73 Catalin Marinas 2012-03-05 228

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

maintainer Acked-by on v2 9/23
#20 lore raw

Re: [PATCH v2 09/23] m68k: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
Quoted 3 lines · Nicholas Piggin

With the below fixed:

Quoted 6 lines
arch/m68k/include/asm/mmu_context.h +0 -0
@@ -79,19 +76,6 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
        set_context(tsk->mm->context, next->pgd);
 }
 

arch/m68k/include/asm/mmu_context.h static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, · line 91

Quoted 10 lines
arch/m68k/include/asm/mmu_context.h +0 -10
-/*
- * After we have set current->mm to a new value, this activates
- * the context for the new mm so we see the new mappings.
- */
-static inline void activate_mm(struct mm_struct *active_mm,
-       struct mm_struct *mm)
-{
-       get_mmu_context(mm);
-       set_context(mm->context, mm->pgd);
-}

Assumed switch_mm() in [PATCH v2 01/23] is revived with the above body.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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
Acked-by on v2 12/23
#31 lore raw

Re: [PATCH v2 12/23] nds32: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin

Nicholas Piggin <[email protected]> 於 2020年8月26日 週三 下午10:53寫道:

Quoted 42 lines
Cc Nick Hu <[email protected]>
Cc Greentime Hu <[email protected]>
Cc Vincent Chen <[email protected]>
---
 arch/nds32/include/asm/mmu_context.h | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
arch/nds32/include/asm/mmu_context.h +1 -6
index b8fd3d189fdc..c651bc8cacdc 100644
@@ -9,6 +9,7 @@
 #include <asm/proc-fns.h>
 #include <asm-generic/mm_hooks.h>
 
+#define init_new_context init_new_context
 static inline int
 init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 {
@@ -16,8 +17,6 @@ init_new_context(struct task_struct *tsk, struct mm_struct *mm)
        return 0;
 }
 
-#define destroy_context(mm)    do { } while(0)
-
 #define CID_BITS       9
 extern spinlock_t cid_lock;
 extern unsigned int cpu_last_cid;
@@ -47,10 +46,6 @@ static inline void check_context(struct mm_struct *mm)
                __new_context(mm);
 }
 
-static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
-{
-}
-
 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
                             struct task_struct *tsk)
 {

arch/nds32/include/asm/mmu_context.h static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, · line 62

Quoted 8 lines
arch/nds32/include/asm/mmu_context.h +1 -2
@@ -62,7 +57,6 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
        }
 }
 
-#define deactivate_mm(tsk,mm)  do { } while (0)
-#define activate_mm(prev,next) switch_mm(prev, next, NULL)
+#include <asm-generic/mmu_context.h>
 
 #endif

Thank you. :)

maintainer Acked-by on v2 15/23
#35 lore raw

Re: [PATCH v2 15/23] parisc: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
Quoted 4 lines · Nicholas Piggin
Cc "James E.J. Bottomley" <[email protected]>
Cc Helge Deller <[email protected]>
Quoted 53 lines
---
 arch/parisc/include/asm/mmu_context.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
arch/parisc/include/asm/mmu_context.h +6 -6
index cb5f2f730421..46f8c22c5977 100644
@@ -7,16 +7,13 @@
 #include <linux/atomic.h>
 #include <asm-generic/mm_hooks.h>
 
-static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
-{
-}
-
 /* on PA-RISC, we actually have enough contexts to justify an allocator
  * for them.  prumpf */
 
 extern unsigned long alloc_sid(void);
 extern void free_sid(unsigned long);
 
+#define init_new_context init_new_context
 static inline int
 init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 {
@@ -26,6 +23,7 @@ init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 	return 0;
 }
 
+#define destroy_context destroy_context
 static inline void
 destroy_context(struct mm_struct *mm)
 {
@@ -71,8 +69,7 @@ static inline void switch_mm(struct mm_struct *prev,
 }
 #define switch_mm_irqs_off switch_mm_irqs_off
 
-#define deactivate_mm(tsk,mm)	do { } while (0)
-
+#define activate_mm activate_mm
 static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
 {
 	/*
@@ -90,4 +87,7 @@ static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
 
 	switch_mm(prev,next,current);
 }
+
+#include <asm-generic/mmu_context.h>
+
 #endif
Acked-by on the v2 series
#47 lore raw
In reply to Nicholas Piggin
Quoted 6 lines · Nicholas Piggin

It would be nice to be able to modify mmu_context functions or add a hook without updating all architectures, many of which will be no-ops.

The motivation for this series is a change to lazy mmu handling, but this series stands on its own as a good cleanup whether or not we end up making that change.

I really like this series, I just have some small comments in reply to patch 1, otherwise feel free to add

Quoted 72 lines

Arnd, is this something you could take through your asm-generic tree? (assuming arch maintainers are okay with it)

Thanks,
Nick

Since v1:
- Added acks and feedback from various people.
- Fixed a nommu build error caught by ktp.
- Dropped unicore32.

Nicholas Piggin (23):
asm-generic: add generic MMU versions of mmu context functions
alpha: use asm-generic/mmu_context.h for no-op implementations
arc: use asm-generic/mmu_context.h for no-op implementations
arm: use asm-generic/mmu_context.h for no-op implementations
arm64: use asm-generic/mmu_context.h for no-op implementations
csky: use asm-generic/mmu_context.h for no-op implementations
hexagon: use asm-generic/mmu_context.h for no-op implementations
ia64: use asm-generic/mmu_context.h for no-op implementations
m68k: use asm-generic/mmu_context.h for no-op implementations
microblaze: use asm-generic/mmu_context.h for no-op implementations
mips: use asm-generic/mmu_context.h for no-op implementations
nds32: use asm-generic/mmu_context.h for no-op implementations
nios2: use asm-generic/mmu_context.h for no-op implementations
openrisc: use asm-generic/mmu_context.h for no-op implementations
parisc: use asm-generic/mmu_context.h for no-op implementations
powerpc: use asm-generic/mmu_context.h for no-op implementations
riscv: use asm-generic/mmu_context.h for no-op implementations
s390: use asm-generic/mmu_context.h for no-op implementations
sh: use asm-generic/mmu_context.h for no-op implementations
sparc: use asm-generic/mmu_context.h for no-op implementations
um: use asm-generic/mmu_context.h for no-op implementations
x86: use asm-generic/mmu_context.h for no-op implementations
xtensa: use asm-generic/mmu_context.h for no-op implementations

 arch/alpha/include/asm/mmu_context.h         | 12 ++---
 arch/arc/include/asm/mmu_context.h           | 17 +++---
 arch/arm/include/asm/mmu_context.h           | 26 ++-------
 arch/arm64/include/asm/mmu_context.h         |  9 ++--
 arch/csky/include/asm/mmu_context.h          |  8 ++-
 arch/hexagon/include/asm/mmu_context.h       | 33 ++----------
 arch/ia64/include/asm/mmu_context.h          | 17 ++----
 arch/m68k/include/asm/mmu_context.h          | 47 +++-------------
 arch/microblaze/include/asm/mmu_context.h    |  2 +-
 arch/microblaze/include/asm/mmu_context_mm.h |  8 +--
 arch/microblaze/include/asm/processor.h      |  3 --
 arch/mips/include/asm/mmu_context.h          | 11 ++--
 arch/nds32/include/asm/mmu_context.h         | 10 +---
 arch/nios2/include/asm/mmu_context.h         | 21 ++------
 arch/openrisc/include/asm/mmu_context.h      |  8 ++-
 arch/parisc/include/asm/mmu_context.h        | 12 ++---
 arch/powerpc/include/asm/mmu_context.h       | 22 +++-----
 arch/riscv/include/asm/mmu_context.h         | 22 +-------
 arch/s390/include/asm/mmu_context.h          |  9 ++--
 arch/sh/include/asm/mmu_context.h            |  7 ++-
 arch/sh/include/asm/mmu_context_32.h         |  9 ----
 arch/sparc/include/asm/mmu_context_32.h      | 10 ++--
 arch/sparc/include/asm/mmu_context_64.h      | 10 ++--
 arch/um/include/asm/mmu_context.h            | 12 ++---
 arch/x86/include/asm/mmu_context.h           |  6 +++
 arch/xtensa/include/asm/mmu_context.h        | 11 ++--
 arch/xtensa/include/asm/nommu_context.h      | 26 +--------
 include/asm-generic/mmu_context.h            | 57 +++++++++++++++-----
 include/asm-generic/nommu_context.h          | 19 +++++++
 29 files changed, 166 insertions(+), 298 deletions(-)
 create mode 100644 include/asm-generic/nommu_context.h
Signature · 1 line
2.23.0
Signature · 2 lines
Sincerely yours,
Mike.
maintainer Acked-by on v2 10/23
#25 lore raw

Re: [PATCH v2 10/23] microblaze: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
Quoted 52 lines · Nicholas Piggin
---
 arch/microblaze/include/asm/mmu_context_mm.h | 8 ++++----
 arch/microblaze/include/asm/processor.h      | 3 ---
 2 files changed, 4 insertions(+), 7 deletions(-)
arch/microblaze/include/asm/mmu_context_mm.h +4 -4
index a1c7dd48454c..c2c77f708455 100644
@@ -33,10 +33,6 @@
    to represent all kernel pages as shared among all contexts.
  */
 
-static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
-{
-}
-
 # define NO_CONTEXT	256
 # define LAST_CONTEXT	255
 # define FIRST_CONTEXT	1
@@ -105,6 +101,7 @@ static inline void get_mmu_context(struct mm_struct *mm)
 /*
  * We're finished using the context for an address space.
  */
+#define destroy_context destroy_context
 static inline void destroy_context(struct mm_struct *mm)
 {
 	if (mm->context != NO_CONTEXT) {
@@ -126,6 +123,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
  * After we have set current->mm to a new value, this activates
  * the context for the new mm so we see the new mappings.
  */
+#define activate_mm activate_mm
 static inline void activate_mm(struct mm_struct *active_mm,
 			struct mm_struct *mm)
 {
@@ -136,5 +134,7 @@ static inline void activate_mm(struct mm_struct *active_mm,
 
 extern void mmu_context_init(void);
 
+#include <asm-generic/mmu_context.h>
+
 # endif /* __KERNEL__ */
 #endif /* _ASM_MICROBLAZE_MMU_CONTEXT_H */
arch/microblaze/include/asm/processor.h +0 -0
index 1ff5a82b76b6..616211871a6e 100644

arch/microblaze/include/asm/processor.h unsigned long get_wchan(struct task_struct *p); · line 127

Quoted 9 lines
arch/microblaze/include/asm/processor.h +0 -3
@@ -122,9 +122,6 @@ unsigned long get_wchan(struct task_struct *p);
 #  define KSTK_EIP(task)	(task_pc(task))
 #  define KSTK_ESP(task)	(task_sp(task))
 
-/* FIXME */
-#  define deactivate_mm(tsk, mm)	do { } while (0)
-
 #  define STACK_TOP	TASK_SIZE
 #  define STACK_TOP_MAX	STACK_TOP
 

I am fine with the patch but I pretty much don't like that commit message is empty and there is only subject.
With fixing that you can add my:

Thanks,
Michal

Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs
author reviewer
#26 lore raw

Re: [PATCH v2 10/23] microblaze: use asm-generic/mmu_context.h for no-op implementations

Excerpts from Michal Simek's message of September 1, 2020 12:15 am:

Quoted 68 lines · Nicholas Piggin
Quoted 52 lines
---
 arch/microblaze/include/asm/mmu_context_mm.h | 8 ++++----
 arch/microblaze/include/asm/processor.h      | 3 ---
 2 files changed, 4 insertions(+), 7 deletions(-)
arch/microblaze/include/asm/mmu_context_mm.h +4 -4
index a1c7dd48454c..c2c77f708455 100644
@@ -33,10 +33,6 @@
    to represent all kernel pages as shared among all contexts.
  */
 
-static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
-{
-}
-
 # define NO_CONTEXT	256
 # define LAST_CONTEXT	255
 # define FIRST_CONTEXT	1
@@ -105,6 +101,7 @@ static inline void get_mmu_context(struct mm_struct *mm)
 /*
  * We're finished using the context for an address space.
  */
+#define destroy_context destroy_context
 static inline void destroy_context(struct mm_struct *mm)
 {
 	if (mm->context != NO_CONTEXT) {
@@ -126,6 +123,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
  * After we have set current->mm to a new value, this activates
  * the context for the new mm so we see the new mappings.
  */
+#define activate_mm activate_mm
 static inline void activate_mm(struct mm_struct *active_mm,
 			struct mm_struct *mm)
 {
@@ -136,5 +134,7 @@ static inline void activate_mm(struct mm_struct *active_mm,
 
 extern void mmu_context_init(void);
 
+#include <asm-generic/mmu_context.h>
+
 # endif /* __KERNEL__ */
 #endif /* _ASM_MICROBLAZE_MMU_CONTEXT_H */
arch/microblaze/include/asm/processor.h +0 -0
index 1ff5a82b76b6..616211871a6e 100644

arch/microblaze/include/asm/processor.h unsigned long get_wchan(struct task_struct *p); · line 127

Quoted 9 lines
arch/microblaze/include/asm/processor.h +0 -3
@@ -122,9 +122,6 @@ unsigned long get_wchan(struct task_struct *p);
 #  define KSTK_EIP(task)	(task_pc(task))
 #  define KSTK_ESP(task)	(task_sp(task))
 
-/* FIXME */
-#  define deactivate_mm(tsk, mm)	do { } while (0)
-
 #  define STACK_TOP	TASK_SIZE
 #  define STACK_TOP_MAX	STACK_TOP
 

I am fine with the patch but I pretty much don't like that commit message is empty and there is only subject.
With fixing that you can add my:

Quoted 1 line

Thanks for the review, will do. Any suggestion for a useful commit message?

Thanks,
Nick

author reviewer
#48 lore raw
In reply to Mike Rapoport

Excerpts from Mike Rapoport's message of August 30, 2020 8:18 pm:

Quoted 12 lines · Nicholas Piggin
Quoted 6 lines

It would be nice to be able to modify mmu_context functions or add a hook without updating all architectures, many of which will be no-ops.

The motivation for this series is a change to lazy mmu handling, but this series stands on its own as a good cleanup whether or not we end up making that change.

I really like this series, I just have some small comments in reply to patch 1, otherwise feel free to add

I can't see your comments in reply to patch 1.

Thanks,
Nick

author reviewer
#21 lore raw

Re: [PATCH v2 09/23] m68k: use asm-generic/mmu_context.h for no-op implementations

In reply to Geert Uytterhoeven

Excerpts from Geert Uytterhoeven's message of August 27, 2020 7:33 pm:

Quoted 14 lines · Nicholas Piggin
Quoted 3 lines

With the below fixed:

Quoted 6 lines
arch/m68k/include/asm/mmu_context.h +0 -0
@@ -79,19 +76,6 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
        set_context(tsk->mm->context, next->pgd);
 }
 
Quoted 12 lines

arch/m68k/include/asm/mmu_context.h static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, · line 91

Quoted 10 lines
arch/m68k/include/asm/mmu_context.h +0 -10
-/*
- * After we have set current->mm to a new value, this activates
- * the context for the new mm so we see the new mappings.
- */
-static inline void activate_mm(struct mm_struct *active_mm,
-       struct mm_struct *mm)
-{
-       get_mmu_context(mm);
-       set_context(mm->context, mm->pgd);
-}

Assumed switch_mm() in [PATCH v2 01/23] is revived with the above body.

I'm not sure what you mean here. We can remove this because it's a copy of switch_mm above, and that's what the new header defaults to if you don't provide an active_mm.

Patch 1 should not have changed that, it should only affect the nommu architectures (and actually didn't touch m68k because it was not using the asm-generic/mmu_context.h header).

Thanks,
Nick

#27 lore raw

Re: [PATCH v2 10/23] microblaze: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
Quoted 71 lines · Nicholas Piggin

Excerpts from Michal Simek's message of September 1, 2020 12:15 am:

Quoted 68 lines · Nicholas Piggin
Quoted 52 lines
---
 arch/microblaze/include/asm/mmu_context_mm.h | 8 ++++----
 arch/microblaze/include/asm/processor.h      | 3 ---
 2 files changed, 4 insertions(+), 7 deletions(-)
arch/microblaze/include/asm/mmu_context_mm.h +4 -4
index a1c7dd48454c..c2c77f708455 100644
@@ -33,10 +33,6 @@
    to represent all kernel pages as shared among all contexts.
  */
 
-static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
-{
-}
-
 # define NO_CONTEXT	256
 # define LAST_CONTEXT	255
 # define FIRST_CONTEXT	1
@@ -105,6 +101,7 @@ static inline void get_mmu_context(struct mm_struct *mm)
 /*
  * We're finished using the context for an address space.
  */
+#define destroy_context destroy_context
 static inline void destroy_context(struct mm_struct *mm)
 {
 	if (mm->context != NO_CONTEXT) {
@@ -126,6 +123,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
  * After we have set current->mm to a new value, this activates
  * the context for the new mm so we see the new mappings.
  */
+#define activate_mm activate_mm
 static inline void activate_mm(struct mm_struct *active_mm,
 			struct mm_struct *mm)
 {
@@ -136,5 +134,7 @@ static inline void activate_mm(struct mm_struct *active_mm,
 
 extern void mmu_context_init(void);
 
+#include <asm-generic/mmu_context.h>
+
 # endif /* __KERNEL__ */
 #endif /* _ASM_MICROBLAZE_MMU_CONTEXT_H */
arch/microblaze/include/asm/processor.h +0 -0
index 1ff5a82b76b6..616211871a6e 100644

arch/microblaze/include/asm/processor.h unsigned long get_wchan(struct task_struct *p); · line 127

Quoted 9 lines
arch/microblaze/include/asm/processor.h +0 -3
@@ -122,9 +122,6 @@ unsigned long get_wchan(struct task_struct *p);
 #  define KSTK_EIP(task)	(task_pc(task))
 #  define KSTK_ESP(task)	(task_sp(task))
 
-/* FIXME */
-#  define deactivate_mm(tsk, mm)	do { } while (0)
-
 #  define STACK_TOP	TASK_SIZE
 #  define STACK_TOP_MAX	STACK_TOP
 

I am fine with the patch but I pretty much don't like that commit message is empty and there is only subject.
With fixing that you can add my:

Quoted 1 line
Quoted 1 line

Thanks for the review, will do. Any suggestion for a useful commit message?

What about?
Wire asm-generic/mmu_context.h to provide generic empty hooks for arch code simplification.

Thanks,
Michal

#3 lore raw

Re: [PATCH v2 01/23] asm-generic: add generic MMU versions of mmu context functions

In reply to Nicholas Piggin
Quoted 65 lines · Nicholas Piggin

Many of these are no-ops on many architectures, so extend mmu_context.h to cover MMU and NOMMU, and split the NOMMU bits out to nommu_context.h

---
 arch/microblaze/include/asm/mmu_context.h |  2 +-
 arch/sh/include/asm/mmu_context.h         |  2 +-
 include/asm-generic/mmu_context.h         | 57 +++++++++++++++++------
 include/asm-generic/nommu_context.h       | 19 ++++++++
 4 files changed, 64 insertions(+), 16 deletions(-)
 create mode 100644 include/asm-generic/nommu_context.h
arch/microblaze/include/asm/mmu_context.h +1 -1
index f74f9da07fdc..34004efb3def 100644
@@ -2,5 +2,5 @@
 #ifdef CONFIG_MMU
 # include <asm/mmu_context_mm.h>
 #else
-# include <asm-generic/mmu_context.h>
+# include <asm-generic/nommu_context.h>
 #endif
arch/sh/include/asm/mmu_context.h +1 -1
index f664e51e8a15..461b1304580b 100644
@@ -133,7 +133,7 @@ static inline void switch_mm(struct mm_struct *prev,
 #define set_TTB(pgd)			do { } while (0)
 #define get_TTB()			(0)
 
-#include <asm-generic/mmu_context.h>
+#include <asm-generic/nommu_context.h>
 
 #endif /* CONFIG_MMU */
 
include/asm-generic/mmu_context.h +10 -4
index 6be9106fb6fb..86cea80a50df 100644
@@ -3,44 +3,73 @@
 #define __ASM_GENERIC_MMU_CONTEXT_H
 
 /*
- * Generic hooks for NOMMU architectures, which do not need to do
- * anything special here.
+ * Generic hooks to implement no-op functionality.
  */
 
-#include <asm-generic/mm_hooks.h>
-
 struct task_struct;
 struct mm_struct;
 
+/*
+ * enter_lazy_tlb - Called when "tsk" is about to enter lazy TLB mode.
+ *
+ * @mm:  the currently active mm context which is becoming lazy
+ * @tsk: task which is entering lazy tlb
+ *
+ * tsk->mm will be NULL
+ */
+#ifndef enter_lazy_tlb

include/asm-generic/mmu_context.h line 30

Quoted 10 lines
include/asm-generic/mmu_context.h +5 -0
 static inline void enter_lazy_tlb(struct mm_struct *mm,
 			struct task_struct *tsk)
 {
 }
+#endif
 
+/**
+ * init_new_context - Initialize context of a new mm_struct.
+ * @tsk: task struct for the mm
+ * @mm:  the new mm struct

'make *docs' will complain here about missing Return: description

include/asm-generic/mmu_context.h line 38

Quoted 8 lines
include/asm-generic/mmu_context.h +3 -0
+ */
+#ifndef init_new_context
 static inline int init_new_context(struct task_struct *tsk,
 			struct mm_struct *mm)
 {
 	return 0;
 }
+#endif

Most architectures have non-trivial init_new_context, maybe this should go into nommu_context.h?

Quoted 75 lines
include/asm-generic/mmu_context.h +25 -10
+/**
+ * destroy_context - Undo init_new_context when the mm is going away
+ * @mm: old mm struct
+ */
+#ifndef destroy_context
 static inline void destroy_context(struct mm_struct *mm)
 {
 }
+#endif
 
-static inline void deactivate_mm(struct task_struct *task,
-			struct mm_struct *mm)
-{
-}
-
-static inline void switch_mm(struct mm_struct *prev,
-			struct mm_struct *next,
-			struct task_struct *tsk)
+/**
+ * activate_mm - called after exec switches the current task to a new mm, to switch to it
+ * @prev_mm: previous mm of this task
+ * @next_mm: new mm
+ */
+#ifndef activate_mm
+static inline void activate_mm(struct mm_struct *prev_mm,
+			       struct mm_struct *next_mm)
 {
+	switch_mm(prev_mm, next_mm, current);
 }
+#endif
 
-static inline void activate_mm(struct mm_struct *prev_mm,
-			       struct mm_struct *next_mm)
+/**
+ * dectivate_mm - called when an mm is released after exit or exec switches away from it
+ * @tsk: the task
+ * @mm:  the old mm
+ */
+#ifndef deactivate_mm
+static inline void deactivate_mm(struct task_struct *tsk,
+			struct mm_struct *mm)
 {
 }
+#endif
 
 #endif /* __ASM_GENERIC_MMU_CONTEXT_H */
include/asm-generic/nommu_context.h new file +19 -0
new file mode 100644
index 000000000000..4f916f9e16cd
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_GENERIC_NOMMU_H
+#define __ASM_GENERIC_NOMMU_H
+
+/*
+ * Generic hooks for NOMMU architectures, which do not need to do
+ * anything special here.
+ */
+#include <asm-generic/mm_hooks.h>
+
+static inline void switch_mm(struct mm_struct *prev,
+			struct mm_struct *next,
+			struct task_struct *tsk)
+{
+}
+
+#include <asm-generic/mmu_context.h>
+
+#endif /* __ASM_GENERIC_NOMMU_H */
Signature · 1 line
2.23.0
Signature · 2 lines
Sincerely yours,
Mike.
#49 lore raw
In reply to Nicholas Piggin
Quoted 9 lines · Nicholas Piggin

Excerpts from Mike Rapoport's message of August 30, 2020 8:18 pm:

Quoted 8 lines · Nicholas Piggin
Quoted 6 lines

It would be nice to be able to modify mmu_context functions or add a hook without updating all architectures, many of which will be no-ops.

The motivation for this series is a change to lazy mmu handling, but this series stands on its own as a good cleanup whether or not we end up making that change.

Quoted 6 lines
Quoted 4 lines

I really like this series, I just have some small comments in reply to patch 1, otherwise feel free to add

I can't see your comments in reply to patch 1.

Hmm, apparently I forgot to hit "Send"...

Quoted 3 lines

Thanks,
Nick

Signature · 2 lines
Sincerely yours,
Mike.
#22 lore raw

Re: [PATCH v2 09/23] m68k: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin

Hi Nick,

Quoted 28 lines · Nicholas Piggin

Excerpts from Geert Uytterhoeven's message of August 27, 2020 7:33 pm:

Quoted 14 lines · Nicholas Piggin
Quoted 3 lines

With the below fixed:

Quoted 6 lines
arch/m68k/include/asm/mmu_context.h +0 -0
@@ -79,19 +76,6 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
        set_context(tsk->mm->context, next->pgd);
 }
 
Quoted 12 lines

arch/m68k/include/asm/mmu_context.h static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, · line 91

Quoted 10 lines
arch/m68k/include/asm/mmu_context.h +0 -10
-/*
- * After we have set current->mm to a new value, this activates
- * the context for the new mm so we see the new mappings.
- */
-static inline void activate_mm(struct mm_struct *active_mm,
-       struct mm_struct *mm)
-{
-       get_mmu_context(mm);
-       set_context(mm->context, mm->pgd);
-}

Assumed switch_mm() in [PATCH v2 01/23] is revived with the above body.

Quoted 3 lines

I'm not sure what you mean here. We can remove this because it's a copy of switch_mm above, and that's what the new header defaults to if you don't provide an active_mm.

IC. I thought it started relying on <asm-generic/mmu_context.h> for this, where you removed switch_mm().

Seems I missed the definition above.

Quoted 3 lines

Patch 1 should not have changed that, it should only affect the nommu architectures (and actually didn't touch m68k because it was not using the asm-generic/mmu_context.h header).

OK. Sorry for the noise.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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
author reviewer
#28 lore raw

Re: [PATCH v2 10/23] microblaze: use asm-generic/mmu_context.h for no-op implementations

In reply to Michal Simek

Excerpts from Michal Simek's message of September 1, 2020 4:41 pm:

Quoted 74 lines · Nicholas Piggin
Quoted 71 lines

Excerpts from Michal Simek's message of September 1, 2020 12:15 am:

Quoted 69 lines · Nicholas Piggin
Quoted 52 lines
---
 arch/microblaze/include/asm/mmu_context_mm.h | 8 ++++----
 arch/microblaze/include/asm/processor.h      | 3 ---
 2 files changed, 4 insertions(+), 7 deletions(-)
arch/microblaze/include/asm/mmu_context_mm.h +4 -4
index a1c7dd48454c..c2c77f708455 100644
@@ -33,10 +33,6 @@
    to represent all kernel pages as shared among all contexts.
  */
 
-static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
-{
-}
-
 # define NO_CONTEXT	256
 # define LAST_CONTEXT	255
 # define FIRST_CONTEXT	1
@@ -105,6 +101,7 @@ static inline void get_mmu_context(struct mm_struct *mm)
 /*
  * We're finished using the context for an address space.
  */
+#define destroy_context destroy_context
 static inline void destroy_context(struct mm_struct *mm)
 {
 	if (mm->context != NO_CONTEXT) {
@@ -126,6 +123,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
  * After we have set current->mm to a new value, this activates
  * the context for the new mm so we see the new mappings.
  */
+#define activate_mm activate_mm
 static inline void activate_mm(struct mm_struct *active_mm,
 			struct mm_struct *mm)
 {
@@ -136,5 +134,7 @@ static inline void activate_mm(struct mm_struct *active_mm,
 
 extern void mmu_context_init(void);
 
+#include <asm-generic/mmu_context.h>
+
 # endif /* __KERNEL__ */
 #endif /* _ASM_MICROBLAZE_MMU_CONTEXT_H */
arch/microblaze/include/asm/processor.h +0 -0
index 1ff5a82b76b6..616211871a6e 100644

arch/microblaze/include/asm/processor.h unsigned long get_wchan(struct task_struct *p); · line 127

Quoted 9 lines
arch/microblaze/include/asm/processor.h +0 -3
@@ -122,9 +122,6 @@ unsigned long get_wchan(struct task_struct *p);
 #  define KSTK_EIP(task)	(task_pc(task))
 #  define KSTK_ESP(task)	(task_sp(task))
 
-/* FIXME */
-#  define deactivate_mm(tsk, mm)	do { } while (0)
-
 #  define STACK_TOP	TASK_SIZE
 #  define STACK_TOP_MAX	STACK_TOP
 

I am fine with the patch but I pretty much don't like that commit message is empty and there is only subject.
With fixing that you can add my:

Quoted 5 lines
Quoted 1 line

Thanks for the review, will do. Any suggestion for a useful commit message?

What about?
Wire asm-generic/mmu_context.h to provide generic empty hooks for arch code simplification.

Sure I'll add it.

Thanks,
Nick

author reviewer
#4 lore raw

Re: [PATCH v2 01/23] asm-generic: add generic MMU versions of mmu context functions

In reply to Mike Rapoport

Excerpts from Mike Rapoport's message of September 1, 2020 4:49 pm:

Quoted 72 lines · Nicholas Piggin
Quoted 71 lines

Many of these are no-ops on many architectures, so extend mmu_context.h to cover MMU and NOMMU, and split the NOMMU bits out to nommu_context.h

---
 arch/microblaze/include/asm/mmu_context.h |  2 +-
 arch/sh/include/asm/mmu_context.h         |  2 +-
 include/asm-generic/mmu_context.h         | 57 +++++++++++++++++------
 include/asm-generic/nommu_context.h       | 19 ++++++++
 4 files changed, 64 insertions(+), 16 deletions(-)
 create mode 100644 include/asm-generic/nommu_context.h
arch/microblaze/include/asm/mmu_context.h +1 -1
index f74f9da07fdc..34004efb3def 100644
@@ -2,5 +2,5 @@
 #ifdef CONFIG_MMU
 # include <asm/mmu_context_mm.h>
 #else
-# include <asm-generic/mmu_context.h>
+# include <asm-generic/nommu_context.h>
 #endif
arch/sh/include/asm/mmu_context.h +1 -1
index f664e51e8a15..461b1304580b 100644
@@ -133,7 +133,7 @@ static inline void switch_mm(struct mm_struct *prev,
 #define set_TTB(pgd)			do { } while (0)
 #define get_TTB()			(0)
 
-#include <asm-generic/mmu_context.h>
+#include <asm-generic/nommu_context.h>
 
 #endif /* CONFIG_MMU */
 
include/asm-generic/mmu_context.h +11 -4
index 6be9106fb6fb..86cea80a50df 100644
@@ -3,44 +3,73 @@
 #define __ASM_GENERIC_MMU_CONTEXT_H
 
 /*
- * Generic hooks for NOMMU architectures, which do not need to do
- * anything special here.
+ * Generic hooks to implement no-op functionality.
  */
 
-#include <asm-generic/mm_hooks.h>
-
 struct task_struct;
 struct mm_struct;
 
+/*
+ * enter_lazy_tlb - Called when "tsk" is about to enter lazy TLB mode.
+ *
+ * @mm:  the currently active mm context which is becoming lazy
+ * @tsk: task which is entering lazy tlb
+ *
+ * tsk->mm will be NULL
+ */
+#ifndef enter_lazy_tlb
 static inline void enter_lazy_tlb(struct mm_struct *mm,
 			struct task_struct *tsk)
 {
 }
+#endif
 
Quoted 6 lines

include/asm-generic/mmu_context.h line 30

Quoted 4 lines
include/asm-generic/mmu_context.h +4 -0
+/**
+ * init_new_context - Initialize context of a new mm_struct.
+ * @tsk: task struct for the mm
+ * @mm:  the new mm struct

'make *docs' will complain here about missing Return: description

Thanks, I added something. Looks like we can't get rid of it, sparc and um can return error. Oh well.

Quoted 11 lines

include/asm-generic/mmu_context.h line 38

Quoted 8 lines
include/asm-generic/mmu_context.h +3 -0
+ */
+#ifndef init_new_context
 static inline int init_new_context(struct task_struct *tsk,
 			struct mm_struct *mm)
 {
 	return 0;
 }
+#endif

Most architectures have non-trivial init_new_context, maybe this should go into nommu_context.h?

Hmm, I guess you could go either way. A few do have no-op functions so I think that qualifies them if the rule is less ambiguous and we provide no-op for functions unless it does not make any sense (e.g., switch_mm for MMU). More importantly I already have the code written and am lazy :)

Thanks,
Nick

reviewer Acked-by on v2 16/23
#37 lore raw

Re: [PATCH v2 16/23] powerpc: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
Quoted 8 lines · Nicholas Piggin
Cc Michael Ellerman <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Paul Mackerras <[email protected]>
---
 arch/powerpc/include/asm/mmu_context.h | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

cheers

Quoted 55 lines
arch/powerpc/include/asm/mmu_context.h +7 -15
index 7f3658a97384..bc22e247ab55 100644
@@ -14,7 +14,9 @@
 /*
  * Most if the context management is out of line
  */
+#define init_new_context init_new_context
 extern int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
+#define destroy_context destroy_context
 extern void destroy_context(struct mm_struct *mm);
 #ifdef CONFIG_SPAPR_TCE_IOMMU
 struct mm_iommu_table_group_mem_t;
@@ -235,27 +237,15 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
 }
 #define switch_mm_irqs_off switch_mm_irqs_off
 
-
-#define deactivate_mm(tsk,mm)	do { } while (0)
-
-/*
- * After we have set current->mm to a new value, this activates
- * the context for the new mm so we see the new mappings.
- */
-static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
-{
-	switch_mm(prev, next, current);
-}
-
-/* We don't currently use enter_lazy_tlb() for anything */
+#ifdef CONFIG_PPC_BOOK3E_64
+#define enter_lazy_tlb enter_lazy_tlb
 static inline void enter_lazy_tlb(struct mm_struct *mm,
 				  struct task_struct *tsk)
 {
 	/* 64-bit Book3E keeps track of current PGD in the PACA */
-#ifdef CONFIG_PPC_BOOK3E_64
 	get_paca()->pgd = NULL;
-#endif
 }
+#endif
 
 extern void arch_exit_mmap(struct mm_struct *mm);
 
@@ -298,5 +288,7 @@ static inline int arch_dup_mmap(struct mm_struct *oldmm,
 	return 0;
 }
 
+#include <asm-generic/mmu_context.h>
+
 #endif /* __KERNEL__ */
 #endif /* __ASM_POWERPC_MMU_CONTEXT_H */
Signature · 1 line
2.23.0
author reviewer
#23 lore raw

Re: [PATCH v2 09/23] m68k: use asm-generic/mmu_context.h for no-op implementations

In reply to Geert Uytterhoeven

Excerpts from Geert Uytterhoeven's message of September 1, 2020 5:03 pm:

Quoted 31 lines

Hi Nick,

Quoted 28 lines · Nicholas Piggin

Excerpts from Geert Uytterhoeven's message of August 27, 2020 7:33 pm:

Quoted 26 lines · Nicholas Piggin
Quoted 3 lines

With the below fixed:

Quoted 6 lines
arch/m68k/include/asm/mmu_context.h +0 -0
@@ -79,19 +76,6 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
        set_context(tsk->mm->context, next->pgd);
 }
 

arch/m68k/include/asm/mmu_context.h static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, · line 91

Quoted 10 lines
arch/m68k/include/asm/mmu_context.h +0 -10
-/*
- * After we have set current->mm to a new value, this activates
- * the context for the new mm so we see the new mappings.
- */
-static inline void activate_mm(struct mm_struct *active_mm,
-       struct mm_struct *mm)
-{
-       get_mmu_context(mm);
-       set_context(mm->context, mm->pgd);
-}

Assumed switch_mm() in [PATCH v2 01/23] is revived with the above body.

Quoted 8 lines
Quoted 3 lines

I'm not sure what you mean here. We can remove this because it's a copy of switch_mm above, and that's what the new header defaults to if you don't provide an active_mm.

IC. I thought it started relying on <asm-generic/mmu_context.h> for this, where you removed switch_mm().

Seems I missed the definition above.

It's supposed to all build incrementally, I'll try to make sure it's right...

Quoted 6 lines
Quoted 4 lines

Patch 1 should not have changed that, it should only affect the nommu architectures (and actually didn't touch m68k because it was not using the asm-generic/mmu_context.h header).

OK. Sorry for the noise.

No problem thanks for looking at it.

Thanks,
Nick

#11 lore raw

Re: [PATCH v2 05/23] arm64: use asm-generic/mmu_context.h for no-op implementations

In reply to Nicholas Piggin
Quoted 8 lines · Nicholas Piggin

Excerpts from Catalin Marinas's message of August 27, 2020 1:25 am:

Quoted 6 lines · Nicholas Piggin
Quoted 4 lines
Quoted 5 lines
Quoted 2 lines

Thank you, I see I stupidly mis-rebased this patch too :( Sorry I'll fix that.

arm64 build error caused due to this patch on linux next 20201027 tag.

make -sk KBUILD_BUILD_USER=TuxBuild -C/linux ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- HOSTCC=gcc CC="sccache aarch64-linux-gnu-gcc" O=build defconfig
#
#
#
set -e
cd /linux
export ARCH=arm64
export HOSTCC=gcc
export CC=gcc
export CROSS_COMPILE=aarch64-linux-gnu- scripts/kconfig/merge_config.sh -O build 'build/.config' 'build/frag.config' #
#

# make -sk KBUILD_BUILD_USER=TuxBuild -C/linux -j16 ARCH=arm64
CROSS_COMPILE=aarch64-linux-gnu- HOSTCC=gcc CC="sccache
aarch64-linux-gnu-gcc" O=build Image
#
In file included from ../arch/arm64/include/asm/mmu_context.h:257,
                 from ../arch/arm64/include/asm/efi.h:10,
                 from ../arch/arm64/xen/../../arm/xen/enlighten.c:19:
../include/asm-generic/mmu_context.h:34:19: error: redefinition of
‘init_new_context’
   34 | static inline int init_new_context(struct task_struct *tsk,
      |                   ^~~~~~~~~~~~~~~~
In file included from ../arch/arm64/include/asm/efi.h:10,
                 from ../arch/arm64/xen/../../arm/xen/enlighten.c:19:
../arch/arm64/include/asm/mmu_context.h:180:1: note: previous
definition of ‘init_new_context’ was here
  180 | init_new_context(struct task_struct *tsk, struct mm_struct *mm)
      | ^~~~~~~~~~~~~~~~
make[3]: *** [../scripts/Makefile.build:283:
arch/arm64/xen/../../arm/xen/enlighten.o] Error 1
In file included from ../arch/arm64/include/asm/mmu_context.h:257,
                 from ../include/linux/mmu_context.h:5,
                 from ../kernel/sched/sched.h:54,
                 from ../kernel/sched/core.c:13:
../include/asm-generic/mmu_context.h:34:19: error: redefinition of
‘init_new_context’
   34 | static inline int init_new_context(struct task_struct *tsk,
      |                   ^~~~~~~~~~~~~~~~
In file included from ../include/linux/mmu_context.h:5,
                 from ../kernel/sched/sched.h:54,
                 from ../kernel/sched/core.c:13:
../arch/arm64/include/asm/mmu_context.h:180:1: note: previous
definition of ‘init_new_context’ was here
  180 | init_new_context(struct task_struct *tsk, struct mm_struct *mm)
      | ^~~~~~~~~~~~~~~~
make[3]: *** [../scripts/Makefile.build:283: kernel/sched/core.o] Error 1

full build log link,
https://gitlab.com/Linaro/lkft/mirrors/next/linux-next/-/jobs/813497297

Signature · 2 lines
Linaro LKFT
https://lkft.linaro.org
maintainer
#12 lore raw

Re: [PATCH v2 05/23] arm64: use asm-generic/mmu_context.h for no-op implementations

Quoted 6 lines · Naresh Kamboju

On Wed, 26 Aug 2020 at 21:50, Nicholas Piggin <[email protected]> wrote:

full build log link,
https://gitlab.com/Linaro/lkft/mirrors/next/linux-next/-/jobs/813497297

Thanks for the report. I added a one-line fix into the original commit, as it was my mistake during rebasing: Nick's version was fine, but 48118151d8cc ("arm64: mm: Pin down ASIDs for sharing mm with devices") turned a macro into an inline function, which makde it no longer override the generic version.

Arnd