From patchwork Wed Jul 25 16:19:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 10544291 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F30717FD for ; Wed, 25 Jul 2018 16:19:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F19E42A449 for ; Wed, 25 Jul 2018 16:19:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E46C22A5BD; Wed, 25 Jul 2018 16:19:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65D3E2A533 for ; Wed, 25 Jul 2018 16:19:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59E476B0266; Wed, 25 Jul 2018 12:19:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 54AA36B0269; Wed, 25 Jul 2018 12:19:38 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 413226B026A; Wed, 25 Jul 2018 12:19:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id D3A436B0266 for ; Wed, 25 Jul 2018 12:19:37 -0400 (EDT) Received: by mail-ed1-f71.google.com with SMTP id b25-v6so3282165eds.17 for ; Wed, 25 Jul 2018 09:19:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:in-reply-to:references:message-id; bh=EM0Flo1FA2/x+GtR7BBxHrRMMhw5Taay92yajznjpFY=; b=mfnmuQVWAzXEmWIfw6nEENLSMcKjE0ETJnNWrUF4C5R6tUmbzI+sXhBkQs4gXDmgMk /cdfLR1gbAY/dBHfQgcarNPMMtLaNgu1WRNFoHE3zLEZ2ouubscejx4pBsX3GemxNNtJ kkkWQeYaZi1MqhQw1V2VsiIqbNXleBvTUN2BtrmNSu4XdOODhBua5wktXRon5aoq77N6 Bg0E/pfXyIVl8roygEUPzF1O4C+M+1cZyE44tNXKXbsKyeWiAQtjENGKP5tPIGw6rBh/ FzrzyhCNlNRd9brIYfJeFnByaYmzOGuz8SPmyPrPVZTOQ3sYnj28pQz8wX9cZneLypH5 kpjA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: AOUpUlEey+uuUjswpEX2dz6q/15IYww1HMec/X/lRmjGfg7lrJobfNRO Av706L0Nf2npBp1Ai6TwEf73GLRuwLMejItXH2REniJML764kufXk/c6W52oHaI1cJlRUMSEs2Z XvsNeNonH6aR1jsF1rjOpsABbbOVPQGe/pZ39MCSJS3zpmK3p9CwgVVVHM2UEHBGDpw== X-Received: by 2002:a50:84e9:: with SMTP id 96-v6mr22928362edq.118.1532535577411; Wed, 25 Jul 2018 09:19:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfxscL6OR1B+wFIlfMKTMYrCPAo9WrJInhzNva3WiK3ISWfgva/+w3UA6Nru11ZzkNK/IYg X-Received: by 2002:a50:84e9:: with SMTP id 96-v6mr22928329edq.118.1532535576729; Wed, 25 Jul 2018 09:19:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532535576; cv=none; d=google.com; s=arc-20160816; b=nxbNLb0wqBMMWEwh3InnD6Y9Jlw8RRo0YCrgfP/x9XTv13N597+pWMDRTlZVKNAJkb VuYaZlN1+u3DIm+1FOB1EGk9UPjb1G6w3VGJvazbMyzdKOLjqFOtACuaG1j9KuFchXU+ ZJxKOJuU0SMaNbSZie93C+kyDIGmH3HZHoWMjtxwqJCQAlyFcRGTA12NW6aw/8rm0qNX 92JMj8gw2Nw68uaVS4tvc6OMv0z8AQnTirxHZsmNa/zQZ/T9DLYQbR9/tHj2Tki/hyQC GEWqg5rjLOrpXytyV7YEt7EmHLIIUp6gSu+Y1XP/PwPcKjeSihbJk16fPGY/H/vPcqL4 WoXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:references:in-reply-to:date:subject:cc:to:from :arc-authentication-results; bh=EM0Flo1FA2/x+GtR7BBxHrRMMhw5Taay92yajznjpFY=; b=hwHR0c5FdZzvWRALxXrX5eF4XlzPLutnYINGFDrkOMPHs6sYk2p7OyRMSPHvluhMG6 VfAWklUIoc0RDBBwnR76A7ZBXSvN4Y8PDz4ssv24ZH0jsA5Dggfck6nM6seZy+ctzGb8 NueO+oJNRqtpTcsMQpm2Fmx6RjYZ+six7/fOaqBmrD6LzqjnKSZR94HUOjUfYTPrK335 yXbRZ8pa1z+hni+ZJAn41aS66HX+cGLFfFH7P1qZj9iMSP2hrpzcCAvCPcPxOpcdeALH C6+ER1GH2mybK5FRcr8vSJbec5WaH/ZUr7NYo0uF9MKdK/1Tf5qcBnq+JoAXM1xoejEH OAEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com. [148.163.156.1]) by mx.google.com with ESMTPS id v57-v6si1356074edm.88.2018.07.25.09.19.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 09:19:36 -0700 (PDT) Received-SPF: pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) client-ip=148.163.156.1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6PGFgW8055717 for ; Wed, 25 Jul 2018 12:19:34 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0a-001b2d01.pphosted.com with ESMTP id 2keu9rm1wb-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 25 Jul 2018 12:19:34 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 25 Jul 2018 12:19:32 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 25 Jul 2018 12:19:29 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w6PGJS2863045816 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 25 Jul 2018 16:19:28 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 89A0DAE05F; Wed, 25 Jul 2018 12:18:43 -0400 (EDT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D9BC3AE05C; Wed, 25 Jul 2018 12:18:40 -0400 (EDT) Received: from skywalker.ibmmodules.com (unknown [9.199.35.55]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 25 Jul 2018 12:18:40 -0400 (EDT) From: "Aneesh Kumar K.V" To: npiggin@gmail.com, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, Naoya Horiguchi Cc: linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, "Aneesh Kumar K.V" Subject: [PATCH V2 5/6] powerpc/mm/thp: update pmd_trans_huge to check for pmd_present Date: Wed, 25 Jul 2018 21:49:02 +0530 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180725161903.31257-1-aneesh.kumar@linux.ibm.com> References: <20180725161903.31257-1-aneesh.kumar@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18072516-0040-0000-0000-00000453B6E9 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009425; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01065988; UDB=6.00547631; IPR=6.00843848; MB=3.00022321; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-25 16:19:31 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18072516-0041-0000-0000-00000859EB4E Message-Id: <20180725161903.31257-5-aneesh.kumar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-25_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807250174 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP We need to make sure pmd_trans_huge returns false for a pmd migration entry. We mark the migration entry by clearing the _PAGE_PRESENT bit. We keep the _PAGE_PTE bit set to indicate a leaf page table entry. Hence we need to make sure we check for pmd_present() so that pmd_trans_huge won't return true on pmd migration entry. Signed-off-by: Aneesh Kumar K.V --- .../include/asm/book3s/64/pgtable-64k.h | 3 +++ arch/powerpc/include/asm/book3s/64/pgtable.h | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/arch/powerpc/include/asm/book3s/64/pgtable-64k.h b/arch/powerpc/include/asm/book3s/64/pgtable-64k.h index d7ee249d6890..e3d4dd4ae2fa 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable-64k.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable-64k.h @@ -10,6 +10,9 @@ * * Defined in such a way that we can optimize away code block at build time * if CONFIG_HUGETLB_PAGE=n. + * + * returns true for pmd migration entries, THP, devmap, hugetlb + * But compile time dependent on CONFIG_HUGETLB_PAGE */ static inline int pmd_huge(pmd_t pmd) { diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index fce9ce8781a0..8b80c5e16896 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -1129,6 +1129,10 @@ pmd_hugepage_update(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, return hash__pmd_hugepage_update(mm, addr, pmdp, clr, set); } +/* + * returns true for pmd migration entries, THP, devmap, hugetlb + * But compile time dependent on THP config + */ static inline int pmd_large(pmd_t pmd) { return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); @@ -1163,8 +1167,22 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm, unsigned long addr, pmd_hugepage_update(mm, addr, pmdp, 0, _PAGE_PRIVILEGED); } +/* + * Only returns true for a THP. False for pmd migration entry. + * We also need to return true when we come across a pte that + * in between a thp split. While splitting THP, we mark the pmd + * invalid (pmdp_invalidate()) before we set it with pte page + * address. A pmd_trans_huge() check against a pmd entry during that time + * should return true. + * We should not call this on a hugetlb entry. We should check for HugeTLB + * entry using vma->vm_flags + * The page table walk rule is explained in Documentation/vm/transhuge.rst + */ static inline int pmd_trans_huge(pmd_t pmd) { + if (!pmd_present(pmd)) + return false; + if (radix_enabled()) return radix__pmd_trans_huge(pmd); return hash__pmd_trans_huge(pmd);