Received: by 10.213.65.68 with SMTP id h4csp2117147imn; Sun, 8 Apr 2018 20:08:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx48aOYPvCATWSOgeZrPYxRtbMjHXCcd6VLx7YLZ8sXbiAI/OmSqFezxPZvmPJWxhc5R8uyu1 X-Received: by 10.101.65.75 with SMTP id x11mr24105986pgp.203.1523243289530; Sun, 08 Apr 2018 20:08:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243289; cv=none; d=google.com; s=arc-20160816; b=xTRMjMhkJcmE9rOEc03DjoIw4FmYKTRDslbv84kboOcw9LdTtaCEV+QO/hVAgNYlol KbKPmoZNOQQC/IXHkiSV1MAjgBbr32v0/IqYLu7sswcoTMafAgFJCk5wG+zLjNgAlvBU 7B4J50n0/RVBkBmo8eup8hTEBsKmAEENx6sE2Bmq26gNDbaTtuBS8DxTkFr4pqU0AWjT UQMYNybgHboc1hvVMjKwUdZ5A1YHX3g5ioqebsftJSxMWSQBxsZEr+Lu6Hx2KKuWIzox 5pmXt9ZzB3O27hGCKuaCak+hYMhrVMCs6uhdf4+rWKEkbDmBqnc4GEDZF1aEWSW5UDGe wyGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=j+OYy6cz8ZPCfIV27YFyi9teIQz9U1SCCcmWWigUUqk=; b=o8A+9nN/FZkTC4WiIJ3GFUaHj9fQ36RusiPCsSgFckETGWYlOrMPibfCrzB9wEXwNL Nr8ORqpQ0w02enG13vzFk9qBvSi7fKr5wZkzEDh+tg5AlW5AeIPDt9AtuFfu69KzObDY n6X6273LZUvV+ScWheToymFx8HB7jEOTcMnlK77UMPOu+bKOhrrifswDIPCgi7OcVmmZ 2KRLGVFjjA3psd9kZ6HDAo9zYkkAbKtU+KNAoCOBah7b5odTSe4DACPwvf/yUiSrufcL m7Q4ZpTFJ0u20P+IZ+GDPfih1+Ny/qZM7p0liHr2CvbFazsscywSP0WSI4X/aGa/9Ir1 csIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=YQmwUOFr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q61-v6si13230124plb.729.2018.04.08.20.07.32; Sun, 08 Apr 2018 20:08:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=YQmwUOFr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757337AbeDIBtI (ORCPT + 99 others); Sun, 8 Apr 2018 21:49:08 -0400 Received: from mail-by2nam01on0130.outbound.protection.outlook.com ([104.47.34.130]:18358 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932389AbeDIAd6 (ORCPT ); Sun, 8 Apr 2018 20:33:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=j+OYy6cz8ZPCfIV27YFyi9teIQz9U1SCCcmWWigUUqk=; b=YQmwUOFrckUjLAOgKhsrhVN5bO5fvEEU+oQ8GLpCishsffAFFH181KNFPx9j96p4AtchdORCRHNdbnntDZ0lKdXUO0T395sBUxhYdERiIvxiZXyoaHcJGBUY5lS8/WmxRFN2cSwnJ1Whg3GQaOWl1B3IicjyDGQa0D6eGKKqYd0= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0806.namprd21.prod.outlook.com (10.167.107.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.3; Mon, 9 Apr 2018 00:33:55 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:33:55 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Nitin Gupta , "Kirill A . Shutemov" , David Miller , Vlastimil Babka , Andrea Arcangeli , Michal Hocko , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 260/293] sparc64: update pmdp_invalidate() to return old pmd value Thread-Topic: [PATCH AUTOSEL for 4.9 260/293] sparc64: update pmdp_invalidate() to return old pmd value Thread-Index: AQHTz5lgvKIGG/kwxECdjbEdJOL0WQ== Date: Mon, 9 Apr 2018 00:26:17 +0000 Message-ID: <20180409002239.163177-260-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0806;7:8gitSj5KkjNTWuByUdYRPbPPsUkW1D/eE7eKgBwAZkAFwCsTO85wAMzfJzDJCwaKP/xBGcs70hrEUVNtU51pbiD9xddXnW5rotAVDrO/E9Wilnp1UtXKRGZuzdnDjToNonQThNqsBmTyyUhC3HWCkAq1kqpbl958t+5PipZSBX7iJs890pTjSFSOCqWsHpZUIlhjnArHvc7jqT1zS0Kqty7AaS8lQxSf5qu8oXazfYNsIfGSipd0rRvg3zrt8Zou;20:W0dZ64QBiLUyZFjqXc7XAhIx8TJjz1wk9n5SgE2RkeObSE6b1lfFtpnq6FTEjsxO2nvYqSsCkLTQ4LQ6G1rlWOYwU25iv4f0QycsY+yjtnn7cXgySXwf98/O0lUpLyHWxdonz9aCm/qyeYFHQV2MpIIFRNSzV7guY2bAwOcInn8= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 111bc324-ae70-4af0-b2d2-08d59db19373 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0806; x-ms-traffictypediagnostic: DM5PR2101MB0806: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(42068640409301)(146099531331640)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB0806;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0806; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(376002)(396003)(366004)(39380400002)(199004)(189003)(2906002)(25786009)(2501003)(10290500003)(476003)(10710500007)(11346002)(446003)(97736004)(5250100002)(68736007)(2616005)(102836004)(7110500001)(6506007)(59450400001)(3846002)(3660700001)(486006)(3280700002)(305945005)(6666003)(99286004)(5660300001)(76176011)(7416002)(1076002)(186003)(26005)(7736002)(6116002)(81156014)(81166006)(86612001)(4326008)(105586002)(2420400007)(15650500001)(10090500001)(2900100001)(54906003)(22452003)(316002)(36756003)(110136005)(107886003)(8676002)(6436002)(478600001)(53936002)(66066001)(6486002)(6512007)(6306002)(575784001)(86362001)(966005)(14454004)(72206003)(8936002)(106356001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0806;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 7lfEv0peTkHho9VQIabXOesl3sUAAcffjrVvxbKbSrlQQMfDEUWRPL0ZWoZmq9bs3FQmqCUF9TykOjy88QcA3cLWBttRRmyw3s5mTA6aTMRW44czA6oXs1fAMUcdc3C4IOtFDuBXBww1hYSEgccRBK6K1PU210+eK/Njso+ViYWDoIKTJcedoIdIZcb1m8RsZaEq5vust9r9C8qFUlumS4gp0rwIHuwXbnqwJW0XLoqGIB4xqJA/L5t/tgqcyMDUvOfsAQBOOzo5KAWCjWh2O01jQncD6v8oQeTpIsko7vkTSOY1CTuk/OTIcAhGD/DrmY857QLFDvrbttsEoH2Vhw6teN+sSc6tsg+6i9s/UNBOSjvwaxuF9YKVxjzDePJceagPfHk0X3j4bvsN915FMlX9tQyBGSxMFLiPRcxRRos= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 111bc324-ae70-4af0-b2d2-08d59db19373 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:26:17.5507 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0806 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nitin Gupta [ Upstream commit a8e654f01cb725d0bfd741ebca1bf4c9337969cc ] It's required to avoid losing dirty and accessed bits. [akpm@linux-foundation.org: add a `do' to the do-while loop] Link: http://lkml.kernel.org/r/20171213105756.69879-9-kirill.shutemov@linux= .intel.com Signed-off-by: Nitin Gupta Signed-off-by: Kirill A. Shutemov Cc: David Miller Cc: Vlastimil Babka Cc: Andrea Arcangeli Cc: Michal Hocko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- arch/sparc/include/asm/pgtable_64.h | 2 +- arch/sparc/mm/tlb.c | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/p= gtable_64.h index b6802b978140..81ad06a1672f 100644 --- a/arch/sparc/include/asm/pgtable_64.h +++ b/arch/sparc/include/asm/pgtable_64.h @@ -952,7 +952,7 @@ void update_mmu_cache_pmd(struct vm_area_struct *vma, u= nsigned long addr, pmd_t *pmd); =20 #define __HAVE_ARCH_PMDP_INVALIDATE -extern void pmdp_invalidate(struct vm_area_struct *vma, unsigned long addr= ess, +extern pmd_t pmdp_invalidate(struct vm_area_struct *vma, unsigned long add= ress, pmd_t *pmdp); =20 #define __HAVE_ARCH_PGTABLE_DEPOSIT diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c index c56a195c9071..b2722ed31053 100644 --- a/arch/sparc/mm/tlb.c +++ b/arch/sparc/mm/tlb.c @@ -219,17 +219,28 @@ void set_pmd_at(struct mm_struct *mm, unsigned long a= ddr, } } =20 +static inline pmd_t pmdp_establish(struct vm_area_struct *vma, + unsigned long address, pmd_t *pmdp, pmd_t pmd) +{ + pmd_t old; + + do { + old =3D *pmdp; + } while (cmpxchg64(&pmdp->pmd, old.pmd, pmd.pmd) !=3D old.pmd); + + return old; +} + /* * This routine is only called when splitting a THP */ -void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, +pmd_t pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp) { - pmd_t entry =3D *pmdp; - - pmd_val(entry) &=3D ~_PAGE_VALID; + pmd_t old, entry; =20 - set_pmd_at(vma->vm_mm, address, pmdp, entry); + entry =3D __pmd(pmd_val(*pmdp) & ~_PAGE_VALID); + old =3D pmdp_establish(vma, address, pmdp, entry); flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE); =20 /* @@ -240,6 +251,8 @@ void pmdp_invalidate(struct vm_area_struct *vma, unsign= ed long address, if ((pmd_val(entry) & _PAGE_PMD_HUGE) && !is_huge_zero_page(pmd_page(entry))) (vma->vm_mm)->context.thp_pte_count--; + + return old; } =20 void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp, --=20 2.15.1