/* * If we store section details in page->flags we can't increase the MAX_PHYSMEM_BITS * if we increase SECTIONS_WIDTH we will not store node details in page->flags and * page_to_nid does a page->section->node lookup * Hence only increase for VMEMMAP. Further depending on SPARSEMEM_EXTREME reduce * memory requirements with large number of sections. * 51 bits is the max physical real address on POWER9
*/ #ifdefined(CONFIG_SPARSEMEM_VMEMMAP) && defined(CONFIG_SPARSEMEM_EXTREME) #define H_MAX_PHYSMEM_BITS 51 #else #define H_MAX_PHYSMEM_BITS 46 #endif
/* * Each context is 512TB size. SLB miss for first context/default context * is handled in the hotpath.
*/ #define MAX_EA_BITS_PER_CONTEXT 49 #define REGION_SHIFT MAX_EA_BITS_PER_CONTEXT
/* * We use one context for each MAP area.
*/ #define H_KERN_MAP_SIZE (1UL << MAX_EA_BITS_PER_CONTEXT)
/* * Define the address range of the kernel non-linear virtual area * 2PB
*/ #define H_KERN_VIRT_START ASM_CONST(0xc008000000000000)
/* * 64k aligned address free up few of the lower bits of RPN for us * We steal that here. For more deatils look at pte_pfn/pfn_pte()
*/ #define H_PAGE_COMBO _RPAGE_RPN0 /* this is a combo 4k page */ #define H_PAGE_4K_PFN _RPAGE_RPN1 /* PFN is for a single 4k page */ #define H_PAGE_BUSY _RPAGE_RSV1 /* software: PTE & hash are busy */ #define H_PAGE_HASHPTE _RPAGE_RPN43 /* PTE has associated HPTE */
/* * We need to differentiate between explicit huge page and THP huge * page, since THP huge page also need to track real subpage details
*/ #define H_PAGE_THP_HUGE H_PAGE_4K_PFN
/* PTE flags to conserve for HPTE identification */ #define _PAGE_HPTEFLAGS (H_PAGE_BUSY | H_PAGE_HASHPTE | H_PAGE_COMBO) /* * We use a 2K PTE page fragment and another 2K for storing * real_pte_t hash index * 8 bytes per each pte entry and another 8 bytes for storing * slot details.
*/ #define H_PTE_FRAG_SIZE_SHIFT (H_PTE_INDEX_SIZE + 3 + 1) #define H_PTE_FRAG_NR (PAGE_SIZE >> H_PTE_FRAG_SIZE_SHIFT)
/* * With 64K pages on hash table, we have a special PTE format that * uses a second "half" of the page table to encode sub-page information * in order to deal with 64K made of 4K HW pages. Thus we override the * generic accessors and iterators here
*/ #define __real_pte __real_pte staticinline real_pte_t __real_pte(pte_t pte, pte_t *ptep, int offset)
{
real_pte_t rpte; unsignedlong *hidxp;
rpte.pte = pte;
/* * Ensure that we do not read the hidx before we read the PTE. Because * the writer side is expected to finish writing the hidx first followed * by the PTE, by using smp_wmb(). pte_set_hash_slot() ensures that.
*/
smp_rmb();
/* * shift the hidx representation by one-modulo-0xf; i.e hidx 0 is respresented * as 1, 1 as 2,... , and 0xf as 0. This convention lets us represent a * invalid hidx 0xf with a 0x0 bit value. PTEs are anyway zero'd when * allocated. We dont have to zero them gain; thus save on the initialization.
*/ #define HIDX_UNSHIFT_BY_ONE(x) ((x + 0xfUL) & 0xfUL) /* shift backward by one */ #define HIDX_SHIFT_BY_ONE(x) ((x + 0x1UL) & 0xfUL) /* shift forward by one */ #define HIDX_BITS(x, index) (x << (index << 2)) #define BITS_TO_HIDX(x, index) ((x >> (index << 2)) & 0xfUL) #define INVALID_RPTE_HIDX 0x0UL
/* * Commit the hidx and return PTE bits that needs to be modified. The caller is * expected to modify the PTE bits accordingly and commit the PTE to memory.
*/ staticinlineunsignedlong pte_set_hidx(pte_t *ptep, real_pte_t rpte, unsignedint subpg_index, unsignedlong hidx, int offset)
{ unsignedlong *hidxp = (unsignedlong *)(ptep + offset);
/* * Anyone reading PTE must ensure hidx bits are read after reading the * PTE by using the read-side barrier smp_rmb(). __real_pte() can be * used for that.
*/
smp_wmb();
/* No PTE bits to be modified, return 0x0UL */ return 0x0UL;
}
#define __rpte_to_pte(r) ((r).pte) externbool __rpte_sub_valid(real_pte_t rpte, unsignedlong index); /* * Trick: we set __end to va + 64k, which happens works for * a 16M page as well as we want only one iteration
*/ #define pte_iterate_hashed_subpages(rpte, psize, vpn, index, shift) \ do { \ unsignedlong __end = vpn + (1UL << (PAGE_SHIFT - VPN_SHIFT)); \ unsigned __split = (psize == MMU_PAGE_4K || \
psize == MMU_PAGE_64K_AP); \
shift = mmu_psize_defs[psize].shift; \ for (index = 0; vpn < __end; index++, \
vpn += (1L << (shift - VPN_SHIFT))) { \ if (!__split || __rpte_sub_valid(rpte, index))
#ifdef CONFIG_TRANSPARENT_HUGEPAGE staticinlinechar *get_hpte_slot_array(pmd_t *pmdp)
{ /* * The hpte hindex is stored in the pgtable whose address is in the * second half of the PMD * * Order this load with the test for pmd_trans_huge in the caller
*/
smp_rmb(); return *(char **)(pmdp + PTRS_PER_PMD);
} /* * The linux hugepage PMD now include the pmd entries followed by the address * to the stashed pgtable_t. The stashed pgtable_t contains the hpte bits. * [ 000 | 1 bit secondary | 3 bit hidx | 1 bit valid]. We use one byte per * each HPTE entry. With 16MB hugepage and 64K HPTE we need 256 entries and * with 4K HPTE we need 4096 entries. Both will fit in a 4K pgtable_t. * * The top three bits are intentionally left as zero. This memory location * are also used as normal page PTE pointers. So if we have any pointers * left around while we collapse a hugepage, we need to make sure * _PAGE_PRESENT bit of that is zero when we look at them
*/ staticinlineunsignedint hpte_valid(unsignedchar *hpte_slot_array, int index)
{ return hpte_slot_array[index] & 0x1;
}
/* * * For core kernel code by design pmd_trans_huge is never run on any hugetlbfs * page. The hugetlbfs page table walking and mangling paths are totally * separated form the core VM paths and they're differentiated by * VM_HUGETLB being set on vm_flags well before any pmd_trans_huge could run. * * pmd_trans_huge() is defined as false at build time if * CONFIG_TRANSPARENT_HUGEPAGE=n to optimize away code blocks at build * time in such case. * * For ppc64 we need to differntiate from explicit hugepages from THP, because * for THP we also track the subpage details at the pmd level. We don't do * that for explicit huge pages. *
*/ staticinlineint hash__pmd_trans_huge(pmd_t pmd)
{ return !!((pmd_val(pmd) & (_PAGE_PTE | H_PAGE_THP_HUGE)) ==
(_PAGE_PTE | H_PAGE_THP_HUGE));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.