Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp347452ybi; Tue, 2 Jul 2019 21:40:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCypSmRf2eCIWRyJYoE5NOFudNGPgFmYlW60Ghina7g+GFG5NOh+soaX+AvNnH9Qfo1/da X-Received: by 2002:a17:902:7c03:: with SMTP id x3mr40260612pll.242.1562128832643; Tue, 02 Jul 2019 21:40:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562128832; cv=none; d=google.com; s=arc-20160816; b=HwdhMiu/OVMX4BpO22EqmInnne96Aqw/N5iQEXchxZ5urDaT9hUTBxmZ43L/Jh9+hU G5C3p9TFmNqwE0h0cynVssA4yeSC0kpA078SmPMXazwD3ZxMk/sdJXkMojEOYcsmV+Gd +uSL9SK0RQakA56GFpRUPXjuAlHEN3Qa2JTw6UqJpqP1FTRhTUcMd+3hE3XAPe1Py0Q/ eYeldTeTbcJk9XOPUh8UsIHLCOjFTj/0DH23J3QtasoQJwEfmb95KImO+isHqdmVKrvb KeDL/AimmqsNdrNoeLk+3OAWuVZwlz4LfUs8k1RiEGPV5aNmFWRa6hKRrDT3Dy5XnSu9 qB/w== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=xcs6LVebZeYfm34tR+E2iNRTl8rNqT5+HyCV9cmyWAg=; b=Cy3vpKcaPZyds3CiZKeiL7RPMllFyeJ8nh1C/deA4bHCEozYgouVGqzeFUTvnHP4kl vzrwhXm/nBZmNaFcjIwHhImGVPshk7UxDxOEggHkwe8819TQQ3iWDLGiIKoL1zWGOZK7 0m0rFOedbHQ+rSvNZkHxdcqD7g+VamciO5Mr4Cu76jnMo4zTFAnQh1SHBbT0PGlvWIyb OUt2raUfHaujy0se0qyS46c4kib51kMkgSan38xOwIdSTyvx6teMO5IpVPCwFXC4WChN NUbsPMkHGdbtrJe3p4/rCy6Or8iofE9iHJHWih5UqJSV/ed38GurD+bWw/AKDgq6W8/y FVnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=bew0bE1v; 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 y12si1004558pgr.329.2019.07.02.21.40.17; Tue, 02 Jul 2019 21:40:32 -0700 (PDT) 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; dkim=pass header.i=@joelfernandes.org header.s=google header.b=bew0bE1v; 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 S1726094AbfGCEj7 (ORCPT + 99 others); Wed, 3 Jul 2019 00:39:59 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:34054 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725807AbfGCEj7 (ORCPT ); Wed, 3 Jul 2019 00:39:59 -0400 Received: by mail-pf1-f195.google.com with SMTP id c85so575863pfc.1 for ; Tue, 02 Jul 2019 21:39:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xcs6LVebZeYfm34tR+E2iNRTl8rNqT5+HyCV9cmyWAg=; b=bew0bE1vCsEia5mVlCBgThQkoqZt0DhnInUjeC77F/hf/+eC+B0SiAETi90XUiO6KV 6iu+WAqDm/w4DbOoYmBau0bh4sjSRrLiEwCEqq3zaol5B7pM/Ab1FsynaKaGKMg7/u09 +R7IgIITU1Yrg8Ynt/NttzgZEPOT5UeLuOnqM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xcs6LVebZeYfm34tR+E2iNRTl8rNqT5+HyCV9cmyWAg=; b=CsNyuyYH6J4RZ+byQa599xHmZFTkfuZ6Yn12oEUfYgXXZ2ktzc3lz1sZV9Oy+LLBgT Zvi5VUz8H7UVoPYlqVF4hQhdRfEp4sDcSrvoASC79oUTqhE453f8Wl8YGYj1wRPhytXr vOXRV03aQlCdpsjyIuvg1ejDEKlklQ0V7gJZYKOBwgpEy3hJMgcpcXVecdiav28ZQxRM CgXiqu5VzMYIzRsxJiS1Rx9nG1j0NqLNknAPNqyW7Rz05EMO0dVEoanZiiDN2iohi3PM AL8/MNRoHeGiJ+4TZoknTxtBtZXLGoeovdibJRYujcJWxXmjL8TwfhvUK63PGAh0dLjb cI6g== X-Gm-Message-State: APjAAAVLttn52FqFKPMJiz6c4xLDqsocCPGAACz0rYS8RpmcmTI72YIv 7ObPjNIRWmtzgu+DT/c65PZl67ULkr4= X-Received: by 2002:a63:1723:: with SMTP id x35mr34081099pgl.233.1562128797851; Tue, 02 Jul 2019 21:39:57 -0700 (PDT) Received: from joelaf.cam.corp.google.com ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id 2sm678953pff.174.2019.07.02.21.39.55 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 02 Jul 2019 21:39:56 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , Davidlohr Bueso , Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , "Paul E. McKenney" , rcu@vger.kernel.org, Steven Rostedt Subject: [RFC] rcuperf: Make rcuperf test more robust for !expedited mode Date: Wed, 3 Jul 2019 00:39:45 -0400 Message-Id: <20190703043945.128825-1-joel@joelfernandes.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is possible that rcuperf run concurrently with init starting up. During this time, the system is running all grace periods as expedited. However, rcuperf can also be run in a normal mode. The rcuperf test depends on a holdoff before starting the test to ensure grace periods start later. This works fine with the default holdoff time however it is not robust in situations where init takes greater than the holdoff time the finish running. Or, as in my case: I modified the rcuperf test locally to also run a thread that did preempt disable/enable in a loop. This had the effect of slowing down init. The end result was "batches:" counter was 0. This was because only expedited GPs seem to happen, not normal ones which led to the rcu_state.gp_seq counter remaining constant across grace periods which unexpectedly happen to be expedited. This led me to debug that even though the test could be for normal GP performance, because init has still not run enough, the rcu_unexpedited_gp() call would not have run yet. In other words, the test would concurrently with init booting in expedited GP mode. To fix this properly, let us just check for whether rcu_unexpedited_gp() was called yet before starting the writer test. With this, the holdoff parameter could also be dropped or reduced to speed up the test. Signed-off-by: Joel Fernandes (Google) --- Please consider this patch as an RFC only! This is the first time I am running the RCU performance tests, thanks! Question: I actually did not know that expedited gp does not increment rcu_state.gp_seq. Does expedited GPs not go through the same RCU-tree machinery as non-expedited? If yes, why doesn't rcu_state.gp_seq increment when we are expedited? If no, why not? kernel/rcu/rcu.h | 2 ++ kernel/rcu/rcuperf.c | 5 +++++ kernel/rcu/update.c | 9 +++++++++ 3 files changed, 16 insertions(+) diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h index 8fd4f82c9b3d..5d30dbc7000b 100644 --- a/kernel/rcu/rcu.h +++ b/kernel/rcu/rcu.h @@ -429,12 +429,14 @@ static inline void srcu_init(void) { } static inline bool rcu_gp_is_normal(void) { return true; } static inline bool rcu_gp_is_expedited(void) { return false; } static inline void rcu_expedite_gp(void) { } +static inline bool rcu_expedite_gp_called(void) { } static inline void rcu_unexpedite_gp(void) { } static inline void rcu_request_urgent_qs_task(struct task_struct *t) { } #else /* #ifdef CONFIG_TINY_RCU */ bool rcu_gp_is_normal(void); /* Internal RCU use. */ bool rcu_gp_is_expedited(void); /* Internal RCU use. */ void rcu_expedite_gp(void); +bool rcu_expedite_gp_called(void); void rcu_unexpedite_gp(void); void rcupdate_announce_bootup_oddness(void); void rcu_request_urgent_qs_task(struct task_struct *t); diff --git a/kernel/rcu/rcuperf.c b/kernel/rcu/rcuperf.c index 4513807cd4c4..9902857d3cc6 100644 --- a/kernel/rcu/rcuperf.c +++ b/kernel/rcu/rcuperf.c @@ -375,6 +375,11 @@ rcu_perf_writer(void *arg) if (holdoff) schedule_timeout_uninterruptible(holdoff * HZ); + // Wait for rcu_unexpedite_gp() to be called from init to avoid + // doing expedited GPs if we are not supposed to + while (!gp_exp && rcu_expedite_gp_called()) + schedule_timeout_uninterruptible(1); + t = ktime_get_mono_fast_ns(); if (atomic_inc_return(&n_rcu_perf_writer_started) >= nrealwriters) { t_rcu_perf_writer_started = t; diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c index 249517058b13..840f62805d62 100644 --- a/kernel/rcu/update.c +++ b/kernel/rcu/update.c @@ -154,6 +154,15 @@ void rcu_expedite_gp(void) } EXPORT_SYMBOL_GPL(rcu_expedite_gp); +/** + * rcu_expedite_gp_called - Was there a prior call to rcu_expedite_gp()? + */ +bool rcu_expedite_gp_called(void) +{ + return (atomic_read(&rcu_expedited_nesting) != 0); +} +EXPORT_SYMBOL_GPL(rcu_expedite_gp_called); + /** * rcu_unexpedite_gp - Cancel prior rcu_expedite_gp() invocation * -- 2.22.0.410.gd8fdbe21b5-goog