Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1194619pxb; Fri, 20 Nov 2020 03:43:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMqzFLO+j2Qbs48WrJgDZq8eGIGfPiIpCSe7cAKXCckovxz7GM6PZwBzE+QsDbomKTCux5 X-Received: by 2002:a05:6402:cb4:: with SMTP id cn20mr34545803edb.235.1605872606290; Fri, 20 Nov 2020 03:43:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605872606; cv=none; d=google.com; s=arc-20160816; b=hJTXvt3BT6HrKxtPbqJVSIv7QA3/HnkPJGqkNEaPwKso5y6vC52Sz5syorslaVGTBb QrCIZgQgZ9U3sTRW16qncowewDqEQ//rTnWHQ3EeebDIvJs7kEtoMIsfaLPqk5q1OroE JfS1CHpf42pCRh/6M7U6HLWaREG3EuPtLH2lAsiasEA5oAnMLrzeKwTAx4VaDx2Roc18 l4+nh54l8OeXAzkY+u7YTkRYBZH4vZtKGWa6j6nziQth88o8czZbF5KQIyJZIQMuVfFV k6BSwalEwa9+R44QI0YgVdXcSATAgnQi18fDlGLQEuHsGwbG5wDJt5MqDJ6tJq0x0Jcp 5gcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dmarc-filter:sender:dkim-signature; bh=zeUkBZJSG3m+Px0GQ95i9hVc445A7oX9PZfP5zdKnDo=; b=UqalPafFBY+fatXTLv8skQME4s9zLiiEyQV2M98D7R474//A3EA3cMt5kIujORgfHe QdXoKFLpf/PAM06K9mHt4w97rB5X3ttCIzXP+rfQpkZVZrv75CoKXH7ZXgWh+I68I+0c HP9mp3Xmg4+QvCcMykuqV/Knk4W7lwgE2KzrpznzYdTe/cw88tnZwrE0muf3ZL+sdeUO cDV1hm9y9Jd3g/XZoM1DXVTOkcX8FtRNpft64VziuGwqnZCQNdN9B10cTSeoAZiPTezS xIAX9eNBCaHY3GLJFq8egub8yllZURMEvSUJ1OmPDSJbjBFY/jfZXYSjsfCA+rhBFQA5 pFLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=QXJtgDal; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l13si1596161edn.43.2020.11.20.03.43.03; Fri, 20 Nov 2020 03:43:26 -0800 (PST) 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=@mg.codeaurora.org header.s=smtp header.b=QXJtgDal; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727799AbgKTLhB (ORCPT + 99 others); Fri, 20 Nov 2020 06:37:01 -0500 Received: from m42-4.mailgun.net ([69.72.42.4]:50636 "EHLO m42-4.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727770AbgKTLhA (ORCPT ); Fri, 20 Nov 2020 06:37:00 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1605872220; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=zeUkBZJSG3m+Px0GQ95i9hVc445A7oX9PZfP5zdKnDo=; b=QXJtgDaleBr2Bka8ycMwoEvidoH+UK30Q53LtDROHW20qBv3J1SaTx3zBXWxcYST/0wZVTz/ bZj32PEiNzQN8o7CL4U50/nlvImyAerm9d8aqtnQj9/divqTLY7V1xsU8f63oRKVXU4ZFaML 4GrdTsDLhDfuAYHlRc4rilIn71E= X-Mailgun-Sending-Ip: 69.72.42.4 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n07.prod.us-east-1.postgun.com with SMTP id 5fb7aa5b7f0cfa6a16d3fc70 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 20 Nov 2020 11:36:59 GMT Sender: neeraju=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id DD506C43468; Fri, 20 Nov 2020 11:36:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00, NICE_REPLY_A,SPF_FAIL,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from [192.168.0.101] (unknown [124.123.182.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: neeraju) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2E7DBC433C6; Fri, 20 Nov 2020 11:36:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 2E7DBC433C6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=neeraju@codeaurora.org Subject: Re: [PATCH RFC tip/core/rcu 3/5] srcu: Provide internal interface to start a Tree SRCU grace period To: paulmck@kernel.org, rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, mingo@kernel.org, jiangshanlai@gmail.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org References: <20201117004017.GA7444@paulmck-ThinkPad-P72> <20201117004052.14758-3-paulmck@kernel.org> From: Neeraj Upadhyay Message-ID: <69c05cd0-8187-49a7-5b2d-1a10ba42fa44@codeaurora.org> Date: Fri, 20 Nov 2020 17:06:50 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.3 MIME-Version: 1.0 In-Reply-To: <20201117004052.14758-3-paulmck@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/17/2020 6:10 AM, paulmck@kernel.org wrote: > From: "Paul E. McKenney" > > There is a need for a polling interface for SRCU grace periods. > This polling needs to initiate an SRCU grace period without having > to queue (and manage) a callback. This commit therefore splits the > Tree SRCU __call_srcu() function into callback-initialization and > queuing/start-grace-period portions, with the latter in a new function > named srcu_gp_start_if_needed(). This function may be passed a NULL > callback pointer, in which case it will refrain from queuing anything. > > Why have the new function mess with queuing? Locking considerations, > of course! > > Link: https://lore.kernel.org/rcu/20201112201547.GF3365678@moria.home.lan/ > Reported-by: Kent Overstreet > Signed-off-by: Paul E. McKenney > --- Reviewed-by: Neeraj Upadhyay Thanks Neeraj > kernel/rcu/srcutree.c | 66 +++++++++++++++++++++++++++++---------------------- > 1 file changed, 37 insertions(+), 29 deletions(-) > > diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c > index 79b7081..d930ece 100644 > --- a/kernel/rcu/srcutree.c > +++ b/kernel/rcu/srcutree.c > @@ -808,6 +808,42 @@ static void srcu_leak_callback(struct rcu_head *rhp) > } > > /* > + * Start an SRCU grace period, and also queue the callback if non-NULL. > + */ > +static void srcu_gp_start_if_needed(struct srcu_struct *ssp, struct rcu_head *rhp, bool do_norm) > +{ > + unsigned long flags; > + int idx; > + bool needexp = false; > + bool needgp = false; > + unsigned long s; > + struct srcu_data *sdp; > + > + idx = srcu_read_lock(ssp); > + sdp = raw_cpu_ptr(ssp->sda); > + spin_lock_irqsave_rcu_node(sdp, flags); > + rcu_segcblist_enqueue(&sdp->srcu_cblist, rhp); > + rcu_segcblist_advance(&sdp->srcu_cblist, > + rcu_seq_current(&ssp->srcu_gp_seq)); > + s = rcu_seq_snap(&ssp->srcu_gp_seq); > + (void)rcu_segcblist_accelerate(&sdp->srcu_cblist, s); > + if (ULONG_CMP_LT(sdp->srcu_gp_seq_needed, s)) { > + sdp->srcu_gp_seq_needed = s; > + needgp = true; > + } > + if (!do_norm && ULONG_CMP_LT(sdp->srcu_gp_seq_needed_exp, s)) { > + sdp->srcu_gp_seq_needed_exp = s; > + needexp = true; > + } > + spin_unlock_irqrestore_rcu_node(sdp, flags); > + if (needgp) > + srcu_funnel_gp_start(ssp, sdp, s, do_norm); > + else if (needexp) > + srcu_funnel_exp_start(ssp, sdp->mynode, s); > + srcu_read_unlock(ssp, idx); > +} > + > +/* > * Enqueue an SRCU callback on the srcu_data structure associated with > * the current CPU and the specified srcu_struct structure, initiating > * grace-period processing if it is not already running. > @@ -838,13 +874,6 @@ static void srcu_leak_callback(struct rcu_head *rhp) > static void __call_srcu(struct srcu_struct *ssp, struct rcu_head *rhp, > rcu_callback_t func, bool do_norm) > { > - unsigned long flags; > - int idx; > - bool needexp = false; > - bool needgp = false; > - unsigned long s; > - struct srcu_data *sdp; > - > check_init_srcu_struct(ssp); > if (debug_rcu_head_queue(rhp)) { > /* Probable double call_srcu(), so leak the callback. */ > @@ -853,28 +882,7 @@ static void __call_srcu(struct srcu_struct *ssp, struct rcu_head *rhp, > return; > } > rhp->func = func; > - idx = srcu_read_lock(ssp); > - sdp = raw_cpu_ptr(ssp->sda); > - spin_lock_irqsave_rcu_node(sdp, flags); > - rcu_segcblist_enqueue(&sdp->srcu_cblist, rhp); > - rcu_segcblist_advance(&sdp->srcu_cblist, > - rcu_seq_current(&ssp->srcu_gp_seq)); > - s = rcu_seq_snap(&ssp->srcu_gp_seq); > - (void)rcu_segcblist_accelerate(&sdp->srcu_cblist, s); > - if (ULONG_CMP_LT(sdp->srcu_gp_seq_needed, s)) { > - sdp->srcu_gp_seq_needed = s; > - needgp = true; > - } > - if (!do_norm && ULONG_CMP_LT(sdp->srcu_gp_seq_needed_exp, s)) { > - sdp->srcu_gp_seq_needed_exp = s; > - needexp = true; > - } > - spin_unlock_irqrestore_rcu_node(sdp, flags); > - if (needgp) > - srcu_funnel_gp_start(ssp, sdp, s, do_norm); > - else if (needexp) > - srcu_funnel_exp_start(ssp, sdp->mynode, s); > - srcu_read_unlock(ssp, idx); > + srcu_gp_start_if_needed(ssp, rhp, do_norm); > } > > /** > -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation