Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1155240ybi; Wed, 3 Jul 2019 10:25:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwF+FEXy3y/pd4G+Hd3+CnoNQ4qEdBtjtzaNfhAETy/7RoA/iIvGPpPeDMxixVpRUjxSw/a X-Received: by 2002:a17:902:74c7:: with SMTP id f7mr43099896plt.329.1562174740285; Wed, 03 Jul 2019 10:25:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562174740; cv=none; d=google.com; s=arc-20160816; b=qpZ9woSwnq+yY1VqA7FGE6KHrH0fGJwLWGZp/tmiu1UJ3DbS8H7tz9QnusntS7Ex4E Yi91a8iqjV0v675ND75e8yPCvzJGToi7Akynmf35r6VAGtkU4CdrosZ5Bjna+Ezj0DP1 9dzgpj+WhchI52YzftlRtmZUDvBsE68TBh8zpUShgkpI1neFai1+BZXx1ZiuzRJeYL0A 8I+jzBQ8iKMrOD3r0TO2XWxMxmhOpy4o8x2yaicn5NwGJBvn331BDl1gKreFVVy5J79R q2kONnDFE2uGxyRZ3Qbz/Rmcsx/4FcmswxY4V4Y+7Br5GpKYxQ5xyEdgWIStf3ZycaFT KPPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date; bh=U1AkXJhscGc9Tvsz/tfoU2bkzpNbVgKIb/3wFDPTXUA=; b=dK7g1OIygO3vPW5Vrsd0tvtTP9jQCadvLPZpOzkBCkwuUDi5G9MFIbKt6NGFn9RoYe qxxwxyC8n0QHukYi2MTB5adDgzlJR7zpD1fb9YjlSJl031/DUe0TIuzJU4QBFQWkowQS BLsFDYScUpV3mQdzZyYEkEb9d+SAqhfPTjPNj+dr6m5qBoVVsQH4gUOSbyYINyGVrlai AybyRxrGcfhGjTp/oLQfYIRID+jWBcOjy5pWUQi1Ifx1PUau+rZj9Y9PxW18qnWXQHwE ovdIbJm+zavRSuqyYNgl/+vLFBQCRpoaXLJGiKEe5gPirRTp/DWu5gWyF2hb+btdMzzq LRnA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f33si2445903pjg.81.2019.07.03.10.25.25; Wed, 03 Jul 2019 10:25:40 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727091AbfGCRZE (ORCPT + 99 others); Wed, 3 Jul 2019 13:25:04 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:18046 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726430AbfGCRZE (ORCPT ); Wed, 3 Jul 2019 13:25:04 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x63HNZEZ127516 for ; Wed, 3 Jul 2019 13:25:02 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tgxn158sd-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 03 Jul 2019 13:25:02 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 3 Jul 2019 18:25:01 +0100 Received: from b01cxnp22034.gho.pok.ibm.com (9.57.198.24) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 3 Jul 2019 18:24:58 +0100 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x63HNhUe48693676 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 3 Jul 2019 17:23:43 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F0028B205F; Wed, 3 Jul 2019 17:23:42 +0000 (GMT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C3067B2064; Wed, 3 Jul 2019 17:23:42 +0000 (GMT) Received: from paulmck-ThinkPad-W541 (unknown [9.70.82.26]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 3 Jul 2019 17:23:42 +0000 (GMT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id 4BDC716C1F1D; Wed, 3 Jul 2019 10:23:44 -0700 (PDT) Date: Wed, 3 Jul 2019 10:23:44 -0700 From: "Paul E. McKenney" To: "Joel Fernandes (Google)" Cc: linux-kernel@vger.kernel.org, Davidlohr Bueso , Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , rcu@vger.kernel.org, Steven Rostedt Subject: Re: [RFC] rcuperf: Make rcuperf test more robust for !expedited mode Reply-To: paulmck@linux.ibm.com References: <20190703043945.128825-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190703043945.128825-1-joel@joelfernandes.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 19070317-0052-0000-0000-000003D9F86B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011372; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01226933; UDB=6.00645968; IPR=6.01008160; MB=3.00027570; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-03 17:25:01 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19070317-0053-0000-0000-0000618E3F84 Message-Id: <20190703172344.GR26519@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-07-03_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907030211 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 03, 2019 at 12:39:45AM -0400, Joel Fernandes (Google) wrote: > 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! Another approach is to create (say) a late_initcall() function that sets a global variable. Then have the wait loop wait for that global variable to be set. Or use an explicit wait/wakeup scheme, if you wish. This has the virtue of keeping this (admittedly small) bit of complexit out of the core kernel. > 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? They are indeed (mostly) independent mechanisms. This is in contrast to SRCU, where an expedited grace period does what you expect, causing all grace periods to do less waiting until the most recent expedited grace period has completed. Why the difference? o Current SRCU uses have relatively few updates, so the decreases in batching effectiveness for normal grace periods are less troublesome than they would be for RCU. Shortening RCU grace periods would significantly increase per-update overhead, for example, and less so for SRCU. o RCU uses a much more distributed design, which means that expediting an already-started RCU grace period would be more challenging than it is for SRCU. The race conditions between an "expedite now!" event and the various changes in state for a normal RCU grace period would be challenging. o In addition, RCU's more distributed design results in higher latencies. Expedited RCU grace periods simply bypass this and get much better latencies. So, yes, normal and expedited RCU grace periods could be converged, but it does not seem like a good idea given current requirements. Thanx, Paul > 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 >