Skip to content

Commit 0effa48

Browse files
Laurent Dufourmpe
Laurent Dufour
authored andcommitted
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" <[email protected]> Cc: Nicholas Piggin <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Reviewed-by: Aneesh Kumar K.V <[email protected]> Signed-off-by: Laurent Dufour <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 5600fbe commit 0effa48

File tree

1 file changed

+20
-7
lines changed
  • arch/powerpc/platforms/pseries

1 file changed

+20
-7
lines changed

arch/powerpc/platforms/pseries/lpar.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,24 @@ static int pSeries_lpar_hpte_removebolted(unsigned long ea,
546546
return 0;
547547
}
548548

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+
549567
/*
550568
* Take a spinlock around flushes to avoid bouncing the hypervisor tlbie
551569
* lock.
@@ -558,7 +576,7 @@ static void pSeries_lpar_flush_hash_range(unsigned long number, int local)
558576
struct ppc64_tlb_batch *batch = this_cpu_ptr(&ppc64_tlb_batch);
559577
int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE);
560578
unsigned long param[PLPAR_HCALL9_BUFSIZE];
561-
unsigned long hash, index, shift, hidx, slot;
579+
unsigned long index, shift, slot;
562580
real_pte_t pte;
563581
int psize, ssize;
564582

@@ -572,12 +590,7 @@ static void pSeries_lpar_flush_hash_range(unsigned long number, int local)
572590
vpn = batch->vpn[i];
573591
pte = batch->pte[i];
574592
pte_iterate_hashed_subpages(pte, psize, vpn, index, shift) {
575-
hash = hpt_hash(vpn, shift, ssize);
576-
hidx = __rpte_to_hidx(pte, index);
577-
if (hidx & _PTEIDX_SECONDARY)
578-
hash = ~hash;
579-
slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;
580-
slot += hidx & _PTEIDX_GROUP_IX;
593+
slot = compute_slot(pte, vpn, index, shift, ssize);
581594
if (!firmware_has_feature(FW_FEATURE_BULK_REMOVE)) {
582595
/*
583596
* lpar doesn't use the passed actual page size

0 commit comments

Comments
 (0)