From patchwork Wed Jul 25 16:18:58 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: 10544281 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 0F5F817FD for ; Wed, 25 Jul 2018 16:19:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1F272A409 for ; Wed, 25 Jul 2018 16:19:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E44DC2A5BD; Wed, 25 Jul 2018 16:19:23 +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 3338B2A409 for ; Wed, 25 Jul 2018 16:19:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0B9E46B0006; Wed, 25 Jul 2018 12:19:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 069C66B0007; Wed, 25 Jul 2018 12:19:22 -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 E4C806B0008; Wed, 25 Jul 2018 12:19:21 -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 7EC576B0006 for ; Wed, 25 Jul 2018 12:19:21 -0400 (EDT) Received: by mail-ed1-f71.google.com with SMTP id b25-v6so3281940eds.17 for ; Wed, 25 Jul 2018 09:19:21 -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:message-id; bh=+fCFlF4eolsGb/kFDiQghaeCwGM1mxZGgO0SyG4u4Mg=; b=Mdoq2ZD9NjO109J5hah9WQF1VvCr+YRx0JE+PWmW7O+vPobFcaKgeSw4C9rghQOn5E LbNmTO5sYXet3hPKVsp/EeqCa3lAgNpGBr0l7Vif8yZSVT+mX0SkB1NpT2DSiEY/OwiY bSGW4O/WQSW/SY/myuNl+PSzePeGCSbOT0nQBwZSMFz4n4lq9UXRDBgQscHckVOvEG72 q31RKT0uVejH+/HY/WDwf3YgxV2KuAd0xajB/1P/yqnuV0wBz8+CYYqByUagKamwSe/S gxQyUED5oBhAh7J9zUmzO8mzm/Skwc/0D0maVX2K4Zs4pdIl64PI/XrWIusIrdj/CqNH W4fg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 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: AOUpUlEsRZ6JayRlnHTHvfjAULHVCCZNwEeCqky2qUXpkklYx9CiYool cTHzfwIYf12ZUujaLrPOhf+2h+3HuEJxn4cMs95ZhQZ+yciB8LzbpIS4TuGehYMU6qYd+JY8sv2 ADa03BgYDpa7uesf495RV1xbJfKNtTaqhFrhoSC2QW1ysj68veLTEkOxpEtHvum0B7g== X-Received: by 2002:a50:9226:: with SMTP id i35-v6mr23306917eda.27.1532535561026; Wed, 25 Jul 2018 09:19:21 -0700 (PDT) X-Google-Smtp-Source: AAOMgpft3x5iAUE/EGyUHF1zHwT8v6nBwUNU9NumaZaPkPU2OHOX08PW/32ENZZnDV3tNosSpgOB X-Received: by 2002:a50:9226:: with SMTP id i35-v6mr23306857eda.27.1532535559908; Wed, 25 Jul 2018 09:19:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532535559; cv=none; d=google.com; s=arc-20160816; b=oa5BT8P06g1Coq6/i3wlwzgyp5tXqvEYLkfhnl5/Sj8CTwth5h28pyLOl+oG2lUsQF LLkgmdauyxbJ0i7fGgxsgN0ea/rdHcWWM5HyHNGkRvxQoBVh94XL6fVmEZf5R7XBDCwt sY0jEYe54CpiKU0Z0czjclkrWYQz4UmxXk99iQGHEMhvhb5w4KTq2kMqu8a36HmcCTyC +jCr5mdQL6BA7LypOQKIhTeXi2+x7+BZliokYy+Ccy0MZgSc/UOwp0pc/1aw2+RRLtwv dTkQx517djBAbQwCeR0+w7SweFlIQDL/wEay2ROEcUgJQ4Mss9ss3Iob2PlaPkpoeZGR +PHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=+fCFlF4eolsGb/kFDiQghaeCwGM1mxZGgO0SyG4u4Mg=; b=thHyu9OtY3cYQXWH5JL2lPKRpM2fLpUK04tGmvCNRAv34lj8AMTSZcD1vPLbe7sJP5 aMpK9PzZe1VS0kkO7B3eE4MeJan2kZEAYdB0dRu6KwLNf2Ff4Ar3Ca9ruJ2wHsRnYklt Jgubsh2gMvSF+R1UwitHvM6haiSfFUzIKvXZUhs2UkIS8M5DVJ/uC4qDanatpdeBypzs B9lPRuXwBuWtsIToSL+0f9FGpRZXAj08Vl5LSA7pvhvVTi7do2psGlst1JBwoMYciW1W WWjwI3bIyFYoOt72pqImavb7HD7UmPpirSptAttfdfbvTvTZs7Jur2p4EuT2fde7GVIa oIxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 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 (mx0b-001b2d01.pphosted.com. [148.163.158.5]) by mx.google.com with ESMTPS id n22-v6si36569edo.298.2018.07.25.09.19.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 09:19:19 -0700 (PDT) Received-SPF: pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) client-ip=148.163.158.5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 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 (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6PGFio8037500 for ; Wed, 25 Jul 2018 12:19:18 -0400 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0b-001b2d01.pphosted.com with ESMTP id 2keuhsk46t-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 25 Jul 2018 12:19:17 -0400 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 25 Jul 2018 12:19:16 -0400 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e13.ny.us.ibm.com (146.89.104.200) 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:12 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w6PGJBGv14418242 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 25 Jul 2018 16:19:12 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CB387AE05C; Wed, 25 Jul 2018 12:18:26 -0400 (EDT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 01B73AE063; Wed, 25 Jul 2018 12:18:23 -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:23 -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 1/6] powerpc/mm/book3s: Update pmd_present to look at _PAGE_PRESENT bit Date: Wed, 25 Jul 2018 21:48:58 +0530 X-Mailer: git-send-email 2.17.1 X-TM-AS-GCONF: 00 x-cbid: 18072516-0064-0000-0000-0000032F86F3 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:15 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18072516-0065-0000-0000-00003A114C57 Message-Id: <20180725161903.31257-1-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 With this patch we use 0x8000000000000000UL (_PAGE_PRESENT) to indicate a valid pgd/pud/pmd entry. We also switch the p**_present() to look at this bit. With pmd_present, we have a special case. We need to make sure we consider a pmd marked invalid during THP split as present. Right now we clear the _PAGE_PRESENT bit during a pmdp_invalidate. Inorder to consider this special case we add a new pte bit _PAGE_INVALID (mapped to _RPAGE_SW0). This bit is only used with _PAGE_PRESENT cleared. Hence we are not really losing a pte bit for this special case. pmd_present is also updated to look at _PAGE_INVALID. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book3s/64/hash.h | 5 +++++ arch/powerpc/include/asm/book3s/64/pgtable.h | 23 +++++++++++++++++--- arch/powerpc/mm/hash_utils_64.c | 6 ++--- arch/powerpc/mm/pgtable-book3s64.c | 2 +- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/hash.h b/arch/powerpc/include/asm/book3s/64/hash.h index 0387b155f13d..a371ac7c3183 100644 --- a/arch/powerpc/include/asm/book3s/64/hash.h +++ b/arch/powerpc/include/asm/book3s/64/hash.h @@ -16,6 +16,11 @@ #include #endif +/* Bits to set in a PMD/PUD/PGD entry valid bit*/ +#define HASH_PMD_VAL_BITS (0x8000000000000000UL) +#define HASH_PUD_VAL_BITS (0x8000000000000000UL) +#define HASH_PGD_VAL_BITS (0x8000000000000000UL) + /* * Size of EA range mapped by our pagetables. */ diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index 676118743a06..fce9ce8781a0 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -44,6 +44,15 @@ #define _PAGE_PTE 0x4000000000000000UL /* distinguishes PTEs from pointers */ #define _PAGE_PRESENT 0x8000000000000000UL /* pte contains a translation */ +/* + * We need to mark a pmd pte invalid while splitting. We can do that by clearing the + * _PAGE_PRESENT bit. But then that will be taken as a swap pte. Inorder to differentiate + * between two use a SW field when invalidating. We don't add a special bit to indicate + * swap pte because that is also used for migration ptes, and we do back and forth between + * a valid pte entry and migration ptes. So any information in the software bits will be + * lost if we overload those bits. + */ +#define _PAGE_INVALID _RPAGE_SW0 /* * Top and bottom bits of RPN which can be used by hash @@ -859,8 +868,16 @@ static inline int pmd_none(pmd_t pmd) static inline int pmd_present(pmd_t pmd) { + /* + * A pmd is considerent present if _PAGE_PRESENT is set. + * We also need to consider the pmd present which is marked + * invalid during a split. Hence we look for _PAGE_INVALID + * if we find _PAGE_PRESENT cleared. + */ + if (pmd_raw(pmd) & cpu_to_be64(_PAGE_PRESENT | _PAGE_INVALID)) + return true; - return !pmd_none(pmd); + return false; } static inline int pmd_bad(pmd_t pmd) @@ -887,7 +904,7 @@ static inline int pud_none(pud_t pud) static inline int pud_present(pud_t pud) { - return !pud_none(pud); + return (pud_raw(pud) & cpu_to_be64(_PAGE_PRESENT)); } extern struct page *pud_page(pud_t pud); @@ -934,7 +951,7 @@ static inline int pgd_none(pgd_t pgd) static inline int pgd_present(pgd_t pgd) { - return !pgd_none(pgd); + return (pgd_raw(pgd) & cpu_to_be64(_PAGE_PRESENT)); } static inline pte_t pgd_pte(pgd_t pgd) diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c index 5a72e980e25a..7ce7fa5397d5 100644 --- a/arch/powerpc/mm/hash_utils_64.c +++ b/arch/powerpc/mm/hash_utils_64.c @@ -1002,9 +1002,9 @@ void __init hash__early_init_mmu(void) * 4k use hugepd format, so for hash set then to * zero */ - __pmd_val_bits = 0; - __pud_val_bits = 0; - __pgd_val_bits = 0; + __pmd_val_bits = HASH_PMD_VAL_BITS; + __pud_val_bits = HASH_PUD_VAL_BITS; + __pgd_val_bits = HASH_PGD_VAL_BITS; __kernel_virt_start = H_KERN_VIRT_START; __kernel_virt_size = H_KERN_VIRT_SIZE; diff --git a/arch/powerpc/mm/pgtable-book3s64.c b/arch/powerpc/mm/pgtable-book3s64.c index 4afbfbb64bfd..24346ab4cd37 100644 --- a/arch/powerpc/mm/pgtable-book3s64.c +++ b/arch/powerpc/mm/pgtable-book3s64.c @@ -106,7 +106,7 @@ pmd_t pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, { unsigned long old_pmd; - old_pmd = pmd_hugepage_update(vma->vm_mm, address, pmdp, _PAGE_PRESENT, 0); + old_pmd = pmd_hugepage_update(vma->vm_mm, address, pmdp, _PAGE_PRESENT, _PAGE_INVALID); flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE); /* * This ensures that generic code that rely on IRQ disabling From patchwork Wed Jul 25 16:18:59 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: 10544283 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 34225139A for ; Wed, 25 Jul 2018 16:19:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2365C2A409 for ; Wed, 25 Jul 2018 16:19:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 177DF2A5BD; Wed, 25 Jul 2018 16:19:26 +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 9A9912A409 for ; Wed, 25 Jul 2018 16:19:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF6B36B0008; Wed, 25 Jul 2018 12:19:23 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C56776B000C; Wed, 25 Jul 2018 12:19:23 -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 A2FFD6B000A; Wed, 25 Jul 2018 12:19:23 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi0-f71.google.com (mail-oi0-f71.google.com [209.85.218.71]) by kanga.kvack.org (Postfix) with ESMTP id 766546B0007 for ; Wed, 25 Jul 2018 12:19:23 -0400 (EDT) Received: by mail-oi0-f71.google.com with SMTP id l26-v6so7875480oii.14 for ; Wed, 25 Jul 2018 09:19:23 -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=V+sygEGKvXvFhpgglgEjm9Z8dmbThvVv1SQ3brsosoA=; b=ughr2TUInATvj0kjIcFJlJODduAj0q3ySLoEBgbiJcPZdLFxo6AvduM12JsjWPEgBH 5czFZQOQOLVxHtXR+1+rVfULpDLW/zWxZBncsxePiYk0j2bscAmQ9x5/Reu2O0D+q4A1 Ru8WSQJblErx2pqVd4wNtbVpt6rz5fg/t4s74WaVHX54FLAa0IaW4RXsovuwkcpBtVxw FlHsrL83v1LAa8z0jV7eMEd0D1t9huuYrR/tUEehu+Tjkof0cdljgCMSN3JULrv+F2pY J512VhkhiFcHVKc0kg8sc9BatIhETc9slidxSDwAn1FrxTzDVxFi+xhWKSsTQX05Wpds VKTw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 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: AOUpUlGbn/qy6bNboFRvgtLlYSiP9miE8YAM32umelvtytDAaYlGXwuh Rb9J6w56jpOkVisayUluK/nMo4oZL+Fpmp7HPXxvQz76Txekz+K7MVSDeVvfX3HCTFqa4Rd8MA0 gJnPdxMqreIBuHi4sGdXwx+rNfkVRS63Tbyz5MYf4kQ1GRFc17Ylji1fWQ6e/ZU90eg== X-Received: by 2002:aca:3254:: with SMTP id y81-v6mr3818580oiy.317.1532535563257; Wed, 25 Jul 2018 09:19:23 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeeBMroUavN55hKvVZCIyqjOKk07lc/XcdyN32sV2wsujxUwMA8vjKYiMthfMoWo5s6WBIG X-Received: by 2002:aca:3254:: with SMTP id y81-v6mr3818533oiy.317.1532535562557; Wed, 25 Jul 2018 09:19:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532535562; cv=none; d=google.com; s=arc-20160816; b=fsCHjlMGUfj6fKLS8pqwC6QS1a0KlvozZjiFUYw/n5aPhW4uc49hyQiNxOkgRoStSF Ugu8h6BpL0Pay8+udGm9QF2HYCKTZpFePw9trXsba+fTE6gJMGyTFqCbooSRQtJIFYgn tzBSh1n888PX5ee76bGtqd1Qy6UfaGsXukhCVWdN+q+xIzIVOJnpo8m9+VoGNJeAv+8F RWY0M0QrhXvYSMDiK+RicWd2QBBWfxKLlKC3lSROUwI8I6mZv5k23IicGrwpw0aXL1vh I0HUQ9qG1az9eOXwlyWDU1basj0jCB9Bx3jq1jK1uaYuOhfEC+0ZX7+5qcA6lscuxvev eOaA== 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=V+sygEGKvXvFhpgglgEjm9Z8dmbThvVv1SQ3brsosoA=; b=cFWsRaqcuXWq2XlBP33UQSh1cOOirKnTIM+VUGZtWhSqpp5ttWhfZ6seHil/k5zMgE dotD9vganmcckFA5bN9X9O8MzD1sDJEevkXOpy9kf1arSJjwPoH8oRXLnhWL6fc0Q49u AR8BG/XawAdiLBes6j7eAukY43/ePXcXjCW14ThCqZPR7RyWH3tbNGXNfA/ovSkI8gr1 J7qT7uDMUszfxgi10/LUPi0/7AQSvvsk5y6xjQG4X4chVZcOZ1ZVq0AYPDhqxNoYCK0+ SPaktC0FUAxAk3UE/TiuSEmOlRfRqol2iQczRyI0R/5hJQJYobmX2mv1mzIhRsPjx0RE D+1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 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 (mx0b-001b2d01.pphosted.com. [148.163.158.5]) by mx.google.com with ESMTPS id r133-v6si9519786oib.112.2018.07.25.09.19.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 09:19:22 -0700 (PDT) Received-SPF: pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) client-ip=148.163.158.5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 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 (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6PGE4ro097813 for ; Wed, 25 Jul 2018 12:19:21 -0400 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0a-001b2d01.pphosted.com with ESMTP id 2kevhe890s-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 25 Jul 2018 12:19:21 -0400 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 25 Jul 2018 12:19:20 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e13.ny.us.ibm.com (146.89.104.200) 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:17 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w6PGJGSK5112084 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 25 Jul 2018 16:19:16 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2EC33AE060; Wed, 25 Jul 2018 12:18:31 -0400 (EDT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7A295AE05C; Wed, 25 Jul 2018 12:18:28 -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:28 -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 2/6] powerpc/mm/hugetlb/book3s: add _PAGE_PRESENT to hugepd pointer. Date: Wed, 25 Jul 2018 21:48:59 +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-0064-0000-0000-0000032F86F5 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.01065989; UDB=6.00547631; IPR=6.00843848; MB=3.00022321; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-25 16:19:19 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18072516-0065-0000-0000-00003A114C63 Message-Id: <20180725161903.31257-2-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=1011 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 This make hugetlb directory pointer similar to other page able entries. A hugepd entry is identified by lack of _PAGE_PTE bit set and directory size stored in HUGEPD_SHIFT_MASK. We update that to also look at _PAGE_PRESENT Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book3s/64/hash-4k.h | 2 +- arch/powerpc/include/asm/book3s/64/hugetlb.h | 3 +++ arch/powerpc/mm/hugetlbpage.c | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/hash-4k.h b/arch/powerpc/include/asm/book3s/64/hash-4k.h index 9a3798660cef..15bc16b1dc9c 100644 --- a/arch/powerpc/include/asm/book3s/64/hash-4k.h +++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h @@ -66,7 +66,7 @@ static inline int hash__hugepd_ok(hugepd_t hpd) * if it is not a pte and have hugepd shift mask * set, then it is a hugepd directory pointer */ - if (!(hpdval & _PAGE_PTE) && + if (!(hpdval & _PAGE_PTE) && (hpdval & _PAGE_PRESENT) && ((hpdval & HUGEPD_SHIFT_MASK) != 0)) return true; return false; diff --git a/arch/powerpc/include/asm/book3s/64/hugetlb.h b/arch/powerpc/include/asm/book3s/64/hugetlb.h index 50888388a359..5b0177733994 100644 --- a/arch/powerpc/include/asm/book3s/64/hugetlb.h +++ b/arch/powerpc/include/asm/book3s/64/hugetlb.h @@ -39,4 +39,7 @@ static inline bool gigantic_page_supported(void) } #endif +/* hugepd entry valid bit */ +#define HUGEPD_VAL_BITS (0x8000000000000000UL) + #endif diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index f425b5b37d58..7ae5e4bfd318 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -95,7 +95,7 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, break; else { #ifdef CONFIG_PPC_BOOK3S_64 - *hpdp = __hugepd(__pa(new) | + *hpdp = __hugepd(__pa(new) | HUGEPD_VAL_BITS | (shift_to_mmu_psize(pshift) << 2)); #elif defined(CONFIG_PPC_8xx) *hpdp = __hugepd(__pa(new) | _PMD_USER | From patchwork Wed Jul 25 16:19:00 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: 10544285 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 4A14A139A for ; Wed, 25 Jul 2018 16:19:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 386722A409 for ; Wed, 25 Jul 2018 16:19:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C8F02A5BD; Wed, 25 Jul 2018 16:19:31 +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 A76FE2A409 for ; Wed, 25 Jul 2018 16:19:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4144E6B000C; Wed, 25 Jul 2018 12:19:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3C60C6B000D; Wed, 25 Jul 2018 12:19:29 -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 266EA6B000E; Wed, 25 Jul 2018 12:19:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id B91216B000C for ; Wed, 25 Jul 2018 12:19:28 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id f8-v6so3319010eds.6 for ; Wed, 25 Jul 2018 09:19:28 -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=DtE+6njeqUAnvrqy6u+uinFRfQwK5Qw8zLxMquiDQQ4=; b=BWo4G83iMo4CSLjKW72qUIaq8v8T1dI+BWpYHva56z7MbOZ27mFtywHt3bzT2wA3n7 jwdWga/9OngpBZMqyg9vn2X+VYcmoavtdSOA69/fegBT7XGUlr2RU2ragiltMzVONqu8 Zq9QHVPuzS6/0E7oxi0oRDRfRiwZPe5D/sY6Z+wOeMOIxV7IrAu2kCxfoWbftwoko9qv FOXnPSGKVJlNVVsTTE5SEidc9CxXEzDZbrxzmLj3BiFQEe3yqX/ip5lvyjB7STr39UWK SmwGm5qQFrqCqKq9ggi8TAf+3DZ3bdXywXzeWzLX83zlXngOZCnPj7jJ2ZjY6R00EwTk QIQQ== 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: AOUpUlGDAsnHJrKTdmTy/0iuyQuQLVtZm0a1HBpg/crGhwyeyT6Hw1QU 0jwdUwFD44v7PxDOwz8eOrhqoNIqQYUw8/jM6AJz9cZ9S/FlN9EoOeKMpEWyRZTczBSx6L+JFLn PrfchrAqqi5pTCXokU4qXMgMnHwHUOIV/5f/kYVrub7PQmpVvtDnYXzupEHCowOXvow== X-Received: by 2002:a50:afc4:: with SMTP id h62-v6mr23600049edd.251.1532535568314; Wed, 25 Jul 2018 09:19:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeI+T2hcmzLEkRqJBmGq69zN20rndxjq66tTLhv4SgroBxIEKIdU0vcUiH5e4788p57BCLY X-Received: by 2002:a50:afc4:: with SMTP id h62-v6mr23600005edd.251.1532535567586; Wed, 25 Jul 2018 09:19:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532535567; cv=none; d=google.com; s=arc-20160816; b=sfxzcLsZnZW0VLkHYhbcsJ+dZTxnYJw9rggddQtMsc4JVpQMUIj9KzAHGgcJIjc8vP 0zSpMZGurK27FSkBijvUBgQo8XF9yN2J+XCocRWLrk73VsxD08m9c7B3FgH8t/cEHGOD uLMjKCmHiqYE8fu/aEkmyfbbc3t23n5z9USpsK82yakPd16adzwWwKiwfvtlUBjaJaWa 1BGYlYIQfvW/aE+o9dv3t3NYLJ9ooqzhNvv7mZDQMCIrMS4yZkycD54zt5DyrOE8Lf5j 3lV72aWv/G/5K0Nm7a+oHnUuXl3JrDEBYliHSxgnDFNQmyIiDFylWXo/evgZ7QbgV30c 8IJw== 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=DtE+6njeqUAnvrqy6u+uinFRfQwK5Qw8zLxMquiDQQ4=; b=aGXWBdUVyEQFsXI25bqPg4HZklXpSE0wq4dZeekgZwigX7i+zr4abItR26MsDvhVc4 Jj8uSOmF6WK3RbEQDWDACneaN4PkoClJIKuBK4M618+VFSQEAGJsbiruDQvFc84OuNqE PZ7/0Swj/99ES0kmvUfxZtkBlOIzryMt44TGtIXZgZc6B4r4EhOSsfVAEGjK2LcKsi9U aRORZgQALdiS5ZgOAnYZGgvJsfFj+A2l1J5WJBQ4VQKnSHJ3KJ2le130pG/zI6gBv95V /wrcRLC7b2D6DRnCiaTcxge58pQTJFNaPGt0JEbqNfohaYptUewtJkb6M2K4FDBjo2ov Qx9w== 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 b24-v6si4385723edj.131.2018.07.25.09.19.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 09:19:27 -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 (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6PGEN4X008009 for ; Wed, 25 Jul 2018 12:19:25 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0a-001b2d01.pphosted.com with ESMTP id 2kevj206rf-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 25 Jul 2018 12:19:25 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 25 Jul 2018 12:19:24 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e16.ny.us.ibm.com (146.89.104.203) 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:21 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w6PGJKZL58327116 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 25 Jul 2018 16:19:20 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 56209AE05F; Wed, 25 Jul 2018 12:18:35 -0400 (EDT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AA6A6AE05C; Wed, 25 Jul 2018 12:18:32 -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:32 -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 3/6] powerpc/mm/book3s: Check for pmd_large instead of pmd_trans_huge Date: Wed, 25 Jul 2018 21:49:00 +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-0072-0000-0000-00000385A95A 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.01065989; UDB=6.00547631; IPR=6.00843848; MB=3.00022321; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-25 16:19:23 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18072516-0073-0000-0000-000048D76DEB Message-Id: <20180725161903.31257-3-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 Update few code paths to check for pmd_large. set_pmd_at: We want to use this to store swap pte at pmd level. For swap ptes we don't want to set H_PAGE_THP_HUGE. Hence check for pmd_large in set_pmd_at. This remove the false WARN_ON when using this with swap pmd entry. pmd_page: We don't really use them on pmd migration entries. But they can also work with migration entries and we don't differentiate at the pte level. Hence update pmd_page to work with pmd migration entries too __find_linux_pte: lockless page table walk need to handle pmd migration entries. pmd_trans_huge check will return false on them. We don't set thp = 1 for such entries, but update hpage_shift correctly. Without this we will walk pmd migration entries as a pte page pointer which is wrong. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/mm/hugetlbpage.c | 8 ++++++-- arch/powerpc/mm/pgtable-book3s64.c | 2 +- arch/powerpc/mm/pgtable_64.c | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index 7ae5e4bfd318..80fdeec89698 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -846,8 +846,12 @@ pte_t *__find_linux_pte(pgd_t *pgdir, unsigned long ea, ret_pte = (pte_t *) pmdp; goto out; } - - if (pmd_huge(pmd)) { + /* + * pmd_large check below will handle the swap pmd pte + * we need to do both the check because they are config + * dependent. + */ + if (pmd_huge(pmd) || pmd_large(pmd)) { ret_pte = (pte_t *) pmdp; goto out; } else if (is_hugepd(__hugepd(pmd_val(pmd)))) diff --git a/arch/powerpc/mm/pgtable-book3s64.c b/arch/powerpc/mm/pgtable-book3s64.c index 24346ab4cd37..16d963f281a3 100644 --- a/arch/powerpc/mm/pgtable-book3s64.c +++ b/arch/powerpc/mm/pgtable-book3s64.c @@ -71,7 +71,7 @@ void set_pmd_at(struct mm_struct *mm, unsigned long addr, #ifdef CONFIG_DEBUG_VM WARN_ON(pte_present(pmd_pte(*pmdp)) && !pte_protnone(pmd_pte(*pmdp))); assert_spin_locked(pmd_lockptr(mm, pmdp)); - WARN_ON(!(pmd_trans_huge(pmd) || pmd_devmap(pmd))); + WARN_ON(!(pmd_large(pmd) || pmd_devmap(pmd))); #endif trace_hugepage_set_pmd(addr, pmd_val(pmd)); return set_pte_at(mm, addr, pmdp_ptep(pmdp), pmd_pte(pmd)); diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c index 53e9eeecd5d4..e15e63079ba8 100644 --- a/arch/powerpc/mm/pgtable_64.c +++ b/arch/powerpc/mm/pgtable_64.c @@ -306,7 +306,7 @@ struct page *pud_page(pud_t pud) */ struct page *pmd_page(pmd_t pmd) { - if (pmd_trans_huge(pmd) || pmd_huge(pmd) || pmd_devmap(pmd)) + if (pmd_large(pmd) || pmd_huge(pmd) || pmd_devmap(pmd)) return pte_page(pmd_pte(pmd)); return virt_to_page(pmd_page_vaddr(pmd)); } From patchwork Wed Jul 25 16:19:01 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: 10544289 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 584CF139A for ; Wed, 25 Jul 2018 16:19:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 471B12A409 for ; Wed, 25 Jul 2018 16:19:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B1E12A5BD; Wed, 25 Jul 2018 16:19:35 +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 06F542A409 for ; Wed, 25 Jul 2018 16:19:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB4E36B000E; Wed, 25 Jul 2018 12:19:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B65766B0010; Wed, 25 Jul 2018 12:19:32 -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 A0CE76B0266; Wed, 25 Jul 2018 12:19:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id 3B3286B000E for ; Wed, 25 Jul 2018 12:19:32 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id g5-v6so3327970edp.1 for ; Wed, 25 Jul 2018 09:19:32 -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=zqVLkTkU/lLq0stGM6EnRxGSYl8xHl8xQNFnRBhoK20=; b=e21dHQuzh01ZFlN/IeLNvjcmqyUNWtc8D0mJ1g4NU7og2173n5TlvxC6M7FtMZUEnj /RVhbx5hwB4SZsDMtmIRthIuZGI7BjbiYYBcu6+uIDVfNzLUtTp5w0FB1ywfQlOIXZ5C RKO4kI4q/E+Icd0gSdFUNXTwRqpl9HLIRlG68WztoHJst9y0C7iL2h65vw6Tw2XejPls XjPYEP4VwFC/BAo4suCJWH8H0+7ILszW66M+zg3ykj7/8Lum+7xIlcKWGPn31tLXXveB p5Nwc9YE3K3fqXn1ZjVHbAvn5S1d2OQmF4i0kcl8kpFH+HnrxwXRsD59gI2oLwFW7RQK quSA== 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: AOUpUlEWV5lTz+dFmWNCstfMfY1NeBb1P/wtSxD7z87OHna79quN0Cxd +/g9kyqrX3vzJq4O3u664fElxFyhKb9t9RjCDw8/DVXThxFu0N8u1HV2K4hIFijhO9f9SJwHUzv jWCNliTvv8o9Q7zSHRcjUpqLQuYNcdZbNPFN084ZFnGIdV3FQJbLLXxq1j2+NjT5C1A== X-Received: by 2002:a50:ad55:: with SMTP id z21-v6mr22861169edc.142.1532535571805; Wed, 25 Jul 2018 09:19:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfihkb0kXxLPnJRcLVUF+XkrZSUkB59Su0CgxkzF63EaX29B54vRFNZf4/o5er66na02n32 X-Received: by 2002:a50:ad55:: with SMTP id z21-v6mr22861135edc.142.1532535571174; Wed, 25 Jul 2018 09:19:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532535571; cv=none; d=google.com; s=arc-20160816; b=VBmn1YXJnN8NGhjgiwPuctHSg+YEBifs09JuiUnokPaJHOLuCQxsSp+LhUWwGveC7k VR2QSa90JV+tN/QaIw0OHYa/T6yGmmbPHStbC6Q/+PTUtMXoX5GuL1xNRX4/FQdenBLz LP4n9j4WvwUYFr+oSmyxwcVBMHlUhcULGHlBgxj0h2++XLbvFJ/wPso8n1s6p7MbWf3M GgXcRbYjSibuVtiuo7dzdC5ZuvhWyDSSpLviDVfafl6QBtbUOQcbD+AZJk58F9WLVYxP hGC8ZtwN45/L4WsK3Bqdwyf7lY+xWSOHm7ML92cLKkyycw8RUKR78ucxXYoo1uAzE4Ep BRsg== 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=zqVLkTkU/lLq0stGM6EnRxGSYl8xHl8xQNFnRBhoK20=; b=bJsqgywLdrGDURCzqA9bvIfAa5ZJWGg6TbuIH5wogb5/shjBvauqNpD2ka84Hhkawv tT4tjR0ulgX5a5F+qoDotZJq8kmmWOTgl8X1oFiyHLq+0YEvHLtjDg35tNHgH58WVSLA EkdvzH1LL1P2YVMnaB5naZ4c+S2fy1/rUS1obTf0kVWxK5/PwGuu890aopt1gy2Sd4iU oeILepFI1nZUCecoNLLQBwvL4sHlEObMJ+OVO7UH36dE9ZkB4NwXGWkpWlazWsykrdR9 OjwIsN5bzm6tJ8ggIYCBEzByYL2fT1aSkoP6eeErof/E0tXJyfY9xGah9AJj20MWUB3n M3qw== 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 n6-v6si1346353edb.59.2018.07.25.09.19.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 09:19:31 -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 (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6PGERvk008270 for ; Wed, 25 Jul 2018 12:19:29 -0400 Received: from e15.ny.us.ibm.com (e15.ny.us.ibm.com [129.33.205.205]) by mx0a-001b2d01.pphosted.com with ESMTP id 2kevj206tr-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 25 Jul 2018 12:19:28 -0400 Received: from localhost by e15.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 25 Jul 2018 12:19:27 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e15.ny.us.ibm.com (146.89.104.202) 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:25 -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 w6PGJOWP11731332 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 25 Jul 2018 16:19:24 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 46F4EAE062; Wed, 25 Jul 2018 12:18:39 -0400 (EDT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F412CAE05C; Wed, 25 Jul 2018 12:18:36 -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:36 -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 4/6] arch/powerpc/mm/hash: validate the pte entries before handling the hash fault Date: Wed, 25 Jul 2018 21:49:01 +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-0068-0000-0000-0000031E0581 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:27 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18072516-0069-0000-0000-000045281CAE Message-Id: <20180725161903.31257-4-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=663 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.000014, 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 Make sure we are operating on THP and hugetlb entries in the respective hash fault handling routines. No functional change in this patch. If we walked the table wrongly before, we will retry the access. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/mm/hugepage-hash64.c | 6 ++++++ arch/powerpc/mm/hugetlbpage-hash64.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/arch/powerpc/mm/hugepage-hash64.c b/arch/powerpc/mm/hugepage-hash64.c index f20d16f849c5..049dcb8c95c2 100644 --- a/arch/powerpc/mm/hugepage-hash64.c +++ b/arch/powerpc/mm/hugepage-hash64.c @@ -51,6 +51,12 @@ int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid, new_pmd |= _PAGE_DIRTY; } while (!pmd_xchg(pmdp, __pmd(old_pmd), __pmd(new_pmd))); + /* + * Make sure this is thp or devmap entry + */ + if (!(old_pmd & (H_PAGE_THP_HUGE | _PAGE_DEVMAP))) + return 0; + rflags = htab_convert_pte_flags(new_pmd); #if 0 diff --git a/arch/powerpc/mm/hugetlbpage-hash64.c b/arch/powerpc/mm/hugetlbpage-hash64.c index b320f5097a06..2e6a8f9345d3 100644 --- a/arch/powerpc/mm/hugetlbpage-hash64.c +++ b/arch/powerpc/mm/hugetlbpage-hash64.c @@ -62,6 +62,10 @@ int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid, new_pte |= _PAGE_DIRTY; } while(!pte_xchg(ptep, __pte(old_pte), __pte(new_pte))); + /* Make sure this is a hugetlb entry */ + if (old_pte & (H_PAGE_THP_HUGE | _PAGE_DEVMAP)) + return 0; + rflags = htab_convert_pte_flags(new_pte); if (unlikely(mmu_psize == MMU_PAGE_16G)) offset = PTRS_PER_PUD; 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); From patchwork Wed Jul 25 16:19:03 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: 10544293 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 A6249139A for ; Wed, 25 Jul 2018 16:19:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 956882A409 for ; Wed, 25 Jul 2018 16:19:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8977C2A533; Wed, 25 Jul 2018 16:19:42 +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 18D192A409 for ; Wed, 25 Jul 2018 16:19:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 812276B026A; Wed, 25 Jul 2018 12:19:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 76F6E6B026B; Wed, 25 Jul 2018 12:19:40 -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 574796B026C; Wed, 25 Jul 2018 12:19:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi0-f70.google.com (mail-oi0-f70.google.com [209.85.218.70]) by kanga.kvack.org (Postfix) with ESMTP id 26D566B026A for ; Wed, 25 Jul 2018 12:19:40 -0400 (EDT) Received: by mail-oi0-f70.google.com with SMTP id t138-v6so7947216oih.5 for ; Wed, 25 Jul 2018 09:19:40 -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=lM7M9ux8ienPIjtz1tu4IkSsQ2nWdiZIL3KDTcUqaIA=; b=oIwH+PQERslSEi24fvozi1jNYcV184nP2oNA+IkuYFIh0PltTkx2FuUeE5EU3/UAfl +BLFxgwAdashc4IZl2zBo7jEM/XoOQxCVQKjFIHkfBJs6oyF6CwJgSU1nfdVcwV6MEx6 gw9V59JP/6WDNi4FR2kJf8VqhroS3RPBnHi21giNhI0ej/QSNSOp65H3byI/fdbqf4d7 8N2Lrz7xdunK8tZz+PQG1dxmAvBe3ALh5nhYncHeFs7Vd4KC4MaN6CNBB+vd96cepk+x J7Q+KPGAJKqMrnjch7WPMUkiL45slW5WV9YOT6MoJk5COWMTRgCsd3gXSqGibS5pBqJK eBNQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 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: AOUpUlGRbD5aGghH7W6DjFIc8ymCJQJB+rj1TBu3f69l8e7XjkTcui+5 oW9oQ3QG3O5dW8giRZd2F6/A9XRFE52D3mD3YlR29BhN9Fi/BL/eETZeJRrGXKsgUN/4K0ukzJB xdy9rm3stXE7ceaCB3qgScAnvQSydRQ9jtUyxJ9eDQmkgi1m1IlTGlX9FLT+Oms28Yg== X-Received: by 2002:aca:3bc2:: with SMTP id i185-v6mr4365006oia.156.1532535579952; Wed, 25 Jul 2018 09:19:39 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd4UzvVYg2mBmGMPjKCwbuzQo64O5APKKgxicZ9B67K4HNl36h/DIJmXb43wmIXqRuuFay6 X-Received: by 2002:aca:3bc2:: with SMTP id i185-v6mr4364945oia.156.1532535579211; Wed, 25 Jul 2018 09:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532535579; cv=none; d=google.com; s=arc-20160816; b=wLNEifcbDpJOgXVPfIiVIMQjWQF0dZ63rHuDirbUTOox/nOd+MKg3cZeDhGatbqkNh 1paw61W6IOWJomWBD/SuE3YHwVQRGh9JJ8Bw7KlFBpU9PcrQxKeM+RN6nAM2HGpDggan /BzVZXkMxTDsVlpjA96HG1PdM1RmKDsOe7ls+tFJogZz8IBDb05CprC0JABdGp2nHzkl RDFum0CYky8SyX89fQN/jYYh57TWzyR8YJGKVBNPCE3zWr2a+Q2KeqcBDkNTZAxmptho p8KC91IAsqMlNjAqBKfew4SAWXoxqKI+iPjtyBs9eigjjCVbkyXWY3CI4gR+prsmaVhU 3G1w== 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=lM7M9ux8ienPIjtz1tu4IkSsQ2nWdiZIL3KDTcUqaIA=; b=oBOqFQX2aqUcsqXHYKfNeuAKRC2Y0+lTz4hb+OXtksAC0B4XJDnLvN3UL0xVPO1ejc zPfVj9uZJDQwAWkRR5PAGIggZbyRPHHFcNYoY6lOKPtAOvdkOnkvu83xRh0mQpVrY7A2 oWO4Fwk+0ozyU6S5O/ETsbEOptnXAq45YZhdT4irfr9MZr78sOuHdERC6M8ZCirTKHog h9gycR7023qWQeU1AUiu1PP1rEp21pAy0ZXyyQDE7EY+enHlG04+4yB06jAwHeA1krJn 0Whh/puJbW/PoeY6THsALxLGFJlnuG9jXHPB38gB1r+990UxLDEkqRTJ/Y+1iDIdm+rn WgbQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 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 (mx0b-001b2d01.pphosted.com. [148.163.158.5]) by mx.google.com with ESMTPS id d188-v6si10359281oih.266.2018.07.25.09.19.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 09:19:39 -0700 (PDT) Received-SPF: pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) client-ip=148.163.158.5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 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 (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6PGE3gf097769 for ; Wed, 25 Jul 2018 12:19:38 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0a-001b2d01.pphosted.com with ESMTP id 2kevhe89b5-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 25 Jul 2018 12:19:38 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 25 Jul 2018 12:19:37 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e16.ny.us.ibm.com (146.89.104.203) 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:33 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w6PGJW7k5439994 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 25 Jul 2018 16:19:33 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E0B90AE05F; Wed, 25 Jul 2018 12:18:47 -0400 (EDT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 16877AE05C; Wed, 25 Jul 2018 12:18:45 -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:44 -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 6/6] powerpc/mm:book3s: Enable THP migration support Date: Wed, 25 Jul 2018 21:49:03 +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-0072-0000-0000-00000385A965 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.01065989; UDB=6.00547631; IPR=6.00843848; MB=3.00022321; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-25 16:19:36 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18072516-0073-0000-0000-000048D76E05 Message-Id: <20180725161903.31257-6-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=986 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 Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book3s/64/pgtable.h | 8 ++++++++ arch/powerpc/platforms/Kconfig.cputype | 1 + 2 files changed, 9 insertions(+) diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index 8b80c5e16896..2f12732952f0 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -734,6 +734,8 @@ static inline bool pte_user(pte_t pte) */ #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val((pte)) & ~_PAGE_PTE }) #define __swp_entry_to_pte(x) __pte((x).val | _PAGE_PTE) +#define __pmd_to_swp_entry(pmd) (__pte_to_swp_entry(pmd_pte(pmd))) +#define __swp_entry_to_pmd(x) (pte_pmd(__swp_entry_to_pte(x))) #ifdef CONFIG_MEM_SOFT_DIRTY #define _PAGE_SWP_SOFT_DIRTY (1UL << (SWP_TYPE_BITS + _PAGE_BIT_SWAP_TYPE)) @@ -1084,6 +1086,12 @@ static inline pte_t *pmdp_ptep(pmd_t *pmd) #define pmd_soft_dirty(pmd) pte_soft_dirty(pmd_pte(pmd)) #define pmd_mksoft_dirty(pmd) pte_pmd(pte_mksoft_dirty(pmd_pte(pmd))) #define pmd_clear_soft_dirty(pmd) pte_pmd(pte_clear_soft_dirty(pmd_pte(pmd))) + +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION +#define pmd_swp_mksoft_dirty(pmd) pte_pmd(pte_swp_mksoft_dirty(pmd_pte(pmd))) +#define pmd_swp_soft_dirty(pmd) pte_swp_soft_dirty(pmd_pte(pmd)) +#define pmd_swp_clear_soft_dirty(pmd) pte_pmd(pte_swp_clear_soft_dirty(pmd_pte(pmd))) +#endif #endif /* CONFIG_HAVE_ARCH_SOFT_DIRTY */ #ifdef CONFIG_NUMA_BALANCING diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype index e93d6186de6e..f83ca0ca3bd8 100644 --- a/arch/powerpc/platforms/Kconfig.cputype +++ b/arch/powerpc/platforms/Kconfig.cputype @@ -72,6 +72,7 @@ config PPC_BOOK3S_64 select PPC_HAVE_PMU_SUPPORT select SYS_SUPPORTS_HUGETLBFS select HAVE_ARCH_TRANSPARENT_HUGEPAGE + select ARCH_ENABLE_THP_MIGRATION if TRANSPARENT_HUGEPAGE select ARCH_SUPPORTS_NUMA_BALANCING select IRQ_WORK