powerpc: hugetlb pgtable cache access cleanup
PATCH v2 1/1 powerpc: hugetlb pgtable cache access cleanup
It was suggested by Andrew that using a macro that made an array look like a function call made it harder to understand the code. Cleaned up use of macro. We now reference the pgtable_cache array directly instead of using a macro.
Signed-off-by Jon Tollefson <[email protected]>
Cc Nick Piggin <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
Acked-by David Gibson <[email protected]>
---
arch/powerpc/mm/hugetlbpage.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
arch/powerpc/mm/hugetlbpage.c renamed from arch/powerpc/mm/hugetlbpage.c~powerpc-hugetlb-pgtable-cache-access-cleanup +11 -11
@@ -53,8 +53,7 @@ unsigned int mmu_huge_psizes[MMU_PAGE_CO/* Subtract one from array size because we don't need a cache for 4K since * is not a huge page size */ -#define huge_pgtable_cache (psize) (pgtable_cache[HUGEPTE_CACHE_NUM \ - + psize-1]) +#define HUGE_PGTABLE_INDEX (psize) (HUGEPTE_CACHE_NUM + psize - 1)#define HUGEPTE_CACHE_NAME (psize) (huge_pgtable_cache_name[psize])static const char *huge_pgtable_cache_name[MMU_PAGE_COUNT ] = {
@@ -113,7 +112,7 @@ static inline pte_t *hugepte_offset(hugestatic int __hugepte_alloc (struct mm_struct *mm,hugepd_t *hpdp,unsigned long address,unsigned int psize) { -pte_t *new =kmem_cache_zalloc (huge_pgtable_cache (psize), +pte_t *new =kmem_cache_zalloc (pgtable_cache[HUGE_PGTABLE_INDEX (psize)],GFP_KERNEL |__GFP_REPEAT);if (! new)
@@ -121,7 +120,7 @@ static int __hugepte_alloc(struct mm_strspin_lock (&mm->page_table_lock);if (!hugepd_none (*hpdp)) -kmem_cache_free (huge_pgtable_cache (psize), new); +kmem_cache_free (pgtable_cache[HUGE_PGTABLE_INDEX (psize)], new);else hpdp->pd = (unsigned long )new |HUGEPD_OK ;spin_unlock (&mm->page_table_lock);
@@ -760,13 +759,14 @@ static int __init hugetlbpage_init(void)for (psize =0 ; psize <MMU_PAGE_COUNT ; ++psize) {if (mmu_huge_psizes[psize]) { -huge_pgtable_cache (psize) =kmem_cache_create ( -HUGEPTE_CACHE_NAME (psize), -HUGEPTE_TABLE_SIZE (psize), -HUGEPTE_TABLE_SIZE (psize), -0 , -NULL ); -if (!huge_pgtable_cache (psize)) + pgtable_cache[HUGE_PGTABLE_INDEX (psize)] = +kmem_cache_create ( +HUGEPTE_CACHE_NAME (psize), +HUGEPTE_TABLE_SIZE (psize), +HUGEPTE_TABLE_SIZE (psize), +0 , +NULL ); +if (!pgtable_cache[HUGE_PGTABLE_INDEX (psize)])panic ("hugetlbpage_init(): could not create %s" \"\n" ,HUGEPTE_CACHE_NAME (psize)); }
_
Quoted 4 lines · On Thu, 30 Oct 2008 17:03:57 -0500 Jon Tollefson <[email protected]>…
It was suggested by Andrew that using a macro that made an array look like a function call made it harder to understand the code. Cleaned up use of macro. We now reference the
pgtable_cachearray directly instead of using a macro.
I felt compelled to apply this. See http://en.wikipedia.org/wiki/Sunk_costs
to see why I am an irrational actor.