Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1116432rwl; Fri, 24 Mar 2023 06:33:41 -0700 (PDT) X-Google-Smtp-Source: AKy350bwt/mCIxK074RFWPTVD+a6la3eSg9nsA3HyrOFIeuJTnZlAAuRM5IUnWtv5NI5l5YeDbH5 X-Received: by 2002:a17:902:da8a:b0:19e:b2f3:e8c4 with SMTP id j10-20020a170902da8a00b0019eb2f3e8c4mr3292723plx.25.1679664821086; Fri, 24 Mar 2023 06:33:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679664821; cv=none; d=google.com; s=arc-20160816; b=NMNQim9/T54o5RZqvqAoRrIHZwtSFsA69M996MaFVOcLe44laMIPuXQazqQZZwtcEd xVWh2zEQ52RrMVrtI+Zp0ZNZbqy+t6WVNZ798C9eAL6Yn+u+u3E9TDOL0E6n1p98Ly5J JThImlfap2KTk/b8XCDj/4cotDTZfWxcbMnbrIJP7SIY+DlImmiIcbmJ9dVJYKFmShGV r28yahTZXMRLw0wMnco2oyL9FMSHWwXZaZluqI7fuYCeCrWCdprmtJ2B8H1i9WZM2Wgx 3rJztDKfWJsRRmYtP+13151SRgbHCHZFXFHdDMgc/IBHX4gUvlCK26BipF/JbX28yVve vO4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=I28hRGirzN8hVkdWraPB+LlmHvIXHPkHvuCGx6fgbb8=; b=Kr0MV4NrMSTT2RPIwvd1L3DAg9HntZph9WYygTiHp9rMdjUKfNSLpmFS96VxnaJT30 oZG4/aC9R/YW4NJVfjj5+dWlhlzJSDlH8nmSofpkSAjULLP7mljftRcGAnL1LBCDbwWm lU/a4EkW1wREaqTjz7O4vNXgy9xy/TzSeOUj6SsqG8kEvsjGuv34cJjaOd0HWK6Rq3h2 c7dtBN/9eU6Yvaktnyq6WwfQFSgT2qvKO6991cZYv3hlaBZ8apy+HedleM0zh1R+hHdA PLuCbwxvEpuhY+eL2n4DYx3rUdRkUWFKsVv7rz/Hc5f6ocBAoBQ6BTw6CeWJ0uFoSyco f5ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="deQGo/FB"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e17-20020a17090301d100b001a05a44093csi22888524plh.58.2023.03.24.06.33.29; Fri, 24 Mar 2023 06:33:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="deQGo/FB"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231603AbjCXNbe (ORCPT + 99 others); Fri, 24 Mar 2023 09:31:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231602AbjCXNba (ORCPT ); Fri, 24 Mar 2023 09:31:30 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B20F512BF5 for ; Fri, 24 Mar 2023 06:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=I28hRGirzN8hVkdWraPB+LlmHvIXHPkHvuCGx6fgbb8=; b=deQGo/FBs7ILMJ0dTmKsELounr HhBCEdzaOOzJt8I7mw3sUgiLBiPF1a/faXbaPe9hOnRg6AsE+Ca6CSKmj/+liTQCIp5z7W1h+hF6x j2RYseCqveDUtpXDWBlSlVvr8/UonyboXnqrgVFcHuvYfx+jGlm1qzm+LDtb4kro8Jn5iZg+fZzsS j66F4KffTxpsPLP9u0+DiRsoG7n9t0DQ3RrHSCDAg8CEGH4lB5FmiDtXStfTKlaiTcf4KW5/uoany j13FeTOwKqOO1O986xUNamcLQFsscNPleoYZRgbWN03DX5+8dRqNJWecu3geNZASyYrS2OIRcfbQC S6FZtW7g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pfhVf-004wTv-N3; Fri, 24 Mar 2023 13:31:11 +0000 Date: Fri, 24 Mar 2023 13:31:11 +0000 From: Matthew Wilcox To: Song Liu Cc: Hugh Dickins , Song Liu , Jiri Olsa , David Stevens , Linux-MM , Andrew Morton , Peter Xu , "Kirill A . Shutemov" , Yang Shi , David Hildenbrand , Jiaqi Yan , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v5 3/3] mm/khugepaged: maintain page cache uptodate flag Message-ID: References: <20230307052036.1520708-1-stevensd@google.com> <20230307052036.1520708-4-stevensd@google.com> <866d1a75-d462-563-dfd7-1aa2971a285b@google.com> <6F9B0A6A-B7F1-4E25-AB15-8F3782D2EF83@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6F9B0A6A-B7F1-4E25-AB15-8F3782D2EF83@fb.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 24, 2023 at 06:03:37AM +0000, Song Liu wrote: > > > > On Mar 23, 2023, at 8:30 PM, Matthew Wilcox wrote: > > [...] > > > > > The Uptodate flag check needs to be done by the caller; the > > find_get_page() family return !uptodate pages. > > > > But find_get_page() does not advertise itself as NMI-safe. And I > > think it's wrong to try to make it NMI-safe. Most of the kernel is > > not NMI-safe. I think it's incumbent on the BPF people to get the > > information they need ahead of taking the NMI. NMI handlers are not > > supposed to be doing a huge amount of work! I don't really understand > > why it needs to do work in NMI context; surely it can note the location of > > the fault and queue work to be done later (eg on irq-enable, task-switch > > or return-to-user) > > The use case here is a profiler (similar to perf-record). Parsing the > build id in side the NMI makes the profiler a lot simpler. Otherwise, > we will need some post processing for each sample. Simpler for you, maybe. But this is an NMI! It's not supposed to be doing printf-formatting or whatever, much less poking around in the file cache. Like perf, it should record a sample and then convert that later. Maybe it can defer to a tasklet, but i think scheduling work is a better option. > OTOH, it is totally fine if build_id_parse() fails some time, say < 5%. > The profiler output is still useful in such cases. > > I guess the next step is to replace find_get_page() with a NMI-safe > version? No, absolutely not. Stop doing so much work in an NMI.