linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/pgtable: Move extern zero_pfn outside __HAVE_COLOR_ZERO_PAGE
@ 2020-06-16  4:08 Anshuman Khandual
  2020-06-16  5:24 ` Anshuman Khandual
  2020-06-16  7:39 ` David Hildenbrand
  0 siblings, 2 replies; 5+ messages in thread
From: Anshuman Khandual @ 2020-06-16  4:08 UTC (permalink / raw)
  To: linux-mm; +Cc: Anshuman Khandual, Arnd Bergmann, linux-arch, linux-kernel

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.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arch@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
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(-)

diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index 32b6c52d41b9..078e9864abca 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -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_PAGE
 static 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
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/pgtable: Move extern zero_pfn outside __HAVE_COLOR_ZERO_PAGE
  2020-06-16  4:08 [PATCH] mm/pgtable: Move extern zero_pfn outside __HAVE_COLOR_ZERO_PAGE Anshuman Khandual
@ 2020-06-16  5:24 ` Anshuman Khandual
  2020-06-16  7:39 ` David Hildenbrand
  1 sibling, 0 replies; 5+ messages in thread
From: Anshuman Khandual @ 2020-06-16  5:24 UTC (permalink / raw)
  To: linux-mm
  Cc: Arnd Bergmann, linux-arch, linux-kernel, Andrew Morton,
	Mike Rapoport, Kirill A . Shutemov

On 06/16/2020 09:38 AM, Anshuman Khandual wrote:
> 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.
> 
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: linux-arch@vger.kernel.org
> Cc: linux-mm@kvack.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
> 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(-)
> 
> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
> index 32b6c52d41b9..078e9864abca 100644
> --- a/include/linux/pgtable.h
> +++ b/include/linux/pgtable.h
> @@ -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_PAGE
>  static 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
> 

The CC list is incomplete. Adding Andrew, Mike and Kirill.

+Cc: Andrew Morton <akpm@linux-foundation.org>
+Cc: Mike Rapoport <rppt@linux.ibm.com>
+Cc: Kirill A . Shutemov <kirill.shutemov@linux.intel.com>

Will update the CC list next time around.

- Anshuman


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/pgtable: Move extern zero_pfn outside __HAVE_COLOR_ZERO_PAGE
  2020-06-16  4:08 [PATCH] mm/pgtable: Move extern zero_pfn outside __HAVE_COLOR_ZERO_PAGE Anshuman Khandual
  2020-06-16  5:24 ` Anshuman Khandual
@ 2020-06-16  7:39 ` David Hildenbrand
  2020-06-16  9:48   ` Anshuman Khandual
  1 sibling, 1 reply; 5+ messages in thread
From: David Hildenbrand @ 2020-06-16  7:39 UTC (permalink / raw)
  To: Anshuman Khandual, linux-mm; +Cc: Arnd Bergmann, linux-arch, linux-kernel

On 16.06.20 06:08, Anshuman Khandual wrote:
> zero_pfn variable is required whether __HAVE_COLOR_ZERO_PAGE is enabled

Why is that relevant for this patch?

> 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.

> 
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: linux-arch@vger.kernel.org
> Cc: linux-mm@kvack.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
> 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(-)
> 
> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
> index 32b6c52d41b9..078e9864abca 100644
> --- a/include/linux/pgtable.h
> +++ b/include/linux/pgtable.h
> @@ -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_PAGE
>  static 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
> 


-- 
Thanks,

David / dhildenb



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/pgtable: Move extern zero_pfn outside __HAVE_COLOR_ZERO_PAGE
  2020-06-16  7:39 ` David Hildenbrand
@ 2020-06-16  9:48   ` Anshuman Khandual
  2020-06-16 10:04     ` David Hildenbrand
  0 siblings, 1 reply; 5+ messages in thread
From: Anshuman Khandual @ 2020-06-16  9:48 UTC (permalink / raw)
  To: David Hildenbrand, linux-mm; +Cc: Arnd Bergmann, linux-arch, linux-kernel



On 06/16/2020 01:09 PM, David Hildenbrand wrote:
> On 16.06.20 06:08, Anshuman Khandual wrote:
>> zero_pfn variable is required whether __HAVE_COLOR_ZERO_PAGE is enabled
> 
> Why is that relevant for this patch?

That just states how it is organized right now wrt __HAVE_COLOR_ZERO_PAGE.

> 
>> 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.

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.

> 
> 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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/pgtable: Move extern zero_pfn outside __HAVE_COLOR_ZERO_PAGE
  2020-06-16  9:48   ` Anshuman Khandual
@ 2020-06-16 10:04     ` David Hildenbrand
  0 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2020-06-16 10:04 UTC (permalink / raw)
  To: Anshuman Khandual, linux-mm; +Cc: Arnd Bergmann, linux-arch, linux-kernel

On 16.06.20 11:48, Anshuman Khandual wrote:
> 
> 
> On 06/16/2020 01:09 PM, David Hildenbrand wrote:
>> On 16.06.20 06:08, Anshuman Khandual wrote:
>>> zero_pfn variable is required whether __HAVE_COLOR_ZERO_PAGE is enabled
>>
>> Why is that relevant for this patch?
> 
> That just states how it is organized right now wrt __HAVE_COLOR_ZERO_PAGE.
> 
>>
>>> 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.
> 
> 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.
> 
>>
>> 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.
> 

... or just leave it as is and have self-documenting code.

-- 
Thanks,

David / dhildenb



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-06-16 10:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-16  4:08 [PATCH] mm/pgtable: Move extern zero_pfn outside __HAVE_COLOR_ZERO_PAGE Anshuman Khandual
2020-06-16  5:24 ` Anshuman Khandual
2020-06-16  7:39 ` David Hildenbrand
2020-06-16  9:48   ` Anshuman Khandual
2020-06-16 10:04     ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).