mm/pgtable: Move extern zero_pfn outside __HAVE_COLOR_ZERO_PAGE
Subsystems (3)
PATCH 1/1 mm/pgtable: Move extern zero_pfn outside __HAVE_COLOR_ZERO_PAGE
zero_pfn variable is required whether __HAVE_COLOR_ZERO_PAGE is enabled or not. Also it should not really be declared individually in all functions where it gets used. Just move the declaration outside, which also makes it available for other potential users.
---
Applies on 5.8-rc1. If the earlier motivation was to hide zero_pfn from general visibility, we could just put in a comment and update the commit message that my_zero_pfn() should always be used rather than zero_pfn. Build tested on many platforms and boot tested on arm64, x86.
include/linux/pgtable.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
include/linux/pgtable.h +2 -3
@@ -1020,10 +1020,11 @@ extern void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn,extern void untrack_pfn_moved (struct vm_area_struct *vma);#endif +extern unsigned long zero_pfn; +#ifdef __HAVE_COLOR_ZERO_PAGEstatic inline int is_zero_pfn (unsigned long pfn) { -extern unsigned long zero_pfn;unsigned long offset_from_zero_pfn = pfn - zero_pfn;return offset_from_zero_pfn <= (zero_page_mask >>PAGE_SHIFT ); }
@@ -1033,13 +1034,11 @@ static inline int is_zero_pfn(unsigned long pfn)#else static inline int is_zero_pfn (unsigned long pfn) { -extern unsigned long zero_pfn;return pfn == zero_pfn; }static inline unsigned long my_zero_pfn (unsigned long addr) { -extern unsigned long zero_pfn;return zero_pfn; }#endif
Signature · 1 line
2.20.1
Quoted 41 lines · Anshuman Khandual
zero_pfnvariable is required whether__HAVE_COLOR_ZERO_PAGEis enabled or not. Also it should not really be declared individually in all functions where it gets used. Just move the declaration outside, which also makes it available for other potential users.Cc Arnd Bergmann <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>---
Applies on 5.8-rc1. If the earlier motivation was to hidezero_pfnfrom general visibility, we could just put in a comment and update the commit message thatmy_zero_pfn()should always be used rather thanzero_pfn. Build tested on many platforms and boot tested on arm64, x86.include/linux/pgtable.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)include/linux/pgtable.h +2
-1@@ -1020,10 +1020,11 @@ extern void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn,extern void untrack_pfn_moved (struct vm_area_struct *vma);#endif +extern unsigned long zero_pfn; +#ifdef __HAVE_COLOR_ZERO_PAGEstatic inline int is_zero_pfn (unsigned long pfn) { -extern unsigned long zero_pfn;unsigned long offset_from_zero_pfn = pfn - zero_pfn;return offset_from_zero_pfn <= (zero_page_mask >>PAGE_SHIFT ); }@@ -1033,13 +1034,11 @@ static inline int is_zero_pfn(unsigned long pfn)#else static inline int is_zero_pfn (unsigned long pfn) {
include/linux/pgtable.h static inline int is_zero_pfn(unsigned long pfn) · line 1044
Quoted 10 lines
include/linux/pgtable.h +0
-2-extern unsigned long zero_pfn; return pfn == zero_pfn; }static inline unsigned long my_zero_pfn (unsigned long addr) { -extern unsigned long zero_pfn;return zero_pfn; }#endif
The CC list is incomplete. Adding Andrew, Mike and Kirill.
+Cc: Andrew Morton <[email protected]> +Cc: Mike Rapoport <[email protected]>
+Cc: Kirill A . Shutemov <[email protected]>
Will update the CC list next time around.
- Anshuman
Quoted 1 line · Anshuman Khandual
zero_pfnvariable is required whether__HAVE_COLOR_ZERO_PAGEis enabled
Why is that relevant for this patch?
Quoted 3 lines
or not. Also it should not really be declared individually in all functions where it gets used. Just move the declaration outside, which also makes it available for other potential users.
So, all you're essentially doing is exposing zero_pfn in pgtable.h now.
If everybody should just use my_zero_pfn(), I don't really see the benefit of this patch, sorry.
Quoted 47 lines
Cc Arnd Bergmann <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>---
Applies on 5.8-rc1. If the earlier motivation was to hidezero_pfnfrom general visibility, we could just put in a comment and update the commit message thatmy_zero_pfn()should always be used rather thanzero_pfn. Build tested on many platforms and boot tested on arm64, x86.include/linux/pgtable.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)include/linux/pgtable.h +2
-3@@ -1020,10 +1020,11 @@ extern void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn,extern void untrack_pfn_moved (struct vm_area_struct *vma);#endif +extern unsigned long zero_pfn; +#ifdef __HAVE_COLOR_ZERO_PAGEstatic inline int is_zero_pfn (unsigned long pfn) { -extern unsigned long zero_pfn;unsigned long offset_from_zero_pfn = pfn - zero_pfn;return offset_from_zero_pfn <= (zero_page_mask >>PAGE_SHIFT ); }@@ -1033,13 +1034,11 @@ static inline int is_zero_pfn(unsigned long pfn)#else static inline int is_zero_pfn (unsigned long pfn) { -extern unsigned long zero_pfn;return pfn == zero_pfn; }static inline unsigned long my_zero_pfn (unsigned long addr) { -extern unsigned long zero_pfn;return zero_pfn; }#endif
Signature · 3 lines
Thanks, David / dhildenb
Quoted 4 lines · David Hildenbrand
Quoted 1 line · Anshuman Khandual
zero_pfnvariable is required whether__HAVE_COLOR_ZERO_PAGEis enabledWhy is that relevant for this patch?
That just states how it is organized right now wrt __HAVE_COLOR_ZERO_PAGE.
Quoted 6 lines
Quoted 4 lines
or not. Also it should not really be declared individually in all functions where it gets used. Just move the declaration outside, which also makes it available for other potential users.
So, all you're essentially doing is exposing
zero_pfninpgtable.hnow.
Right, but it just happens in the process of consolidating three different instances of 'extern unsigned long zero_pfn' in the same file which are redundant.
Quoted 3 lines
If everybody should just use
my_zero_pfn(), I don't really see the benefit of this patch, sorry.
It consolidates redundant declarations and reduces code. We could just have a comment for zero_pfn stating that it should not be used directly.
Quoted 22 lines · Anshuman Khandual
Quoted 4 lines · David Hildenbrand
Quoted 1 line · Anshuman Khandual
zero_pfnvariable is required whether__HAVE_COLOR_ZERO_PAGEis enabledWhy is that relevant for this patch?
That just states how it is organized right now wrt
__HAVE_COLOR_ZERO_PAGE.Quoted 6 lines
Quoted 4 lines
or not. Also it should not really be declared individually in all functions where it gets used. Just move the declaration outside, which also makes it available for other potential users.
So, all you're essentially doing is exposing
zero_pfninpgtable.hnow.Right, but it just happens in the process of consolidating three different instances of 'extern unsigned long
zero_pfn' in the same file which are redundant.Quoted 1 line
Quoted 6 lines
Quoted 2 lines
If everybody should just use
my_zero_pfn(), I don't really see the benefit of this patch, sorry.It consolidates redundant declarations and reduces code. We could just have a comment for
zero_pfnstating that it should not be used directly.
... or just leave it as is and have self-documenting code.
Signature · 3 lines
Thanks, David / dhildenb