Received: by 10.213.65.68 with SMTP id h4csp2203750imn; Sun, 8 Apr 2018 22:25:59 -0700 (PDT) X-Google-Smtp-Source: AIpwx48bZivZ1e6bjygFxRhz7atugUW0h48EFbAOtQ5jtogHgA/Gh4xHi7FYpJin8GvuMTIAYXWJ X-Received: by 10.101.98.151 with SMTP id f23mr24080348pgv.98.1523251559196; Sun, 08 Apr 2018 22:25:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523251559; cv=none; d=google.com; s=arc-20160816; b=J/eYbdZ/STaULAsqWoythRruAGLLzf2qo96vQRFnWl6LiyjOGPgTBiA2Od4lzovQ6N n6MqyuaY5Q677y7Tf2ZkW4CIoUM7UcEaxp5shL/QvyDPHgSwbhM/4Y9T6zvyMAcy0udY rR/pAfGN2lVXHKIeUNH2lAhfArd/+t35mhH5tN/UKuUtDc8igxAyAF1xoNJIO1QT1hKu 1vwLRysD+WccGWTTxhG2IVYw2r5eD2Yjfogw31r4LoG0IMId+GT5vluLlr19BkUWOhKu nAOWV7s4SvIkiGG/posSBUSvMG73QDDIixooL2QcoBHnrUyM9Qy3xftoI+We6Jc3CVBb nXxQ== 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=UgfrCpcH81Pod6iodZz0qYzDWUS5Hzk1T8wXqBFyItg=; b=voy6VGAYIDm8h8SXXOpnEdnh5GMyPuuNXwu1VvRoHambMc9Oh8FNZJ+EIZqmzuA9E9 7qrvxQgruoXPYV7+3rFzMJTZ20BcxX5bCAIsYw9hf4LBp8scwB+MR3Rtx9ln+RjogiCa MO+PVYD8lKpJA4CmhTiKBOFONnywVl76XCMIHKBu8DTB2EcTfFknRUWlm8oW/ikFEhl6 BW+9AF9UGfm4UFepCsAGWi5NAHn0BbSsLmhhgibuytBtDeO1ARK72sk0i40EBVzFrUJM F363R2u7jO98B+r9/34Ub6GZeZi2kvoJv83GihgEM9rpUVmDzhsY1+j1YN/pOPZQWvmg yI/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=ZKYF2vgo; 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 i4si10695480pgr.820.2018.04.08.22.25.22; Sun, 08 Apr 2018 22:25:59 -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=ZKYF2vgo; 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 S1755087AbeDIAYw (ORCPT + 99 others); Sun, 8 Apr 2018 20:24:52 -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 S932107AbeDIAYo (ORCPT ); Sun, 8 Apr 2018 20:24:44 -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=UgfrCpcH81Pod6iodZz0qYzDWUS5Hzk1T8wXqBFyItg=; b=ZKYF2vgo1hScLna/cgvi2SJZyUkMzYe4UyEAenm6uL9JQFb6+JjtVdAjGKTGafbXJYhb9JKvFGuhxeVmWr7B5/WyT8DKOrk1yy+wLh8dZA+IlNaXyoZUPI92ZL/vXIPUO85MqAU1L8fnTz/45UT1jBaXl/AHvlgcvj36L0xQXYw= 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:42 +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:42 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: "Kirill A. Shutemov" , Vlastimil Babka , Andrea Arcangeli , Michal Hocko , "Aneesh Kumar K . V" , Catalin Marinas , David Daney , David Miller , "H . Peter Anvin" , Hugh Dickins , Ingo Molnar , Martin Schwidefsky , Nitin Gupta , Ralf Baechle , Thomas Gleixner , Vineet Gupta , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 101/161] asm-generic: provide generic_pmdp_establish() Thread-Topic: [PATCH AUTOSEL for 4.14 101/161] asm-generic: provide generic_pmdp_establish() Thread-Index: AQHTz5irbW9ba6ZUvEGFamGTXqeKNA== Date: Mon, 9 Apr 2018 00:21:13 +0000 Message-ID: <20180409001936.162706-101-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:ej0j+q9FrCtrQatlbYMNXCz9vQPia7KiI58fMNpzHdOzybZS7D8RX8Cqwa2hliOqdpgmeQ89iCCVUFVce+10XH7YDDn8kyVGtb3qUuhXU5KOhGIpPjhu6FF+/jLXD3ZcXPiD/WhEfv0qgarYivSM7M/C6LaAUvRC1VyyXH0wj6y3KkvHWO+mxAThUQKnSKqv+0fDeCOaMSEAYaEogpWkP/wX7cRA8Pm5ww692RWdEBrznpWEIXu/q+0L97+gLYK7;20:+i/ZPMs6lgfIJm921NZdWlIx6i5MYufO5rvN2RTvklovl5P90czeaTKjcVu1zrdfa21AQ6Ozx5mR13aizdnRgWv/ictMA4IS81UlNz1ucnIrBrjXPrnJRw3W83aDK3N7fLPSzXDhmqfVsR6+N8+aUOoJZ656Qu7nEUKl0OEuZ+E= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 4cc2fb2c-7697-4ef7-313a-08d59db04a15 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)(180628864354917)(20558992708506)(89211679590171)(190383065149520)(211936372134217)(42068640409301)(153496737603132)(104084551191319)(146099531331640); 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)(1076002)(476003)(2616005)(7416002)(10090500001)(6486002)(107886003)(36756003)(4326008)(966005)(2501003)(68736007)(186003)(305945005)(3280700002)(5250100002)(6306002)(6512007)(26005)(14454004)(22906009)(41533002)(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: jCXP4icKNRJQimvsFR26G2ORZn6Z0tmxF5IsQH4NFn4t4LBjaOBa+c+LKIZ6844OO2og9DpN5iENr+iuFgAQCPXb9WC70/0XFAS3NXDzIVcLA9ZDI05khM7VIF1QGHXkFPEF02jXR6X9ONoOKZGuprkLy5MWCA8aZrstaxZ7f6ajyViljAb5Vp9JZhG/60TWcfIOQTQQdA3F4NptFQwLwMjN0f81/FibHvBpCztklSz2d+jDFO1Iyx/KO6LgeZcQe9zWM815Xl4bzuN3OpGURD5CYEM7jSiI+L+26BKzYK2fktYjYaBUAKwcNUecqKqRDJMZ/3uabU/JuRZuc39bFeD2blVuiF3yB+oJIyzepI823siTIxXvOuJU/i4wBA6ew4lbcjtnpVHnGveRJk9mSXjb8clrDuSlb6ahlGvMcX8= 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: 4cc2fb2c-7697-4ef7-313a-08d59db04a15 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:21:13.8156 (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: "Kirill A. Shutemov" [ Upstream commit c58f0bb77ed8bf93dfdde762b01cb67eebbdfc29 ] Patch series "Do not lose dirty bit on THP pages", v4. Vlastimil noted that pmdp_invalidate() is not atomic and we can lose dirty and access bits if CPU sets them after pmdp dereference, but before set_pmd_at(). The bug can lead to data loss, but the race window is tiny and I haven't seen any reports that suggested that it happens in reality. So I don't think it worth sending it to stable. Unfortunately, there's no way to address the issue in a generic way. We need to fix all architectures that support THP one-by-one. All architectures that have THP supported have to provide atomic pmdp_invalidate() that returns previous value. If generic implementation of pmdp_invalidate() is used, architecture needs to provide atomic pmdp_estabish(). pmdp_estabish() is not used out-side generic implementation of pmdp_invalidate() so far, but I think this can change in the future. This patch (of 12): This is an implementation of pmdp_establish() that is only suitable for an architecture that doesn't have hardware dirty/accessed bits. In this case we can't race with CPU which sets these bits and non-atomic approach is fine. Link: http://lkml.kernel.org/r/20171213105756.69879-2-kirill.shutemov@linux= .intel.com Signed-off-by: Kirill A. Shutemov Cc: Vlastimil Babka Cc: Andrea Arcangeli Cc: Michal Hocko Cc: Aneesh Kumar K.V Cc: Catalin Marinas Cc: David Daney Cc: David Miller Cc: H. Peter Anvin Cc: Hugh Dickins Cc: Ingo Molnar Cc: Martin Schwidefsky Cc: Nitin Gupta Cc: Ralf Baechle Cc: Thomas Gleixner Cc: Vineet Gupta Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- include/asm-generic/pgtable.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h index 77b891a8f191..2142bceaeb75 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h @@ -309,6 +309,21 @@ extern void pgtable_trans_huge_deposit(struct mm_struc= t *mm, pmd_t *pmdp, extern pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *= pmdp); #endif =20 +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +/* + * This is an implementation of pmdp_establish() that is only suitable for= an + * architecture that doesn't have hardware dirty/accessed bits. In this ca= se we + * can't race with CPU which sets these bits and non-atomic aproach is fin= e. + */ +static inline pmd_t generic_pmdp_establish(struct vm_area_struct *vma, + unsigned long address, pmd_t *pmdp, pmd_t pmd) +{ + pmd_t old_pmd =3D *pmdp; + set_pmd_at(vma->vm_mm, address, pmdp, pmd); + return old_pmd; +} +#endif + #ifndef __HAVE_ARCH_PMDP_INVALIDATE extern void pmdp_invalidate(struct vm_area_struct *vma, unsigned long addr= ess, pmd_t *pmdp); --=20 2.15.1