Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10535822ybi; Thu, 11 Jul 2019 06:54:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfQvnUQoafjkrK1i2LSYurw0rlBFx0DQmW6nT6w/PY9lWBtj6C0upp62Cq3/GeLIx8pBJ9 X-Received: by 2002:a63:7942:: with SMTP id u63mr4436906pgc.399.1562853293469; Thu, 11 Jul 2019 06:54:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562853293; cv=none; d=google.com; s=arc-20160816; b=0/DMXgoaPu6qFRYfe7WEzAdPStWnZTV5J1tlqQGSswDY/PzWSlPI7ci8MBqJErKf5H h8qic3oIKgnQGgJk7JiI5HA4ui97l8KcgxLYotDeUA3W6A2fo3MqlZGN55igQ1YhnhjV aR8GT/eeaQoC6y8yCdg6Z1HjAc5UzTeYQ/uNWJW95KMJ5jw1ie7+yFDjkfODco2qhO8k l968Htg5gHowipML2XtrjMsX8gW83A6B9N+Op1lVAhZEeFlcTKPMzIuLZmw5XyUQMqIF zQe6MhmltN1shGkVo74+Tyw7S3ao7eHvL2fhGgreg6nQXKYj3YNR3RFIHJstJKFk4Xdf GyLg== 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:message-id:subject:cc :to:from:date:dkim-signature; bh=bERwlcG3C4nlijCFRRI6OTUZ0wG24LbZHXp5D5LjinE=; b=0g2koVrwjeM+RTDjbL/LncNPVMHPmorvuLKO5zcgnf1RL2Xj/U8CrmXSER4KK+OtO1 JWiwDbVkK98ZnCKI4JeWBGVcuOCyrmB32scWKoXjUbLr3594EtQLikT+a3n0lxX4M1ng ppzLiSSMWNofJJrNUM2xh4wsc5KT3AcM26CYM6D82F84pL4EuCh+WXummSJ1fMEaSz4M kdqMMPSAWhbFNQkYwJqOA/E7KClyqv37uBiMDZLpy//OFcXhEJAFBUsp5ziYHLT8OQho WzTzxxMr81Q+8ccFXDbPVNDDajCL8PgpuYmh/WNwIkZpmQicwjFlcER5rA3obf0xJAea 56lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b="qW7/U0pU"; 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 y5si5479507pfq.181.2019.07.11.06.54.37; Thu, 11 Jul 2019 06:54:53 -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="qW7/U0pU"; 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 S1728760AbfGKNIx (ORCPT + 99 others); Thu, 11 Jul 2019 09:08:53 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:46417 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728655AbfGKNIx (ORCPT ); Thu, 11 Jul 2019 09:08:53 -0400 Received: by mail-pl1-f193.google.com with SMTP id c2so2991348plz.13 for ; Thu, 11 Jul 2019 06:08:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=bERwlcG3C4nlijCFRRI6OTUZ0wG24LbZHXp5D5LjinE=; b=qW7/U0pUSWBXYYdu4uGqL2CtKwWUWkSrSSyzBaOT6PO0jcr3truea92twlsXMeiV1T ksURAl7b7Br64uZp1KBabXWQBsq3pIpEXy3M0scKBzH90+A4/bdvN/La+Hsih+VYrsiV sGcWqpV5iQFnGtKnEJ5ss0/GprmTbxdGUpE8k= 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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=bERwlcG3C4nlijCFRRI6OTUZ0wG24LbZHXp5D5LjinE=; b=k9KDdtetn9bsUETDu0fr/Fdqw1mSHCCCX6c9vqWcrgoEVkuOBW8vaIKNRTeSIYueKN oAmUWXbxX5m6f/8dWrWlj3t67Ms4n5Nv6s8DvVfLNK1aMwSUFxz5nPym/gkno8oWl9Eo BEaLKiwbqifcfpCj+ABlPJ/5iqXgcm07RHKt+aaxxx3GMIa471J7cvgYUMGXMpsdmpKR oihg8u2hNnQ0sJnz4xtMJlpvcY0iVlBHU/KTk+zgkn+lpinTtvhixkqn2ZTXMInSVdGX DMnRCzfIQS4q70ENMQQ1wQ68Ja4+Y+9NXdfWz4z27p/ZPLq/YeIZIpSkPFI9LiYKtiJV N1HQ== X-Gm-Message-State: APjAAAXV+V/15maA+iFBLIqS0r87500VelrRToA61TUzzcYj3LyHT1m0 VGJjkO10jbX7MVhVsoQWedY= X-Received: by 2002:a17:902:8696:: with SMTP id g22mr4483534plo.249.1562850531927; Thu, 11 Jul 2019 06:08:51 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id s24sm5885299pfh.133.2019.07.11.06.08.50 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 11 Jul 2019 06:08:51 -0700 (PDT) Date: Thu, 11 Jul 2019 09:08:49 -0400 From: Joel Fernandes To: "Paul E. McKenney" Cc: Byungchul Park , josh@joshtriplett.org, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@lge.com Subject: Re: [PATCH] rcu: Make jiffies_till_sched_qs writable Message-ID: <20190711130849.GA212044@google.com> References: <1562565609-12482-1-git-send-email-byungchul.park@lge.com> <20190708125013.GG26519@linux.ibm.com> <20190708130359.GA42888@google.com> <20190709055815.GA19459@X58A-UD3R> <20190709124102.GR26519@linux.ibm.com> <20190710012025.GA20711@X58A-UD3R> <20190711123052.GI26519@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190711123052.GI26519@linux.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 11, 2019 at 05:30:52AM -0700, Paul E. McKenney wrote: > On Wed, Jul 10, 2019 at 10:20:25AM +0900, Byungchul Park wrote: > > On Tue, Jul 09, 2019 at 05:41:02AM -0700, Paul E. McKenney wrote: > > > > Hi Paul, > > > > > > > > IMHO, as much as we want to tune the time for fqs to be initiated, we > > > > can also want to tune the time for the help from scheduler to start. > > > > I thought only difference between them is a level of urgency. I might be > > > > wrong. It would be appreciated if you let me know if I miss something. > > > > > > Hello, Byungchul, > > > > > > I understand that one hypothetically might want to tune this at runtime, > > > but have you had need to tune this at runtime on a real production > > > workload? If so, what problem was happening that caused you to want to > > > do this tuning? > > > > Not actually. > > > > > > And it's ok even if the patch is turned down based on your criteria. :) > > > > > > If there is a real need, something needs to be provided to meet that > > > need. But in the absence of a real need, past experience has shown > > > that speculative tuning knobs usually do more harm than good. ;-) > > > > It makes sense, "A speculative tuning knobs do more harm than good". > > > > Then, it would be better to leave jiffies_till_{first,next}_fqs tunnable > > but jiffies_till_sched_qs until we need it. > > > > However, > > > > (1) In case that jiffies_till_sched_qs is tunnable: > > > > We might need all of jiffies_till_{first,next}_qs, > > jiffies_till_sched_qs and jiffies_to_sched_qs because > > jiffies_to_sched_qs can be affected by any of them. So we > > should be able to read each value at any time. > > > > (2) In case that jiffies_till_sched_qs is not tunnable: > > > > I think we don't have to keep the jiffies_till_sched_qs any > > longer since that's only for setting jiffies_to_sched_qs at > > *booting time*, which can be done with jiffies_to_sched_qs too. > > It's meaningless to keep all of tree variables. > > > > The simpler and less knobs that we really need we have, the better. > > > > what do you think about it? > > > > In the following patch, I (1) removed jiffies_till_sched_qs and then > > (2) renamed jiffies_*to*_sched_qs to jiffies_*till*_sched_qs because I > > think jiffies_till_sched_qs is a much better name for the purpose. I > > will resend it with a commit msg after knowing your opinion on it. > > I will give you a definite "maybe". > > Here are the two reasons for changing RCU's embarrassingly large array > of tuning parameters: > > 1. They are causing a problem in production. This would represent a > bug that clearly must be fixed. As you say, this change is not > in this category. > > 2. The change simplifies either RCU's code or the process of tuning > RCU, but without degrading RCU's ability to run everywhere and > without removing debugging tools. > > The change below clearly simplifies things by removing a few lines of > code, and it does not change RCU's default self-configuration. But are > we sure about the debugging aspect? (Please keep in mind that many more > sites are willing to change boot parameters than are willing to patch > their kernels.) > > What do you think? Just to add that independent of whether the runtime tunable make sense or not, may be it is still worth correcting the 0444 to be 0644 to be a separate patch? > Finally, I urge you to join with Joel Fernandes and go through these > grace-period-duration tuning parameters. Once you guys get your heads > completely around all of them and how they interact across the different > possible RCU configurations, I bet that the two of you will have excellent > ideas for improvement. Yes, I am quite happy to join forces. Byungchul, let me know what about this or other things you had in mind. I have some other RCU topics too I am trying to get my head around and planning to work on more patches. Paul, in case you had any other specific tunables or experiments in mind, let me know. I am quite happy to try out new experiments and learn something based on tuning something. thanks, - Joel > > Thanks, > > Byungchul > > > > ---8<--- > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > > index e72c184..94b58f5 100644 > > --- a/Documentation/admin-guide/kernel-parameters.txt > > +++ b/Documentation/admin-guide/kernel-parameters.txt > > @@ -3792,10 +3792,6 @@ > > a value based on the most recent settings > > of rcutree.jiffies_till_first_fqs > > and rcutree.jiffies_till_next_fqs. > > - This calculated value may be viewed in > > - rcutree.jiffies_to_sched_qs. Any attempt to set > > - rcutree.jiffies_to_sched_qs will be cheerfully > > - overwritten. > > > > rcutree.kthread_prio= [KNL,BOOT] > > Set the SCHED_FIFO priority of the RCU per-CPU > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > > index a2f8ba2..ad9dc86 100644 > > --- a/kernel/rcu/tree.c > > +++ b/kernel/rcu/tree.c > > @@ -421,10 +421,8 @@ static int rcu_is_cpu_rrupt_from_idle(void) > > * How long the grace period must be before we start recruiting > > * quiescent-state help from rcu_note_context_switch(). > > */ > > -static ulong jiffies_till_sched_qs = ULONG_MAX; > > +static ulong jiffies_till_sched_qs = ULONG_MAX; /* See adjust_jiffies_till_sched_qs(). */ > > module_param(jiffies_till_sched_qs, ulong, 0444); > > -static ulong jiffies_to_sched_qs; /* See adjust_jiffies_till_sched_qs(). */ > > -module_param(jiffies_to_sched_qs, ulong, 0444); /* Display only! */ > > > > /* > > * Make sure that we give the grace-period kthread time to detect any > > @@ -436,18 +434,13 @@ static void adjust_jiffies_till_sched_qs(void) > > { > > unsigned long j; > > > > - /* If jiffies_till_sched_qs was specified, respect the request. */ > > - if (jiffies_till_sched_qs != ULONG_MAX) { > > - WRITE_ONCE(jiffies_to_sched_qs, jiffies_till_sched_qs); > > - return; > > - } > > /* Otherwise, set to third fqs scan, but bound below on large system. */ > > j = READ_ONCE(jiffies_till_first_fqs) + > > 2 * READ_ONCE(jiffies_till_next_fqs); > > if (j < HZ / 10 + nr_cpu_ids / RCU_JIFFIES_FQS_DIV) > > j = HZ / 10 + nr_cpu_ids / RCU_JIFFIES_FQS_DIV; > > pr_info("RCU calculated value of scheduler-enlistment delay is %ld jiffies.\n", j); > > - WRITE_ONCE(jiffies_to_sched_qs, j); > > + WRITE_ONCE(jiffies_till_sched_qs, j); > > } > > > > static int param_set_first_fqs_jiffies(const char *val, const struct kernel_param *kp) > > @@ -1033,16 +1026,16 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp) > > > > /* > > * A CPU running for an extended time within the kernel can > > - * delay RCU grace periods: (1) At age jiffies_to_sched_qs, > > - * set .rcu_urgent_qs, (2) At age 2*jiffies_to_sched_qs, set > > + * delay RCU grace periods: (1) At age jiffies_till_sched_qs, > > + * set .rcu_urgent_qs, (2) At age 2*jiffies_till_sched_qs, set > > * both .rcu_need_heavy_qs and .rcu_urgent_qs. Note that the > > * unsynchronized assignments to the per-CPU rcu_need_heavy_qs > > * variable are safe because the assignments are repeated if this > > * CPU failed to pass through a quiescent state. This code > > - * also checks .jiffies_resched in case jiffies_to_sched_qs > > + * also checks .jiffies_resched in case jiffies_till_sched_qs > > * is set way high. > > */ > > - jtsq = READ_ONCE(jiffies_to_sched_qs); > > + jtsq = READ_ONCE(jiffies_till_sched_qs); > > ruqp = per_cpu_ptr(&rcu_data.rcu_urgent_qs, rdp->cpu); > > rnhqp = &per_cpu(rcu_data.rcu_need_heavy_qs, rdp->cpu); > > if (!READ_ONCE(*rnhqp) && > > @@ -3383,7 +3376,8 @@ static void __init rcu_init_geometry(void) > > jiffies_till_first_fqs = d; > > if (jiffies_till_next_fqs == ULONG_MAX) > > jiffies_till_next_fqs = d; > > - adjust_jiffies_till_sched_qs(); > > + if (jiffies_till_sched_qs == ULONG_MAX) > > + adjust_jiffies_till_sched_qs(); > > > > /* If the compile-time values are accurate, just leave. */ > > if (rcu_fanout_leaf == RCU_FANOUT_LEAF && >