This patch allows the cpu.stats values to be reset in cgroups without having to remove and recreate it. I wrote this patch because I've had use cases where resetting the counters made it much easier to read, and it may help with custom userland scripts when parsing statistics. Many other components of cgroups allows stats to be reset, such as cpuacct.stats. To reset the stats counters, simply `echo 0 > cpu.stats` --- linux/kernel/sched/core.c.orig 2016-02-15 13:47:22.359443599 -0600 +++ linux/kernel/sched/core.c 2016-02-15 13:48:14.439443599 -0600 @@ -8629,6 +8629,22 @@ static int cpu_stats_show(struct seq_fil return 0; } + +static int cpu_stats_reset(struct cgroup_subsys_state *css, struct cftype *cft, + u64 reset) +{ + struct task_group *tg = css_tg(css); + struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth; + + raw_spin_lock(&cfs_b->lock); + cfs_b->nr_periods = 0; + cfs_b->nr_throttled = 0; + cfs_b->throttled_time = 0; + raw_spin_unlock(&cfs_b->lock); + + return 0; +} + #endif /* CONFIG_CFS_BANDWIDTH */ #endif /* CONFIG_FAIR_GROUP_SCHED */ @@ -8680,6 +8696,7 @@ static struct cftype cpu_files[] = { { .name = "stat", .seq_show = cpu_stats_show, + .write_u64 = cpu_stats_reset, }, #endif #ifdef CONFIG_RT_GROUP_SCHED -- To unsubscribe from this list: send the line "unsubscribe cgroups" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html