Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752754AbdGEVW4 (ORCPT ); Wed, 5 Jul 2017 17:22:56 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:33056 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752642AbdGEVWv (ORCPT ); Wed, 5 Jul 2017 17:22:51 -0400 From: Ram Pai To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, khandual@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com, bsingharora@gmail.com, dave.hansen@intel.com, hbabu@us.ibm.com, linuxram@us.ibm.com, arnd@arndb.de, akpm@linux-foundation.org, corbet@lwn.net, mingo@redhat.com Subject: [RFC v5 07/38] powerpc: use helper functions in __hash_page_huge() for 64K PTE Date: Wed, 5 Jul 2017 14:21:44 -0700 Message-Id: <1499289735-14220-8-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1499289735-14220-1-git-send-email-linuxram@us.ibm.com> References: <1499289735-14220-1-git-send-email-linuxram@us.ibm.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2046 Lines: 60 replace redundant code in __hash_page_huge() with helper functions pte_get_hash_gslot() and pte_set_hash_slot() Signed-off-by: Ram Pai --- arch/powerpc/mm/hugetlbpage-hash64.c | 24 ++++-------------------- 1 files changed, 4 insertions(+), 20 deletions(-) diff --git a/arch/powerpc/mm/hugetlbpage-hash64.c b/arch/powerpc/mm/hugetlbpage-hash64.c index 6f7aee3..e6dcd50 100644 --- a/arch/powerpc/mm/hugetlbpage-hash64.c +++ b/arch/powerpc/mm/hugetlbpage-hash64.c @@ -23,7 +23,6 @@ int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid, int ssize, unsigned int shift, unsigned int mmu_psize) { real_pte_t rpte; - unsigned long *hidxp; unsigned long vpn; unsigned long old_pte, new_pte; unsigned long rflags, pa, sz; @@ -74,16 +73,10 @@ int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid, /* Check if pte already has an hpte (case 2) */ if (unlikely(old_pte & H_PAGE_HASHPTE)) { /* There MIGHT be an HPTE for this pte */ - unsigned long hash, slot, hidx; + unsigned long gslot; - hash = hpt_hash(vpn, shift, ssize); - hidx = __rpte_to_hidx(rpte, 0); - if (hidx & _PTEIDX_SECONDARY) - hash = ~hash; - slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; - slot += hidx & _PTEIDX_GROUP_IX; - - if (mmu_hash_ops.hpte_updatepp(slot, rflags, vpn, mmu_psize, + gslot = pte_get_hash_gslot(vpn, shift, ssize, rpte, 0); + if (mmu_hash_ops.hpte_updatepp(gslot, rflags, vpn, mmu_psize, mmu_psize, ssize, flags) == -1) old_pte &= ~_PAGE_HPTEFLAGS; } @@ -110,16 +103,7 @@ int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid, return -1; } - /* - * Insert slot number & secondary bit in PTE second half. - */ - hidxp = (unsigned long *)(ptep + PTRS_PER_PTE); - rpte.hidx &= ~(0xfUL); - *hidxp = rpte.hidx | (slot & 0xfUL); - /* - * check __real_pte for details on matching smp_rmb() - */ - smp_wmb(); + new_pte |= pte_set_hash_slot(ptep, rpte, 0, slot); } /* -- 1.7.1