Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751009AbdHMGO1 (ORCPT ); Sun, 13 Aug 2017 02:14:27 -0400 Received: from mail-co1nam03on0083.outbound.protection.outlook.com ([104.47.40.83]:64240 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750863AbdHMGOZ (ORCPT ); Sun, 13 Aug 2017 02:14:25 -0400 From: Nadav Amit To: Peter Zijlstra CC: "open list:MEMORY MANAGEMENT" , "Linux Kernel Mailing List" , Andrew Morton , Minchan Kim , Ingo Molnar , Russell King , Tony Luck , Martin Schwidefsky , "David S. Miller" , Heiko Carstens , Yoshinori Sato , Jeff Dike , "linux-arch@vger.kernel.org" Subject: Re: [PATCH v6 6/7] mm: fix MADV_[FREE|DONTNEED] TLB flush miss problem Thread-Topic: [PATCH v6 6/7] mm: fix MADV_[FREE|DONTNEED] TLB flush miss problem Thread-Index: AQHTC1+TxCEaBxMZR0CSGo2awCTWD6J/NTUAgAKq2AA= Date: Sun, 13 Aug 2017 06:14:21 +0000 Message-ID: References: <20170802000818.4760-1-namit@vmware.com> <20170802000818.4760-7-namit@vmware.com> <20170811133020.zozuuhbw72lzolj5@hirez.programming.kicks-ass.net> In-Reply-To: <20170811133020.zozuuhbw72lzolj5@hirez.programming.kicks-ass.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2601:647:4580:b719:ccc4:4166:fd5b:554e] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BY2PR05MB2296;20:+ubQaQbwzolAoy1ZXIXz/ocmsXRgdYGCOtF6cY0vkNaaZKzXDz5z76bcnTsJzMy8WvCV/Ttxr+HRaRrv80sSzFmyz9LUSx06kdmeNEI3e7mAxi3JKH2j+EQNZexaIL2sGSwHbBK1JN1GmXEGx9ddec7UWr+80T85vpP58XjAbJ0= x-ms-office365-filtering-correlation-id: bbf36d73-40bb-43ac-7c38-08d4e2128a1a x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603124)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:BY2PR05MB2296; x-ms-traffictypediagnostic: BY2PR05MB2296: x-exchange-antispam-report-test: UriScan:; x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123558100)(20161123564025)(20161123555025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BY2PR05MB2296;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BY2PR05MB2296; x-forefront-prvs: 03982FDC1D x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(199003)(189002)(24454002)(86362001)(54356999)(36756003)(189998001)(50986999)(76176999)(2906002)(110136004)(102836003)(6116002)(7416002)(14454004)(4326008)(229853002)(3280700002)(101416001)(6436002)(25786009)(33656002)(106356001)(68736007)(105586002)(3660700001)(6246003)(6916009)(2950100002)(83716003)(53936002)(82746002)(54906002)(305945005)(81166006)(99286003)(8936002)(7736002)(478600001)(81156014)(6512007)(5660300001)(77096006)(8676002)(6486002)(97736004)(2900100001)(6506006)(83133001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR05MB2296;H:BY2PR05MB2215.namprd05.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; authentication-results: spf=none (sender IP is ) smtp.mailfrom=namit@vmware.com; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: MIME-Version: 1.0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Aug 2017 06:14:21.8018 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR05MB2296 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v7D6Eawi024393 Content-Length: 1253 Lines: 33 Peter Zijlstra wrote: > On Tue, Aug 01, 2017 at 05:08:17PM -0700, Nadav Amit wrote: >> void tlb_finish_mmu(struct mmu_gather *tlb, >> unsigned long start, unsigned long end) >> { >> - arch_tlb_finish_mmu(tlb, start, end); >> + /* >> + * If there are parallel threads are doing PTE changes on same range >> + * under non-exclusive lock(e.g., mmap_sem read-side) but defer TLB >> + * flush by batching, a thread has stable TLB entry can fail to flush >> + * the TLB by observing pte_none|!pte_dirty, for example so flush TLB >> + * forcefully if we detect parallel PTE batching threads. >> + */ >> + bool force = mm_tlb_flush_nested(tlb->mm); >> + >> + arch_tlb_finish_mmu(tlb, start, end, force); >> } > > I don't understand the comment nor the ordering. What guarantees we see > the increment if we need to? The comment regards the problem that is described in the change-log, and a long thread that is referenced in it. So the question is whether “I don’t understand” means “I don’t understand” or “it is not clear enough”. I’ll be glad to address either one - just say which. As for the ordering - I tried to clarify it in the thread of the commit. Let me know if it is clear now. Regards, Nadav