linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Li Zefan <lizefan@huawei.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Paul Turner <pjt@google.com>,
	Mike Galbraith <umgwanakikbuti@gmail.com>,
	Ingo Molnar <mingo@redhat.com>
Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
	linux-api@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH 1/2] sched: Misc preps for cgroup unified hierarchy interface
Date: Fri, 5 Aug 2016 13:09:20 -0400	[thread overview]
Message-ID: <20160805170920.GL2542@mtj.duckdns.org> (raw)
In-Reply-To: <20160805170752.GK2542@mtj.duckdns.org>

>From 0d966df508ef4d6c0b1baae9e369f4fb0d3e10af Mon Sep 17 00:00:00 2001
From: Tejun Heo <tj@kernel.org>
Date: Fri, 11 Mar 2016 07:31:23 -0500

Make the following changes in preparation for the cpu controller
interface implementation for the unified hierarchy.  This patch
doesn't cause any functional differences.

* s/cpu_stats_show()/cpu_cfs_stats_show()/

* s/cpu_files/cpu_legacy_files/

* Separate out cpuacct_stats_read() from cpuacct_stats_show().  While
  at it, remove pointless cpuacct_stat_desc[] array.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
---
 kernel/sched/core.c    |  8 ++++----
 kernel/sched/cpuacct.c | 33 +++++++++++++++------------------
 2 files changed, 19 insertions(+), 22 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 97ee9ac..c148dfe 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -8482,7 +8482,7 @@ static int __cfs_schedulable(struct task_group *tg, u64 period, u64 quota)
 	return ret;
 }
 
-static int cpu_stats_show(struct seq_file *sf, void *v)
+static int cpu_cfs_stats_show(struct seq_file *sf, void *v)
 {
 	struct task_group *tg = css_tg(seq_css(sf));
 	struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth;
@@ -8522,7 +8522,7 @@ static u64 cpu_rt_period_read_uint(struct cgroup_subsys_state *css,
 }
 #endif /* CONFIG_RT_GROUP_SCHED */
 
-static struct cftype cpu_files[] = {
+static struct cftype cpu_legacy_files[] = {
 #ifdef CONFIG_FAIR_GROUP_SCHED
 	{
 		.name = "shares",
@@ -8543,7 +8543,7 @@ static struct cftype cpu_files[] = {
 	},
 	{
 		.name = "stat",
-		.seq_show = cpu_stats_show,
+		.seq_show = cpu_cfs_stats_show,
 	},
 #endif
 #ifdef CONFIG_RT_GROUP_SCHED
@@ -8568,7 +8568,7 @@ struct cgroup_subsys cpu_cgrp_subsys = {
 	.fork		= cpu_cgroup_fork,
 	.can_attach	= cpu_cgroup_can_attach,
 	.attach		= cpu_cgroup_attach,
-	.legacy_cftypes	= cpu_files,
+	.legacy_cftypes	= cpu_legacy_files,
 	.early_init	= true,
 };
 
diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c
index 41f85c4..3eb9eda 100644
--- a/kernel/sched/cpuacct.c
+++ b/kernel/sched/cpuacct.c
@@ -242,36 +242,33 @@ static int cpuacct_percpu_seq_show(struct seq_file *m, void *V)
 	return __cpuacct_percpu_seq_show(m, CPUACCT_USAGE_NRUSAGE);
 }
 
-static const char * const cpuacct_stat_desc[] = {
-	[CPUACCT_STAT_USER] = "user",
-	[CPUACCT_STAT_SYSTEM] = "system",
-};
-
-static int cpuacct_stats_show(struct seq_file *sf, void *v)
+static void cpuacct_stats_read(struct cpuacct *ca, u64 *userp, u64 *sysp)
 {
-	struct cpuacct *ca = css_ca(seq_css(sf));
 	int cpu;
-	s64 val = 0;
 
+	*userp = 0;
 	for_each_possible_cpu(cpu) {
 		struct kernel_cpustat *kcpustat = per_cpu_ptr(ca->cpustat, cpu);
-		val += kcpustat->cpustat[CPUTIME_USER];
-		val += kcpustat->cpustat[CPUTIME_NICE];
+		*userp += kcpustat->cpustat[CPUTIME_USER];
+		*userp += kcpustat->cpustat[CPUTIME_NICE];
 	}
-	val = cputime64_to_clock_t(val);
-	seq_printf(sf, "%s %lld\n", cpuacct_stat_desc[CPUACCT_STAT_USER], val);
 
-	val = 0;
+	*sysp = 0;
 	for_each_possible_cpu(cpu) {
 		struct kernel_cpustat *kcpustat = per_cpu_ptr(ca->cpustat, cpu);
-		val += kcpustat->cpustat[CPUTIME_SYSTEM];
-		val += kcpustat->cpustat[CPUTIME_IRQ];
-		val += kcpustat->cpustat[CPUTIME_SOFTIRQ];
+		*sysp += kcpustat->cpustat[CPUTIME_SYSTEM];
+		*sysp += kcpustat->cpustat[CPUTIME_IRQ];
+		*sysp += kcpustat->cpustat[CPUTIME_SOFTIRQ];
 	}
+}
 
-	val = cputime64_to_clock_t(val);
-	seq_printf(sf, "%s %lld\n", cpuacct_stat_desc[CPUACCT_STAT_SYSTEM], val);
+static int cpuacct_stats_show(struct seq_file *sf, void *v)
+{
+	cputime64_t user, sys;
 
+	cpuacct_stats_read(css_ca(seq_css(sf)), &user, &sys);
+	seq_printf(sf, "user %lld\n", cputime64_to_clock_t(user));
+	seq_printf(sf, "system %lld\n", cputime64_to_clock_t(sys));
 	return 0;
 }
 
-- 
2.7.4

  reply	other threads:[~2016-08-05 17:09 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-05 17:07 [Documentation] State of CPU controller in cgroup v2 Tejun Heo
2016-08-05 17:09 ` Tejun Heo [this message]
2016-08-05 17:09 ` [PATCH 2/2] sched: Implement interface for cgroup unified hierarchy Tejun Heo
     [not found] ` <20160805170752.GK2542-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2016-08-06  9:04   ` [Documentation] State of CPU controller in cgroup v2 Mike Galbraith
     [not found]     ` <1470474291.4117.243.camel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-10 22:09       ` Johannes Weiner
     [not found]         ` <20160810220944.GB3085-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
2016-08-11  6:25           ` Mike Galbraith
     [not found]             ` <1470896706.4116.146.camel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-12 22:17               ` Johannes Weiner
     [not found]                 ` <20160812221742.GA24736-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
2016-08-13  5:08                   ` Mike Galbraith
2016-08-16 14:07           ` Peter Zijlstra
     [not found]             ` <20160816140738.GW6879-ndre7Fmf5hadTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
2016-08-16 14:58               ` Chris Mason
2016-08-16 16:30               ` Johannes Weiner
2016-08-17  9:33                 ` Mike Galbraith
2016-08-16 21:59               ` Tejun Heo
2016-08-17 20:18 ` Andy Lutomirski
     [not found]   ` <CALCETrXvLNeds+ugZ8j3eD1Zg1RZYJSAET3Kguz5G2vqSLFCwQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-08-20 15:56     ` Tejun Heo
2016-08-20 18:45       ` Andy Lutomirski
     [not found]         ` <CALCETrUWn1ux-ZRJoMjFCuP1aQrPOo3oTPD7k-ojsaov29NsRw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-08-29 22:20           ` Tejun Heo
     [not found]             ` <20160829222048.GH28713-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2016-08-31  3:42               ` Andy Lutomirski
2016-08-31 17:32                 ` Tejun Heo
     [not found]                   ` <20160831173251.GY12660-piEFEHQLUPpN0TnZuCh8vA@public.gmane.org>
2016-08-31 19:11                     ` Andy Lutomirski
     [not found]                       ` <CALCETrUKOJZS+=QDPyQD+vxXpwyjoj4+Crg6wU7Xk8rP4prYkA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-08-31 21:07                         ` Tejun Heo
2016-08-31 21:46                           ` Andy Lutomirski
     [not found]                             ` <CALCETrXj2Z=-GMaWV_EpCvw_8C3t1vc=D53Ff2wdvo=At8ZF1Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-09-03 22:05                               ` Tejun Heo
2016-09-05 17:37                                 ` Andy Lutomirski
     [not found]                                   ` <CALCETrVcAjFWLQ1arjSP-g=4jRY_J7G-j9JJHrvTDgOnxApYPw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-09-06 10:29                                     ` Peter Zijlstra
2016-10-04 14:47                                       ` Tejun Heo
     [not found]                                         ` <20161004144717.GA4205-piEFEHQLUPpN0TnZuCh8vA@public.gmane.org>
2016-10-05  8:07                                           ` Peter Zijlstra
2016-09-09 22:57                                   ` Tejun Heo
     [not found]                                     ` <20160909225747.GA30105-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2016-09-10  8:54                                       ` Mike Galbraith
2016-09-10 10:08                                       ` Mike Galbraith
     [not found]                                         ` <1473502137.3857.218.camel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-09-30  9:06                                           ` Tejun Heo
     [not found]                                             ` <20160930090603.GD29207-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2016-09-30 14:53                                               ` Mike Galbraith
2016-09-12 15:20                                       ` Austin S. Hemmelgarn
     [not found]                                         ` <ab6f3376-4c09-a339-f984-937f537ddc17-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-09-19 21:34                                           ` Tejun Heo
     [not found]                                     ` <CALCETrUhpPQdyZ-6WRjdB+iLbpGBduRZMWXQtCuS+R7Cq7rygg@mail.gmail.com>
2016-09-14 20:00                                       ` Tejun Heo
     [not found]                                         ` <20160914200041.GB6832-piEFEHQLUPpN0TnZuCh8vA@public.gmane.org>
2016-09-15 20:08                                           ` Andy Lutomirski
     [not found]                                             ` <CALCETrUA6_noue4kq9JLqr-V_yo7hB+v1Arhg6i6fFn0tyTrpw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-09-16  7:51                                               ` Peter Zijlstra
     [not found]                                                 ` <20160916075137.GK5012-ndre7Fmf5hadTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
2016-09-16 15:12                                                   ` Andy Lutomirski
     [not found]                                                     ` <CALCETrXzrXJmZoFVfAXS1Zf9uNZjibnHizEhwgqdmRvnbJEksw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-09-16 16:19                                                       ` Peter Zijlstra
     [not found]                                                         ` <20160916161951.GH5016-ndre7Fmf5hadTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
2016-09-16 16:29                                                           ` Andy Lutomirski
     [not found]                                                             ` <CALCETrXoTfhaDxZJ9_XcFknnniDvrYLY9SATVXj+tK1UdaWw4A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-09-16 16:50                                                               ` Peter Zijlstra
     [not found]                                                                 ` <20160916165045.GJ5016-ndre7Fmf5hadTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
2016-09-16 18:19                                                                   ` Andy Lutomirski
     [not found]                                                                     ` <CALCETrVMw4Nd-QZER9qzOzRte5s48WrUaM8ZZzkY_g3B6s+5Ow-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-09-17  1:47                                                                       ` Peter Zijlstra
2016-09-19 21:53                                               ` Tejun Heo
2016-08-31 19:57               ` Andy Lutomirski
     [not found]       ` <20160820155659.GA16906-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2016-08-22 10:12         ` Mike Galbraith
2016-08-21  5:34     ` James Bottomley
     [not found]       ` <1471757654.2354.97.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2016-08-29 22:35         ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160805170920.GL2542@mtj.duckdns.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@fb.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pjt@google.com \
    --cc=torvalds@linux-foundation.org \
    --cc=umgwanakikbuti@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).