All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pgtable: do not expose _refcount field via ptdesc
@ 2023-11-21 12:03 Alexander Gordeev
  2023-11-21 14:47 ` Heiko Carstens
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Gordeev @ 2023-11-21 12:03 UTC (permalink / raw)
  To: Vishal Moola
  Cc: linux-mm, linux-s390, linux-kernel, Gerald Schaefer, Heiko Carstens

Since commit d08d4e7cd6bf ("s390/mm: use full 4KB page for 2KB PTE")
_refcount field is not used for fragmented page tracking on s390 and
there is no other code left that accesses this field explicitly.

Suggested-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
---
 include/linux/mm_types.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 957ce38768b2..0330e0ddca11 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -401,11 +401,10 @@ FOLIO_MATCH(compound_head, _head_2a);
  * @pmd_huge_pte:     Protected by ptdesc->ptl, used for THPs.
  * @__page_mapping:   Aliases with page->mapping. Unused for page tables.
  * @pt_mm:            Used for x86 pgds.
- * @pt_frag_refcount: For fragmented page table tracking. Powerpc and s390 only.
+ * @pt_frag_refcount: For fragmented page table tracking. Powerpc only.
  * @_pt_pad_2:        Padding to ensure proper alignment.
  * @ptl:              Lock for the page table.
  * @__page_type:      Same as page->page_type. Unused for page tables.
- * @_refcount:        Same as page refcount. Used for s390 page tables.
  * @pt_memcg_data:    Memcg data. Tracked for page tables here.
  *
  * This struct overlays struct page for now. Do not modify without a good
@@ -438,7 +437,7 @@ struct ptdesc {
 #endif
 	};
 	unsigned int __page_type;
-	atomic_t _refcount;
+	unsigned int _pt_pad_3;
 #ifdef CONFIG_MEMCG
 	unsigned long pt_memcg_data;
 #endif
@@ -452,7 +451,6 @@ TABLE_MATCH(compound_head, _pt_pad_1);
 TABLE_MATCH(mapping, __page_mapping);
 TABLE_MATCH(rcu_head, pt_rcu_head);
 TABLE_MATCH(page_type, __page_type);
-TABLE_MATCH(_refcount, _refcount);
 #ifdef CONFIG_MEMCG
 TABLE_MATCH(memcg_data, pt_memcg_data);
 #endif
-- 
2.39.2


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

* Re: [PATCH] pgtable: do not expose _refcount field via ptdesc
  2023-11-21 12:03 [PATCH] pgtable: do not expose _refcount field via ptdesc Alexander Gordeev
@ 2023-11-21 14:47 ` Heiko Carstens
  2023-11-21 15:45   ` [PATCH v2] " Alexander Gordeev
  0 siblings, 1 reply; 4+ messages in thread
From: Heiko Carstens @ 2023-11-21 14:47 UTC (permalink / raw)
  To: Alexander Gordeev
  Cc: Vishal Moola, linux-mm, linux-s390, linux-kernel, Gerald Schaefer

On Tue, Nov 21, 2023 at 01:03:10PM +0100, Alexander Gordeev wrote:
> Since commit d08d4e7cd6bf ("s390/mm: use full 4KB page for 2KB PTE")
> _refcount field is not used for fragmented page tracking on s390 and
> there is no other code left that accesses this field explicitly.
> 
> Suggested-by: Heiko Carstens <hca@linux.ibm.com>
> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
> ---
>  include/linux/mm_types.h | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
> index 957ce38768b2..0330e0ddca11 100644
> --- a/include/linux/mm_types.h
> +++ b/include/linux/mm_types.h
> @@ -401,11 +401,10 @@ FOLIO_MATCH(compound_head, _head_2a);
>   * @pmd_huge_pte:     Protected by ptdesc->ptl, used for THPs.
>   * @__page_mapping:   Aliases with page->mapping. Unused for page tables.
>   * @pt_mm:            Used for x86 pgds.
> - * @pt_frag_refcount: For fragmented page table tracking. Powerpc and s390 only.
> + * @pt_frag_refcount: For fragmented page table tracking. Powerpc only.
>   * @_pt_pad_2:        Padding to ensure proper alignment.
>   * @ptl:              Lock for the page table.
>   * @__page_type:      Same as page->page_type. Unused for page tables.
> - * @_refcount:        Same as page refcount. Used for s390 page tables.

I would guess that you need to describe _pt_pad_3 instead here, just
like it is done for the other two pad members.

And most likely you need to add Andrew to "To:" so he doesn't miss
this :)

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

* [PATCH v2] pgtable: do not expose _refcount field via ptdesc
  2023-11-21 14:47 ` Heiko Carstens
@ 2023-11-21 15:45   ` Alexander Gordeev
  2023-11-21 16:46     ` Vishal Moola
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Gordeev @ 2023-11-21 15:45 UTC (permalink / raw)
  To: Heiko Carstens, Andrew Morton
  Cc: Vishal Moola, linux-mm, linux-s390, linux-kernel, Gerald Schaefer

Since commit d08d4e7cd6bf ("s390/mm: use full 4KB page for 2KB PTE")
_refcount field is not used for fragmented page tracking on s390 and
there is no other code left that accesses this field explicitly.

Suggested-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
---
 include/linux/mm_types.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 957ce38768b2..ce0cfc6e4d94 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -401,11 +401,11 @@ FOLIO_MATCH(compound_head, _head_2a);
  * @pmd_huge_pte:     Protected by ptdesc->ptl, used for THPs.
  * @__page_mapping:   Aliases with page->mapping. Unused for page tables.
  * @pt_mm:            Used for x86 pgds.
- * @pt_frag_refcount: For fragmented page table tracking. Powerpc and s390 only.
+ * @pt_frag_refcount: For fragmented page table tracking. Powerpc only.
  * @_pt_pad_2:        Padding to ensure proper alignment.
  * @ptl:              Lock for the page table.
  * @__page_type:      Same as page->page_type. Unused for page tables.
- * @_refcount:        Same as page refcount. Used for s390 page tables.
+ * @_pt_pad_3:        Padding that aliases with page's refcount.
  * @pt_memcg_data:    Memcg data. Tracked for page tables here.
  *
  * This struct overlays struct page for now. Do not modify without a good
@@ -438,7 +438,7 @@ struct ptdesc {
 #endif
 	};
 	unsigned int __page_type;
-	atomic_t _refcount;
+	unsigned int _pt_pad_3;
 #ifdef CONFIG_MEMCG
 	unsigned long pt_memcg_data;
 #endif
@@ -452,7 +452,6 @@ TABLE_MATCH(compound_head, _pt_pad_1);
 TABLE_MATCH(mapping, __page_mapping);
 TABLE_MATCH(rcu_head, pt_rcu_head);
 TABLE_MATCH(page_type, __page_type);
-TABLE_MATCH(_refcount, _refcount);
 #ifdef CONFIG_MEMCG
 TABLE_MATCH(memcg_data, pt_memcg_data);
 #endif
-- 
2.39.2


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

* Re: [PATCH v2] pgtable: do not expose _refcount field via ptdesc
  2023-11-21 15:45   ` [PATCH v2] " Alexander Gordeev
@ 2023-11-21 16:46     ` Vishal Moola
  0 siblings, 0 replies; 4+ messages in thread
From: Vishal Moola @ 2023-11-21 16:46 UTC (permalink / raw)
  To: Alexander Gordeev
  Cc: Heiko Carstens, Andrew Morton, linux-mm, linux-s390,
	linux-kernel, Gerald Schaefer

On Tue, Nov 21, 2023 at 04:45:21PM +0100, Alexander Gordeev wrote:
> Since commit d08d4e7cd6bf ("s390/mm: use full 4KB page for 2KB PTE")
> _refcount field is not used for fragmented page tracking on s390 and
> there is no other code left that accesses this field explicitly.
> 
> Suggested-by: Heiko Carstens <hca@linux.ibm.com>
> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
> ---
>  include/linux/mm_types.h | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
> index 957ce38768b2..ce0cfc6e4d94 100644
> --- a/include/linux/mm_types.h
> +++ b/include/linux/mm_types.h
> @@ -401,11 +401,11 @@ FOLIO_MATCH(compound_head, _head_2a);
>   * @pmd_huge_pte:     Protected by ptdesc->ptl, used for THPs.
>   * @__page_mapping:   Aliases with page->mapping. Unused for page tables.
>   * @pt_mm:            Used for x86 pgds.
> - * @pt_frag_refcount: For fragmented page table tracking. Powerpc and s390 only.
> + * @pt_frag_refcount: For fragmented page table tracking. Powerpc only.
>   * @_pt_pad_2:        Padding to ensure proper alignment.
>   * @ptl:              Lock for the page table.
>   * @__page_type:      Same as page->page_type. Unused for page tables.
> - * @_refcount:        Same as page refcount. Used for s390 page tables.
> + * @_pt_pad_3:        Padding that aliases with page's refcount.

I like updating the documentation, but I'd rather see _refcount renamed
to __page_refcount similar to the other unused page fields. _pt_pad_*
is used for variables that aren't present in struct page (and are
required for padding).

>   * @pt_memcg_data:    Memcg data. Tracked for page tables here.
>   *
>   * This struct overlays struct page for now. Do not modify without a good
> @@ -438,7 +438,7 @@ struct ptdesc {
>  #endif
>  	};
>  	unsigned int __page_type;
> -	atomic_t _refcount;
> +	unsigned int _pt_pad_3;
>  #ifdef CONFIG_MEMCG
>  	unsigned long pt_memcg_data;
>  #endif
> @@ -452,7 +452,6 @@ TABLE_MATCH(compound_head, _pt_pad_1);
>  TABLE_MATCH(mapping, __page_mapping);
>  TABLE_MATCH(rcu_head, pt_rcu_head);
>  TABLE_MATCH(page_type, __page_type);
> -TABLE_MATCH(_refcount, _refcount);

Its still a good idea to keep this check. In the case of !CONFIG_MEMCG,
_refcount is the last variable of ptdesc and if some change were to happen
that caused it to be misaligned we will want to know.

>  #ifdef CONFIG_MEMCG
>  TABLE_MATCH(memcg_data, pt_memcg_data);
>  #endif
> -- 
> 2.39.2
> 
> 

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

end of thread, other threads:[~2023-11-21 16:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-21 12:03 [PATCH] pgtable: do not expose _refcount field via ptdesc Alexander Gordeev
2023-11-21 14:47 ` Heiko Carstens
2023-11-21 15:45   ` [PATCH v2] " Alexander Gordeev
2023-11-21 16:46     ` Vishal Moola

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.