Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1739074ybz; Thu, 16 Apr 2020 14:46:54 -0700 (PDT) X-Google-Smtp-Source: APiQypKzLsVmS1qU++bIlrLmJw8gVj93jMqcfo8bzikh/J1PwYwi1zdBFnG138Ku4sJSOf4dwJsi X-Received: by 2002:a17:906:6b1b:: with SMTP id q27mr104540ejr.158.1587073614160; Thu, 16 Apr 2020 14:46:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587073614; cv=none; d=google.com; s=arc-20160816; b=q+Bm7kcTUWdr31eutzUxprGyGpeYpvyWsiE2yAv830kjG3UOlFVdAdeCTQEkUxKbYO sN9KC5/veNSx8ZfE0YjK/FuWRaq0JmLHFZNqmceQPy1LAeI7zv/YYyKcUpOpk2gDHaFj 00g9KwgrAsWD4kp0beNEiw9/zBTiSzUgowoLpTzKDzf1IEkd6Xhu4b+EhK3nNxsWUwjN OXNDpvdlg6e4xlaIhwLUQCqTpelMeIAEcv+luQAyDDh0OgsIK/xNz/bHNQe9uNiZukv6 6dwbHxQWcxJzsS1pghr5dW+x9oXzo8hQ4aYCmCSlDkEd3n0E5OyItZfiOfX2tfAu5tYK 2CFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=sffAzPhQCHYxlONYOcziAs0q3Ct9dInBstNF3EUot0A=; b=iOfTMJ/deA/h+1zE6fRVhdgYAnVJ2NzOKqAc0skwHuAHihEvxbbYIjOvleCfHBx8WI iNL/8CPlb3vdPudDrZKgJ1C397OqWRKo/udrtnsFYGXroFPPxlLFWe/Gj/ReU7d5+OAT ymt0MuSE2Ng3zqwNS+P9woXtpdgdUDo9qGwlX9F4NnhhlUaCtVVaDiCQGcWObi9gJ/a/ LViJ0KkgtgbaItr7fP6wGRVBse99Rl1Yf6LG9sg2RXI3MsxzcDWi6OOnd6CvD6IGVTHS zvngt/fMWwMVc5mz98jN35INwVTOP747vnLUkhRY+JFiMCARrYEDnxc/TuGr/jNNKmda N4hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YEYNjhgX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y25si13035935edr.60.2020.04.16.14.46.27; Thu, 16 Apr 2020 14:46:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YEYNjhgX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726429AbgDPVoR (ORCPT + 99 others); Thu, 16 Apr 2020 17:44:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725843AbgDPVoQ (ORCPT ); Thu, 16 Apr 2020 17:44:16 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BC2DC061A0C; Thu, 16 Apr 2020 14:44:16 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id a25so428258wrd.0; Thu, 16 Apr 2020 14:44:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:reply-to:references:mime-version :content-disposition:in-reply-to:user-agent; bh=sffAzPhQCHYxlONYOcziAs0q3Ct9dInBstNF3EUot0A=; b=YEYNjhgXkDenCpaBe24hLDaEJUvQf+AFbMkJW/M52iScpAsaPalPvb+cBzOAG4sWqw VJUdkzApo+PR/PcD6/dpOypTZD35Cn+iYnDeBotGPwhxW08ok2pII37KP12YBWBlEwTj zS3zoJ2kQuuLQtrKMIjJ6DVsVTg8gG34PMl4nMQ74O565/TEoKtCiFFquOfmKc3B2e2J jqMcujTLmug9H9x8b31CN1vi6tnRVlZBCDvetFwy1hXGPaVV+BD9Qxq+EkGT5rwDQi49 lF2n9nFXAJNuIsIwNgPL566gMYGIiLmAyOLLCCQBJgYKHpjRsA508DIsMGXw27uti8u1 3naw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:reply-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=sffAzPhQCHYxlONYOcziAs0q3Ct9dInBstNF3EUot0A=; b=HIxTGV2oRdRTTeyPyu4t3eZBnA/PS218S2OrxeE1cPn1nZmHyQV8Shx4ST7LWoMqed QNW8ThFZIl9/f12yaKuKF/Vgm5La6yHH8m6EZhLzzocD9i65eZ6xqMjIQDNu6fB6Sip5 BpZWOnn6bueK0Tc/Cdc+W8gRaf8vn2m6lMS9dJJ88tBnvD5e0Kdgj8ZPE7g14ot+75Le MxB1o7pR7jgrfVuTVjVRHhKiYcrzZAxkyXz+IFtJ6Znh6K5mG3Go/2lHSpwZLwUzFYot C1NAE3EvcEZYoV7YTTbKgNJnADSVyrGfNTMEcxJ0MgMsgSAoSjtpq7Wt8ZmFsKBzrJsz AuHg== X-Gm-Message-State: AGi0PuYlr8HoOfNAF5hO9L4EFxDrVqufnC74/Y8Umth9EtjLSTML57X+ NkgPaizFuIhE/VtC3D0SnT8= X-Received: by 2002:a5d:6646:: with SMTP id f6mr275421wrw.318.1587073455065; Thu, 16 Apr 2020 14:44:15 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id s27sm20203721wra.94.2020.04.16.14.44.14 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Apr 2020 14:44:14 -0700 (PDT) Date: Thu, 16 Apr 2020 21:44:13 +0000 From: Wei Yang To: "Paul E. McKenney" Cc: Wei Yang , josh@joshtriplett.org, rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] rcu: init and destroy rcu_synchronize when necessary Message-ID: <20200416214413.uabk6ojzykiy5rol@master> Reply-To: Wei Yang References: <20200415222655.9006-1-richard.weiyang@gmail.com> <20200416002400.GL17661@paulmck-ThinkPad-P72> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200416002400.GL17661@paulmck-ThinkPad-P72> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 15, 2020 at 05:24:00PM -0700, Paul E. McKenney wrote: >On Wed, Apr 15, 2020 at 10:26:55PM +0000, Wei Yang wrote: >> We would skip the rcu_synchronize if it is a duplicate call back function. >> >> This is not necessary to init and destroy for them. >> >> Signed-off-by: Wei Yang > >Applied, thank you! > >I edited the commit log a bit. Could you please check below to make >sure that I didn't mess anything up? > Yep, the changelog looks good to me :-) Glad you like it. > Thanx, Paul > >------------------------------------------------------------------------ > >commit d9eaddf545fe8e3e2725e2fa0bf87b59b5667c14 >Author: Wei Yang >Date: Wed Apr 15 22:26:55 2020 +0000 > > rcu: Initialize and destroy rcu_synchronize only when necessary > > The __wait_rcu_gp() function unconditionally initializes and cleans up > each element of rs_array[], whether used or not. This is slightly > wasteful and rather confusing, so this commit skips both initialization > and cleanup for duplicate callback functions. > > Signed-off-by: Wei Yang > Signed-off-by: Paul E. McKenney > >diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c >index 3ce63a9..351c322 100644 >--- a/kernel/rcu/update.c >+++ b/kernel/rcu/update.c >@@ -391,13 +391,14 @@ void __wait_rcu_gp(bool checktiny, int n, call_rcu_func_t *crcu_array, > might_sleep(); > continue; > } >- init_rcu_head_on_stack(&rs_array[i].head); >- init_completion(&rs_array[i].completion); > for (j = 0; j < i; j++) > if (crcu_array[j] == crcu_array[i]) > break; >- if (j == i) >+ if (j == i) { >+ init_rcu_head_on_stack(&rs_array[i].head); >+ init_completion(&rs_array[i].completion); > (crcu_array[i])(&rs_array[i].head, wakeme_after_rcu); >+ } > } > > /* Wait for all callbacks to be invoked. */ >@@ -408,9 +409,10 @@ void __wait_rcu_gp(bool checktiny, int n, call_rcu_func_t *crcu_array, > for (j = 0; j < i; j++) > if (crcu_array[j] == crcu_array[i]) > break; >- if (j == i) >+ if (j == i) { > wait_for_completion(&rs_array[i].completion); >- destroy_rcu_head_on_stack(&rs_array[i].head); >+ destroy_rcu_head_on_stack(&rs_array[i].head); >+ } > } > } > EXPORT_SYMBOL_GPL(__wait_rcu_gp); -- Wei Yang Help you, Help me