Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2142147rwl; Thu, 13 Apr 2023 02:08:56 -0700 (PDT) X-Google-Smtp-Source: AKy350YcZ+HpzEU46uSi8/PXf0MEcrhg9Q1kdJZPAHLEHksJLSWt1aJ9lYF9NUeH3oSuZClRzzBP X-Received: by 2002:a50:eb4d:0:b0:504:a2c8:ea60 with SMTP id z13-20020a50eb4d000000b00504a2c8ea60mr1764823edp.35.1681376936199; Thu, 13 Apr 2023 02:08:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681376936; cv=none; d=google.com; s=arc-20160816; b=GXCyDQ8CCvuuXBDva8JlOK8Do4LinfFMoB84CuBOTa0JGgRdyQy0CSW+1iGWQLITcW illN+ylf32J36GoAXbDi+vW6by1cbeC3Ac8jPahhzv/PhTSWUxKcwXfFY9ZFO4oizIZH rDh/5/K0IehwjBDfcRPQ38KOf38Cle+PwqpvNZGxqDj5jtcSkylhXkJIKXAyogF4w05f gMo+R0Pt8di+HlcMFTkg5M45jXaU6Sxjnr3psrCyArDCN0xcwR0QRQI9FEBYXHwLjX+F 3JRnv94R3XKxvZoz7hEm96iv0o9l/62S6UklYadBNUsX2IGT9ja1DeYCE8gK1ZjDGF2p PnHQ== 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:date:from:dkim-signature; bh=2nwth3f3dlESn+xcWsI3GV0ApYXXBMlu6d6OTG1ZvlY=; b=No84B1wlP2cyioQrfUszBfqPZnmjHhjG6a23Uw46hf+x7O3z3W895VuPTiTH6IeTel 6f5cX78WdvYvhlKQQsTcBW003Rq2B3HM44CRXYEgotA8S/u5hZaJHvlv/PNJxqaUfnsD BQYZXCPkfYPOK+uRaIPoCXopS4uzVY3FEkn6WibF4VGI+dFzXdNrd4KvufP24mX/rrCp cVcq7ggeIJwJeFpIOkjpO8DLpEMCt9pdKLT/aC1m9gKdTeaD/binqiPhP+Ct9NcIs857 PNKKg3tssrbz1R45v4SkVsTiOlIenOEUyPLnEOVEsAYxZthrKYMGzi2GH2/CVTfu75ih vImA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=KmPbLiqs; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay11-20020a170907900b00b00947de9f9b54si1230384ejc.367.2023.04.13.02.08.32; Thu, 13 Apr 2023 02:08:56 -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=@gmail.com header.s=20221208 header.b=KmPbLiqs; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229831AbjDMJH1 (ORCPT + 99 others); Thu, 13 Apr 2023 05:07:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229787AbjDMJHY (ORCPT ); Thu, 13 Apr 2023 05:07:24 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C6F783F8; Thu, 13 Apr 2023 02:07:14 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id b33so10352202ljf.2; Thu, 13 Apr 2023 02:07:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681376833; x=1683968833; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=2nwth3f3dlESn+xcWsI3GV0ApYXXBMlu6d6OTG1ZvlY=; b=KmPbLiqsmMc4cNxb7TG0JMYJLr3RywbCDFSS8PotigkKMUdFMykxLdwdKlh74yvAWY /KYxKqLYp6WujQ15SPk0h5gXaVNCDKf/8kgjas+MxnK4Il6Q5dTN+yQh2YL7VpbQJmhN 7cF+BEZKXbINt7wGyjxEyQL5lBWDqWxLyCd70MBtgWkY3MGxIUXTlmqBtuIjPW72E8Td QZwls6tlVWymzbnRsHHX7SL8c72SFMesKa3tlvtd5QJGz27UDq5ZtI0IjYsIWLOvn9Oj wF9IgvURsb5eSGU8ktr079UdkULuGxk+hBcNZ1fZM0F9yHRoIfBF02np47+kmKeR8kAv zFDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681376833; x=1683968833; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2nwth3f3dlESn+xcWsI3GV0ApYXXBMlu6d6OTG1ZvlY=; b=GXkMi5Wrevf2spOMOqQheYBs+Vun2EqfZ56aJa9q3eUyHI7hMh/ci+JQA2PY5oimRX DaYNuUY7mrKxmOL5QWjHTmBl7PYiwIdjSc9L9/h+vSfWRBNYnZ0u0mE0rh7Ihwe2MlPH LiqRGK31b7KoZuZIP79k7W0dtxeID2XwZKuEQxCeXqBwFBZIAajrKikUs6YrD1aaQT92 h4O0aFC7bNq9kDRDM7Us6GIwyPDJMjagy/2P8M1fnbA6PJPhdujX5zNDi5dDx6VG8DsH MQ2migEDFN1tsNixJ2wFPud1+00bNWoWfF8BtPhEUcVmh/lwyZG45tnKLY8K1/VLySM6 XYgg== X-Gm-Message-State: AAQBX9cW9STWuSFVqeCVhxWx2uMSrFRG5sqPd0t9FZm/OpGUszU1CxNN GJb3TKMv2SELUYozo7rKY+s= X-Received: by 2002:a2e:301a:0:b0:29b:80b4:7bf7 with SMTP id w26-20020a2e301a000000b0029b80b47bf7mr598325ljw.41.1681376832750; Thu, 13 Apr 2023 02:07:12 -0700 (PDT) Received: from pc636 (host-90-235-5-238.mobileonline.telia.com. [90.235.5.238]) by smtp.gmail.com with ESMTPSA id h13-20020a2e900d000000b002987088bda4sm177565ljg.69.2023.04.13.02.07.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Apr 2023 02:07:12 -0700 (PDT) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Thu, 13 Apr 2023 11:07:09 +0200 To: Zqiang Cc: urezki@gmail.com, paulmck@kernel.org, frederic@kernel.org, joel@joelfernandes.org, qiang.zhang1211@gmail.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] rcu/kvfree: Make fill page cache start from krcp->nr_bkv_objs Message-ID: References: <20230412143127.1062367-1-qiang1.zhang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230412143127.1062367-1-qiang1.zhang@intel.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, 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 Wed, Apr 12, 2023 at 10:31:27PM +0800, Zqiang wrote: > The fill_page_cache_func() is invoked and start from zero to > allocate nr_pages of page, if the kfree_rcu_work() executes before > the fill_page_cache_func(), the krcp->nr_bkv_objs is updated before > enter for-loop and equal to nr_pages, since the page is allocated > first, and then check the krcp->nr_bkv_objs in put_cached_bnode(), > this produces a meaningless __get_free_page() call, this commit > therefore make allocate page start from krcp->nr_bkv_objs and > check krcp->nr_bkv_objs before allocate page. > > Signed-off-by: Zqiang > --- > kernel/rcu/tree.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 41daae3239b5..dcb86f9f2dd6 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -3223,7 +3223,7 @@ static void fill_page_cache_func(struct work_struct *work) > nr_pages = atomic_read(&krcp->backoff_page_cache_fill) ? > 1 : rcu_min_cached_objs; > > - for (i = 0; i < nr_pages; i++) { > + for (i = READ_ONCE(krcp->nr_bkv_objs); i < nr_pages; i++) { > bnode = (struct kvfree_rcu_bulk_data *) > __get_free_page(GFP_KERNEL | __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN); > > -- > 2.32.0 > Reviewed-by: Uladzislau Rezki (Sony) -- Uladzislau Rezki