Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp5576190rwe; Tue, 18 Apr 2023 08:34:26 -0700 (PDT) X-Google-Smtp-Source: AKy350blRRxCShT88sBdgstba6hhyA2ybkcTbwS7xYXhTapL2w9ytLUO8TfXVn7nYqxHBtSJNmSs X-Received: by 2002:a05:6a00:2488:b0:63b:6933:a30d with SMTP id c8-20020a056a00248800b0063b6933a30dmr128421pfv.25.1681832065701; Tue, 18 Apr 2023 08:34:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681832065; cv=none; d=google.com; s=arc-20160816; b=OKY15sfRjwp/LtgrnupzEjSV/B+MgdkwVxxoAj2g0e8TLpN4QYTvK07OIacatn6QJ8 YneWt8naFCF8PSoacS3L2QOkReS/RrmUczsaslvDw4lcxNlF/RLNpZKOeaRMnw/6mR3M fea3n87FSPwh+TkDlpPP6Vecy9hMIh11Z7P2BotRjnZrKGGbnIFIk9rMxeoZyeuDaLsF H/4du8zk+LWaUS5p8ZIaOLv9wlJ6fDNxCQzTdw8R/gRuCU5qb73vQxYtHndI6MJp3al5 rhVe+Lpt4MjALLwMMUeCpgdvk9WNmRNNFhnHcpuy+csszhNC56vAJ1r+WSa2c149hlDz LtwA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=V7/9YRdvpUWFsXQviScvn8PuAX8GmByqNXRyVJ4I/AY=; b=uNkZGVDDzzWoFWCq965PFm0TFVhLvLr9F9rSNxKwZVmGWYoA5w5B7Q7Vxvm/2AYlQx NmDdU/25w8rGdKshvLr2C8CpjxsZRgT5a7YzXKLnSbPRnsCQvCM/7teYhK3ie1SuuLwp qWhjPa8vPcoF7GfNdtuKZwVNhR6R07BfpdH2LSzzoX22WSde6dDQ36RdY4JzOP/bm46W cxvLrCwNdYmMAD+PFo/LDqBTNVNVFlU44np4WcNb20o14ZFZf4IpR5Yt25uqPK/IYcmS ckRPMaaofuZS7A5FCDYfRW0+YXgoLbJDGUZfq0yckeCULfjNv6Mj6DyHXWN5sE3PHc6B u2Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=WlAVA2Oj; 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 x29-20020aa7941d000000b0058003199fbbsi14395630pfo.63.2023.04.18.08.34.12; Tue, 18 Apr 2023 08:34:25 -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=WlAVA2Oj; 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 S230407AbjDRPda (ORCPT + 99 others); Tue, 18 Apr 2023 11:33:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230377AbjDRPd1 (ORCPT ); Tue, 18 Apr 2023 11:33:27 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB32B15464 for ; Tue, 18 Apr 2023 08:32:56 -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-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=V7/9YRdvpUWFsXQviScvn8PuAX8GmByqNXRyVJ4I/AY=; b=WlAVA2OjOzVTDkW8+aCtJciaho lqdKYfqeZAufjQz1Xnq9HPX8lCtz3K6qeOwHwZDp28164W5YJIIOEU4r5LyQPzNSGsvQnPyC1+9Kp cD5M3g+r66zzNEDk9Obk63OL/f/UPipC5qzKBQH+R7yqlGbWGdXXtdtULiuoK8kiUHh9kBDo/FD4I dgcGkhnDDA6fjnaIFbkzCN1jH820wZAGoGj8ar1Zuzrd4d13bJyMEzMUlcobwvOdv0f+mD3HxyNk9 Hq1GXLx6PnVqAw9F8wT0PRbyMiCmJkwCjTboFhTGWzkbi9EnmrF0lG+axsPXnVJjt8QMAVB9cnsAk tnviWRPA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1ponJj-00CPTZ-KO; Tue, 18 Apr 2023 15:32:27 +0000 Date: Tue, 18 Apr 2023 16:32:27 +0100 From: Matthew Wilcox To: Peter Xu Cc: Suren Baghdasaryan , 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 v2 1/1] mm: do not increment pgfault stats when page fault handler retries Message-ID: References: <20230415000818.1955007-1-surenb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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,URIBL_BLOCKED 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 Tue, Apr 18, 2023 at 11:19:40AM -0400, Peter Xu wrote: > On Mon, Apr 17, 2023 at 03:47:57PM -0700, Suren Baghdasaryan wrote: > > On Mon, Apr 17, 2023 at 2:26 PM Peter Xu wrote: > > > > > > On Fri, Apr 14, 2023 at 05:08:18PM -0700, Suren Baghdasaryan wrote: > > > > @@ -5223,8 +5230,8 @@ vm_fault_t handle_mm_fault(struct vm_area_struct *vma, unsigned long address, > > > > if (task_in_memcg_oom(current) && !(ret & VM_FAULT_OOM)) > > > > mem_cgroup_oom_synchronize(false); > > > > } > > > > - > > > > - mm_account_fault(regs, address, flags, ret); > > > > +out: > > > > + mm_account_fault(mm, regs, address, flags, ret); > > > > > > Ah, one more question.. can this cached mm race with a destroying mm (just > > > like the vma race we wanted to avoid)? Still a question only applies to > > > COMPLETE case when mmap read lock can be released. Thanks, > > > > I believe that is impossible because whoever is calling the page fault > > handler has stabilized the mm by getting a refcount. > > Do you have a hint on where that refcount is taken? ... when we called clone()? A thread by definition has a reference to its own mm. > Btw, it's definitely not a question sololy for this patch but a more common > question to the page fault path. It's just that when I wanted to look for > any refcount boost (which I also expect to have somewhere) I didn't really > see that in current path (e.g. do_user_addr_fault() for x86_64). > > I also had a quick look on do_exit() but I also didn't see where do we > e.g. wait for all the threads to stop before recycles a mm. > > I had a feeling that I must have missed something, but just want to make > sure it's the case. > > -- > Peter Xu >