Commit 7e25de77 authored by Anshuman Khandual's avatar Anshuman Khandual Committed by Andrew Morton

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.

Link: https://lkml.kernel.org/r/20221125034502.1559986-1-anshuman.khandual@arm.comSigned-off-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
Acked-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 373dfda2
...@@ -336,12 +336,11 @@ static int gmap_alloc_table(struct gmap *gmap, unsigned long *table, ...@@ -336,12 +336,11 @@ static int gmap_alloc_table(struct gmap *gmap, unsigned long *table,
static unsigned long __gmap_segment_gaddr(unsigned long *entry) static unsigned long __gmap_segment_gaddr(unsigned long *entry)
{ {
struct page *page; struct page *page;
unsigned long offset, mask; unsigned long offset;
offset = (unsigned long) entry / sizeof(unsigned long); offset = (unsigned long) entry / sizeof(unsigned long);
offset = (offset & (PTRS_PER_PMD - 1)) * PMD_SIZE; offset = (offset & (PTRS_PER_PMD - 1)) * PMD_SIZE;
mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1); page = pmd_pgtable_page((pmd_t *) entry);
page = virt_to_page((void *)((unsigned long) entry & mask));
return page->index + offset; return page->index + offset;
} }
......
...@@ -2510,7 +2510,7 @@ static inline void pgtable_pte_page_dtor(struct page *page) ...@@ -2510,7 +2510,7 @@ static inline void pgtable_pte_page_dtor(struct page *page)
#if USE_SPLIT_PMD_PTLOCKS #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); unsigned long mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1);
return virt_to_page((void *)((unsigned long) pmd & mask)); return virt_to_page((void *)((unsigned long) pmd & mask));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment