From patchwork Wed Jan 16 08:50:34 2019 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: 10765527 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 1B90F13B5 for ; Wed, 16 Jan 2019 08:51:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 093872C5AC for ; Wed, 16 Jan 2019 08:51:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 073BE2D45E; Wed, 16 Jan 2019 08:51: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 826802D46F for ; Wed, 16 Jan 2019 08:51:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EAB68E0007; Wed, 16 Jan 2019 03:51:18 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 99DB08E0002; Wed, 16 Jan 2019 03:51:18 -0500 (EST) 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 818FC8E0007; Wed, 16 Jan 2019 03:51:18 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 5B1EB8E0002 for ; Wed, 16 Jan 2019 03:51:18 -0500 (EST) Received: by mail-qk1-f199.google.com with SMTP id z68so4709000qkb.14 for ; Wed, 16 Jan 2019 00:51:18 -0800 (PST) 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:mime-version :content-transfer-encoding:message-id; bh=mg28NG94mybuLX5+acUKQgY+OO8ZLtPufCpV3YNng5U=; b=WowuQghiRCfA4SxKqbO0wy/gMKhN2IUiuJQbTtcke0Lhzx9EoLnY7vffZmocDabpFa GnezX5efK5gw1QVAX5Glt+Q2WtcWWtTMxjP0/4qTOZedu9PDeq3RN81L7KCXorzZ/jaY /1jGP2e7QEyteod7yYMUF8bWoaUNjTx6PleS2+B0JD1f+i/ezKUTAJAE3oFNo/dtvVwi /KS8U1haXSxUPoJbwxm/pRUnmx1seMLWfzl2EV/Rscvic5vDEGv+8ZVoMId0LCPXge+o Xkw9FO3fc/ONuf33/QD7JX74zVQaGKKfkdKpMnKkvz1mMCOmpHYMrSDt/XSlVZJv3XNi HM+Q== 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: AJcUukceKKg+05j3ZDZCrCAFh8CI4D7sHCREDiTb0KnwrvWSQ4DoT3rO qlNIXWSjg+pzYM7VXmRyQvaYMMMxDRIBJfgbera+KicsmFDAvqmdB6/yPGE5m4yfvV9Jj2vDM1f KPXFdaCq19/5KTL9gWrrzazugBaiScka0kV/b1WKzzrrYTDNtpCLyIXg3bd7IOWPDiQ== X-Received: by 2002:ac8:4359:: with SMTP id a25mr6286459qtn.361.1547628678153; Wed, 16 Jan 2019 00:51:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN7hw9AUu2jPUv+ENhsRNAw1c6+SH9Qtn3khZMpgJCFDdMBuC6QbLCSdnYMHzJonPiMa7Qxv X-Received: by 2002:ac8:4359:: with SMTP id a25mr6286429qtn.361.1547628677490; Wed, 16 Jan 2019 00:51:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547628677; cv=none; d=google.com; s=arc-20160816; b=jzKK4MJhMuZrp+rleQIihVCXHhGbhPcyY7s0nw/XafS6JwCW8f9dSj8VGWFRSALHKS K4d+oc6XkOGl2ZB6IMNLb9xSehgSEjALA9vbT0s1RpRNUDJ8d9pmccct/2qWnXrHSq1p 8OTcnRuwBpfHaeFKWHHA7FkQoHyELZqpd2MHhM4Ufqd3EsUjeFc1/p5hV48tL8FjR7H0 /bRlMAZDW1KM7RqwVf6DDmvg9ve/Ykb14FVWoQXRbZZZs8smq25NtbLfxiAl06jsjCSp TdsylDuvYzCZCRn8xlelI5jyvZlwtJHZbtOpr+vUWZ+2lvjSzs2DdnVy8bsX3PKWdrL/ VJkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:content-transfer-encoding:mime-version:references :in-reply-to:date:subject:cc:to:from; bh=mg28NG94mybuLX5+acUKQgY+OO8ZLtPufCpV3YNng5U=; b=sDThqYQ8Yez0nQSvMzMlbnNY0uua/HjP2LreJOnOTGsOkYeQzV2BeJgRjRWbaSHW1a II4LvlQxFrWnBbifdXthDHCOfo04Mp/KXzmROy3Po5aODHza7vMyEB7zYZ2OTfF3f7Fr PMsXAx1OlPIfAt9gNVb5VeZbXKJ8JE5TqpLJAw4zp2C00YGLtxWJUuGbGEehaIWii5um sumJwCpGfco19ehCb/+cadDJ8yvTpPLnlRqsxSzdE/xA24v+9YbwQqkRDnDy6KLuvOcJ gyqBqiEtcGal4jNF051F03imt4HHgpnxawOSYPfn0gswdPhpqPzcCfJirZAwCCdgGdG/ Y22Q== 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 z34si1473909qvg.50.2019.01.16.00.51.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 00:51:17 -0800 (PST) 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 (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x0G8n3Ve083356 for ; Wed, 16 Jan 2019 03:51:17 -0500 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0b-001b2d01.pphosted.com with ESMTP id 2q1ybepau3-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 16 Jan 2019 03:51:16 -0500 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 16 Jan 2019 08:51:16 -0000 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 16 Jan 2019 08:51:13 -0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0G8pCoT11403476 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Jan 2019 08:51:13 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD796124055; Wed, 16 Jan 2019 08:51:12 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 92ABE12405A; Wed, 16 Jan 2019 08:51:10 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.124.31.92]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 16 Jan 2019 08:51:10 +0000 (GMT) From: "Aneesh Kumar K.V" To: npiggin@gmail.com, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, akpm@linux-foundation.org, x86@kernel.org Cc: linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, "Aneesh Kumar K.V" Subject: [PATCH V5 4/5] mm/hugetlb: Add prot_modify_start/commit sequence for hugetlb update Date: Wed, 16 Jan 2019 14:20:34 +0530 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190116085035.29729-1-aneesh.kumar@linux.ibm.com> References: <20190116085035.29729-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19011608-0060-0000-0000-000002FA4BCC X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010416; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000274; SDB=6.01147214; UDB=6.00597570; IPR=6.00927509; MB=3.00025150; MTD=3.00000008; XFM=3.00000015; UTC=2019-01-16 08:51:16 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011608-0061-0000-0000-000047F13D2F Message-Id: <20190116085035.29729-5-aneesh.kumar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-16_04:,, 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=786 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901160075 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 Architectures like ppc64 require to do a conditional tlb flush based on the old and new value of pte. Follow the regular pte change protection sequence for hugetlb too. This allows the architectures to override the update sequence. Signed-off-by: Aneesh Kumar K.V Reviewed-by: Michael Ellerman --- include/linux/hugetlb.h | 20 ++++++++++++++++++++ mm/hugetlb.c | 8 +++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 087fd5f48c91..39e78b80375c 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -543,6 +543,26 @@ static inline void set_huge_swap_pte_at(struct mm_struct *mm, unsigned long addr set_huge_pte_at(mm, addr, ptep, pte); } #endif + +#ifndef huge_ptep_modify_prot_start +#define huge_ptep_modify_prot_start huge_ptep_modify_prot_start +static inline pte_t huge_ptep_modify_prot_start(struct vm_area_struct *vma, + unsigned long addr, pte_t *ptep) +{ + return huge_ptep_get_and_clear(vma->vm_mm, addr, ptep); +} +#endif + +#ifndef huge_ptep_modify_prot_commit +#define huge_ptep_modify_prot_commit huge_ptep_modify_prot_commit +static inline void huge_ptep_modify_prot_commit(struct vm_area_struct *vma, + unsigned long addr, pte_t *ptep, + pte_t old_pte, pte_t pte) +{ + set_huge_pte_at(vma->vm_mm, addr, ptep, pte); +} +#endif + #else /* CONFIG_HUGETLB_PAGE */ struct hstate {}; #define alloc_huge_page(v, a, r) NULL diff --git a/mm/hugetlb.c b/mm/hugetlb.c index df2e7dd5ff17..f824d2200ca9 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4387,10 +4387,12 @@ unsigned long hugetlb_change_protection(struct vm_area_struct *vma, continue; } if (!huge_pte_none(pte)) { - pte = huge_ptep_get_and_clear(mm, address, ptep); - pte = pte_mkhuge(huge_pte_modify(pte, newprot)); + pte_t old_pte; + + old_pte = huge_ptep_modify_prot_start(vma, address, ptep); + pte = pte_mkhuge(huge_pte_modify(old_pte, newprot)); pte = arch_make_huge_pte(pte, vma, NULL, 0); - set_huge_pte_at(mm, address, ptep, pte); + huge_ptep_modify_prot_commit(vma, address, ptep, old_pte, pte); pages++; } spin_unlock(ptl);