Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp431296pxa; Wed, 12 Aug 2020 05:56:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGsTAXPY8vF5yP1zh1q0qMkrhiIQ/aSNFSGh0UxOzD7xLpO94nNFBRHhzE3mm7kuiqmWo4 X-Received: by 2002:a17:906:98c1:: with SMTP id zd1mr32297074ejb.410.1597236986812; Wed, 12 Aug 2020 05:56:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597236986; cv=none; d=google.com; s=arc-20160816; b=cw1DJbLGBJDLwOoW+pTY0tAxg7nd3ECvlBESaYTbRDxgxurVDgRGx6Trwtjys5i4Ih tKW+Eiiog5EyE0hhKeDMVHQgBEoE9sG0DzemYw61b58s/IzQP+eXHtX2+2K659wLbGEt /0kGlCcXP+jEcfn2G0IzVdp2vm18fH8uOqS6MUmKykT7C8iNbs2SfwRTZz+VSTK1FZgC oDxoMpSDP64KIGRPQsT7UodMEeERubpY9RfytvInqacx10y4p9fyDzJgPMQDloZ1nAov T++biIYuM+m3iBCYY3zoiDL+Xsi9iLaMC5pRaMZbYdCk4qjeJGTJGIKs3ZJvrrawBzds TABw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=k0Xer3WauuLwTFrjtDSsoL6/gD/iLM+ELyAWSEBdjY4=; b=FEqtdCSesjuLMT09ur+F3cIlVja7i+2oeJ7tRwVQ7lZNePFrMfQxfIFNg5rHcySGwJ a7+v3RClWAJsOe6ZsCI8QfK76sem5UTihrXsyAaBLYLeSA7m6w+GgVYtbgQdUXjhEzbD 4jyhAewNI8lnB+FN/GmvZ5EimKWVRHmARboDEI2QTvrEL7cxg1aiDcOeGE4a7AxJq8o6 tNuOx36ox6Y8suxoSng70JBOAJe5dtMQOnxoYOF6vSHewhOnl02mlLWS2b+1ZGnIrTyU V/vK6nTeUpNR1eBwI4qENs51cKiwLt+5HTAEwvWU9uU7WAhUB4xVnLbmIXXKbgsP/TCd qLiQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q5si1126152ejy.403.2020.08.12.05.56.03; Wed, 12 Aug 2020 05:56:26 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728204AbgHLMy1 (ORCPT + 99 others); Wed, 12 Aug 2020 08:54:27 -0400 Received: from foss.arm.com ([217.140.110.172]:44582 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727987AbgHLMxW (ORCPT ); Wed, 12 Aug 2020 08:53:22 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8CDAF11B3; Wed, 12 Aug 2020 05:53:21 -0700 (PDT) Received: from e113632-lin.cambridge.arm.com (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 581523F70D; Wed, 12 Aug 2020 05:53:20 -0700 (PDT) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: mingo@kernel.org, peterz@infradead.org, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, morten.rasmussen@arm.com, Quentin Perret Subject: [PATCH v5 06/17] sched/debug: Output SD flag names rather than their values Date: Wed, 12 Aug 2020 13:52:49 +0100 Message-Id: <20200812125300.11889-7-valentin.schneider@arm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200812125300.11889-1-valentin.schneider@arm.com> References: <20200812125300.11889-1-valentin.schneider@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Decoding the output of /proc/sys/kernel/sched_domain/cpu*/domain*/flags has always been somewhat annoying, as one needs to go fetch the bit -> name mapping from the source code itself. This encoding can be saved in a script somewhere, but that isn't safe from flags being added, removed or even shuffled around. What matters for debugging purposes is to get *which* flags are set in a given domain, their associated value is pretty much meaningless. Make the sd flags debug file output flag names. Signed-off-by: Valentin Schneider --- kernel/sched/debug.c | 53 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 36c54265bb2b..e9e036a41c55 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -245,6 +245,57 @@ set_table_entry(struct ctl_table *entry, entry->proc_handler = proc_handler; } +static int sd_ctl_doflags(struct ctl_table *table, int write, + void *buffer, size_t *lenp, loff_t *ppos) +{ + unsigned long flags = *(unsigned long *)table->data; + size_t data_size = 0; + size_t len = 0; + char *tmp; + int idx; + + if (write) + return 0; + + for_each_set_bit(idx, &flags, __SD_FLAG_CNT) { + char *name = sd_flag_debug[idx].name; + + /* Name plus whitespace */ + data_size += strlen(name) + 1; + } + + if (*ppos > data_size) { + *lenp = 0; + return 0; + } + + tmp = kcalloc(data_size + 1, sizeof(tmp), GFP_KERNEL); + for_each_set_bit(idx, &flags, __SD_FLAG_CNT) { + char *name = sd_flag_debug[idx].name; + + len += snprintf(tmp + len, strlen(name) + 2, "%s ", name); + } + + tmp += *ppos; + len -= *ppos; + + if (len > *lenp) + len = *lenp; + if (len) + memcpy(buffer, tmp, len); + if (len < *lenp) { + ((char *)buffer)[len] = '\n'; + len++; + } + + *lenp = len; + *ppos += len; + + kfree(tmp); + + return 0; +} + static struct ctl_table * sd_alloc_ctl_domain_table(struct sched_domain *sd) { @@ -258,7 +309,7 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd) 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), 0444, sd_ctl_doflags); 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 */ -- 2.27.0