Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp907846rwe; Fri, 14 Apr 2023 11:15:06 -0700 (PDT) X-Google-Smtp-Source: AKy350bNcmKH/OnBarYUdS6zmk9pFs7GZusNdxd080wS/rCooqDEoZNI2eaW9pJOgPo3rUl3N/tt X-Received: by 2002:a17:90b:3a82:b0:246:8497:37c5 with SMTP id om2-20020a17090b3a8200b00246849737c5mr6114472pjb.46.1681496106663; Fri, 14 Apr 2023 11:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681496106; cv=none; d=google.com; s=arc-20160816; b=dOyfeE5mkaktpsliq+8ysQkrOv18gXQboy0Usf/T/RDv8sGs0aLTnlQrz6DtYhaHlD S0eJHXyjvhjWSIB9u7LJaklRBro1gPxwCuIAv9gvGdLHsstLYWIuRj0aYkGA6PzpspQF PrImt64Z5k55tMfFdjG0jqLQm/fAIHkID+WXPeyb+uu9+hw7PNwMjSwe2Z3BhFZRAyCc 8hAu/FwzZIMRIFqsjA9UMy2XfrKSdahc9EJgKTQSPEHIiCdSI6AMVfuqqcFy5dfcSYfR 97NUZamzMKjB+dHVhls1i244FsPv2qgnoBdR9ovUJgwKWbEFXmB9rq27zZkDyDYIhtpS t3oA== 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=vZqhG6c9njRhZ7EHyEhLnr2bzHk82i0mvo2aafzvJ6I=; b=GYl6hIi74RnDqAHPPMAAlylYbyDcb3m4R76jhYYkydFs0zk8O+7fsVaWjWbFbppLtQ PKbRVXbG2IOsC/NHiaXP677XOubWSuV5P7IR+Kj2gO5iOoXG31ETO1hiGHILCkx5kLjh CyWSCYboxVHcopY/E6LFHlqTQrI3M4g2y3/f3tZICg52ES1dXzcpi+BsVjiddgsumBvS XxR4KFbJ/tew8knyxN8w5wwi63ce7mj47A1bhNk9JfOH1JxoVF0GVUk4sGcTZP2lS6Ci YfHFL96ek1rDSyiaI5m8WFF84WozmVr76F1KdUo+7TLq7z9TS+If8Dqfm/yLnINSgv8g tMjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=qzri7bds; 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 c3-20020a17090a8d0300b002402275fc56si5051483pjo.118.2023.04.14.11.14.55; Fri, 14 Apr 2023 11:15:06 -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=qzri7bds; 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 S229707AbjDNSMU (ORCPT + 99 others); Fri, 14 Apr 2023 14:12:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229479AbjDNSMT (ORCPT ); Fri, 14 Apr 2023 14:12:19 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D26A8A53 for ; Fri, 14 Apr 2023 11:12:17 -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=vZqhG6c9njRhZ7EHyEhLnr2bzHk82i0mvo2aafzvJ6I=; b=qzri7bds+FjHec184/+U/iYi/E zme+Blem6PjCSZfpjAkCFdYzJ0ywDqOOwq4tgOmk6cHvy2Y23vTeAvxMZEx79MrOud2wE6ZCFGM02 0Q+DTD6kDI/Xyil3mOdOi1DI8egCUKOO/hKeAeDjC/ZGAx1wcYK8zf+fwfsS+nzJVJLuodZr/wcV7 N3GMIDW02u94Y2dcGwuYuPslNsQgfPkHhHXaEBedx3z5qYYcGFr+tddCr5zWOIT3kbmFFxxkLcHH8 ejYBLsyLBnsHn50kZ2EIZJ09raVi2fAIihE6/3tQdV9Y9C5x1ENA2tM3cifXIK2rfieLNYUhQkBwR PQ6Nh+cQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pnNtf-008xzE-Pa; Fri, 14 Apr 2023 18:11:43 +0000 Date: Fri, 14 Apr 2023 19:11:43 +0100 From: Matthew Wilcox To: Suren Baghdasaryan Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, mhocko@suse.com, josef@toxicpanda.com, jack@suse.cz, ldufour@linux.ibm.com, laurent.dufour@fr.ibm.com, michel@lespinasse.org, liam.howlett@oracle.com, jglisse@google.com, vbabka@suse.cz, minchan@google.com, dave@stgolabs.net, punit.agrawal@bytedance.com, lstoakes@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH 1/1] mm: do not increment pgfault stats when page fault handler retries Message-ID: References: <20230414175444.1837474-1-surenb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230414175444.1837474-1-surenb@google.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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, Apr 14, 2023 at 10:54:44AM -0700, Suren Baghdasaryan wrote: > If the page fault handler requests a retry, we will count the fault > multiple times. This is a relatively harmless problem as the retry paths > are not often requested, and the only user-visible problem is that the > fault counter will be slightly higher than it should be. Nevertheless, > userspace only took one fault, and should not see the fact that the > kernel had to retry the fault multiple times. > > Fixes: 6b4c9f446981 ("filemap: drop the mmap_sem for all blocking operations") I know I suggested this fixes line, but I think it's actually been here much longer, perhaps since Fixes: d065bd810b6d ("mm: retry page fault when blocking on disk transfer") Michel, what do you think? > Signed-off-by: Suren Baghdasaryan > Reviewed-by: Matthew Wilcox (Oracle) > --- > Patch applies cleanly over linux-next and mm-unstable > > mm/memory.c | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > > diff --git a/mm/memory.c b/mm/memory.c > index 1c5b231fe6e3..d88f370eacd1 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -5212,17 +5212,16 @@ vm_fault_t handle_mm_fault(struct vm_area_struct *vma, unsigned long address, > > __set_current_state(TASK_RUNNING); > > - count_vm_event(PGFAULT); > - count_memcg_event_mm(vma->vm_mm, PGFAULT); > - > ret = sanitize_fault_flags(vma, &flags); > if (ret) > - return ret; > + goto out; > > if (!arch_vma_access_permitted(vma, flags & FAULT_FLAG_WRITE, > flags & FAULT_FLAG_INSTRUCTION, > - flags & FAULT_FLAG_REMOTE)) > - return VM_FAULT_SIGSEGV; > + flags & FAULT_FLAG_REMOTE)) { > + ret = VM_FAULT_SIGSEGV; > + goto out; > + } > > /* > * Enable the memcg OOM handling for faults triggered in user > @@ -5253,6 +5252,11 @@ vm_fault_t handle_mm_fault(struct vm_area_struct *vma, unsigned long address, > } > > mm_account_fault(regs, address, flags, ret); > +out: > + if (!(ret & VM_FAULT_RETRY)) { > + count_vm_event(PGFAULT); > + count_memcg_event_mm(vma->vm_mm, PGFAULT); > + } > > return ret; > } > -- > 2.40.0.634.g4ca3ef3211-goog >