arm64 changes its kernel page tables in lazy MMU mode, so that a request pays for one set of barriers for a range rather than one for every entry it writes.
The core cannot enter lazy MMU mode by itself. On powerpc with the hash MMU that disables preemption, and a CPA request may sleep. Call arch_cpa_enter() and arch_cpa_leave() around the request of the generic set_memory_*() and set_direct_map_*_noflush(). They do nothing by default. arm64 will use them to enable lazy MMU mode when it switches to the core. Signed-off-by: Mike Rapoport (Microsoft) <[email protected]> --- include/linux/pageattr.h | 12 ++++++++++++ mm/pageattr.c | 12 ++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/include/linux/pageattr.h b/include/linux/pageattr.h index 1a4e7c5dca98..a2a7235a633e 100644 --- a/include/linux/pageattr.h +++ b/include/linux/pageattr.h @@ -171,4 +171,16 @@ static inline void cpa_init_op(struct cpa_data *cpa, int arch_cpa_prepare(struct cpa_data *cpa, enum cpa_op op); +#ifndef arch_cpa_enter +static inline void arch_cpa_enter(void) +{ +} +#endif + +#ifndef arch_cpa_leave +static inline void arch_cpa_leave(void) +{ +} +#endif + #endif /* _LINUX_PAGEATTR_H */ diff --git a/mm/pageattr.c b/mm/pageattr.c index 555e55e7ecea..d8ca8fb9bdd1 100644 --- a/mm/pageattr.c +++ b/mm/pageattr.c @@ -615,7 +615,11 @@ static int set_memory_op(unsigned long addr, int numpages, enum cpa_op op) !(cpa.flags & CPA_REQ_SPLIT)) return 0; - return change_page_attr(&cpa); + arch_cpa_enter(); + ret = change_page_attr(&cpa); + arch_cpa_leave(); + + return ret; } int set_memory_x(unsigned long addr, int numpages) @@ -661,7 +665,11 @@ static int set_direct_map(struct page *page, unsigned int nr, enum cpa_op op) * set_direct_map_*_noflush() change only the direct map, not its * aliases. */ - return change_page_attr_noflush(&cpa); + arch_cpa_enter(); + ret = change_page_attr_noflush(&cpa); + arch_cpa_leave(); + + return ret; } int set_direct_map_invalid_noflush(struct page *page, unsigned int nr) -- 2.53.0
