From: David Collins <david-GOU7F2WGkdXPplzRYGY9Cw@public.gmane.org>
To: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
david-PnRKb+1yrG7L5xMBEfyS8A@public.gmane.org
Subject: [PATCH] cgroup: cpu.stats reset counters support
Date: Mon, 15 Feb 2016 15:14:05 -0600 [thread overview]
Message-ID: <56C23F9D.2020705@collins.email> (raw)
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
next reply other threads:[~2016-02-15 21:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-15 21:14 David Collins [this message]
[not found] ` <56C23F9D.2020705-GOU7F2WGkdXPplzRYGY9Cw@public.gmane.org>
2016-02-15 21:15 ` [PATCH] cgroup: cpu.stats reset counters support 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=56C23F9D.2020705@collins.email \
--to=david-gou7f2wgkdxpplzrygy9cw@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=david-PnRKb+1yrG7L5xMBEfyS8A@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.