From patchwork Wed Nov 28 14:34:37 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: 10702777 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 A69C517D5 for ; Wed, 28 Nov 2018 14:35:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9766D2CC97 for ; Wed, 28 Nov 2018 14:35:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B7B62CC99; Wed, 28 Nov 2018 14:35:22 +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 170502CC97 for ; Wed, 28 Nov 2018 14:35:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 519406B4D74; Wed, 28 Nov 2018 09:35:19 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4A0CE6B4D75; Wed, 28 Nov 2018 09:35:19 -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 2F5CC6B4D76; Wed, 28 Nov 2018 09:35:19 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id E1E876B4D74 for ; Wed, 28 Nov 2018 09:35:18 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id t72so10097210pfi.21 for ; Wed, 28 Nov 2018 06:35: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=0CHtk93zjxSBfH1sgMDcjD34yWO3RG5hYpBQIy+BXGY=; b=nk+KntJt9r3upZx5T5vQZKu7HRq/WdOLsg/xlpzpiW1828XkuNwF5ASY7N9tBY43G/ u3zzAV5eLWW7tVsHbHUf5yb6KyLJd+0L2lroMwE0CEmVJU2ybGdg+e8kUKc9UvGHNnVW +fqtAYy9p/bXIyLNmjbO49b3I/iNxHsmT06lqIOdeKlXk5DpG05Sbu1LjR9fdkZXmGu0 OSfRG2N+C+nw3kacY/0rwP17vx7aAXpDomE09k2HTcJQSQSCKtESoo1mVjGsXEz7lWFq 80XaxCslSF11xLpfAQxbPneO8VgeX+GEL7LD1o6mNjkXyLjN5rl0zDZlfxChojAjZ+vy fBGA== 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: AA+aEWY7Ffwo6WJB84uVMTsXdTeOi+mykR+qz4M3xEkLx3xXDuPF99HE BiaeLm7imQdaB5agldV5sXLntUMwqN4QrvH1xv5+U2SPD7rZ8UZSizhk9M6sZUeAAlRdUShp4Lc 7zM0QBWQ7hb5TxW4mCFvl2SPg4oHafjjGQ3b4BXnBy8VThQL9yfhrhww0YG7RiX6dig== X-Received: by 2002:a62:34c6:: with SMTP id b189mr30657914pfa.229.1543415718542; Wed, 28 Nov 2018 06:35:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/W+27cswDeRNIasUeLO4N5LAvdRDT/baWTo2ParHOT/gh3U+UMVsnV9NznzIUowf67syns9 X-Received: by 2002:a62:34c6:: with SMTP id b189mr30657867pfa.229.1543415717851; Wed, 28 Nov 2018 06:35:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543415717; cv=none; d=google.com; s=arc-20160816; b=e3lpOVNWcY+65BeKbz4egtt+55Rw6YQIIuFmQeWNrar80Vj3tEFlupYrUQHzK762aE Ruw8pMc3i8GedLyt2bK308Y4tZWVlpoGyVqOSq4OLB3jwJ/1T6TciPkHAEGuZNk+28y1 Q8A21kVDzoyKtD8rbdxzh5SKGg7WoiN28QNwhIO+E/UATP5Z778K8ucN/PvX4kJsswQV yBHJlqbcADc7X54xxecr1njGQodC/Q8tv9EhP7SCYVzT0klAzpwVztzo8IifkkUP/qxy EUsLnP/LKM3TUx/LIg302208P6nfnmXx7loaIO4OWQWwDzr0OhEfHTAf0sNQp+ojwvnd u6qQ== 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=0CHtk93zjxSBfH1sgMDcjD34yWO3RG5hYpBQIy+BXGY=; b=0kFxI5k+Rk5sYAJlBe5CZjbe0LE9srizPhCS41twWbYmronRExTUiGl4gNDBQpK3/n HlLpw3zaD140sw2mugRy80aZyWoLtPqsPplbr5AmJNJt16o5L5LIGo38q8edRZjdHUAR k+I5spErH77RQS+7XX/rexd1vN4si28GsNAseDYH6gM7xwmFwG5W3Ewm8+Doj8dOqlUU is1SiBclV+kq2rB5LYQmTpppoJtGG+MWh306c0xz78E9Kfo/+rqC5so4stvCEocvZolw IsWv02d99Rdnn0uT+D+ciEyRro9T7fbMqtO1smGzYLKC/R0b7nWrAkSyJ8PXwkV8G1uL KaPQ== 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 q64si7446000pga.280.2018.11.28.06.35.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Nov 2018 06:35:17 -0800 (PST) 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 (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wASEYIjF126475 for ; Wed, 28 Nov 2018 09:35:17 -0500 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 2p1t4qfsg3-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 28 Nov 2018 09:35:17 -0500 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 28 Nov 2018 14:35:16 -0000 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 28 Nov 2018 14:35:13 -0000 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wASEZCEA23462128 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 28 Nov 2018 14:35:12 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AD7376E056; Wed, 28 Nov 2018 14:35:12 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9D0EE6E054; Wed, 28 Nov 2018 14:35:09 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.85.87.253]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 28 Nov 2018 14:35:09 +0000 (GMT) From: "Aneesh Kumar K.V" To: akpm@linux-foundation.org, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "Aneesh Kumar K.V" Subject: [PATCH V2 4/5] mm/hugetlb: Add prot_modify_start/commit sequence for hugetlb update Date: Wed, 28 Nov 2018 20:04:37 +0530 X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181128143438.29458-1-aneesh.kumar@linux.ibm.com> References: <20181128143438.29458-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18112814-0016-0000-0000-0000095C37AF X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010137; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000270; SDB=6.01124008; UDB=6.00583546; IPR=6.00904137; MB=3.00024366; MTD=3.00000008; XFM=3.00000015; UTC=2018-11-28 14:35:15 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18112814-0017-0000-0000-000041381595 Message-Id: <20181128143438.29458-5-aneesh.kumar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-11-28_07:,, 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=981 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811280129 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 --- include/linux/hugetlb.h | 18 ++++++++++++++++++ mm/hugetlb.c | 8 +++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 087fd5f48c91..e2a3b0c854eb 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -543,6 +543,24 @@ 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 +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 +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 7f2a28ab46d5..e5f5cda14f28 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4388,10 +4388,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);