Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2095430rwb; Thu, 17 Nov 2022 06:31:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf4t1LGZ4N9z6yhZLSAZ8S8aJoNVa0auIcTYG3QkZbfXBXkFZHemJXbaxmT4/LcGU/sz9dyq X-Received: by 2002:a17:90a:884:b0:214:6fd:90df with SMTP id v4-20020a17090a088400b0021406fd90dfmr3107085pjc.35.1668695505530; Thu, 17 Nov 2022 06:31:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668695505; cv=none; d=google.com; s=arc-20160816; b=R8/UPHIrWeeSdjss6QPeB+5/WmWrqMGmJOg6GUCJIDDxlB7qThdVxNyJWH7nHyS1hr wxnA/Zr1syQOEIiU+WaUROZ5Yc+j5Tq++Oj4OQj9/St2MBPFVV1VzytxsqUnRecztAaW kd1KzRHO2WgPXuqx1jrbGEJMa/p28Wjs+xvmQIruw3nfpWf1YVNAk7fUK+FhErJJ6EUa 65bMl1YVMeWwRHB5lQyUkepeGGCKwzBnOXug27KQYTxV0SrQPVOcNHT+A6qXSiRX4neB KCcmUZ21dLBJT/2qOVYn0lADiiU8rXwFLlwnVslFAsivPjkX4MP9KVt60N8HbOxptFVw qE6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:cc:references:message-id:date :subject:mime-version:from:content-transfer-encoding:dkim-signature; bh=P4qE9RTmLTvrWv23dU+LZNw4qYAOY7fS7onaXUzE0KE=; b=spgNiQhyFv9WBJhHC6Y4CQR2/rnJsH3V+X1keglbcwN3fymtiHjbDl2hsTmg42NXdi k/K+5ptjVQzw3Buf/ft1eVw3YrqLDUc3ua1tEC0X4yB5QXIbptlcFKos8agG78Ah0NI0 CMOhebP+78Un4RmQtpBxkt43Ldr/016d8EoWGKAjgMvQhPW/v3ERRtVE0pqmvlymOIE8 OTLBg4E8MTjONV+7ZUFMM9H2980+VM65rfbjS2iwsP9gRdOhweAywy5Iag3R599odd3g 6/OwGyzzoJWsLbkas0YNKHb7M2FYc+Ehy07SdEySBztizTEjrp6s/Obw85g0cJJ9dw2L qG7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=hCgwdYKJ; 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 n6-20020a170902d2c600b0017f5bacd4d8si1162428plc.571.2022.11.17.06.31.21; Thu, 17 Nov 2022 06:31:45 -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=@joelfernandes.org header.s=google header.b=hCgwdYKJ; 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 S239980AbiKQNXm (ORCPT + 92 others); Thu, 17 Nov 2022 08:23:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239967AbiKQNXi (ORCPT ); Thu, 17 Nov 2022 08:23:38 -0500 Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B120E17046 for ; Thu, 17 Nov 2022 05:23:32 -0800 (PST) Received: by mail-qv1-xf34.google.com with SMTP id i12so1160175qvs.2 for ; Thu, 17 Nov 2022 05:23:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:from:to:cc:subject:date:message-id :reply-to; bh=P4qE9RTmLTvrWv23dU+LZNw4qYAOY7fS7onaXUzE0KE=; b=hCgwdYKJAabgQcG7x7Z5xhvq/SHD0Zb7OxSrL9ICbK+vw9MifK7iAQRL6b7ew/68vk upRDnHFRIfKf6apYbyKsvxDKZi8ktRxFjqK9fizdwCT/yedtDvrWJd3QHY8PtegqezR2 XNa5fXdQ2M8Iovz6JKGLtSYiX1rLVbupFnI6k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P4qE9RTmLTvrWv23dU+LZNw4qYAOY7fS7onaXUzE0KE=; b=ip9cCiJ1Ou4igzu3IATK8e6qunV9dJcioHSRDDBECZDYlZuEmxaoA0YGiq5APzfrbK NmLlGXhzStXKZQ3LVjYRWg2FZFAtc5PKe517oPl85DvxeVEBSbveEgEDtlPGGn3mI2PM epUiQrVwPeBkh0zGY8tdMff8InI56YqDkwPc4dUSXF/wvIDjKLBX6OMYoT2J7BbUOJG6 dDp8yd79V8tMJgS9rc4K2AiVxr+0Tl6C8fCBtSMeStnaXBnPFFrc6R4F0sVezSsZxtH/ McVzyApX5kAT6d19JwHlmJwcuHVzlRBCLoq4qOdz+p7UTMLVhUcD+OgMjzP9ucnOLc35 dC1A== X-Gm-Message-State: ANoB5pkZ2qS7xY3foz3WL8OeaRKTFBMpsx3+fdeJrGuvIzQh52g1YG8s b5hldzla52U4nJ5qgByjltkrepTuFmoQkg== X-Received: by 2002:a0c:ea88:0:b0:4bb:8304:23b1 with SMTP id d8-20020a0cea88000000b004bb830423b1mr2332515qvp.15.1668691411529; Thu, 17 Nov 2022 05:23:31 -0800 (PST) Received: from smtpclient.apple (c-73-148-104-166.hsd1.va.comcast.net. [73.148.104.166]) by smtp.gmail.com with ESMTPSA id dm50-20020a05620a1d7200b006fb7f94a65bsm448221qkb.44.2022.11.17.05.23.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Nov 2022 05:23:31 -0800 (PST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Joel Fernandes Mime-Version: 1.0 (1.0) Subject: Re: [PATCH v2] rcu/kfree: Do not request RCU when not needed Date: Thu, 17 Nov 2022 08:23:30 -0500 Message-Id: <938BD0DD-9F91-44E6-BCBA-3DA3FA6779C0@joelfernandes.org> References: Cc: paulmck@kernel.org, linux-kernel@vger.kernel.org, rcu@vger.kernel.org In-Reply-To: To: Uladzislau Rezki X-Mailer: iPhone Mail (19G82) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MIME_QP_LONG_LINE, RCVD_IN_DNSWL_NONE,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 Nov 17, 2022, at 8:11 AM, Uladzislau Rezki wrote: >=20 > =EF=BB=BFOn Thu, Nov 17, 2022 at 08:06:21AM -0500, Joel Fernandes wrote: >>=20 >>=20 >>>> On Nov 17, 2022, at 7:58 AM, Uladzislau Rezki wrote:= >>>=20 >>> =EF=BB=BFOn Wed, Nov 16, 2022 at 10:05:46PM +0000, Joel Fernandes wrote:= >>>>> On Wed, Nov 16, 2022 at 7:19 PM Uladzislau Rezki wr= ote: >>>>>=20 >>>>> Hello, Paul, Joel. >>>>>=20 >>>>>>>=20 >>>>>>> Yes sure, I am doing a run now with my patch. However, I have a >>>>>>> question -- why do you feel blocking in the kworker is not an issue?= >>>>>>> You are taking a snapshot before queuing the normal kwork and then >>>>>>> reading the snapshot when the normal kwork runs. Considering it is a= >>>>>>> high priority queue, the delay between when you are taking the >>>>>>> snapshot, and reading it is likely small so there is a bigger chance= >>>>>>> of blocking in cond_synchronize_rcu(). Did I miss something? >>>>>>>=20 >>>>>> We can wait indeed in the reclaim worker. But the worker does not do a= ny >>>>>> nasty or extra work here. If there is a need we block and wait. After= a >>>>>> grace period, we are awoken and proceed. >>>>>>=20 >>>>>> Therefore i do not see the reason in handling two cases: >>>>>>=20 >>>>>> if (gp_done) >>>>>> queue_work(); >>>>>> else >>>>>> queue_rcu_work(); >>>>>>=20 >>>>>> it is the same if we just queue the work and check on entry. The curr= ent >>>>>> scenario is: queue the work after a grace period. This is the differe= nce. >>>>>>=20 >>>>>> Right if the reclaimer was a high prio kthread a time would be shorte= r. >>>>>>=20 >>>>>> In your scenario the time seems even shorter(i have not checked) beca= use >>>>>> you update a snapshot of krcp each time a kvfree_rcu() is invoked. So= >>>>>> basically even though you have objects whose grace period is passed y= ou >>>>>> do not separate it anyhow. Because you update the: >>>>>>=20 >>>>>> krcp->gp_snap =3D get_state_synchronize_rcu(); >>>>>>=20 >>>>>> too often. >>>>>>=20 >>>>> Once upon a time we discussed that it is worth to keep track of GP >>>>> per-a-page in order to reduce a memory footprint. Below patch addresse= s >>>>> it: >>>>=20 >>>> In the patch below, it appears you are tracking the GP per krwp, and >>>> not per page. But I could be missing something - could you split it >>>> into separate patches for easier review? >>>>=20 >>> I will split. I was thinking about it. The GP is tracked per-a-page. As f= or >>> krwp it is only for channel_3. Everything goes there if no-page or no ca= che. >>>=20 >> Ah, ok. >>=20 >>>>=20 >>>> Also it still does cond_synchronize_rcu() :-( >>>>=20 >>> Sometimes we need to wait for a GP we can not just release :) >>=20 >> You know that is not what I meant ;) I was concerned about the blocking. >>=20 > Let me split. After that we/you can test and check if there is any issue > with sleeping on entry for waiting a GP if needed. Ack. What I=E2=80=99ll also do is, whenever you split it, I=E2=80=99ll put i= t on ChromeOS and see in real world, how many times we block. It could be I=E2= =80=99m missing something of how polled GP works. thanks, - Joel=20 >=20 > -- > Uladzislau Rezki