Skip to content

Commit 318995b

Browse files
Ram Paimpe
authored andcommitted
powerpc: introduce pte_get_hash_gslot() helper
Introduce pte_get_hash_gslot()() which returns the global slot number of the HPTE in the global hash table. This function will come in handy as we work towards re-arranging the PTE bits in the later patches. Reviewed-by: Aneesh Kumar K.V <[email protected]> Signed-off-by: Ram Pai <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 59aa31f commit 318995b

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

arch/powerpc/include/asm/book3s/64/hash.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ static inline int hash__pte_none(pte_t pte)
167167
return (pte_val(pte) & ~H_PTE_NONE_MASK) == 0;
168168
}
169169

170+
unsigned long pte_get_hash_gslot(unsigned long vpn, unsigned long shift,
171+
int ssize, real_pte_t rpte, unsigned int subpg_index);
172+
170173
/* This low level function performs the actual PTE insertion
171174
* Setting the PTE depends on the MMU type and other factors. It's
172175
* an horrible mess that I'm not going to try to clean up now but

arch/powerpc/mm/hash_utils_64.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,24 @@ static inline void tm_flush_hash_page(int local)
15921592
}
15931593
#endif
15941594

1595+
/*
1596+
* Return the global hash slot, corresponding to the given PTE, which contains
1597+
* the HPTE.
1598+
*/
1599+
unsigned long pte_get_hash_gslot(unsigned long vpn, unsigned long shift,
1600+
int ssize, real_pte_t rpte, unsigned int subpg_index)
1601+
{
1602+
unsigned long hash, gslot, hidx;
1603+
1604+
hash = hpt_hash(vpn, shift, ssize);
1605+
hidx = __rpte_to_hidx(rpte, subpg_index);
1606+
if (hidx & _PTEIDX_SECONDARY)
1607+
hash = ~hash;
1608+
gslot = (hash & htab_hash_mask) * HPTES_PER_GROUP;
1609+
gslot += hidx & _PTEIDX_GROUP_IX;
1610+
return gslot;
1611+
}
1612+
15951613
/* WARNING: This is called from hash_low_64.S, if you change this prototype,
15961614
* do not forget to update the assembly call site !
15971615
*/

0 commit comments

Comments
 (0)