From patchwork Tue Dec 18 09:41:36 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: 10735279 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 EADC2924 for ; Tue, 18 Dec 2018 09:42:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA8552A5AA for ; Tue, 18 Dec 2018 09:42:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CEB5A2A5D2; Tue, 18 Dec 2018 09:42:24 +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 64F802A5AA for ; Tue, 18 Dec 2018 09:42:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 686B58E0006; Tue, 18 Dec 2018 04:42:23 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6345E8E0001; Tue, 18 Dec 2018 04:42:23 -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 4FD7D8E0006; Tue, 18 Dec 2018 04:42:23 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 114F18E0001 for ; Tue, 18 Dec 2018 04:42:23 -0500 (EST) Received: by mail-pg1-f197.google.com with SMTP id d71so13269810pgc.1 for ; Tue, 18 Dec 2018 01:42:23 -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=nW7vege1ESCxENJep+Yvw30G4V7sMglvUR7loHoxXus=; b=gTLABwOBhpKYjTccLhXFKytfiO7LXQX6dRiz71jSP8s2dToxqacYoEHwghBfG7cKFG rLmfxFxboLGt2Rzvyi7f7OUqE8fh7IJExOa8QbpdQt5NglaBhfspfuWJqhRefQ7tQvux E27qnEE99UOWjjqppC13O04zGjnvZ9YHhMd1EAKsxLME/+C6JBVmS9xtvTqnIslPzl88 HkCoF/pGzIvwZ3AtjR1C0dY4hxIKVLznV0ZenMyVWZ0LZBQWw/i4wES1Qd2zg9gCjIkO dXqb2fkF2lVqQNSwhF5T3wSCsY8NQSsYNwVs+KfO1eA2Su5ISPnCgjRvHYmvEc65APLw 6cmA== 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+aEWat4jqom416YE5rJukDMMjDbdO6DnVHgETcRRMjzgFqMFmyrUTh 4a0ZcdDczhpKhZDzgsdCg8qzKaXUEtugjtYRi2RieeUaqfoYaiNPizvbK5PpABwpr+SMnA9C3+x ldrNi7TMb0OTd+O8GLZLDh3fzJZCH2k/pmTP3IhPVxpo76B6sNlviJzxC4L0TGStToA== X-Received: by 2002:a63:e445:: with SMTP id i5mr15125254pgk.307.1545126142737; Tue, 18 Dec 2018 01:42:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/WqoHdlD/Dt4VKTA0JpzDpWhWlRIBBu1SihtyKI2nGSVzUCEAsi8rL/0M2HxO4Db2+Pa9j2 X-Received: by 2002:a63:e445:: with SMTP id i5mr15125239pgk.307.1545126142055; Tue, 18 Dec 2018 01:42:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545126142; cv=none; d=google.com; s=arc-20160816; b=L6NhbWYTp1T5sBY2oTjZPZ060q/lM7xzwZPRVF0CMdA4AohCExC8QqsoRwQ7tKXYUW UBZ49d2S3aSxv16Z9hZNFXOiAG9SCruc7eWyvNzyLSr1YKXZdwiI5jy5LG6KCoyySUvs /CTqthe0yotz3ZjXlnTmu15A9pjViDScfPpAcNe2/WAVfjoiZSlAePgQRXPIHj1ysxFC uZ8K0ZRtMyQb9Mje4j5SiotTBeGS5KUZ3Py9HYg0yzqJV54SZz3g1rasR5ck8lmjghox of60Yn+SvCe1ns58rNmya6orbc3tex9+lGWmgSJtG+89/eliEtPLCeS13MfdWq+2ah+3 xPOw== 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=nW7vege1ESCxENJep+Yvw30G4V7sMglvUR7loHoxXus=; b=G4w4cDl+9FguiatvIGAJq4xNvLE1WfqvtyIze6BOW4wA28dmY9ieXdGWSC1I56AlEI fjaju0H9X9G5c8S1D08hlz137EDt4IjJ0z7irdk5mjs3LSyGCqcFX9uiX0onU2DLCcwN VMdI3gnd3bRrTXFH5md3uTpPJYwlNi91HlVcZ/Yo0tUGJm3XXrplC/RZ3TZ+IgW1b5u6 wkPDEzY653YILXMcB6iWLOQCV490O50lPlIpLRM6WF5QdmIh8ztBXfe2CSGq3IzRv9Xa /YRHY/ysVxdUp3iVyEXJ+j1kZX6IUlMTFDwYn8v1GCDlw18n1+grVCf6VeOJbD/z7Yqm 4OMQ== 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 i4si13596402pfg.218.2018.12.18.01.42.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Dec 2018 01:42:22 -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 (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wBI9eU2q143775 for ; Tue, 18 Dec 2018 04:42:21 -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 2pewf53aha-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 18 Dec 2018 04:42:21 -0500 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 18 Dec 2018 09:42:20 -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) Tue, 18 Dec 2018 09:42:17 -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 wBI9gGMN27263156 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 18 Dec 2018 09:42:16 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D6DB06E050; Tue, 18 Dec 2018 09:42:15 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8231D6E04C; Tue, 18 Dec 2018 09:42:12 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.85.88.39]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 18 Dec 2018 09:42:12 +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 V4 4/5] mm/hugetlb: Add prot_modify_start/commit sequence for hugetlb update Date: Tue, 18 Dec 2018 15:11:36 +0530 X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181218094137.13732-1-aneesh.kumar@linux.ibm.com> References: <20181218094137.13732-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18121809-0016-0000-0000-00000965F7A6 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010242; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000271; SDB=6.01133443; UDB=6.00589233; IPR=6.00913618; MB=3.00024731; MTD=3.00000008; XFM=3.00000015; UTC=2018-12-18 09:42:19 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18121809-0017-0000-0000-000041730C00 Message-Id: <20181218094137.13732-5-aneesh.kumar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-12-18_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=718 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812180086 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 requires 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 allow the architectures to override the update sequence. Signed-off-by: Aneesh Kumar K.V --- 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 705a3e9cc910..353bff385595 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);