From patchwork Mon Nov 6 08:50:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 834516 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yVmpH3KJpz9s4q for ; Mon, 6 Nov 2017 20:04:23 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GiZTORnt"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3yVmpH28n0zDrK5 for ; Mon, 6 Nov 2017 20:04:23 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GiZTORnt"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400d:c0d::241; helo=mail-qt0-x241.google.com; envelope-from=ram.n.pai@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GiZTORnt"; dkim-atps=neutral Received: from mail-qt0-x241.google.com (mail-qt0-x241.google.com [IPv6:2607:f8b0:400d:c0d::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3yVmc00W9HzDr5Q for ; Mon, 6 Nov 2017 19:55:27 +1100 (AEDT) Received: by mail-qt0-x241.google.com with SMTP id p1so10019411qtg.2 for ; Mon, 06 Nov 2017 00:55:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=nH3N9DzJPYarRbpAgH15i9z2G53lBBm69IPbMHmavTc=; b=GiZTORntog5PemdEGdX6BKR2Ia2lYbjKSyXS/HFrntL9quu5zqxTyeEHIXMXghd+aq jqiuJ1NUZWgK03BVSu34p/NJclwUxe18YSPG75in1FhgSo87V5RKYTi7Vz1Ajvo2RzQi jD3bgzbEm46441coILM99P45o81K57r/CwyyIRMTTiczrYLjjYIGy1DauOKSUcC3MT+d WdzH3CXmGwPLvh21/nlD7A1ZnxNNA3gKFHDn4Bpw2LFYgWQq0TLnlSlGhwOmv599bJum 9OVXQXueIA5GDv62OybKqApsd4Rv3pU89XMxee5heZ/MeBb2FK9dAgvVy7doLKa3v8Wf v7XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=nH3N9DzJPYarRbpAgH15i9z2G53lBBm69IPbMHmavTc=; b=AkzonDZCuOqBVrOCHkAenPsM1D1oS3e3aj/Bo2l/x6FEv9D3xI0fH7z3o64NSkb81j 9rtkZJ1rYUwaRBZSE27BZWilNPFfkiFzPr+IsmmA6gGlxGI+SgwPQF3Hj/KM9yyrPsVw ZqXoZTJFLPMNtSy2ufdS6TNqzH0wrRFM3To4iE0JEEWIZmovouVqVTwfqI52Wd3nyRte 5cGuB2C5yB03ImAFbGGXQKlPt7BRqUC3JCjXhCyi0O4Vqz+SLmZ8jLfW1z2VRmf5ohDR SS+VSO1IMUyjJ0UdmLVqITWsXmezaAYxi8Xd14Ol6eOqZfNDJ4DVdYWj93bO7+YY7gcr SYhQ== X-Gm-Message-State: AJaThX7gLHHPOkx7050sNT5Nbt6YxrSd++UvMTjtPZRxVE388Mb3s7FE 1HJnRoTUXEo6tvfZtGMzSv0= X-Google-Smtp-Source: ABhQp+TqMOtI46UR471OVrlc3VjykW3vNIsRUCjXxSBoCMKLdrh4zTvjJeuw8Aog9Cbk6GnItcLFlw== X-Received: by 10.237.37.71 with SMTP id w7mr14871880qtc.299.1509958526081; Mon, 06 Nov 2017 00:55:26 -0800 (PST) Received: from localhost.localdomain (50-39-103-96.bvtn.or.frontiernet.net. [50.39.103.96]) by smtp.gmail.com with ESMTPSA id x80sm2471528qkx.33.2017.11.06.00.55.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 00:55:25 -0800 (PST) From: Ram Pai To: mpe@ellerman.id.au Subject: [PATCH v9 2/8] powerpc: introduce pte_get_hash_gslot() helper Date: Mon, 6 Nov 2017 00:50:46 -0800 Message-Id: <1509958252-18302-3-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1509958252-18302-1-git-send-email-linuxram@us.ibm.com> References: <1509958252-18302-1-git-send-email-linuxram@us.ibm.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ebiederm@xmission.com, linuxram@us.ibm.com, mhocko@kernel.org, paulus@samba.org, aneesh.kumar@linux.vnet.ibm.com, bauerman@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org, khandual@linux.vnet.ibm.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 Signed-off-by: Ram Pai --- arch/powerpc/include/asm/book3s/64/hash.h | 3 +++ arch/powerpc/mm/hash_utils_64.c | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/hash.h b/arch/powerpc/include/asm/book3s/64/hash.h index ecb1239..9099c1f 100644 --- a/arch/powerpc/include/asm/book3s/64/hash.h +++ b/arch/powerpc/include/asm/book3s/64/hash.h @@ -167,6 +167,9 @@ static inline int hash__pte_none(pte_t pte) return (pte_val(pte) & ~H_PTE_NONE_MASK) == 0; } +unsigned long pte_get_hash_gslot(unsigned long vpn, unsigned long shift, + int ssize, real_pte_t rpte, unsigned int subpg_index); + /* This low level function performs the actual PTE insertion * Setting the PTE depends on the MMU type and other factors. It's * an horrible mess that I'm not going to try to clean up now but diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c index 67ec2e9..48b8968 100644 --- a/arch/powerpc/mm/hash_utils_64.c +++ b/arch/powerpc/mm/hash_utils_64.c @@ -1591,6 +1591,24 @@ static inline void tm_flush_hash_page(int local) } #endif +/* + * Return the global hash slot, corresponding to the given PTE, which contains + * the HPTE. + */ +unsigned long pte_get_hash_gslot(unsigned long vpn, unsigned long shift, + int ssize, real_pte_t rpte, unsigned int subpg_index) +{ + unsigned long hash, gslot, hidx; + + hash = hpt_hash(vpn, shift, ssize); + hidx = __rpte_to_hidx(rpte, subpg_index); + if (hidx & _PTEIDX_SECONDARY) + hash = ~hash; + gslot = (hash & htab_hash_mask) * HPTES_PER_GROUP; + gslot += hidx & _PTEIDX_GROUP_IX; + return gslot; +} + /* WARNING: This is called from hash_low_64.S, if you change this prototype, * do not forget to update the assembly call site ! */