X-Received: by 2002:aa7:cc02:0:b0:411:487e:36fe with SMTP id q2-20020aa7cc02000000b00411487e36femr1673729edt.338.1645659610167; Wed, 23 Feb 2022 15:40:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645659610; cv=none; d=google.com; s=arc-20160816; b=pz569oroxcfoX+mqG7/OU4mzlgtL7sBZl8dXqhxVCFRepLnopefNLJ8/KFb1WoAyto 0UCUef3JxDuzJbG975nNUxLgct3cpBj8ZUEYtNOWXFYpZ5XGajI/g86etxY4adkPjvcT l+7v5dku8RNr8qv/zmLaom+yBANTSEWu57WK6Eb75AVct+SSKnd0zWnAt36UCfSJfaM5 m5r1avb1XPas11AND9SeeI4coaAyHmsb5OBPro45mxh+0wVkUpV2xRUb3Y/IjbX2tvPv 1T5tW8ky0zoXFKHPA5p2pRfJUNXz/3NwvFhrkqaSzwGhD7fDcrjrKcpJQhCXEjuulWqi jKXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=xCH18It7Jq2c6f2LJy5TkOfMfYUliHFGpaDTyFx2Hwg=; b=XVEcuJlRvDKqmxtxSijneFZIggoLPxIn0QGvj/hjQoUc12eWYhIL/qWGFtYKqiQGeE ikAWp0aaJlRXZ6WFARYRfhdktyDOMVsMb37LcX83pZ46Th0yp4ONK0VgCzE8KmDCKGXF Gp7UVwxPwBL/q6mS2PO1GbrA7bDlgBahkaMDDtGzb8UNEwPNdga4CAv6HjYct9VrJwZo FemUJ0pjb08soHe+Odo6q/p/MoFZeOqBsCcMSSXFHlFr076tyj92lskhDXxJTVnreQzS PMWWboU2OigDFnIwlqmtCkGIoWrj8mGo/zTZGxaV5Jwby3+D7r3B2ABnbESWdZOwnruO 3+GQ== ARC-Authentication-Results: i=1; mx.google.com; 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 di7si653231ejc.411.2022.02.23.15.39.47; Wed, 23 Feb 2022 15:40:10 -0800 (PST) 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; 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 S242496AbiBWQMT (ORCPT + 99 others); Wed, 23 Feb 2022 11:12:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234750AbiBWQMQ (ORCPT ); Wed, 23 Feb 2022 11:12:16 -0500 Received: from outbound-smtp45.blacknight.com (outbound-smtp45.blacknight.com [46.22.136.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94E1012604 for ; Wed, 23 Feb 2022 08:11:45 -0800 (PST) Received: from mail.blacknight.com (pemlinmail06.blacknight.ie [81.17.255.152]) by outbound-smtp45.blacknight.com (Postfix) with ESMTPS id 86E3FFAAAD for ; Wed, 23 Feb 2022 16:11:44 +0000 (GMT) Received: (qmail 13369 invoked from network); 23 Feb 2022 16:11:44 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.17.223]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 23 Feb 2022 16:11:44 -0000 Date: Wed, 23 Feb 2022 16:11:41 +0000 From: Mel Gorman To: Michel Lespinasse Cc: Linux-MM , linux-kernel@vger.kernel.org, Andrew Morton , kernel-team@fb.com, Laurent Dufour , Jerome Glisse , Peter Zijlstra , Michal Hocko , Vlastimil Babka , Davidlohr Bueso , Matthew Wilcox , Liam Howlett , Rik van Riel , Paul McKenney , Song Liu , Suren Baghdasaryan , Minchan Kim , Joel Fernandes , David Rientjes , Axel Rasmussen , Andy Lutomirski Subject: Re: [PATCH v2 00/35] Speculative page faults Message-ID: <20220223161141.GG4423@techsingularity.net> References: <20220128131006.67712-1-michel@lespinasse.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20220128131006.67712-1-michel@lespinasse.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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, Jan 28, 2022 at 05:09:31AM -0800, Michel Lespinasse wrote: > This patchset is my take on speculative page faults (spf). > It builds on ideas that have been previously proposed by Laurent Dufour, > Peter Zijlstra and others before. While Laurent's previous proposal > was rejected around the time of LSF/MM 2019, I am hoping we can revisit > this now based on what I think is a simpler and more bisectable approach, > much improved scaling numbers in the anonymous vma case, and the Android > use case that has since emerged. I will expand on these points towards > the end of this message. > > The patch series applies on top of linux v5.17-rc1; > a git tree is also available: > git fetch https://github.com/lespinasse/linux.git v5.17-rc1-spf-anon > > I would like these patches to be considered for inclusion into v5.18. > Several android vendors are using Laurent Dufour's previous SPF work into > their kernel tree in order to improve application startup performance, > want to converge to an upstream accepted solution, and have reported good > numbers with previous versions of this patchset. Also, there is a broader > interest into reducing mmap lock dependencies in critical MM paths, > and I think this patchset would be a good first step in that direction. > I think there is serious lack of performance data here. The only performance point offered is the Android Application Startup case. Unfortunately, that benefit may be specific to the Zygote process that preloads classes that may be required and listens for new applications to start. I suspect the benefit wouldn't apply to most Linux distributions and even JVM-based workloads are not primarily constrained by the startup cost. Improving application start up costs is not great justification for this level of code complexity even though I recognise why it is a key performance indicator for Android given that startup times affect the user experience. Laurent's original work was partially motivated by the performance of a proprietary application. While I cannot replicate a full production workload as that can only be done by the company, I could do a basic evaluation commonly conducted on standalone systems. It was extremely fault intensive with SPF success rates greater than 96% but almost no change in actual performance. It's perfectly possible that the application has changed since SPF was first proposed. The developers did spend a fair amount of effort at making the application NUMA-aware and reusing memory more aggressively to avoid faults. It's still very fault intensive but does not appear to suffer due to parallel memory operations guessing from the data. On my own tests, the only preliminary test that was a clear winner was will-it-scale using threads for the page-fault workloads and page-fault-test for threads. To be far, the increases there are dramatic with a high success rate of speculative faults. pft timings 5.17.0-rc3 5.17.0-rc3 vanilla mm-spfault-v2r1 Amean elapsed-1 32.66 ( 0.00%) 32.77 * -0.36%* Amean elapsed-4 9.17 ( 0.00%) 8.89 * 3.07%* Amean elapsed-7 5.53 ( 0.00%) 5.26 * 4.95%* Amean elapsed-12 4.13 ( 0.00%) 3.50 * 15.16%* Amean elapsed-21 3.93 ( 0.00%) 2.79 * 29.03%* Amean elapsed-30 4.02 ( 0.00%) 2.94 * 26.79%* Amean elapsed-48 4.37 ( 0.00%) 2.83 * 35.24%* Amean elapsed-79 4.13 ( 0.00%) 2.17 * 47.36%* Amean elapsed-80 4.12 ( 0.00%) 2.13 * 48.22%* Ops SPFault Attempt 0.00 4734439786.00 Ops SPFault Abort 0.00 9360014.00 Ops SPFault Success 0.00 99.80 This is the ideal case for SPF but not very realistic. Interestingly, ebizzy barely benefitted even though it's threaded because it's not guaranteed to be address space modification intensive. Hackbench took a performance hit between 0-5% depending on the exact configuration and machine used. It is threaded and had high SPF abort rates (up to 50%). It's not a great example but it shows at least one example where SPF hurts more than it help and there may be other applications that are harmed by having to retry faults. The scope of SPF is narrow relative to the much older discussion of breaking up mmap_sem. The only time SPF benefits is when faults are racing against parallel memory address updates holding mmap_sem for write. That requires a threaded application that is both intense in terms of address space updates and fault intensive. That is much narrower than threaded applications that are address space update intensive (e.g. using mprotect to avoid accidentally leaking data, mapping data files for IO etc). Have we examples of realistic applications that meet all the criteria of "threaded", "address-space intensive" and "fault intensive" that are common enough to justify the complexity? Admittedly, I initially just threw this series at a collection of workloads that simply stress the allocator because it stresses faults as a side-effect but most of them did not match the criteria for "threaded application that is both address space update intensive and fault intensive". I'm struggling to think of good examples although redis is a possibility. HPC workloads like NPB parallelised with OpenMP is a possibility but I looked at some old results and while it does trap faults, the vast majority are related to NUMA balancing. The other ones I normally consider for scaling purposes are process orientated and not threads. On the patches themselves, I'm not sure the optimisation for ignoring SPF is guaranteed to work as mm_users could be temporarily elevated although probably not enough to matter. I also think patch 5 stands on its own and could be sent separately. For the others, I didn't read them in sufficient depth but noted that the level of similar logic between speculative and non-speculative paths could be a maintenance headache to keep the speculative and !speculative rules in sync. I didn't see obvious problems as such but I still think the complexity is high for a corner case. -- Mel Gorman SUSE Labs