Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2320864rwb; Fri, 20 Jan 2023 01:04:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXvcf1aayTcHw+lj6TdvBNfDbR961cwBUzMuI6QlvlLbHvT51ZEB0YOJuNX4bSeG4+ZA8Vmm X-Received: by 2002:a17:90a:51:b0:22b:b444:afc8 with SMTP id 17-20020a17090a005100b0022bb444afc8mr559516pjb.34.1674205472922; Fri, 20 Jan 2023 01:04:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674205472; cv=none; d=google.com; s=arc-20160816; b=r2n5ih6dJS6OKINMxu6vzWprVvGl4Fk/OXxYKIwYRyLwkiHzs46odza+ZfnwTK5OTN 7gCWH88HtHoAKqfmGbflWLNSIZPAQJPph2zSWC1uwepXwvJnb8evL+NTzOczDdAbxMUP MJ4E3isUBX+VkpZxjCIRrNRN0yw9rNNKdMOQZ2+vD0gjbyyrYbN1M+OfNECmQ3JpC5os 3kT9jQOt8YVS57VsIRCy1m5ZGCeGtSdSEE1ZumxwVKI1tdzmJ1cOmygL+ThtQqjl/x4y u0MFlHYu6L6d8BRtVxHPbc7hMLJkbnPfb8QOX/9BmE09bJjBJ8TrHXpTffhSEsLffr9a mFaQ== 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=NPjXf88ZU8FVuBa4GWfXY3q6lH6kqoJUTnCqbetZU5Y=; b=zV6EOeE8t45RGswQ0BvJxbSG+R0nr7YwaG/YgnVlRn0+H9gknKHYkTeFaPd5vjlgBB GkuOjWMoTfl6TriLTIDk3L4d1BK+rZf/z0y3iQQguPQL03OrXAsDUaH+tQe0m4sKzgHs FcAJhGmHkGdIABaNUki3rfyXX+YiwO2gxhwhu50EVy0T06GCkIol44NoAdmFcsyPhcKi Sdsi2S/TkoSS2MC0c+EkPOfKNHEpOskXomocROjUoMbdtTKqhDvx/XxpiU09yTvpV3Rh M2xJJwgUT4GUpkq/3QBlE3YmKB6/fgnBrqe+14cQdtCzosnDE0FEGaEf75PTkiUzFIRd GeLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=rVOftAen; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o8-20020a17090ab88800b00228e17f957bsi1904807pjr.69.2023.01.20.01.04.26; Fri, 20 Jan 2023 01:04:32 -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; dkim=pass header.i=@suse.com header.s=susede1 header.b=rVOftAen; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229495AbjATIwt (ORCPT + 48 others); Fri, 20 Jan 2023 03:52:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbjATIwr (ORCPT ); Fri, 20 Jan 2023 03:52:47 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDF801816A for ; Fri, 20 Jan 2023 00:52:45 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D4440228BD; Fri, 20 Jan 2023 08:52:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1674204763; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NPjXf88ZU8FVuBa4GWfXY3q6lH6kqoJUTnCqbetZU5Y=; b=rVOftAenNnA8PiL17Z4Pvgxr3PGI5zIZDNJZhTWOuwjNH7ZF8duaDITjsCCPVYUUl+4mAF SsZLXg+YuWZWmpQYKnBigdv+oOwpwP8b3sMrIOZpOAVevFZTdzxUdshJBulqHxA0CeorJN JV/cNcPxjm+c/YD6MkjUZzLm2MN4Cno= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B24EA13251; Fri, 20 Jan 2023 08:52:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id hsl6K1tWymP+HQAAMHmgww (envelope-from ); Fri, 20 Jan 2023 08:52:43 +0000 Date: Fri, 20 Jan 2023 09:52:43 +0100 From: Michal Hocko To: Suren Baghdasaryan Cc: akpm@linux-foundation.org, michel@lespinasse.org, jglisse@google.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@techsingularity.net, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, peterz@infradead.org, ldufour@linux.ibm.com, laurent.dufour@fr.ibm.com, paulmck@kernel.org, luto@kernel.org, songliubraving@fb.com, peterx@redhat.com, david@redhat.com, dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, kent.overstreet@linux.dev, punit.agrawal@bytedance.com, lstoakes@gmail.com, peterjung1337@gmail.com, rientjes@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, jannh@google.com, shakeelb@google.com, tatashin@google.com, edumazet@google.com, gthelen@google.com, gurua@google.com, arjunroy@google.com, soheil@google.com, hughlynch@google.com, leewalsh@google.com, posk@google.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH 39/41] kernel/fork: throttle call_rcu() calls in vm_area_free Message-ID: References: <20230109205336.3665937-1-surenb@google.com> <20230109205336.3665937-40-surenb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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_PASS 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 Thu 19-01-23 10:52:03, Suren Baghdasaryan wrote: > On Thu, Jan 19, 2023 at 4:59 AM Michal Hocko wrote: > > > > On Mon 09-01-23 12:53:34, Suren Baghdasaryan wrote: > > > call_rcu() can take a long time when callback offloading is enabled. > > > Its use in the vm_area_free can cause regressions in the exit path when > > > multiple VMAs are being freed. To minimize that impact, place VMAs into > > > a list and free them in groups using one call_rcu() call per group. > > > > After some more clarification I can understand how call_rcu might not be > > super happy about thousands of callbacks to be invoked and I do agree > > that this is not really optimal. > > > > On the other hand I do not like this solution much either. > > VM_AREA_FREE_LIST_MAX is arbitrary and it won't really help all that > > much with processes with a huge number of vmas either. It would still be > > in housands of callbacks to be scheduled without a good reason. > > > > Instead, are there any other cases than remove_vma that need this > > batching? We could easily just link all the vmas into linked list and > > use a single call_rcu instead, no? This would both simplify the > > implementation, remove the scaling issue as well and we do not have to > > argue whether VM_AREA_FREE_LIST_MAX should be epsilon or epsilon + 1. > > Yes, I agree the solution is not stellar. I wanted something simple > but this is probably too simple. OTOH keeping all dead vm_area_structs > on the list without hooking up a shrinker (additional complexity) does > not sound too appealing either. I suspect you have missed my idea. I do not really want to keep the list around or any shrinker. It is dead simple. Collect all vmas in remove_vma and then call_rcu the whole list at once after the whole list (be it from exit_mmap or remove_mt). See? -- Michal Hocko SUSE Labs