Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5116773ybv; Mon, 17 Feb 2020 12:37:14 -0800 (PST) X-Google-Smtp-Source: APXvYqyCaFjoUYQFkJkg7ORciUDOQhe9ISH8iqeco2JPCfnDSwPJDOEKhMQa1Ojnd1nDwmbHKwxi X-Received: by 2002:a9d:6a53:: with SMTP id h19mr13931027otn.120.1581971834765; Mon, 17 Feb 2020 12:37:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581971834; cv=none; d=google.com; s=arc-20160816; b=JIP7S0NpjCS9i+oVPIC4f20xctpwJHjkWrjEdOLefCzw5CB7N2EYCdLG+WNVN1WTzi CXvcBYE/ID34yZJEj50+sp23Y5kHQa9f6rPZ6jwS9DF4W9ueD7P5lJA/SZ8tkYvl2UcS ZFPyd98CGk7i92h6nSZLCzomKdAWl5htX2nBo/MmPcMNUYP5pskmvck43ofrOwOYAXZa jr+Q8L/XiHKnA7uX1g//bb+9eM0U7XoYBXWZ1oasZfilrjRL+YT9iidi38jwN+Us+cIX GGorY3IHhljtPSYsSalwjkShw3iMYSxyZjsvn4iRyvhdpzG1LpEUPEQCxA6oWRUAs/VT +wQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=9pb8KzUKG7/RNZZHPF62+3BMZNikFizmiX1VSeOJ67M=; b=WJfSgzJ6UZJVib+BULGbn11m3wEYo6dpJcl/K4HcUzT1UktiCnUDC3CWNU/bl6mpT7 +eVuF78Ah5cTq2RqcShG7paiaRWyejI7kfvMIH1dp2JmMTH2L1+l/cYAi+t463wiaIZ1 6S7rIUIpQIFX2UjpSEvi7AIkCVUyZ6Y4m3ZuMKQOyLISVZWEd7G82p08cnNSm5uW741A DJi2QTYcpqltVPwluLlbo/4laW1hfSFPro3Fje2MIsoRRPBa6evXeP8q6zGG56L9NL2T U5Qe0aDb1jXXpglFJU3vFXlm6QSeeAgWV+/5SWPdW4l4EAwu8+ibXLCDGu43vLp2Npsn 1w+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l20si633421otr.202.2020.02.17.12.37.02; Mon, 17 Feb 2020 12:37:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729814AbgBQUZV (ORCPT + 99 others); Mon, 17 Feb 2020 15:25:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:58234 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727300AbgBQUZU (ORCPT ); Mon, 17 Feb 2020 15:25:20 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A75C72067D; Mon, 17 Feb 2020 20:25:18 +0000 (UTC) Date: Mon, 17 Feb 2020 15:25:17 -0500 From: Steven Rostedt To: "Paul E. McKenney" Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org, Linus Torvalds Subject: Re: [PATCH tip/core/rcu 22/30] rcu: Don't flag non-starting GPs before GP kthread is running Message-ID: <20200217152517.26cc11ea@gandalf.local.home> In-Reply-To: <20200215134208.GA9879@paulmck-ThinkPad-P72> References: <20200214235536.GA13364@paulmck-ThinkPad-P72> <20200214235607.13749-22-paulmck@kernel.org> <20200214225305.48550d6a@oasis.local.home> <20200215110111.GZ2935@paulmck-ThinkPad-P72> <20200215134208.GA9879@paulmck-ThinkPad-P72> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 15 Feb 2020 05:42:08 -0800 "Paul E. McKenney" wrote: > > And does the following V2 look better? > For the issue I brought up, yes. But now I have to ask... > @@ -1252,10 +1253,10 @@ static bool rcu_future_gp_cleanup(struct rcu_node *rnp) > */ > static void rcu_gp_kthread_wake(void) > { > - if ((current == rcu_state.gp_kthread && > - !in_irq() && !in_serving_softirq()) || > - !READ_ONCE(rcu_state.gp_flags) || > - !rcu_state.gp_kthread) > + struct task_struct *t = READ_ONCE(rcu_state.gp_kthread); > + > + if ((current == t && !in_irq() && !in_serving_softirq()) || > + !READ_ONCE(rcu_state.gp_flags) || !t) Why not test !t first? As that is the fastest operation in the if statement, and will shortcut all the other operations if it is true. As I like to micro-optimize ;-), for or (||) statements, I like to add the fastest operations first. To me, that would be: if (!t || READ_ONCE(rcu_state.gp_flags) || (current == t && !in_irq() && !in_serving_softirq())) return; Note, in_irq() reads preempt_count which is not always a fast operation. -- Steve > return; > WRITE_ONCE(rcu_state.gp_wake_time, jiffies); > WRITE_ONCE(rcu_state.gp_wake_seq, READ_ONCE(rcu_state.gp_seq)); > @@ -3554,7 +3555,10 @@ static int __init rcu_spawn_gp_kthread(void) > } > rnp = rcu_get_root(); > raw_spin_lock_irqsave_rcu_node(rnp, flags); > - rcu_state.gp_kthread = t; > + WRITE_ONCE(rcu_state.gp_activity, jiffies); > + WRITE_ONCE(rcu_state.gp_req_activity, jiffies); > + // Reset .gp_activity and .gp_req_activity before setting .gp_kthread. > + smp_store_release(&rcu_state.gp_kthread, t); /* ^^^ */ > raw_spin_unlock_irqrestore_rcu_node(rnp, flags); > wake_up_process(t); > rcu_spawn_nocb_kthreads(); > diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h > index 488b71d..16ad7ad 100644 \