mm/mincore: Use can_pte_batch_count() in mincore_pte_range() for pte batch mincore_pte_range()
Quoted 32 lines · Zhang Qilong
Quoted 27 lines
In current
mincore_pte_range(), ifpte_batch_hint()return one pte, it's not efficient, just call new addedcan_pte_batch_count().In ARM64 qemu, with 8 CPUs, 32G memory, a simple test demo like:
1. mmap 1G anon memory
2. write 1G data by 4k step
3. mincore the mmaped 1G memory
4. get the time consumed by mincoreTested the following cases:
- 4k, disabled all hugepage setting.
- 64k mTHP, only enable 64k hugepage setting.Before
Case status | Consumed time (us) | ----------------------------------| 4k | 7356 | 64k mTHP | 3670 |Pathed:
Case status | Consumed time (us) | ----------------------------------| 4k | 4419 | 64k mTHP | 3061 |Quoted 4 lines
The result is evident and demonstrate a significant improvement in the pte batch. While verification within a single environment may have inherent randomness. there is a high probability of achieving positive effects.
Quoted 4 lines
Recent batch PTE series seriously regressed non-arm, so I'm afraid we can't accept any series that doesn't show statistics for
_otherplatforms_.Please make sure you at least test x86-64.
OK, I will have a test on x86-64 as soon and it may yield unexpected results.
Quoted 3 lines
This code is very sensitive and we're not going to accept a patch like this without
_beingsure_it's ok.
Year, it's a hot path, we should be extremely cautious.
Quoted 38 lines
mm/mincore.c static int mincore_pte_range(pmd_t *pmd,
Quoted 12 lines
Signed-off-by Zhang Qilong <[email protected]>--- mm/mincore.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)mm/mincore.c index renamed from mm/mincore.c +0
-0
8ec4719370e1..2cc5d276d1cd100644mm/mincore.c +0
-0@@ -178,18 +178,14 @@ static int mincore_pte_range(pmd_t *pmd,unsigned long addr, unsigned long end,
mm/mincore.c static int mincore_pte_range(pmd_t *pmd, · line 186
Quoted 9 lines
mm/mincore.c +0
-4/* We need to do cache lookup too for pte markers */ if (pte_none_mostly (pte))__mincore_unmapped_range (addr, addr +PAGE_SIZE , vma, vec);else if (pte_present (pte)) { -unsigned int batch =pte_batch_hint (ptep, pte); - -if (batch >1 ) { - unsigned int max_nr = (end - addr) >>
PAGE_SHIFT;Quoted 15 lines
mm/mincore.c +3
-4- - step = min_t(unsigned int, batch, max_nr); - } +unsigned int max_nr = (end - addr) >>PAGE_SHIFT ; + step =can_pte_batch_count (vma, ptep, &pte, + max_nr,0 );for (i =0 ; i < step; i++) vec[i] =1 ; }else {/* pte is a swap entry */ *vec =mincore_swap (pte_to_swp_entry (pte), false); } --2.43.0