Skip to content

Commit 44ffc75

Browse files
committed
cgroup, sched: convert away from cftype->read_map()
In preparation of conversion to kernfs, cgroup file handling is being consolidated so that it can be easily mapped to the seq_file based interface of kernfs. cftype->read_map() doesn't add any value and being replaced with ->read_seq_string(). Update cpu_stats_show() and cpuacct_stats_show() accordingly. This patch doesn't make any visible behavior changes. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org>
1 parent afb2bc1 commit 44ffc75

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎kernel/sched/core.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7257,14 +7257,14 @@ static int __cfs_schedulable(struct task_group *tg, u64 period, u64 quota)
72577257
}
72587258

72597259
static int cpu_stats_show(struct cgroup_subsys_state *css, struct cftype *cft,
7260-
struct cgroup_map_cb *cb)
7260+
struct seq_file *sf)
72617261
{
72627262
struct task_group *tg = css_tg(css);
72637263
struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth;
72647264

7265-
cb->fill(cb, "nr_periods", cfs_b->nr_periods);
7266-
cb->fill(cb, "nr_throttled", cfs_b->nr_throttled);
7267-
cb->fill(cb, "throttled_time", cfs_b->throttled_time);
7265+
seq_printf(sf, "nr_periods %d\n", cfs_b->nr_periods);
7266+
seq_printf(sf, "nr_throttled %d\n", cfs_b->nr_throttled);
7267+
seq_printf(sf, "throttled_time %llu\n", cfs_b->throttled_time);
72687268

72697269
return 0;
72707270
}
@@ -7318,7 +7318,7 @@ static struct cftype cpu_files[] = {
73187318
},
73197319
{
73207320
.name = "stat",
7321-
.read_map = cpu_stats_show,
7321+
.read_seq_string = cpu_stats_show,
73227322
},
73237323
#endif
73247324
#ifdef CONFIG_RT_GROUP_SCHED

‎kernel/sched/cpuacct.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static const char * const cpuacct_stat_desc[] = {
184184
};
185185

186186
static int cpuacct_stats_show(struct cgroup_subsys_state *css,
187-
struct cftype *cft, struct cgroup_map_cb *cb)
187+
struct cftype *cft, struct seq_file *sf)
188188
{
189189
struct cpuacct *ca = css_ca(css);
190190
int cpu;
@@ -196,7 +196,7 @@ static int cpuacct_stats_show(struct cgroup_subsys_state *css,
196196
val += kcpustat->cpustat[CPUTIME_NICE];
197197
}
198198
val = cputime64_to_clock_t(val);
199-
cb->fill(cb, cpuacct_stat_desc[CPUACCT_STAT_USER], val);
199+
seq_printf(sf, "%s %lld\n", cpuacct_stat_desc[CPUACCT_STAT_USER], val);
200200

201201
val = 0;
202202
for_each_online_cpu(cpu) {
@@ -207,7 +207,7 @@ static int cpuacct_stats_show(struct cgroup_subsys_state *css,
207207
}
208208

209209
val = cputime64_to_clock_t(val);
210-
cb->fill(cb, cpuacct_stat_desc[CPUACCT_STAT_SYSTEM], val);
210+
seq_printf(sf, "%s %lld\n", cpuacct_stat_desc[CPUACCT_STAT_SYSTEM], val);
211211

212212
return 0;
213213
}
@@ -224,7 +224,7 @@ static struct cftype files[] = {
224224
},
225225
{
226226
.name = "stat",
227-
.read_map = cpuacct_stats_show,
227+
.read_seq_string = cpuacct_stats_show,
228228
},
229229
{ } /* terminate */
230230
};

0 commit comments

Comments
 (0)