From patchwork Thu Oct 11 03:52:46 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: 10635687 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 BBAAD16B1 for ; Thu, 11 Oct 2018 03:53:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A23BF289D1 for ; Thu, 11 Oct 2018 03:53:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96E6728AEC; Thu, 11 Oct 2018 03:53:36 +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 28876289D1 for ; Thu, 11 Oct 2018 03:53:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BFDF66B0010; Wed, 10 Oct 2018 23:53:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BAC216B0266; Wed, 10 Oct 2018 23:53:34 -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 A70896B0269; Wed, 10 Oct 2018 23:53:34 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f72.google.com (mail-yw1-f72.google.com [209.85.161.72]) by kanga.kvack.org (Postfix) with ESMTP id 7519C6B0010 for ; Wed, 10 Oct 2018 23:53:34 -0400 (EDT) Received: by mail-yw1-f72.google.com with SMTP id i64-v6so4188948ywa.22 for ; Wed, 10 Oct 2018 20:53:34 -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=57m1YMD9+kSMxjaML43K4toixVQEQq+joAilXE8xWvs=; b=H3Z80KQggoEyM7XhT8R2Fu0Z5nHGssU/O8cLxeMXFv+rACbmIw/kELBdrSsHA+8FJ3 cKCu0RI3qlNrjYXQouGaJk3Oui2KvhHx9RkeJBA+HRfrV2hpTGFZZ9xe3Rr9XfPEv48B 4Nja9kPozoUUqW+0G+4AKYb8hNe0PIKmpkqjEazlkfMzxlAqB5yoGTsjiRqWnJelg/EY nq3LJDynmHYWihfHlXGAAFMCv1ILNGKWCVdvpDw/ZaUJKX1HXkYMJJaM6RQU6jTjvVAa 22LrJVjehzoVLQKGkIw6XVzPO0u1fj+ZQ15RRV7dZ+JdY5/amKSWBr+PAUriInX4J15K T4mQ== 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: ABuFfoiIDFjaAoJVMOB9M9ry318xMt+TVOlzKg8hWCCX6da/N4MpV4fw RM+5nn0s/HbovWOX+F0Pp9n9Gj1mFTSeDqz6aIVwhxZZlEwkdHana86MrTgJUFt4cNE7n0XCO5j ThRXIVLPEOqoeHnL3Ys+wpXl+ThOYIP00d+6lwg6hwAqRyLaHa5gxDyOpYSE4zFtp2A== X-Received: by 2002:a25:d70d:: with SMTP id o13-v6mr20802451ybg.356.1539230014214; Wed, 10 Oct 2018 20:53:34 -0700 (PDT) X-Google-Smtp-Source: ACcGV62qfMhOh67wJYM10TAHoZ/Kh4kfyaHUOTdFfMOKscFllJl8gguw2j0R7Pq9eh9suc5MnW9h X-Received: by 2002:a25:d70d:: with SMTP id o13-v6mr20802445ybg.356.1539230013675; Wed, 10 Oct 2018 20:53:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539230013; cv=none; d=google.com; s=arc-20160816; b=jvYCh3tXzjZjiHalVUQfO0vbVLt80Hv0RQ87smCtqVTT813xLg2K50/tdgrU09Obj8 nBoFPTinKs4F+tAl95to/3ywAEKb3jHXfgOnr1qpQ97rx9810r7Pox8HhwTfHoWT0at4 n+YdPAk6q3j5iKjyzABcIHQyfN8OiOYTzYjYF+bAkgXnC1FLPN/SJtKWGs4igPs0owxa j91w5iMvKZTnvuK2KpGXr8vYMxTqSg5Ayx27oVMg6n2jT1eKh1T79q55a59nGFNLZAcI nu59vkoOCpx2i7/2dDbtQqgC1O/xhwtLO+RcwZTTrz2SlgsMIflSQ5fjX3xaEoDgK76X HWjQ== 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; bh=57m1YMD9+kSMxjaML43K4toixVQEQq+joAilXE8xWvs=; b=omU6uKW1a2McHy/HTuoc2oikbe4q9rnPHpXCPQMvI0Uchxww8tSSbJ10aOpMKjz/j4 Y9/XRTgjaAPL2/No44N6Njns1Y5S05h0dMJTePCasruycK9/KVj9rJzY+Il0H3m21kLA NrJ3SpKDDwV76bQEM63mOvMYzldJWAW+wK+nWYg/0h576DdSpAPe8EI977K2W9fG6jUn dsawlZwYh1CgCReiYaQvZgkxG6Erem0AfxtNV1emaMik7CHlq63pHw1f/Bl4HVSEUAyv b+4aHh2asrVRpEkgmKYv1h2ZhsZoa43pIEQ8eheXGjMJF8HVpwHFOtIfMj3dR4kXB9MU 3S2w== 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 w126-v6si7222506ybe.196.2018.10.10.20.53.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 20:53:33 -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 (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9B3moQV049501 for ; Wed, 10 Oct 2018 23:53:33 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0a-001b2d01.pphosted.com with ESMTP id 2n1uuxe7c4-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 10 Oct 2018 23:53:33 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 10 Oct 2018 21:53:32 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 10 Oct 2018 21:53:28 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9B3rRdL22872150 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 10 Oct 2018 20:53:27 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9694678060; Wed, 10 Oct 2018 21:53:27 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 387B078063; Wed, 10 Oct 2018 21:53:25 -0600 (MDT) Received: from skywalker.ibmuc.com (unknown [9.85.73.187]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 10 Oct 2018 21:53:24 -0600 (MDT) From: "Aneesh Kumar K.V" To: akpm@linux-foundation.org, mpe@ellerman.id.au, benh@kernel.crashing.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "Aneesh Kumar K.V" Subject: [PATCH 4/5] mm/hugetlb: Add prot_modify_start/commit sequence for hugetlb update Date: Thu, 11 Oct 2018 09:22:46 +0530 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181011035247.30687-1-aneesh.kumar@linux.ibm.com> References: <20181011035247.30687-1-aneesh.kumar@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18101103-0012-0000-0000-000016C609D1 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009857; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000268; SDB=6.01100919; UDB=6.00569641; IPR=6.00880964; MB=3.00023702; MTD=3.00000008; XFM=3.00000015; UTC=2018-10-11 03:53:31 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18101103-0013-0000-0000-000054B62FBE Message-Id: <20181011035247.30687-5-aneesh.kumar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-11_01:,, 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-1807170000 definitions=main-1810110036 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 5c390f5a5207..1f3a4df95b2e 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4367,10 +4367,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);