Received: by 10.213.65.68 with SMTP id h4csp2204109imn; Sun, 8 Apr 2018 22:26:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx49xLj/unxNUOrge1NqFGFc83YqxaS3u9ckZeZ7EvpMv8VPUydNkTLPFXn/g+dsC/ApT4CDq X-Received: by 10.99.125.87 with SMTP id m23mr23518623pgn.297.1523251596752; Sun, 08 Apr 2018 22:26:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523251596; cv=none; d=google.com; s=arc-20160816; b=VEu/I81yYd5Tn8KQxlyvEjVKkcgvPFuI0yNqOIm5y/3ecJfDxT+7auB+q0v78MbbLD DTrY2Rj10ylMUUJ1kxXqCfDiOf/3HDKLMdwFCzmP80L55swt4+fx5tkJBfuB99hDh7Kd eQJeMDPOel7iDN6yOGlIiFgStr9O38rIjz2rXRco6zsAD1phbbahQFXRbDh/EfBrbVit nABzX5PTgwCMQX7iH31K2o5YHfgRU9TO4SnmG8AcH+lNQ12lbYmihfEKNJv7GKbmVY+a +wKbTJMDBQG7m2Nct2JusWeXOCgZEOHEyyZAGYOTDPiBXRGVlYA5ASuV/UT4xkKqa1ca pFZQ== 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=KEoXlPuciAKIYgJbBn6KxPefOkh6vDudHfTsDkyFph0=; b=CNoO1mog6SGqI910nZccudySXWugD1eE19xiMS74C1w6X4tnirNlWPaywDK6NzyUxO DFIbzCgfzsPMgRlwF2dLlRr60ab9ELQqJvu1QV3dt+NSo3Y0993xVBs1FP+s3/BFNsLZ vKiuszte6Phc2bRgPhTFd5+3R2NOxMWBEKqlgGWH0xgO0iVuTk0ts0TzUoZEGe9ukZAl p/PwpEaxSoBgfaD+GyJp07djMuVccrUHLYy00xQZPnTVXlLf8kUrHLHi3TC1jeA+dZtm 9T1n7zwAwZw5UhtFUgDLsEG6bc08UrtB7BOzWptNQzTJcKuHIvAKzHLxT7EdDOIMSnw1 zvvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=jyO57HnM; 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 z21-v6si13455429plo.225.2018.04.08.22.26.00; Sun, 08 Apr 2018 22:26:36 -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=jyO57HnM; 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 S1755107AbeDIAYy (ORCPT + 99 others); Sun, 8 Apr 2018 20:24:54 -0400 Received: from mail-sn1nam02on0128.outbound.protection.outlook.com ([104.47.36.128]:23328 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932094AbeDIAYr (ORCPT ); Sun, 8 Apr 2018 20:24:47 -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=KEoXlPuciAKIYgJbBn6KxPefOkh6vDudHfTsDkyFph0=; b=jyO57HnMxBAHXbMLnRYxDmwlouO/mIp6sOs0ftXG5TdrTrgyUrFC0F98Ng7KDIlExEyAc+s/6vyfpayFZz+UcEC83FbOHgs+wN6g635Ql35wZMfHBviSJu/tx72ttA8AebCxe+VfKX3whWmsBcjywRdP47Y/jw23WvksI3U1rEA= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0983.namprd21.prod.outlook.com (52.132.133.29) 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:24:43 +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:24:43 +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.14 102/161] sparc64: update pmdp_invalidate() to return old pmd value Thread-Topic: [PATCH AUTOSEL for 4.14 102/161] sparc64: update pmdp_invalidate() to return old pmd value Thread-Index: AQHTz5irXVKrMj7J002I4h8KOD1WBQ== Date: Mon, 9 Apr 2018 00:21:15 +0000 Message-ID: <20180409001936.162706-102-alexander.levin@microsoft.com> References: <20180409001936.162706-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001936.162706-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;DM5PR2101MB0983;7:qvVLQEM3KUc/5VFSWpSLh1nntZ5wgAApd3eTzlHpH0nw9tYKZxB9pc1CdMPAsDErj8fdsF4c6/gD50ZtPYrl9ZAXaIH/ZJuJt+czMHQ97c1UKepKPWzD+aoFDbBzS/EAbHWSajBTUgyGHV6J1e3arjRFgOp5N20+dp/xfOXNOG/6aWhXMQil5+CiZZboZLD5b19fDoQ7h+r/c0W+20nC+0PUkWdA5aa/oGgWvUc0KoEtXh3ADHnV4LSAX1RhrE8v;20:CUSNeGgWADKIKfMhEHV7J8wvD0fX6ScmgALOOhHvtVUSgAML3fgLfwFDAFPZ8PY7zbyVcxV9E+zTZ731Ab9kKEazTZkezvbwH/7asam1okhXkNFO5YoCUEGmtc/nevkKoGGrB+xcerY5gkHg4gxnOFvTsRyZhiiLeZubrT+w0jE= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 9a04d318-e96b-49ca-7b15-08d59db04a80 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0983; x-ms-traffictypediagnostic: DM5PR2101MB0983: 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)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0983;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0983; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(346002)(376002)(39380400002)(366004)(199004)(189003)(478600001)(59450400001)(72206003)(10290500003)(3846002)(102836004)(6506007)(6116002)(25786009)(6436002)(66066001)(99286004)(54906003)(86612001)(6666003)(105586002)(53936002)(76176011)(316002)(486006)(7736002)(22452003)(3660700001)(86362001)(97736004)(106356001)(575784001)(8936002)(110136005)(5660300001)(11346002)(446003)(81166006)(81156014)(2906002)(8676002)(2900100001)(10710500007)(1076002)(476003)(2616005)(7416002)(10090500001)(6486002)(15650500001)(107886003)(2420400007)(36756003)(4326008)(966005)(2501003)(68736007)(186003)(305945005)(3280700002)(5250100002)(6306002)(6512007)(26005)(7110500001)(14454004)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0983;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: 3KellAvaCuhCf8RnpQdBLTC5gL3uhg5a78EZ2/O41jow/D+WFHXEkpydH0eMWM4fE7pPs8P9az+IdO7KxM/82uur6+fvIEROeHc6A9P+YKtgde7Rtxg83SA4DSZxzDbEGyzBIaKOgWpvzYjiXpjLmMVu7cY4WIUvvlAcwo+DZ5NejE3Chqx+tGNFf0nKrAsvytjAkii2zpr5eacaO5VnUSmmAfL7pvvi3BVt/QbF/CZ4Sii9UtCJWAC/sVgWzKiA8rpagso6YNM6GKrTVA/yVkif0gVV+xfXpuDMfT8nItT4vPKC0b4ef3vXoiXH9pDQzZ+ZpB8AXQzZxz5utm7zYoXTNHT3/gI7bvktqHvjiCO1kjEVYZrURLvx60vP/vJNj4UHeZrJFd63tX3YiE0iGbkgHB3aSCibP0o6wFwawYk= 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: 9a04d318-e96b-49ca-7b15-08d59db04a80 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:21:15.2688 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0983 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 fd9d9bac7cfa..79c3bdaaa0b4 100644 --- a/arch/sparc/include/asm/pgtable_64.h +++ b/arch/sparc/include/asm/pgtable_64.h @@ -980,7 +980,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 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