Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp421457ybt; Mon, 6 Jul 2020 12:37:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqDDE4dvDD7xKjShfG1mUYi5CJIEa1/YgPz+GiMx8/kflaGIrZqDrEYGr45kuqSt5xZcHU X-Received: by 2002:a05:6402:1805:: with SMTP id g5mr47630338edy.357.1594064242196; Mon, 06 Jul 2020 12:37:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594064242; cv=none; d=google.com; s=arc-20160816; b=Ygvsi0UJaorewVVyLXQULE862yRKJ8+I3/xKbav/K7cp+jXA7ZvBnL382WNsgYKk7b oyYXqCLv4PRajJNFVzWJ7OIGoyY5AvmyA5YGJSngu4v2O2oSf4dfsjT5/yh29Rjr1op6 KeAGGHiJ3hPe12J6+PQbgPvRuM2Tu8GAW/wJe/OUPPUvMTGELReDbo4zeIyQgNPmjD8w 8lsYlW6hBXDyN6xZwcBMRnmulpjChHtMKnFfcV+LCFFREgxDoecDsrJF7fd5eEUBQ5H3 dx3UGK6gPQPBDdEKi9OKh4NuIK0TckA28SnPNu/F+cCnQSQhq0ZzCY6upFbRGbyPwBnJ 75xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr:ironport-sdr; bh=vKvajt4geLSJr68Dg+RWU3/nKlfIxLNsJQ0cTtkp80g=; b=IT6mKZ5hHGgEfcA/1bnUcFF+Pid8qpEGBjJzqNGNytV9EwamSUiQbWDR/tC4Ze/Jy0 8kMCIGBV39IpSLJmePby6oBeoL0AeK8swVHbFzFlqNRwcG9/h9YGZEPbFW5MJdW08K0G yO7nuDFOs25p7XMHvIzkl9w8oSsMqq9XKEsHUfumi8CJ4xJhSjJUBrL11jsfQkvzSmnY Wu0lsO9Nos2WsiBRFm8oZq1hmYbE0X42gz9SrHCVIOS+A+1p1XTIok9VPhN1FxKz8Xv1 YTNZe47Gy571kqVYSOK++oSpaGCN79ZIhtHyx7WJ8dwluby4861XCsdeujX4Wh/afNvq MyRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l12si13321704ejq.20.2020.07.06.12.36.59; Mon, 06 Jul 2020 12:37:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726845AbgGFTfu (ORCPT + 99 others); Mon, 6 Jul 2020 15:35:50 -0400 Received: from mga12.intel.com ([192.55.52.136]:27867 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725860AbgGFTfu (ORCPT ); Mon, 6 Jul 2020 15:35:50 -0400 IronPort-SDR: DcnhaeebATSmZVDtUu7Nsr03Qwv3Gi65R4RUN+HEq5ituXm0NzJCk+lKw1TffmxJUipg9hYcSs e0PzQhb/I41Q== X-IronPort-AV: E=McAfee;i="6000,8403,9674"; a="127084369" X-IronPort-AV: E=Sophos;i="5.75,320,1589266800"; d="scan'208";a="127084369" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 12:35:49 -0700 IronPort-SDR: Xqmh/qgz5sDSVIIb8to44uGSW+4tYUjPTWETrSTabV2vPCn1tkDNzDQW+KBEh6DjGVyUYJAhza M+kQx+6nSUAQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,320,1589266800"; d="scan'208";a="482805275" Received: from chenyu-office.sh.intel.com ([10.239.158.173]) by fmsmga006.fm.intel.com with ESMTP; 06 Jul 2020 12:35:46 -0700 From: Chen Yu To: Peter Zijlstra , Valentin Schneider Cc: Vincent Guittot , Ingo Molnar , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , linux-kernel@vger.kernel.org, Chen Yu Subject: [PATCH 2/2][RFC] sched/debug: Make sd->flags sysctl writable again Date: Tue, 7 Jul 2020 03:37:05 +0800 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The flags of sched domain in sysctl was limited to read-only in a recent change. However this might bring inconvenience to some performance tuning/function test which are sensitive to load balance. Since the user might want to evaluate the impact of different combination of sched domain flags on the workloads. Per Commit 9818427c6270 ("sched/debug: Make sd->flags sysctl read-only"), we can make the flags writable if we update the cached pointers after the flag of sched domain has been modified. Leverage update_domain_cpu() to update corresponding cached pointer of that CPU once the flags has been changed. Signed-off-by: Chen Yu --- kernel/sched/debug.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 36c54265bb2b..bfeaf547d4af 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -227,6 +227,8 @@ static void sd_free_ctl_entry(struct ctl_table **tablep) sd_free_ctl_entry(&entry->child); if (entry->proc_handler == NULL) kfree(entry->procname); + if (entry->extra1) + kfree(entry->extra1); } kfree(*tablep); @@ -245,20 +247,42 @@ set_table_entry(struct ctl_table *entry, entry->proc_handler = proc_handler; } +static int sysctl_sd_flags_handler(struct ctl_table *table, int write, void *buffer, + size_t *lenp, loff_t *ppos) +{ + int ret; + + ret = proc_dointvec(table, write, buffer, lenp, ppos); + if (!ret && write) + update_domain_cpu(*(int *)(table->extra1)); + + return ret; +} + static struct ctl_table * -sd_alloc_ctl_domain_table(struct sched_domain *sd) +sd_alloc_ctl_domain_table(struct sched_domain *sd, int cpu) { struct ctl_table *table = sd_alloc_ctl_entry(9); + int *cpu_param; if (table == NULL) return NULL; + /* Pass the CPU index to the handler. */ + cpu_param = kmalloc(sizeof(int), GFP_KERNEL); + if (!cpu_param) { + kfree(table); + return NULL; + } + *cpu_param = cpu; + set_table_entry(&table[0], "min_interval", &sd->min_interval, sizeof(long), 0644, proc_doulongvec_minmax); set_table_entry(&table[1], "max_interval", &sd->max_interval, sizeof(long), 0644, proc_doulongvec_minmax); set_table_entry(&table[2], "busy_factor", &sd->busy_factor, sizeof(int), 0644, proc_dointvec_minmax); set_table_entry(&table[3], "imbalance_pct", &sd->imbalance_pct, sizeof(int), 0644, proc_dointvec_minmax); set_table_entry(&table[4], "cache_nice_tries", &sd->cache_nice_tries, sizeof(int), 0644, proc_dointvec_minmax); - set_table_entry(&table[5], "flags", &sd->flags, sizeof(int), 0444, proc_dointvec_minmax); + set_table_entry(&table[5], "flags", &sd->flags, sizeof(int), 0644, sysctl_sd_flags_handler); + table[5].extra1 = (void *)cpu_param; set_table_entry(&table[6], "max_newidle_lb_cost", &sd->max_newidle_lb_cost, sizeof(long), 0644, proc_doulongvec_minmax); set_table_entry(&table[7], "name", sd->name, CORENAME_MAX_SIZE, 0444, proc_dostring); /* &table[8] is terminator */ @@ -284,7 +308,7 @@ static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu) snprintf(buf, 32, "domain%d", i); entry->procname = kstrdup(buf, GFP_KERNEL); entry->mode = 0555; - entry->child = sd_alloc_ctl_domain_table(sd); + entry->child = sd_alloc_ctl_domain_table(sd, cpu); entry++; i++; } -- 2.17.1