Received: by 10.213.65.68 with SMTP id h4csp2145853imn; Sun, 8 Apr 2018 20:54:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/VNGzvS3/MGb8xw3aSSE7Y1Vew8D4JYLPqButcJ8bIewv9LknUGx5zIkUep7uNc5MfVYPp X-Received: by 10.101.101.15 with SMTP id x15mr24274041pgv.322.1523246068185; Sun, 08 Apr 2018 20:54:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523246068; cv=none; d=google.com; s=arc-20160816; b=quPIgdKWsCOYLL7X4AERaYvACejDjLB3W1c215jPCrAEm7PGZwYJfFRhbyNbWcbXxB 9BUYK1pm8GZ+IRckgdyyxBP6KcUL2ZEJWhVGe3XjLZ3j7svonUDYCeLTYB158lusx/vq JAX5h2SMR7BPkMdCkmxspVPDwV2cyYgaiBI7ygDIbqoc2Vi5CToU10t5QV3h0ZwjVCHw ekdZ140HnL718Uj7VLKoIkX4EXJkjJ8W+KGvj6iEhf38ObPxm3ke//ylVMWXmNfRE1GP jsIcZux8ZQ4Zqz6/XdJ8R42THlrwi32b6s6HJfaRK6X/NBddlHyDxHlvcpWJMqBIHZtO JFxw== 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=l9wYK0oqMmBPm9MV5DTYEHd6q+YfXdVxP9eqM7V9LAg=; b=SglJnD0FbjsfEs9+wOVz+QsMWCkv8IA2HtTaAJHB1DfGQb5LnPlwDCZHLbQnr9GSEW sjgnAg4Sh11nLx0RQ3cHsQJTmper9QVaWllkjfDcbgsH2SnJqO2qwDefA9VYkTTqqkPt KZ3AJaOW5PUb93zNE5hKkbTW2GvhuUTTdYamy0IwtTheEt2WJPHBEM7Af/NfKZbuTyyN g+/6hoIObj3awHNBBkYv3p3/Woj19ooBy6jDioHNq2iTTUk7OWi9GwriAfuleWa5s4ER fduEcS7PdrITW/vIl3XdBgxfe9lyc1qlL4gn7D4Q5/AG2Tih0fTjVUxNlhq/3eo6WhrA jX5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=NWdXz3ee; 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 bi5-v6si15222805plb.609.2018.04.08.20.53.51; Sun, 08 Apr 2018 20:54:28 -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=NWdXz3ee; 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 S1754236AbeDIDsp (ORCPT + 99 others); Sun, 8 Apr 2018 23:48:45 -0400 Received: from mail-bn3nam01on0125.outbound.protection.outlook.com ([104.47.33.125]:5792 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754119AbeDIAUF (ORCPT ); Sun, 8 Apr 2018 20:20:05 -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=l9wYK0oqMmBPm9MV5DTYEHd6q+YfXdVxP9eqM7V9LAg=; b=NWdXz3eeNGfXIOhwrxEfMTAv6Io1oWHhfOXbNLC+t3f2oovj0d3SZgaERzeZKiOxkmBEMs6fJPRJl3mkjZPqKOlt2w9MDL9bsRdk4QEv6Yv2Xj/jgHuVxoeJrZtvEAWL8Nc+fgwIvJBXQUm1yIeq55EezY+OPBv5cVkRf4WgFbU= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0726.namprd21.prod.outlook.com (10.167.108.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:20:03 +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:20:03 +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.15 122/189] sparc64: update pmdp_invalidate() to return old pmd value Thread-Topic: [PATCH AUTOSEL for 4.15 122/189] sparc64: update pmdp_invalidate() to return old pmd value Thread-Index: AQHTz5hG+Wtv09jpO0qZV0VerZTeaQ== Date: Mon, 9 Apr 2018 00:18:24 +0000 Message-ID: <20180409001637.162453-122-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-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;DM5PR2101MB0726;7:3H5dFlO9qSWFAhBKydvEYlNVxZ2pv3w8UoJOSldjaUaki5hTne5PlYK+pKTokp6yU3/F75gIfs2mdXPdRhf9kqjlbdbDEZhAQ1jMyZ4GpkN0yHxtFmwAeomQ0yd8VonRsHP6yiWchjQkEAd6kW+c6EF606qwyXHWhnFbCCqwFkj7VkyiC9Sm2YiO5oXOdMFosrmhtrZWn2Cb794+gRJQQ2a0wkwbckvdIrTUrGpzw/WlWa44nRTyfkmHwldfNbYu;20:nWFiDgLOdkhxiN0R1+nGz+TXWPimUBWTZGiDK/aM2NPo5AsWrP16G7BCZRNC0WsbzFLOfprjaGXBChNhC4A7W3TyMDi3Uz+jt8xQCpnjdDVoCxzPV71zndBmnhIwrCJywlLylRMvlr27rhRQXxj4EFOWsNu2TlseYG7+WbLCwqM= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: e009d3c3-3395-4b6d-8f81-08d59dafa3a5 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0726; x-ms-traffictypediagnostic: DM5PR2101MB0726: 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)(5005006)(8121501046)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:DM5PR2101MB0726;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0726; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(346002)(39380400002)(39860400002)(396003)(376002)(199004)(189003)(6306002)(6486002)(26005)(6512007)(4326008)(81166006)(6666003)(6436002)(81156014)(8676002)(7110500001)(97736004)(15650500001)(186003)(36756003)(72206003)(2420400007)(53936002)(107886003)(2906002)(966005)(86362001)(10710500007)(575784001)(76176011)(7416002)(110136005)(305945005)(10090500001)(486006)(3660700001)(102836004)(5660300001)(14454004)(476003)(86612001)(446003)(99286004)(68736007)(66066001)(11346002)(54906003)(2616005)(1076002)(7736002)(5250100002)(25786009)(8936002)(478600001)(2900100001)(2501003)(3280700002)(105586002)(59450400001)(316002)(106356001)(22452003)(6506007)(3846002)(10290500003)(6116002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0726;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: PTPi2pAilteJ7POgPHmE2MGWPGKxzOpe/YXp9et/6HA/3ESIuzl3kSUvpv8qplZ4Zkjm1yQ3UarPqwUTOmE8dXU//a8uUwML/H34PLx6/qqvpg9+uz9y4uzafwWFI4eNe97L6p3v7iyAm+a+TMvcP0MWMt+MTVidmtenxPpNhMy2m/dGio/bnenZiJo/m4LTeTU34l74d2vpzBSlOLGwoWJ10fppyOwCG1JPNMKvRHBeRVQuOLssBmNWb3uvgjTuiekT/Hntm1Zc57hQyAkpWZ8ssdSn1fSTPFJ/p2IMOXj+iV4hzov4E0e8IiNP3EtPfobeneiVNwN3Hp3UgDnubXkqRP4hAh+r3olbkNSRX20oct34y3yx17vgXIXzUgqpDIcag/xEVUv9mXNrIuY4MZr2eTBbLhUxRha6BJppL4Y= 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: e009d3c3-3395-4b6d-8f81-08d59dafa3a5 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:18:24.3760 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0726 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 9937c5ff94a9..339920fdf9ed 100644 --- a/arch/sparc/include/asm/pgtable_64.h +++ b/arch/sparc/include/asm/pgtable_64.h @@ -1010,7 +1010,7 @@ void update_mmu_cache_pmd(struct vm_area_struct *vma,= unsigned 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 4ae86bc0d35c..847ddffbf38a 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