s390/mm: Use pmd_pgtable_page() helper in __gmap_segment_gaddr()
Subsystems (5)
PATCH 1/1 s390/mm: Use pmd_pgtable_page() helper in __gmap_segment_gaddr()
In __gmap_segment_gaddr() pmd level page table page is being extracted from the pmd pointer, similar to pmd_pgtable_page() implementation. This reduces some redundancy by directly using pmd_pgtable_page() instead, though first making it available.
---
This applies on v6.1-rc6 but after the following patch. Build tested for s390 plaform (defconfig).
https://lore.kernel.org/all/[email protected]/
arch/s390/mm/gmap.c | 5 ++--- include/linux/mm.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-)
arch/s390/mm/gmap.c +2 -3
@@ -336,12 +336,11 @@ static int gmap_alloc_table(struct gmap *gmap, unsigned long *table,static unsigned long __gmap_segment_gaddr (unsigned long *entry) {struct page *page; -unsigned long offset, mask; +unsigned long offset; offset = (unsigned long ) entry /sizeof (unsigned long ); offset = (offset & (PTRS_PER_PMD -1 )) *PMD_SIZE ; - mask = ~(PTRS_PER_PMD *sizeof (pmd_t) -1 ); - page =virt_to_page ((void *)((unsigned long ) entry & mask)); + page =pmd_pgtable_page ((pmd_t *) entry);return page->index + offset; }
include/linux/mm.h +1 -1
@@ -2403,7 +2403,7 @@ static inline void pgtable_pte_page_dtor(struct page *page)#if USE_SPLIT_PMD_PTLOCKS -static struct page *pmd_pgtable_page (pmd_t *pmd) +static inline struct page *pmd_pgtable_page (pmd_t *pmd) {unsigned long mask = ~(PTRS_PER_PMD *sizeof (pmd_t) -1 );return virt_to_page ((void *)((unsigned long ) pmd & mask));
Signature · 1 line
2.25.1
Alexander Gordeev
maintainerOn Fri, Nov 25, 2022 at 09:15:02AM +0530, Anshuman Khandual wrote:
Hi Anshuman,
Quoted 4 lines
In
__gmap_segment_gaddr()pmd level page table page is being extracted from the pmd pointer, similar topmd_pgtable_page()implementation. This reduces some redundancy by directly usingpmd_pgtable_page()instead, though first making it available.
[...]
Quoted 8 lines
arch/s390/mm/gmap.c +0
-0@@ -336,12 +336,11 @@ static int gmap_alloc_table(struct gmap *gmap, unsigned long *table,static unsigned long __gmap_segment_gaddr (unsigned long *entry) {struct page *page;
arch/s390/mm/gmap.c static int gmap_alloc_table(struct gmap *gmap, unsigned long *table, · line 345
Quoted 10 lines
arch/s390/mm/gmap.c +2
-3-unsigned long offset, mask; +unsigned long offset; offset = (unsigned long ) entry /sizeof (unsigned long ); offset = (offset & (PTRS_PER_PMD -1 )) *PMD_SIZE ; - mask = ~(PTRS_PER_PMD *sizeof (pmd_t) -1 ); - page =virt_to_page ((void *)((unsigned long ) entry & mask)); + page =pmd_pgtable_page ((pmd_t *) entry);return page->index + offset; }
Looks okay to me.
include/linux/mm.h static inline void pgtable_pte_page_dtor(struct page *page) · line 2409
Quoted 13 lines
include/linux/mm.h +1
-1@@ -2403,7 +2403,7 @@ static inline void pgtable_pte_page_dtor(struct page *page)#if USE_SPLIT_PMD_PTLOCKS -static struct page *pmd_pgtable_page (pmd_t *pmd) +static inline struct page *pmd_pgtable_page (pmd_t *pmd) {unsigned long mask = ~(PTRS_PER_PMD *sizeof (pmd_t) -1 );return virt_to_page ((void *)((unsigned long ) pmd & mask));
This chunk does not appear to belong to this patch.
Thanks!
Quoted 40 lines · Alexander Gordeev
On Fri, Nov 25, 2022 at 09:15:02AM +0530, Anshuman Khandual wrote:
Hi Anshuman,
Quoted 4 lines
In
__gmap_segment_gaddr()pmd level page table page is being extracted from the pmd pointer, similar topmd_pgtable_page()implementation. This reduces some redundancy by directly usingpmd_pgtable_page()instead, though first making it available.[...]
Quoted 8 lines
arch/s390/mm/gmap.c +0
-0@@ -336,12 +336,11 @@ static int gmap_alloc_table(struct gmap *gmap, unsigned long *table,static unsigned long __gmap_segment_gaddr (unsigned long *entry) {struct page *page;arch/s390/mm/gmap.c static int gmap_alloc_table(struct gmap *gmap, unsigned long *table, · line 345
Quoted 10 lines
arch/s390/mm/gmap.c +2
-3-unsigned long offset, mask; +unsigned long offset; offset = (unsigned long ) entry /sizeof (unsigned long ); offset = (offset & (PTRS_PER_PMD -1 )) *PMD_SIZE ; - mask = ~(PTRS_PER_PMD *sizeof (pmd_t) -1 ); - page =virt_to_page ((void *)((unsigned long ) entry & mask)); + page =pmd_pgtable_page ((pmd_t *) entry);return page->index + offset; }Looks okay to me.
Quoted 8 lines
include/linux/mm.h +0
-0@@ -2403,7 +2403,7 @@ static inline void pgtable_pte_page_dtor(struct page *page)#if USE_SPLIT_PMD_PTLOCKS
Quoted 7 lines
include/linux/mm.h static inline void pgtable_pte_page_dtor(struct page *page) · line 2409
Quoted 5 lines
include/linux/mm.h +1
-1-static struct page *pmd_pgtable_page (pmd_t *pmd) +static inline struct page *pmd_pgtable_page (pmd_t *pmd) {unsigned long mask = ~(PTRS_PER_PMD *sizeof (pmd_t) -1 );return virt_to_page ((void *)((unsigned long ) pmd & mask));This chunk does not appear to belong to this patch.
Should not this helper be made a 'static inline' before using it else where ?
Alexander Gordeev
maintainerQuoted 16 lines · Anshuman Khandual
Quoted 8 lines
Quoted 8 lines
include/linux/mm.h +0
-0@@ -2403,7 +2403,7 @@ static inline void pgtable_pte_page_dtor(struct page *page)#if USE_SPLIT_PMD_PTLOCKS Quoted 7 lines
include/linux/mm.h static inline void pgtable_pte_page_dtor(struct page *page) · line 2409
Quoted 5 lines
include/linux/mm.h +1
-1-static struct page *pmd_pgtable_page (pmd_t *pmd) +static inline struct page *pmd_pgtable_page (pmd_t *pmd) {unsigned long mask = ~(PTRS_PER_PMD *sizeof (pmd_t) -1 );return virt_to_page ((void *)((unsigned long ) pmd & mask));This chunk does not appear to belong to this patch.
Quoted 1 line
Should not this helper be made a 'static inline' before using it else where ?
Probably yes, but it is not kvm s390-specific change.
I guess, you wanted to make it together or as a follow-up to this one?
https://lore.kernel.org/all/[email protected]/
Quoted 17 lines · Alexander Gordeev
Quoted 16 lines · Anshuman Khandual
Quoted 15 lines
include/linux/mm.h static inline void pgtable_pte_page_dtor(struct page *page) · line 2409
Quoted 13 lines
include/linux/mm.h +1
-1@@ -2403,7 +2403,7 @@ static inline void pgtable_pte_page_dtor(struct page *page)#if USE_SPLIT_PMD_PTLOCKS -static struct page *pmd_pgtable_page (pmd_t *pmd) +static inline struct page *pmd_pgtable_page (pmd_t *pmd) {unsigned long mask = ~(PTRS_PER_PMD *sizeof (pmd_t) -1 );return virt_to_page ((void *)((unsigned long ) pmd & mask));This chunk does not appear to belong to this patch.
Quoted 3 lines
Quoted 1 line
Should not this helper be made a 'static inline' before using it else where ?
Probably yes, but it is not kvm s390-specific change.
Right, just that the s390 change here is the first instance where this helper is being used outside the header, hence kept them together.
Quoted 4 lines
I guess, you wanted to make it together or as a follow-up to this one?
https://lore.kernel.org/all/[email protected]/
Unless too much trouble, could we just keep it here as proposed.
Quoted 19 lines · Anshuman Khandual
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
include/linux/mm.h static inline void pgtable_pte_page_dtor(struct page *page) · line 2409
Quoted 12 lines
index
e9e387caffac..5ead9e997510100644include/linux/mm.h +1
-1@@ -2403,7 +2403,7 @@ static inline void pgtable_pte_page_dtor(struct page *page)#if USE_SPLIT_PMD_PTLOCKS -static struct page *pmd_pgtable_page (pmd_t *pmd) +static inline struct page *pmd_pgtable_page (pmd_t *pmd) {unsigned long mask = ~(PTRS_PER_PMD *sizeof (pmd_t) -1 );return virt_to_page ((void *)((unsigned long ) pmd & mask));This chunk does not appear to belong to this patch.
Quoted 3 lines
Quoted 1 line
Should not this helper be made a 'static inline' before using it else where ?
Probably yes, but it is not kvm s390-specific change.
Quoted 8 lines
Right, just that the s390 change here is the first instance where this helper is being used outside the header, hence kept them together.
Quoted 4 lines
I guess, you wanted to make it together or as a follow-up to this one?
https://lore.kernel.org/all/[email protected]/Unless too much trouble, could we just keep it here as proposed.
For s390 part:
Thanks!