Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2956880rwb; Fri, 20 Jan 2023 09:20:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXtVRCIHfVNCodEgK2djc6jnTncriTDQCPADm950EmL+3kF79t2KuQjgBq2phGR4EpaVgCh6 X-Received: by 2002:a17:906:3cf:b0:78d:f455:3118 with SMTP id c15-20020a17090603cf00b0078df4553118mr15921131eja.64.1674235202437; Fri, 20 Jan 2023 09:20:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674235202; cv=none; d=google.com; s=arc-20160816; b=m8oQNIbVH9+AZPlY/4peeQHpDiyQUMDEvWu8bXmT5xzb8nv2AQYQTzn7DPvVjACC/c h3rMUUj/rAOcJ+T65dTdd2UUjwYAxU7Xz1wvX8fBhBMAOKABOISTB2yZqyIUafugn9XB NPSnBc7cTc7GEJMWtOwQFoveV20WL9NW0CDxIWMQBNRIHvq1XGIa4d2byyEBnV+xagHX R52H7bEMZQUcTZSx6szoYz3SYHl7R7qd65CILfm4TgxFVaDL6njST7JWwB/fUE1z5NF8 01mCMc1MPtSf8e03reZRVev6MgwSYHqI7GUz4yM10/U0hWBUiNvc9XCwkVoCh5Fwa2yL fZOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=mfgPoshwuIu4b/1jDgs3cdlztQz/vsY4EyScZyBxABE=; b=YQ4D+0NzZ5MhJEH7ZWn3sOrYGZskXb9nd6oWBm3hSf0+4kLNpaafl9MG62eU3u1A2N cMCaTYK7/Bj/uSGsgoCPYKHZI+OZuvA/kLk7FsBaMUXc3YQ6TkKOXqUJODmzDGShkyNX rjbAk5FDDcxSwiRnvSw1NPNRVqs6lv+ScNmOEqjjKsl/bvjtYzEaFwoQbKTjfjHlVNzv h/UiueF80LROxHiZIdKjVcnbO75A7SjkJX2u2tngbMj94G+UyJM8Ng5z/hOQsMw0S/IS 0lCz5Z5dNaqqAlshEEPrbT6nMY36ojon7enrXC1UgiS6xJy5DWIlNKsyz7wBG4Or3Eq4 +DlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=a3fpOXPW; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xi7-20020a170906dac700b007c1292a824asi48088066ejb.731.2023.01.20.09.19.49; Fri, 20 Jan 2023 09:20:02 -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=@google.com header.s=20210112 header.b=a3fpOXPW; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229963AbjATQVU (ORCPT + 50 others); Fri, 20 Jan 2023 11:21:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229981AbjATQVQ (ORCPT ); Fri, 20 Jan 2023 11:21:16 -0500 Received: from mail-yw1-x1135.google.com (mail-yw1-x1135.google.com [IPv6:2607:f8b0:4864:20::1135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B7AD56482 for ; Fri, 20 Jan 2023 08:20:55 -0800 (PST) Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-4c24993965eso79088297b3.12 for ; Fri, 20 Jan 2023 08:20:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=mfgPoshwuIu4b/1jDgs3cdlztQz/vsY4EyScZyBxABE=; b=a3fpOXPWNViHSb5VK8vv6GJ9OmjGr4J4zqU4T6ftPkVNCscUsuTtDDXL5UD9ux6sdV C0Qm2jvON+yzeEaRn5EGinE0oa53S+FAHBxJzKLsuFtanPw31pELeAvEJoY/yaBISJcM oZyV2Lj9bVOFMBWicMFpowezChEy/etWrkR++6jVuHqIjnOtt+gvWs/hH0z9I+hVbxLK DdHjJ3jcS58ULiPGvEyZtKwUEI8IP12OcCaoFotUfcap+K1AkIWIglgZwi5rcdiqfHFL rPSSgGWeY5keQ2LWcVC+CM7q02imT0drV8318cIgX8BCEYEkWOEzW/6DbkrmOLaX3cWG 1G+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mfgPoshwuIu4b/1jDgs3cdlztQz/vsY4EyScZyBxABE=; b=H3BBLjc9wUgUlyEBxuiBd2V3LcRKrwcFIRb0nA3FHNrbC64KxkZiRW7uo3DxW4Yxf+ tvkaJRvolTyZFHXJ1PujaHxNgbm9yDkiVMa6DoKOz+ARrc6LJLDtYQk2vzO/avD01/Ec 3NNbZ0wA9l2RdXH9u/rufNjMxfS/grhm+gu4z4x/igOuJuQa2zSsFGx6CqQtFQZL2n2h ShCUsu+uV4XzuzbFNXqnQ+ez0jGRVko8TQ5POwaA+Ptm9s723m94Nsg1T6YHumCtJilN PqfmYAAL5nzkmG9XHr1pTm9xwfF4bp53FrjTb+sr6Q+s04yXG0k9Nut/T8ODwNLZSZJZ WLuQ== X-Gm-Message-State: AFqh2kpwdAahoqjfeGt6h0DIIHV8I9PBaJjPutTmHIbayybNzzYrGTMc E3wX4EOLGFKTXUKOQNnI/liVQzm7oJ5e9vauMO95+g== X-Received: by 2002:a0d:d484:0:b0:4dc:4113:f224 with SMTP id w126-20020a0dd484000000b004dc4113f224mr2100604ywd.455.1674231654470; Fri, 20 Jan 2023 08:20:54 -0800 (PST) MIME-Version: 1.0 References: <20230109205336.3665937-1-surenb@google.com> <20230109205336.3665937-40-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Fri, 20 Jan 2023 08:20:43 -0800 Message-ID: Subject: Re: [PATCH 39/41] kernel/fork: throttle call_rcu() calls in vm_area_free To: Michal Hocko 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 20, 2023 at 12:52 AM Michal Hocko wrote: > > 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? Yes, I understood your idea but keeping dead objects until the process exits even when the system is low on memory (no shrinkers attached) seems too wasteful. If we do this I would advocate for attaching a shrinker. > > -- > Michal Hocko > SUSE Labs