Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/pseries/mm: factorize PTE slot computation

This part of code will be called also when dealing with H_BLOCK_REMOVE.

Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Laurent Dufour and committed by
Michael Ellerman
0effa488 5600fbe3

+20 -7
+20 -7
arch/powerpc/platforms/pseries/lpar.c
··· 546 546 return 0; 547 547 } 548 548 549 + 550 + static inline unsigned long compute_slot(real_pte_t pte, 551 + unsigned long vpn, 552 + unsigned long index, 553 + unsigned long shift, 554 + int ssize) 555 + { 556 + unsigned long slot, hash, hidx; 557 + 558 + hash = hpt_hash(vpn, shift, ssize); 559 + hidx = __rpte_to_hidx(pte, index); 560 + if (hidx & _PTEIDX_SECONDARY) 561 + hash = ~hash; 562 + slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; 563 + slot += hidx & _PTEIDX_GROUP_IX; 564 + return slot; 565 + } 566 + 549 567 /* 550 568 * Take a spinlock around flushes to avoid bouncing the hypervisor tlbie 551 569 * lock. ··· 576 558 struct ppc64_tlb_batch *batch = this_cpu_ptr(&ppc64_tlb_batch); 577 559 int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); 578 560 unsigned long param[PLPAR_HCALL9_BUFSIZE]; 579 - unsigned long hash, index, shift, hidx, slot; 561 + unsigned long index, shift, slot; 580 562 real_pte_t pte; 581 563 int psize, ssize; 582 564 ··· 590 572 vpn = batch->vpn[i]; 591 573 pte = batch->pte[i]; 592 574 pte_iterate_hashed_subpages(pte, psize, vpn, index, shift) { 593 - hash = hpt_hash(vpn, shift, ssize); 594 - hidx = __rpte_to_hidx(pte, index); 595 - if (hidx & _PTEIDX_SECONDARY) 596 - hash = ~hash; 597 - slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; 598 - slot += hidx & _PTEIDX_GROUP_IX; 575 + slot = compute_slot(pte, vpn, index, shift, ssize); 599 576 if (!firmware_has_feature(FW_FEATURE_BULK_REMOVE)) { 600 577 /* 601 578 * lpar doesn't use the passed actual page size