Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934246AbdGTF6d (ORCPT ); Thu, 20 Jul 2017 01:58:33 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52551 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934232AbdGTF6a (ORCPT ); Thu, 20 Jul 2017 01:58:30 -0400 From: "Aneesh Kumar K.V" To: Ram Pai , 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, 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, mhocko@kernel.org Subject: Re: [RFC v6 06/62] powerpc: use helper functions in __hash_page_64K() for 64K PTE In-Reply-To: <1500177424-13695-7-git-send-email-linuxram@us.ibm.com> References: <1500177424-13695-1-git-send-email-linuxram@us.ibm.com> <1500177424-13695-7-git-send-email-linuxram@us.ibm.com> Date: Thu, 20 Jul 2017 11:28:13 +0530 MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-MML: disable x-cbid: 17072005-0008-0000-0000-000001516269 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17072005-0009-0000-0000-000009824675 Message-Id: <87y3rjps3u.fsf@skywalker.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-07-20_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707200096 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2270 Lines: 69 Ram Pai writes: > replace redundant code in __hash_page_64K() with helper > functions pte_get_hash_gslot() and pte_set_hash_slot() > Reviewed-by: Aneesh Kumar K.V > Signed-off-by: Ram Pai > --- > arch/powerpc/mm/hash64_64k.c | 24 ++++-------------------- > 1 files changed, 4 insertions(+), 20 deletions(-) > > diff --git a/arch/powerpc/mm/hash64_64k.c b/arch/powerpc/mm/hash64_64k.c > index 0012618..645f621 100644 > --- a/arch/powerpc/mm/hash64_64k.c > +++ b/arch/powerpc/mm/hash64_64k.c > @@ -244,7 +244,6 @@ int __hash_page_64K(unsigned long ea, unsigned long access, > unsigned long flags, int ssize) > { > real_pte_t rpte; > - unsigned long *hidxp; > unsigned long hpte_group; > unsigned long rflags, pa; > unsigned long old_pte, new_pte; > @@ -289,18 +288,12 @@ int __hash_page_64K(unsigned long ea, unsigned long access, > > vpn = hpt_vpn(ea, vsid, ssize); > if (unlikely(old_pte & H_PAGE_HASHPTE)) { > - unsigned long hash, slot, hidx; > - > - 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; > + unsigned long gslot; > /* > * There MIGHT be an HPTE for this pte > */ > - if (mmu_hash_ops.hpte_updatepp(slot, rflags, vpn, MMU_PAGE_64K, > + gslot = pte_get_hash_gslot(vpn, shift, ssize, rpte, 0); > + if (mmu_hash_ops.hpte_updatepp(gslot, rflags, vpn, MMU_PAGE_64K, > MMU_PAGE_64K, ssize, > flags) == -1) > old_pte &= ~_PAGE_HPTEFLAGS; > @@ -350,17 +343,8 @@ int __hash_page_64K(unsigned long ea, unsigned long access, > 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 = (new_pte & ~_PAGE_HPTEFLAGS) | H_PAGE_HASHPTE; > + new_pte |= pte_set_hash_slot(ptep, rpte, 0, slot); > } > *ptep = __pte(new_pte & ~H_PAGE_BUSY); > return 0; > -- > 1.7.1