Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2792694imm; Sun, 3 Jun 2018 11:47:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL0B8hHuKSNVzV/6C0NBLInzEl+cH/aXAvv44o++RpEGqFjfXwkR9jjaIHK+2NvETwQfnCz X-Received: by 2002:a65:5183:: with SMTP id h3-v6mr14645942pgq.58.1528051668984; Sun, 03 Jun 2018 11:47:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528051668; cv=none; d=google.com; s=arc-20160816; b=U8u/dqsYLRsBYaF1tNO40WP8Q8LBIE4n/HhpGs9+KKJN0wn1NNzsx4fzU72QjrnXPr 179jWsmkJ+BwtGBrJ+IOwrsPEtkjZJsjPG5dbFexE/9KWJ3/wpgJjgLmBvE9CAwZuD6o mpEowvr2NExIQKHuGNiwiTh3ipS7LucNwRlBTlXmP21qUKYuYzzdGaFQh7j5/7hS51Zv feB94PVVvdAs1Qe67SX/44GfXsb9aOH9vKMKB721roq7JCGMbCDgOKNTAoLy2TfY43pR g/TEOY6ZdSxrZ/iX+s+pesPKaGo7Qo1Zovhdxx+M3nJQHUHZ4AfoPY0QOSbEhWXlhu4y u6MA== 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:arc-authentication-results; bh=rQa0N3gWYBDT4c2r4bVJZECMlull4NFB4Y3tqdhwpXc=; b=wCl2FbuxM0euskzkMaXFFtnYg6pT9vhdCLKq5Jk7PrH8cu3EfFm18n9YsKthlIHep2 kQuxws8GwTH6v3elsbEGncnzUebHHzo9ADZUAYVQTKTrY+eGb8DfHsXAHQd58VrCsTKZ 14cea3j6sMLC5801YO9bxpL7K/T0YzCAQRc8KnCfLEdJmw5V5llFbkWkqGuRwRNODCTG zcdVB1bPbH9HGjUh8Z2TvCEy/2/1aMscz6Sv8yRIsOf3+nQfPhLDOI2+7jV/RH4HWzXk m63IQHlkCwXPcNMZwEL7pPiqan165HgEW4HV5TDNN9my1Th0SpW+P1YVqUqI+gQjMSc7 9dLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=hVLPzbpe; 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=pass (p=NONE sp=NONE dis=NONE) header.from=joelfernandes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f64-v6si46031025pfa.252.2018.06.03.11.47.34; Sun, 03 Jun 2018 11:47:48 -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=hVLPzbpe; 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=pass (p=NONE sp=NONE dis=NONE) header.from=joelfernandes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751273AbeFCSrI (ORCPT + 99 others); Sun, 3 Jun 2018 14:47:08 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:41646 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750952AbeFCSrH (ORCPT ); Sun, 3 Jun 2018 14:47:07 -0400 Received: by mail-pl0-f65.google.com with SMTP id az12-v6so18232775plb.8 for ; Sun, 03 Jun 2018 11:47:07 -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=rQa0N3gWYBDT4c2r4bVJZECMlull4NFB4Y3tqdhwpXc=; b=hVLPzbpeQkDNvYX9YxlcR/v67K2BgGkj5b7is70DvBksFgE2C42EQxPmNkdZC3wFlu Xnpr2GXtBHr8WM4P6XgQ4BBcC/ZMJS7Tf7r3w2KWPOOsp3NQIVaWLo/VsxAJVaIGl4gQ p9CaH20+RhsRqusKuS6y+fUN7q6QnHi61HDFQ= 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=rQa0N3gWYBDT4c2r4bVJZECMlull4NFB4Y3tqdhwpXc=; b=BUF7NsAnzbbNt9wtx6TnxJV6DAqhYylYFmiEgMokyErHpHMglUddH+rNIjGTzYJ6Zi BwqsfI0IVBp6ClSMBuuSjoUK07SwD26+8TNzGqaqGHccKTtcPNe4dZp+fnUKvK5/UrZr ZcSqHuY25AkeA+l6hfezfUpjFNd07xpbLZc9ZKw7fxDPvDbqRvHKT4LvJSZ2PX8YBah2 ta2WYkTeilgA8DX0gLKu8UauSWedVwVHlqVJQlyVMzt/ofVGPqkdf5yqiRzQOlBHc6Pl zAoj+U6X6xMMPIbKir+e2w5tOy7sD1yLEq7G4XYwt40bZYcwQQh1Ge+zAbSNi45ggemV Ij3g== X-Gm-Message-State: ALKqPwekN+1DoP+nWM0z+80FZ8sgXbNd3lNjaYQwFyHRDXgID7gIHe7s MlqD/+ci17DGwcJG2Hx9WKZVEGOOHGc= X-Received: by 2002:a17:902:164:: with SMTP id 91-v6mr18998700plb.134.1528051626889; Sun, 03 Jun 2018 11:47:06 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id n70-v6sm23578456pfh.140.2018.06.03.11.47.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 03 Jun 2018 11:47:06 -0700 (PDT) Date: Sun, 3 Jun 2018 11:47:05 -0700 From: Joel Fernandes To: Byungchul Park Cc: Byungchul Park , jiangshanlai@gmail.com, Paul McKenney , josh@joshtriplett.org, rostedt@goodmis.org, Mathieu Desnoyers , linux-kernel@vger.kernel.org, kernel-team@lge.com, kernel-team@android.com Subject: Re: [PATCH] rcu: Check the range of jiffies_till_{first,next}_fqs when setting them Message-ID: <20180603184705.GA85962@joelaf.mtv.corp.google.com> References: <1527818589-13476-1-git-send-email-byungchul.park@lge.com> <20180603035848.GA76941@joelaf.mtv.corp.google.com> <20180603062330.GA153988@joelaf.mtv.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jun 03, 2018 at 04:51:06PM +0900, Byungchul Park wrote: > On Sun, Jun 3, 2018 at 3:23 PM, Joel Fernandes wrote: > > On Sun, Jun 03, 2018 at 02:38:04PM +0900, Byungchul Park wrote: > >> On Sun, Jun 3, 2018 at 12:58 PM, Joel Fernandes wrote: > >> > On Fri, Jun 01, 2018 at 11:03:09AM +0900, Byungchul Park wrote: > >> >> Currently, the range of jiffies_till_{first,next}_fqs are checked and > >> >> adjusted on and on in the loop of rcu_gp_kthread on runtime. > >> >> > >> >> However, it's enough to check them only when setting them, not every > >> >> time in the loop. So make them handled on a setting time via sysfs. > >> >> > >> >> Signed-off-by: Byungchul Park > >> >> --- > >> >> kernel/rcu/tree.c | 45 ++++++++++++++++++++++++++++++++------------- > >> >> 1 file changed, 32 insertions(+), 13 deletions(-) > >> >> > >> >> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > >> >> index 4e96761..eb54d7d 100644 > >> >> --- a/kernel/rcu/tree.c > >> >> +++ b/kernel/rcu/tree.c > >> >> @@ -518,8 +518,38 @@ void rcu_all_qs(void) > >> >> static ulong jiffies_till_next_fqs = ULONG_MAX; > >> >> static bool rcu_kick_kthreads; > >> >> > >> >> -module_param(jiffies_till_first_fqs, ulong, 0644); > >> >> -module_param(jiffies_till_next_fqs, ulong, 0644); > >> >> +static int param_set_first_fqs_jiffies(const char *val, const struct kernel_param *kp) > >> >> +{ > >> >> + ulong j; > >> >> + int ret = kstrtoul(val, 0, &j); > >> >> + > >> >> + if (!ret) > >> >> + WRITE_ONCE(*(ulong *)kp->arg, (j > HZ) ? HZ : j); > >> >> + return ret; > >> >> +} > >> >> + > >> >> +static int param_set_next_fqs_jiffies(const char *val, const struct kernel_param *kp) > >> >> +{ > >> >> + ulong j; > >> >> + int ret = kstrtoul(val, 0, &j); > >> >> + > >> >> + if (!ret) > >> >> + WRITE_ONCE(*(ulong *)kp->arg, (j > HZ) ? HZ : (j ?: 1)); > >> >> + return ret; > >> >> +} > >> > > >> > Reviewed-by: Joel Fernandes (Google) > >> > > >> > Also, can we not combine the 2 param_set_ handlers as well? > >> > > >> > Only thing we would be giving up is that jiffies_till_first_fqs = 0 wouldn't > >> > be allowed (if we go with the param_set_next handler to be the common one) > >> > but don't think that's a useful/valid usecase since jiffies_till_first_fqs is > >> > set to a sane non-0 value anyway at boot up because of rcu_init_geometry > >> > anyway.. Thoughts? > >> > >> Excuse me. Which code in rcu_init_geometry() makes jiffies_till_first_fqs > >> be a non-zero in case called with jiffies_till_first_fqs == 0? > > > > What do you mean? I think you misunderstood. I didn't say value of 0 is being > > handled at boot up. What I said is its initialized to something sane that's > > non-zero: > > > > If you see, jiffies_till_first_fqs is assigned to ULONG_MAX at compile time: > > static ulong jiffies_till_first_fqs = ULONG_MAX; > > > > Then in rcu_init_geometry, we have: > > d = RCU_JIFFIES_TILL_FORCE_QS + nr_cpu_ids / RCU_JIFFIES_FQS_DIV; > > if (jiffies_till_first_fqs == ULONG_MAX) > > jiffies_till_first_fqs = d; > > > > On my system, jiffies_till_first_fqs is assigned to 3 because of this at > > boot. > > > >> Furthermore, what if we want to change the value through sysfs to zero > >> on runtime? > > > > My patch was just a suggestion. I didn't know if anyone would want to force > > it to 0 or not and was wondering what the value in doing so was at the cost > > of adding one more function to handle it. It basically says if you set to 0, > > that you never want to wait for a timeout before forcing a qs for the first > > time? Then why are we calling swait_event_idle_timeout anyway? Wouldn't a > > saner timeout be something not zero? > > I'm sorry I tried but don't understand your point :( > Did you happen to read the following? > > https://lkml.org/lkml/2018/5/29/99 No I did not happen to read that and I am very sorry about that. I see Paul said jiffies_till_first_fqs = 0 is a useful case in that thread, to record the idle CPUs quickly, which makes sense. > If yes, it would be appreciated if you let me know what I'm missing. You are right and not missing anything. I'll be more careful to go through old threads next time.. Glad to learn something from the discussions. thanks, BTW one more dumb question - if jiffies_till_first_fqs == 0 is so useful, then why not default initialize it to 0? I'd think most systems expect atleast some of the CPUs to idle. - Joel