Received: by 10.213.65.68 with SMTP id h4csp2196196imn; Sun, 8 Apr 2018 22:14:07 -0700 (PDT) X-Google-Smtp-Source: AIpwx49PjAG2IKTtfpsZxuEsPtAuOmolmPoqnesPVW8C4oxrV04MF50knH4cVo2RPHPxnZnrGoPx X-Received: by 10.98.71.76 with SMTP id u73mr28191007pfa.4.1523250847571; Sun, 08 Apr 2018 22:14:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523250847; cv=none; d=google.com; s=arc-20160816; b=FiFMY9cTQl8ZDlNOFLeLUQJkiL3sEeYxj+A5225764WSPEksgR607KqyQKyoVoxir8 DOa3MS5UdI079elNHAph5J1Ck6aad8wyx9Y/lJr4ZYm5nNf87/S/HG4eIlwMzKMMPJoH RSI5dPgLMdd4SsOOyhgbFN9MUye9xpAvjLRCrS1ugidJOhKl3JzTtWi4l/OM/Gjs8veV DBIvVtNe5tCOTA0AwR4c7iWmVR5iDfqE2UOOxciQqc/ESnJHklTOJEk1FIR49cpw0vzQ uyFH5kY3xWtvooGPsL7JN7J9W7PE9tgacBoEpysTpBO2lKbH021oYUelNhiVrn+Qa45C K0yg== 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=of/OwLR+z+L7pxR+36w5a3prPacve2iynm+T6CQV700=; b=wNh/mrnO11R5qN9IsjyOMvfTn89g5lyN3nwbU7ybSfmIFpIda34BbMdmolEz5YA+Bd i0EVzjupy7e95XebLB8ICg7Lp4fMZ56ZIa/IQl77bRHrEj80BEREWhXhkHpvtfA0ZNA3 NxZgbSL4IVgcNbXouDt6fVZRTBhgKwU5Chwyx0OIHyVPdf6sPZjYOEcDmBu9r1YW/uDL yQlMNqYlm1m8K0bki2dmfGLZsxrbme/HnX0lTJAqVhDyHngbwMptiSBSWGSkNshL4YNa G6t/0af4hdl4yVb0cpwegF3vISpNBrerAUDnMC1NASsSHiaj9s3AzXr9wurTVGEar+Jz qQWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=lIu3FSQI; 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 z79si3950425pfa.120.2018.04.08.22.13.30; Sun, 08 Apr 2018 22:14:07 -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=lIu3FSQI; 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 S1754171AbeDIAUM (ORCPT + 99 others); Sun, 8 Apr 2018 20:20:12 -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 S1754087AbeDIAUE (ORCPT ); Sun, 8 Apr 2018 20:20:04 -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=of/OwLR+z+L7pxR+36w5a3prPacve2iynm+T6CQV700=; b=lIu3FSQI9DZkN6M3ImtwnC1TAtlheORRfRfgSv4fIGZLGXyn6TpqjeL/55EAe+gHLKPxF/uvnejo/mT4w/rMbIOBbxbtUKLh8+xM9VAl9EwhS9jE7gKTdVLxifVi4p+I1rdDraHlDn+Gi5YQs167Js6mpCqd2dT45zXIxpUqUbs= 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:02 +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:01 +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.15 121/189] asm-generic: provide generic_pmdp_establish() Thread-Topic: [PATCH AUTOSEL for 4.15 121/189] asm-generic: provide generic_pmdp_establish() Thread-Index: AQHTz5hF/sYYiH4NNki7wGSwjH2M+Q== Date: Mon, 9 Apr 2018 00:18:23 +0000 Message-ID: <20180409001637.162453-121-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:6PytLbHqMhAs8cHBBdk0LuPegKjhkJuO9PSJTPFmiPAQQBVa0J9eWPAYWTQItLaBgf3WMTOgi0bSWaVDKSJH6ZNylL0jPqSZkxjhmiK1hg2jjhOhqm1pvo8KR45sVJBFdCeq0Whicg1pkzW9x2jol/xBnxwRZj6EUbvPgAvSPSybKibnWosB1kFzAp+/BJVP4nZHR6CbRozw8wfndLtZtOXA3952wfyMkBJhA7EPFXMS5+9WeSYtHl7egZdldWHw;20:mDNwoVDZaC81BxMnIg9XMopaBUyrTDD7xbTkyLHdJU9wcm3qMs3+wO0bT7fo+pNK6Y6lPVR60AO0IUcOmqsMH9y0H+zzgOuHyavo1KRRP9+8BYRrn6NNbWlCTO6nYs2c5w9A2QuCBrzW8XYcRVrT60qYJJveddRe+SMfTC/jm7o= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: cb4d941f-503f-4e96-25bd-08d59dafa2b7 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)(180628864354917)(20558992708506)(89211679590171)(190383065149520)(211936372134217)(42068640409301)(153496737603132)(104084551191319)(146099531331640); 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)(97736004)(186003)(36756003)(72206003)(53936002)(107886003)(2906002)(966005)(86362001)(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)(41533002)(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: zzcM0I1UDBKsOvd+eackZEqi0LNpQIaoH3IdQaCPLXNtj/WSJdddMztbRXIeetRBkTJ9S9T89Q8NDwpVRUJEFfq5ohQFh40Qpe7YsXyh5RPIh02mExKxwX66izFzEdB6BzaeBJsbFg80ogJ+4H1X6ER8ljzGKWSD54yabAARUnHCGT07edwortVpHXKOfK7u+J8VHTSrHs3sHDx63CuXYuajBPgP9eRQgiKi5J7ZGufNlxTEqTD3gOrZEpOm7cJ9th/lNCWnmbnzFMT5MFGDyOIsfCbI2Y6hhPgfI+rBhiVYqwGAME5rkVXgblKdkSdk2Y85bvajvNcglUc6QCmrK3zza6AZSPX98O5RAD+UHYjq3VBijrZqwjh6ug5oO1YKAgLaY2M4a0/UiXgnJAupauoLomyox0rqSIrqc4AGik8= 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: cb4d941f-503f-4e96-25bd-08d59dafa2b7 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:18:23.4116 (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: "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 dfc861caa478..b891134abd39 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