Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2255145imm; Sat, 2 Jun 2018 22:39:09 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI3c+YgIqefKS+aGhjaytdxj8VpN962eL95wG2FkdCoz/YsPHDDKscrUFOpvghUenlRK44h X-Received: by 2002:a17:902:bb0d:: with SMTP id l13-v6mr9697677pls.115.1528004349683; Sat, 02 Jun 2018 22:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528004349; cv=none; d=google.com; s=arc-20160816; b=i0X9LWYt6clHOAlsHJY5UhUrLqnLCRDiqaOzypZ9niC2OAPmc93S6rlAaSpIeHk5Iq RIEtm6RTQMhpjj5Bu8WbW3J3c5sB2llrorHOpjqG2XM8wkcIPwU+XcYaPeuDb9yLaukO SN/WC3PR83hspPhNBrqNyADNgLD+/7lkvCaB84Kzvn1ute9ISSjhzD5gQaCp8LJQ4Uaa 8ict0VIJINF+m88Kh9XtaQWOANAWvTwrLdwg0B/6judnG+q/eIDDM1upfCI1VFEKFzdB feEiP1oMyHoAoAA9v8MSH2YGRrKK5yCyQOOGFAKTFfDB6eqxyZO9e84uJrFoUu4uZSuw Lxdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=T/DCE7Los2KVFB/N7S70AHfiOxehKhOe/PxOC3r2eOE=; b=S4hifgo71FIOwO+CBRYgQDKN+L3sYaE8yQ+Dw7snGFUnVytqgzUHDTkoUR1ifCax6p zts7S1HyfPDvplAoPaEtH23vS/F4+ICP9TMz9KGJz+VKS1+P8TzELrlcB8Hnbb0+Dofh WPGjIFA5kyKZSuC3Jvmk4lLPwLnnJm72otYVXRzskpgLgBt1DTqi+aWdq8Hl/bcowZhA ciWXlMyIFWJ76kw7S7EprqfvJxcaMzcGEdpyGHPRL0vN7DAI0zlyr8p5jcz9oGa5RrzT HHbhdguhVBmd4w45UBBxYs1Q/xq660sHg+wWAMpEJJ9TVLiPHl6CpjiFVRj2NjkMzlhn f0xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hZHoiVrd; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u123-v6si14652309pfc.178.2018.06.02.22.38.43; Sat, 02 Jun 2018 22:39:09 -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=@gmail.com header.s=20161025 header.b=hZHoiVrd; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750980AbeFCFiI (ORCPT + 99 others); Sun, 3 Jun 2018 01:38:08 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:33107 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750789AbeFCFiG (ORCPT ); Sun, 3 Jun 2018 01:38:06 -0400 Received: by mail-lf0-f67.google.com with SMTP id y20-v6so20389940lfy.0 for ; Sat, 02 Jun 2018 22:38:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=T/DCE7Los2KVFB/N7S70AHfiOxehKhOe/PxOC3r2eOE=; b=hZHoiVrdepRoUELQRnx5YYPR55HM93V2+exBFzn2XSgDd0Ct1IxT3mmZ7AgPQ2G52B JQFTYRpOMlKnFKRkSS8gfNf/YbnhJnYPDj9FMfvob1FXzPGrudSaGjdUietiq2ZhVcPY 0V56f4oxMIEthxdrXtbHK+Fcj+KCDPRjwrZ/11HiQoJIDOJDUFEwXJVZuP/pw18VsyJl eFr3AkmrWdGJEayNJnNNvgoQTsYwH62UxP75GvJwsF5SlYOuvF7i89ji6uvSnuKFfCVU mCIhs5SZdkl8ESDV3Bm/X/OG6FMRCBnc5D2SEJaloc4YhfE0bjD56JfpWR3Wcc0VEMWF iM5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=T/DCE7Los2KVFB/N7S70AHfiOxehKhOe/PxOC3r2eOE=; b=AeCu+tLuAr7aGTMSpsTSAgQ9U2TspQ0hQr1ThrodpSZbuyLSxGG1tCR262IUXPsTbO HOZbmDAf5Z/YV8u4l6m168fQ8A6EKMierJbQYrAD6psF5TFwPqM60Sme/eL7uwRmM7qj O1rvhZiXJIHvvzYX/LgXHHEQCGvesf0zZtguoPHPSJfIg/iyLPpz1TVKXjd1TrlBY26h 6zf6s8ehyWM933yWvLefvuuebNpfFF711kZcjWoNBjDcZJEk+7nqPrs8mjVmgm44XogN k9ybFCWNhvYYcHpJgKXGN6QKaD7k3F+hVkAoBu7vIM5H1bcMvHZXZ9n49+KIk8QwJdSe UxOg== X-Gm-Message-State: ALKqPwfV1dSMsLf75iL9YIx3cdsW45Pj/7AKpra4zSI7c1xt/bKCvc6O j3I5dvpURwNpjHi3NtJQqybb9efMIJsxv13+uuA= X-Received: by 2002:a19:e1c2:: with SMTP id l63-v6mr9767499lfk.102.1528004284911; Sat, 02 Jun 2018 22:38:04 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab3:7315:0:0:0:0:0 with HTTP; Sat, 2 Jun 2018 22:38:04 -0700 (PDT) In-Reply-To: <20180603035848.GA76941@joelaf.mtv.corp.google.com> References: <1527818589-13476-1-git-send-email-byungchul.park@lge.com> <20180603035848.GA76941@joelaf.mtv.corp.google.com> From: Byungchul Park Date: Sun, 3 Jun 2018 14:38:04 +0900 Message-ID: Subject: Re: [PATCH] rcu: Check the range of jiffies_till_{first,next}_fqs when setting them To: Joel Fernandes 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Furthermore, what if we want to change the value through sysfs to zero on runtime? > If you agree, the below patch could be applied on top of rcu/dev (tested on > rcu/dev), it saves another 20 lines. > > thanks, > > - Joel > > ---8<----------------------- > > From: "Joel Fernandes (Google)" > Date: Sat, 2 Jun 2018 20:47:06 -0700 > Subject: [PATCH] rcu: Use common handler for setting > jiffies_till_{first,next}_fqs > > Recently the checking of jiffies_till_{first,next}_fqs during forcing of > quiescent states was changed to be done whenever the parameters are set. > > Looking at how jiffies_till_first_fqs is used on my system, I noticed a > value of 0 for it doesn't make much sense and is infact set to a non-0 > value at boot up. In this case, we can combine the module_param handlers > for setting both these and keep code size small. This patch attempts it. > > Signed-off-by: Joel Fernandes (Google) > --- > kernel/rcu/tree.c | 25 +++++-------------------- > 1 file changed, 5 insertions(+), 20 deletions(-) > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index deb2508be923..6550040f8d46 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -498,17 +498,7 @@ static ulong jiffies_till_first_fqs = ULONG_MAX; > static ulong jiffies_till_next_fqs = ULONG_MAX; > static bool rcu_kick_kthreads; > > -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) > +static int param_set_fqs_jiffies(const char *val, const struct kernel_param *kp) > { > ulong j; > int ret = kstrtoul(val, 0, &j); > @@ -518,18 +508,13 @@ static int param_set_next_fqs_jiffies(const char *val, const struct kernel_param > return ret; > } > > -static struct kernel_param_ops first_fqs_jiffies_ops = { > - .set = param_set_first_fqs_jiffies, > - .get = param_get_ulong, > -}; > - > -static struct kernel_param_ops next_fqs_jiffies_ops = { > - .set = param_set_next_fqs_jiffies, > +static struct kernel_param_ops fqs_jiffies_ops = { > + .set = param_set_fqs_jiffies, > .get = param_get_ulong, > }; > > -module_param_cb(jiffies_till_first_fqs, &first_fqs_jiffies_ops, &jiffies_till_first_fqs, 0644); > -module_param_cb(jiffies_till_next_fqs, &next_fqs_jiffies_ops, &jiffies_till_next_fqs, 0644); > +module_param_cb(jiffies_till_first_fqs, &fqs_jiffies_ops, &jiffies_till_first_fqs, 0644); > +module_param_cb(jiffies_till_next_fqs, &fqs_jiffies_ops, &jiffies_till_next_fqs, 0644); > module_param(rcu_kick_kthreads, bool, 0644); > > /* > -- > 2.17.1.1185.g55be947832-goog > -- Thanks, Byungchul