From: Vipin Sharma <vipinsh@google.com>
To: brookxu <brookxu.cn@gmail.com>
Cc: tj@kernel.org, lizefan.x@bytedance.com, hannes@cmpxchg.org,
mkoutny@suse.com, corbet@lwn.net, linux-kernel@vger.kernel.org,
cgroups@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH v3 1/3] misc_cgroup: introduce misc.events to count failures
Date: Wed, 15 Sep 2021 10:04:18 -0700 [thread overview]
Message-ID: <CAHVum0d657HeoSyXS9RGW8YHkwJFmvLQ6ebwYy_wVnR0gM8uPQ@mail.gmail.com> (raw)
In-Reply-To: <3834f917d50a6f19402e179e917ef6a9dde5f64a.1631671936.git.brookxu@tencent.com>
On Tue, Sep 14, 2021 at 7:18 PM brookxu <brookxu.cn@gmail.com> wrote:
>
> From: Chunguang Xu <brookxu@tencent.com>
>
> Introduce misc.events to make it easier for us to understand
> the pressure of resources. Currently only the 'max' event is
> implemented, which indicates the times the resource is about
> to exceeds the max limit.
>
> Signed-off-by: Chunguang Xu <brookxu@tencent.com>
> ---
>
> v3: remove misc.events.local.
> v2: remove cgroup v1 files.
>
> include/linux/misc_cgroup.h | 5 +++++
> kernel/cgroup/misc.c | 24 ++++++++++++++++++++++++
> 2 files changed, 29 insertions(+)
>
> diff --git a/include/linux/misc_cgroup.h b/include/linux/misc_cgroup.h
> index da2367e..091f2d2 100644
> --- a/include/linux/misc_cgroup.h
> +++ b/include/linux/misc_cgroup.h
> @@ -36,6 +36,7 @@ enum misc_res_type {
> struct misc_res {
> unsigned long max;
> atomic_long_t usage;
> + atomic_long_t events;
> bool failed;
> };
>
> @@ -46,6 +47,10 @@ struct misc_res {
> */
> struct misc_cg {
> struct cgroup_subsys_state css;
> +
> + /* misc.events */
> + struct cgroup_file events_file;
> +
> struct misc_res res[MISC_CG_RES_TYPES];
> };
>
> diff --git a/kernel/cgroup/misc.c b/kernel/cgroup/misc.c
> index ec02d96..4b2b492 100644
> --- a/kernel/cgroup/misc.c
> +++ b/kernel/cgroup/misc.c
> @@ -171,6 +171,11 @@ int misc_cg_try_charge(enum misc_res_type type, struct misc_cg *cg,
> return 0;
>
> err_charge:
> + for (j = i; j; j = parent_misc(j)) {
> + atomic_long_inc(&j->res[type].events);
> + cgroup_file_notify(&j->events_file);
> + }
> +
> for (j = cg; j != i; j = parent_misc(j))
> misc_cg_cancel_charge(type, j, amount);
> misc_cg_cancel_charge(type, i, amount);
> @@ -335,6 +340,19 @@ static int misc_cg_capacity_show(struct seq_file *sf, void *v)
> return 0;
> }
>
> +static int misc_events_show(struct seq_file *sf, void *v)
> +{
> + struct misc_cg *cg = css_misc(seq_css(sf));
> + unsigned long events, i;
> +
> + for (i = 0; i < MISC_CG_RES_TYPES; i++) {
> + events = atomic_long_read(&cg->res[i].events);
> + if (READ_ONCE(misc_res_capacity[i]) || events)
> + seq_printf(sf, "%s.max %lu\n", misc_res_name[i], events);
> + }
> + return 0;
> +}
> +
> /* Misc cgroup interface files */
> static struct cftype misc_cg_files[] = {
> {
> @@ -353,6 +371,12 @@ static int misc_cg_capacity_show(struct seq_file *sf, void *v)
> .seq_show = misc_cg_capacity_show,
> .flags = CFTYPE_ONLY_ON_ROOT,
> },
> + {
> + .name = "events",
> + .flags = CFTYPE_NOT_ON_ROOT,
> + .file_offset = offsetof(struct misc_cg, events_file),
> + .seq_show = misc_events_show,
> + },
> {}
> };
>
> --
> 1.8.3.1
>
Reviewed-by: Vipin Sharma <vipinsh@google.com>
next prev parent reply other threads:[~2021-09-15 17:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-15 2:18 [PATCH v3 1/3] misc_cgroup: introduce misc.events to count failures brookxu
2021-09-15 2:18 ` [PATCH v3 2/3] misc_cgroup: remove error log to avoid log flood brookxu
2021-09-16 17:57 ` Michal Koutný
2021-09-17 1:56 ` brookxu
2021-09-17 8:09 ` Michal Koutný
2021-09-15 2:18 ` [PATCH v3 3/3] docs/cgroup: add entry for misc.events brookxu
2021-09-16 17:47 ` Michal Koutný
2021-09-15 17:04 ` Vipin Sharma [this message]
2021-09-16 17:47 ` [PATCH v3 1/3] misc_cgroup: introduce misc.events to count failures Michal Koutný
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=CAHVum0d657HeoSyXS9RGW8YHkwJFmvLQ6ebwYy_wVnR0gM8uPQ@mail.gmail.com \
--to=vipinsh@google.com \
--cc=brookxu.cn@gmail.com \
--cc=cgroups@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=hannes@cmpxchg.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan.x@bytedance.com \
--cc=mkoutny@suse.com \
--cc=tj@kernel.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 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).