Skip to content

Commit f724392

Browse files
Hugh Dickinsakpm00
authored andcommitted
hugetlb: pte_alloc_huge() to replace huge pte_alloc_map()
Some architectures can have their hugetlb pages down at the lowest PTE level: their huge_pte_alloc() using pte_alloc_map(), but without any following pte_unmap(). Since none of these arches uses CONFIG_HIGHPTE, this is not seen as a problem at present; but would become a problem if forthcoming changes were to add an rcu_read_lock() into pte_offset_map(), with the rcu_read_unlock() expected in pte_unmap(). Similarly in their huge_pte_offset(): pte_offset_kernel() is good enough for that, but it's probably less confusing if we define pte_offset_huge() along with pte_alloc_huge(). Only define them without CONFIG_HIGHPTE: so there would be a build error to signal if ever more work is needed. For ease of development, define these now for 6.4-rc1, ahead of any use: then architectures can integrate patches using them, independent from mm. Link: https://lkml.kernel.org/r/ae9e7d98-8a3a-cfd9-4762-bcddffdf96cf@google.com Signed-off-by: Hugh Dickins <hughd@google.com> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com> Cc: Muchun Song <muchun.song@linux.dev> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 29ad6bb commit f724392

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

include/linux/hugetlb.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,23 @@ extern struct list_head huge_boot_pages;
191191

192192
/* arch callbacks */
193193

194+
#ifndef CONFIG_HIGHPTE
195+
/*
196+
* pte_offset_huge() and pte_alloc_huge() are helpers for those architectures
197+
* which may go down to the lowest PTE level in their huge_pte_offset() and
198+
* huge_pte_alloc(): to avoid reliance on pte_offset_map() without pte_unmap().
199+
*/
200+
static inline pte_t *pte_offset_huge(pmd_t *pmd, unsigned long address)
201+
{
202+
return pte_offset_kernel(pmd, address);
203+
}
204+
static inline pte_t *pte_alloc_huge(struct mm_struct *mm, pmd_t *pmd,
205+
unsigned long address)
206+
{
207+
return pte_alloc(mm, pmd) ? NULL : pte_offset_huge(pmd, address);
208+
}
209+
#endif
210+
194211
pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
195212
unsigned long addr, unsigned long sz);
196213
/*

0 commit comments

Comments
 (0)