From patchwork Wed Dec 5 03:09:30 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: 10712921 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 7E1C313BF for ; Wed, 5 Dec 2018 03:10:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B2F92C23D for ; Wed, 5 Dec 2018 03:10:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E62A2C36E; Wed, 5 Dec 2018 03:10:08 +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 D7E402C23D for ; Wed, 5 Dec 2018 03:10:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0431D6B7221; Tue, 4 Dec 2018 22:10:07 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F32DF6B7223; Tue, 4 Dec 2018 22:10:06 -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 DFC046B7224; Tue, 4 Dec 2018 22:10:06 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 879EB6B7221 for ; Tue, 4 Dec 2018 22:10:06 -0500 (EST) Received: by mail-ed1-f72.google.com with SMTP id i55so9180221ede.14 for ; Tue, 04 Dec 2018 19:10:06 -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=iikejjcgESH/wv8TEaZZe7NwN2zu0L9QixwpBUQA7td9q5MkYm4IBvJ+9iTzCrLZL+ tElDsOIAaDoOsYdd0tuWmtvJPtNHwQ98znb/dUmldAxy5KvhUT9VUtFjit4WO6PgJ/Xl LLW2ed30QRyVNRKvqQMt5bq1hlWfonVIBfuc9DzPWqmwO2Cw1sN41iqK+P0OXrO0LeXh ssbdHTj+cN8G/VReMB6VExH4bLnNsWEfDd9q9kckEN76A89hhQGE2ql63iddRmW/oOXm Sl52LqhTO44zFY1BfWEDvutleqQm9Ml9TO2rkr6vJu3wRKIrZhGMl4qzm12rY6HROESf s/UA== 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: AA+aEWZGZ1wJLpyrFeY4f/qIFOX9WbrvY/H2vzWjQ1WC8JqThNZNueI9 WV044fP5YnqwQrxEbUSaZbFsRyk+5wCgL+4eJH0zzh+HMM4Tms+2siGJrfVYByyepAZ/urCT7bv a2pNNDHPJfIWRsv4/SeHTnH0fEhdTmNlmi1zNbZRr0euLX67J16GvAfvB/rFXf0803Q== X-Received: by 2002:a17:906:46c7:: with SMTP id k7-v6mr17233515ejs.71.1543979406044; Tue, 04 Dec 2018 19:10:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/Ucte/dRm0NBu8v7YkBOa1y0pYc4nD9REtwKFQdKZhpEl2DJAQbBgxHUdOicx257EAF0ZJC X-Received: by 2002:a17:906:46c7:: with SMTP id k7-v6mr17233475ejs.71.1543979405066; Tue, 04 Dec 2018 19:10:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543979405; cv=none; d=google.com; s=arc-20160816; b=EREd92dXM76RUdZO0iX4jTsAvTiC6hZgwhwZ3tuqqBnB7AP3qI57MPd5XC5lGpQMUn vuAhCFtxd/vgtzOXzc2QaPkOG9zq8Y1mrQ/y2/x9iVHw/uaA0DZZJkyRcSUx4oP5vVrR 8rS06g8no1jxxvCVzQtt8B7NZzLH6iiatMsAQ7LYHvhe++zR20KLmwaoAO4ltHCsBof+ RHI12esTsrROxTF70jBoCFCOF4hkVV+tjbd6ZqPlJHEhxuhU0F/IAJU/uTR4I6IV7mKJ xaP1+i2X2vqWCtOpnBbhYI7mreTjsU7LePAaNzK8XX6Es6s5hUN5EcOvdCTcEn64fDXu f2Aw== 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=qVVaWolQgShnQzPhFvyegaq3FHUOIEsY0zPuChYIyh3G84SIGAe6luLV4PRgqyCDvu HsXfAbB3uU1ay6iLvY1yJWQeUen0DwTuUe8Du422zPhSZjzsCpVC21INBZ+TEqlMdj3r keg2mMOrAAwCqU3ocnFHbYmditAQIejukpjBmnzwHDCVFmj0U85VKcVmbUuJQ+jXuPNs OynHcxQOGvYVnLHQAk9feniiKjzicYWPRPMa+W4plmv1nIGv1pUMxMzsmokotMcDZlZu MLzsqW/H7zGJaY9F/fFeLBQOM2gII5lJDolu2hQ6kOl4FKgUptRlvtunHrmckKxZdpoi CTgA== 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 c23si3749297edv.143.2018.12.04.19.10.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Dec 2018 19:10:05 -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 (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wB533lEV088380 for ; Tue, 4 Dec 2018 22:10:03 -0500 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0b-001b2d01.pphosted.com with ESMTP id 2p63xf60h5-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 04 Dec 2018 22:10:03 -0500 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 5 Dec 2018 03:10:02 -0000 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 5 Dec 2018 03:09:59 -0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wB539wSN19398814 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 5 Dec 2018 03:09:58 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8887E112062; Wed, 5 Dec 2018 03:09:58 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1ECEB112065; Wed, 5 Dec 2018 03:09:55 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.85.73.253]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 5 Dec 2018 03:09:54 +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 Cc: linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, "Aneesh Kumar K.V" Subject: [PATCH V3 4/5] mm/hugetlb: Add prot_modify_start/commit sequence for hugetlb update Date: Wed, 5 Dec 2018 08:39:30 +0530 X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205030931.12037-1-aneesh.kumar@linux.ibm.com> References: <20181205030931.12037-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18120503-0052-0000-0000-000003618254 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010173; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000270; SDB=6.01127133; UDB=6.00585424; IPR=6.00907267; MB=3.00024450; MTD=3.00000008; XFM=3.00000015; UTC=2018-12-05 03:10:01 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18120503-0053-0000-0000-00005EFDF493 Message-Id: <20181205030931.12037-5-aneesh.kumar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-12-04_10:,, 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=727 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812050027 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);