Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp80329imm; Thu, 31 May 2018 19:05:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLPEsCU7cKExxLmzUA9rKKOUvw7yja+ynrhg29e2AXdAQ5ERtb5dLSXp9J/BZSj2QRc/JSW X-Received: by 2002:a17:902:189:: with SMTP id b9-v6mr9348030plb.204.1527818721963; Thu, 31 May 2018 19:05:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527818721; cv=none; d=google.com; s=arc-20160816; b=hXWPq2B1jrUe1CydEJQiium/2UYZmFBaxzYc7005IU60JwV4sgqFuc13Q5BrtyohGB z1BFPEUNXU8Hk5aoYUq7oV+gKT67KygLFlzEFX3pWFQCU131H7ARfik2yeQoFlicK7vf m7be0DJ/M1E+i7rgtwyK82BbQwsAcN+0wVQTNCKOkO+4Su10Xv6aJyGJh49EcWNET1ZH i6oZrWuyjm0ygcW4tMgJaTNgYYlnY+S6TpRMBQvKWjE6P2M+PgE8FTXAfamzdKK3/H9v BhPVEoLxrcOhmT/9mMfZZhZGp2ZpxZL7Nmp0sLxYkv8mT+ORcHMvd2QrBbBWpBUeiOOT 1zRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=n5otp5O6iBbwdLOwfyGxH/9zAKfzwMgEgd6VuNlpzZ8=; b=Pp5Gwxh/InhAPbPuwxlq3yx97cW5pgSHaUwtSrWL9ppBqluwgGWSopuJ5P/mdjUxzU GXJusP4Idek1kPJal4BJ7wSAVhm7RFnyG8qOOnKSepFokOajwcnA6XouzClwFRRiae/Y 2Ij0Y7Igj1B4Um/GKYaCL1I9nYFewb/dXrT1Bq8CsQZWUOrrlDoZiOaRYpe1tjLtKqSo KMGTksbaZX8CL8ae+bmyty7tWN3yaELO1uRkVUqmUFhZV2FgV0kerab+lw9u+aIQujt2 OrgPfwRk1oat2bu1qfgCuKI8ZqArcdPdETNA35jlFESywTZKrEnmMW1DIGeusjXg6NIm nceA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a11-v6si20692735plt.39.2018.05.31.19.05.07; Thu, 31 May 2018 19:05:21 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750868AbeFACEg (ORCPT + 99 others); Thu, 31 May 2018 22:04:36 -0400 Received: from lgeamrelo11.lge.com ([156.147.23.51]:60164 "EHLO lgeamrelo11.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750711AbeFACEc (ORCPT ); Thu, 31 May 2018 22:04:32 -0400 Received: from unknown (HELO lgeamrelo01.lge.com) (156.147.1.125) by 156.147.23.51 with ESMTP; 1 Jun 2018 11:04:30 +0900 X-Original-SENDERIP: 156.147.1.125 X-Original-MAILFROM: byungchul.park@lge.com Received: from unknown (HELO localhost.localdomain) (10.177.222.33) by 156.147.1.125 with ESMTP; 1 Jun 2018 11:04:30 +0900 X-Original-SENDERIP: 10.177.222.33 X-Original-MAILFROM: byungchul.park@lge.com From: Byungchul Park To: jiangshanlai@gmail.com, paulmck@linux.vnet.ibm.com, josh@joshtriplett.org, rostedt@goodmis.org, mathieu.desnoyers@efficios.com Cc: linux-kernel@vger.kernel.org, kernel-team@lge.com, joel@joelfernandes.org Subject: [PATCH] rcu: Check the range of jiffies_till_{first,next}_fqs when setting them Date: Fri, 1 Jun 2018 11:03:09 +0900 Message-Id: <1527818589-13476-1-git-send-email-byungchul.park@lge.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; +} + +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, + .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(rcu_kick_kthreads, bool, 0644); /* @@ -2129,10 +2159,6 @@ static int __noreturn rcu_gp_kthread(void *arg) /* Handle quiescent-state forcing. */ first_gp_fqs = true; j = jiffies_till_first_fqs; - if (j > HZ) { - j = HZ; - jiffies_till_first_fqs = HZ; - } ret = 0; for (;;) { if (!ret) { @@ -2167,13 +2193,6 @@ static int __noreturn rcu_gp_kthread(void *arg) WRITE_ONCE(rsp->gp_activity, jiffies); ret = 0; /* Force full wait till next FQS. */ j = jiffies_till_next_fqs; - if (j > HZ) { - j = HZ; - jiffies_till_next_fqs = HZ; - } else if (j < 1) { - j = 1; - jiffies_till_next_fqs = 1; - } } else { /* Deal with stray signal. */ cond_resched_tasks_rcu_qs(); -- 1.9.1