Message ID | 20221021052238.580986-5-bgray@linux.ibm.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Use per-CPU temporary mappings for patching | expand |
On Fri, 2022-10-21 at 16:22 +1100, Benjamin Gray wrote: > Adds a local TLB flush operation that works given an mm_struct, VA to > flush, and page size representation. > > This removes the need to create a vm_area_struct, which the temporary > patching mm work does not need. > > Signed-off-by: Benjamin Gray <bgray@linux.ibm.com> > --- > arch/powerpc/include/asm/book3s/32/tlbflush.h | 9 +++++++++ > arch/powerpc/include/asm/book3s/64/tlbflush-hash.h | 5 +++++ > arch/powerpc/include/asm/book3s/64/tlbflush.h | 8 ++++++++ > arch/powerpc/include/asm/nohash/tlbflush.h | 1 + > 4 files changed, 23 insertions(+) > > diff --git a/arch/powerpc/include/asm/book3s/32/tlbflush.h > b/arch/powerpc/include/asm/book3s/32/tlbflush.h > index ba1743c52b56..e5a688cebf69 100644 > --- a/arch/powerpc/include/asm/book3s/32/tlbflush.h > +++ b/arch/powerpc/include/asm/book3s/32/tlbflush.h > @@ -2,6 +2,8 @@ > #ifndef _ASM_POWERPC_BOOK3S_32_TLBFLUSH_H > #define _ASM_POWERPC_BOOK3S_32_TLBFLUSH_H > > +#include <linux/build_bug.h> > + > #define MMU_NO_CONTEXT (0) > /* > * TLB flushing for "classic" hash-MMU 32-bit CPUs, 6xx, 7xx, 7xxx > @@ -74,6 +76,13 @@ static inline void local_flush_tlb_page(struct > vm_area_struct *vma, > { > flush_tlb_page(vma, vmaddr); > } > + > +static inline void local_flush_tlb_page_psize(struct mm_struct *mm, > unsigned long vmaddr, int psize) > +{ > + BUILD_BUG_ON(psize != MMU_PAGE_4K); Is there any utility in adding this for 32bit if the following patches are only for Radix? > + flush_range(mm, vmaddr, vmaddr + PAGE_SIZE); > +} > + > static inline void local_flush_tlb_mm(struct mm_struct *mm) > { > flush_tlb_mm(mm); > diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h > b/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h > index fab8332fe1ad..8fd9dc49b2a1 100644 > --- a/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h > +++ b/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h > @@ -94,6 +94,11 @@ static inline void > hash__local_flush_tlb_page(struct vm_area_struct *vma, > { > } > > +static inline void hash__local_flush_tlb_page_psize(struct mm_struct > *mm, > + unsigned long > vmaddr, int psize) > +{ > +} > + > static inline void hash__flush_tlb_page(struct vm_area_struct *vma, > unsigned long vmaddr) > { > diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush.h > b/arch/powerpc/include/asm/book3s/64/tlbflush.h > index 67655cd60545..2d839dd5c08c 100644 > --- a/arch/powerpc/include/asm/book3s/64/tlbflush.h > +++ b/arch/powerpc/include/asm/book3s/64/tlbflush.h > @@ -92,6 +92,14 @@ static inline void local_flush_tlb_page(struct > vm_area_struct *vma, > return hash__local_flush_tlb_page(vma, vmaddr); > } > > +static inline void local_flush_tlb_page_psize(struct mm_struct *mm, > + unsigned long vmaddr, > int psize) > +{ > + if (radix_enabled()) > + return radix__local_flush_tlb_page_psize(mm, vmaddr, > psize); > + return hash__local_flush_tlb_page_psize(mm, vmaddr, psize); > +} > + > static inline void local_flush_all_mm(struct mm_struct *mm) > { > if (radix_enabled()) > diff --git a/arch/powerpc/include/asm/nohash/tlbflush.h > b/arch/powerpc/include/asm/nohash/tlbflush.h > index bdaf34ad41ea..59bce0ebdcf4 100644 > --- a/arch/powerpc/include/asm/nohash/tlbflush.h > +++ b/arch/powerpc/include/asm/nohash/tlbflush.h > @@ -58,6 +58,7 @@ static inline void flush_tlb_kernel_range(unsigned > long start, unsigned long end > extern void flush_tlb_kernel_range(unsigned long start, unsigned > long end); > extern void local_flush_tlb_mm(struct mm_struct *mm); > extern void local_flush_tlb_page(struct vm_area_struct *vma, > unsigned long vmaddr); > +extern void local_flush_tlb_page_psize(struct mm_struct *mm, > unsigned long vmaddr, int psize); > > extern void __local_flush_tlb_page(struct mm_struct *mm, unsigned > long vmaddr, > int tsize, int ind);
On Fri, 2022-10-21 at 16:22 +1100, Benjamin Gray wrote: > Adds a local TLB flush operation that works given an mm_struct, VA to > flush, and page size representation. > > This removes the need to create a vm_area_struct, which the temporary > patching mm work does not need. > > Signed-off-by: Benjamin Gray <bgray@linux.ibm.com> > --- > arch/powerpc/include/asm/book3s/32/tlbflush.h | 9 +++++++++ > arch/powerpc/include/asm/book3s/64/tlbflush-hash.h | 5 +++++ > arch/powerpc/include/asm/book3s/64/tlbflush.h | 8 ++++++++ > arch/powerpc/include/asm/nohash/tlbflush.h | 1 + > 4 files changed, 23 insertions(+) > > diff --git a/arch/powerpc/include/asm/book3s/32/tlbflush.h > b/arch/powerpc/include/asm/book3s/32/tlbflush.h > index ba1743c52b56..e5a688cebf69 100644 > --- a/arch/powerpc/include/asm/book3s/32/tlbflush.h > +++ b/arch/powerpc/include/asm/book3s/32/tlbflush.h > @@ -2,6 +2,8 @@ > #ifndef _ASM_POWERPC_BOOK3S_32_TLBFLUSH_H > #define _ASM_POWERPC_BOOK3S_32_TLBFLUSH_H > > +#include <linux/build_bug.h> > + > #define MMU_NO_CONTEXT (0) > /* > * TLB flushing for "classic" hash-MMU 32-bit CPUs, 6xx, 7xx, 7xxx > @@ -74,6 +76,13 @@ static inline void local_flush_tlb_page(struct > vm_area_struct *vma, > { > flush_tlb_page(vma, vmaddr); > } > + > +static inline void local_flush_tlb_page_psize(struct mm_struct *mm, > unsigned long vmaddr, int psize) > +{ > + BUILD_BUG_ON(psize != MMU_PAGE_4K); > + flush_range(mm, vmaddr, vmaddr + PAGE_SIZE); > +} > + > static inline void local_flush_tlb_mm(struct mm_struct *mm) > { > flush_tlb_mm(mm); > diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h > b/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h > index fab8332fe1ad..8fd9dc49b2a1 100644 > --- a/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h > +++ b/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h > @@ -94,6 +94,11 @@ static inline void > hash__local_flush_tlb_page(struct vm_area_struct *vma, > { > } > > +static inline void hash__local_flush_tlb_page_psize(struct mm_struct > *mm, > + unsigned long > vmaddr, int psize) > +{ > +} > + > static inline void hash__flush_tlb_page(struct vm_area_struct *vma, > unsigned long vmaddr) > { > diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush.h > b/arch/powerpc/include/asm/book3s/64/tlbflush.h > index 67655cd60545..2d839dd5c08c 100644 > --- a/arch/powerpc/include/asm/book3s/64/tlbflush.h > +++ b/arch/powerpc/include/asm/book3s/64/tlbflush.h > @@ -92,6 +92,14 @@ static inline void local_flush_tlb_page(struct > vm_area_struct *vma, > return hash__local_flush_tlb_page(vma, vmaddr); > } > > +static inline void local_flush_tlb_page_psize(struct mm_struct *mm, > + unsigned long vmaddr, > int psize) > +{ > + if (radix_enabled()) > + return radix__local_flush_tlb_page_psize(mm, vmaddr, > psize); > + return hash__local_flush_tlb_page_psize(mm, vmaddr, psize); > +} > + > static inline void local_flush_all_mm(struct mm_struct *mm) > { > if (radix_enabled()) > diff --git a/arch/powerpc/include/asm/nohash/tlbflush.h > b/arch/powerpc/include/asm/nohash/tlbflush.h > index bdaf34ad41ea..59bce0ebdcf4 100644 > --- a/arch/powerpc/include/asm/nohash/tlbflush.h > +++ b/arch/powerpc/include/asm/nohash/tlbflush.h > @@ -58,6 +58,7 @@ static inline void flush_tlb_kernel_range(unsigned > long start, unsigned long end > extern void flush_tlb_kernel_range(unsigned long start, unsigned > long end); > extern void local_flush_tlb_mm(struct mm_struct *mm); > extern void local_flush_tlb_page(struct vm_area_struct *vma, > unsigned long vmaddr); > +extern void local_flush_tlb_page_psize(struct mm_struct *mm, > unsigned long vmaddr, int psize); This misses a definition for PPC_8xx which leads to a build failure as found by snowpatch here: https://github.com/ruscur/linux-ci/actions/runs/3295033018/jobs/5433162658#step:4:116 > > extern void __local_flush_tlb_page(struct mm_struct *mm, unsigned > long vmaddr, > int tsize, int ind);
On Mon, 2022-10-24 at 14:30 +1100, Russell Currey wrote: > On Fri, 2022-10-21 at 16:22 +1100, Benjamin Gray wrote: > > Adds a local TLB flush operation that works given an mm_struct, VA > > to > > flush, and page size representation. > > > > This removes the need to create a vm_area_struct, which the > > temporary > > patching mm work does not need. > > > > Signed-off-by: Benjamin Gray <bgray@linux.ibm.com> > > --- > > arch/powerpc/include/asm/book3s/32/tlbflush.h | 9 +++++++++ > > arch/powerpc/include/asm/book3s/64/tlbflush-hash.h | 5 +++++ > > arch/powerpc/include/asm/book3s/64/tlbflush.h | 8 ++++++++ > > arch/powerpc/include/asm/nohash/tlbflush.h | 1 + > > 4 files changed, 23 insertions(+) > > > > diff --git a/arch/powerpc/include/asm/book3s/32/tlbflush.h > > b/arch/powerpc/include/asm/book3s/32/tlbflush.h > > index ba1743c52b56..e5a688cebf69 100644 > > --- a/arch/powerpc/include/asm/book3s/32/tlbflush.h > > +++ b/arch/powerpc/include/asm/book3s/32/tlbflush.h > > @@ -2,6 +2,8 @@ > > #ifndef _ASM_POWERPC_BOOK3S_32_TLBFLUSH_H > > #define _ASM_POWERPC_BOOK3S_32_TLBFLUSH_H > > > > +#include <linux/build_bug.h> > > + > > #define MMU_NO_CONTEXT (0) > > /* > > * TLB flushing for "classic" hash-MMU 32-bit CPUs, 6xx, 7xx, 7xxx > > @@ -74,6 +76,13 @@ static inline void local_flush_tlb_page(struct > > vm_area_struct *vma, > > { > > flush_tlb_page(vma, vmaddr); > > } > > + > > +static inline void local_flush_tlb_page_psize(struct mm_struct > > *mm, > > unsigned long vmaddr, int psize) > > +{ > > + BUILD_BUG_ON(psize != MMU_PAGE_4K); > > Is there any utility in adding this for 32bit if the following > patches > are only for Radix? It needs some kind of definition to avoid #ifdef's. I figured I may as well provide a correct implementation, given the functions around it are implemented. The BUILD_BUG_ON specifically is just defensive in case my assumptions are wrong. I don't know anything about these machines, just what the kernel defines. I can remove the check, or replace the whole implementation with a BUILD_BUG?
diff --git a/arch/powerpc/include/asm/book3s/32/tlbflush.h b/arch/powerpc/include/asm/book3s/32/tlbflush.h index ba1743c52b56..e5a688cebf69 100644 --- a/arch/powerpc/include/asm/book3s/32/tlbflush.h +++ b/arch/powerpc/include/asm/book3s/32/tlbflush.h @@ -2,6 +2,8 @@ #ifndef _ASM_POWERPC_BOOK3S_32_TLBFLUSH_H #define _ASM_POWERPC_BOOK3S_32_TLBFLUSH_H +#include <linux/build_bug.h> + #define MMU_NO_CONTEXT (0) /* * TLB flushing for "classic" hash-MMU 32-bit CPUs, 6xx, 7xx, 7xxx @@ -74,6 +76,13 @@ static inline void local_flush_tlb_page(struct vm_area_struct *vma, { flush_tlb_page(vma, vmaddr); } + +static inline void local_flush_tlb_page_psize(struct mm_struct *mm, unsigned long vmaddr, int psize) +{ + BUILD_BUG_ON(psize != MMU_PAGE_4K); + flush_range(mm, vmaddr, vmaddr + PAGE_SIZE); +} + static inline void local_flush_tlb_mm(struct mm_struct *mm) { flush_tlb_mm(mm); diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h b/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h index fab8332fe1ad..8fd9dc49b2a1 100644 --- a/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h +++ b/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h @@ -94,6 +94,11 @@ static inline void hash__local_flush_tlb_page(struct vm_area_struct *vma, { } +static inline void hash__local_flush_tlb_page_psize(struct mm_struct *mm, + unsigned long vmaddr, int psize) +{ +} + static inline void hash__flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr) { diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush.h b/arch/powerpc/include/asm/book3s/64/tlbflush.h index 67655cd60545..2d839dd5c08c 100644 --- a/arch/powerpc/include/asm/book3s/64/tlbflush.h +++ b/arch/powerpc/include/asm/book3s/64/tlbflush.h @@ -92,6 +92,14 @@ static inline void local_flush_tlb_page(struct vm_area_struct *vma, return hash__local_flush_tlb_page(vma, vmaddr); } +static inline void local_flush_tlb_page_psize(struct mm_struct *mm, + unsigned long vmaddr, int psize) +{ + if (radix_enabled()) + return radix__local_flush_tlb_page_psize(mm, vmaddr, psize); + return hash__local_flush_tlb_page_psize(mm, vmaddr, psize); +} + static inline void local_flush_all_mm(struct mm_struct *mm) { if (radix_enabled()) diff --git a/arch/powerpc/include/asm/nohash/tlbflush.h b/arch/powerpc/include/asm/nohash/tlbflush.h index bdaf34ad41ea..59bce0ebdcf4 100644 --- a/arch/powerpc/include/asm/nohash/tlbflush.h +++ b/arch/powerpc/include/asm/nohash/tlbflush.h @@ -58,6 +58,7 @@ static inline void flush_tlb_kernel_range(unsigned long start, unsigned long end extern void flush_tlb_kernel_range(unsigned long start, unsigned long end); extern void local_flush_tlb_mm(struct mm_struct *mm); extern void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr); +extern void local_flush_tlb_page_psize(struct mm_struct *mm, unsigned long vmaddr, int psize); extern void __local_flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr, int tsize, int ind);
Adds a local TLB flush operation that works given an mm_struct, VA to flush, and page size representation. This removes the need to create a vm_area_struct, which the temporary patching mm work does not need. Signed-off-by: Benjamin Gray <bgray@linux.ibm.com> --- arch/powerpc/include/asm/book3s/32/tlbflush.h | 9 +++++++++ arch/powerpc/include/asm/book3s/64/tlbflush-hash.h | 5 +++++ arch/powerpc/include/asm/book3s/64/tlbflush.h | 8 ++++++++ arch/powerpc/include/asm/nohash/tlbflush.h | 1 + 4 files changed, 23 insertions(+)