From: Li Zefan <lizf@cn.fujitsu.com>
To: eranian@google.com
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
mingo@elte.hu, paulus@samba.org, davem@davemloft.net,
fweisbec@gmail.com, perfmon2-devel@lists.sf.net,
eranian@gmail.com, robert.richter@amd.com, acme@redhat.com
Subject: Re: [PATCH 4/5] perf_events: add cgroup support (v7)
Date: Wed, 05 Jan 2011 11:13:21 +0800 [thread overview]
Message-ID: <4D23E1D1.3000400@cn.fujitsu.com> (raw)
In-Reply-To: <4d2205a1.8b02e30a.3541.ffff8aee@mx.google.com>
Stephane Eranian wrote:
> This kernel patch adds the ability to filter monitoring based on
> container groups (cgroups). This is for use in per-cpu mode only.
>
> The cgroup to monitor is passed as a file descriptor in the pid
> argument to the syscall. The file descriptor must be opened to
> the cgroup name in the cgroup filesystem. For instance, if the
> cgroup name is foo and cgroupfs is mounted in /cgroup, then the
> file descriptor is opened to /cgroup/foo. Cgroup mode is
> activated by passing PERF_FLAG_PID_CGROUP in the flags argument
> to the syscall.
>
> For instance to measure in cgroup foo on CPU1 assuming
> cgroupfs is mounted under /cgroup:
>
> struct perf_event_attr attr;
> int cgroup_fd, fd;
>
> cgroup_fd = open("/cgroup/foo", O_RDONLY);
> fd = perf_event_open(&attr, cgroup_fd, 1, -1, PERF_FLAG_PID_CGROUP);
> close(cgroup_fd);
>
> Signed-off-by: Stephane Eranian <eranian@google.com>
For the cgroup part:
Acked-by: Li Zefan <lizf@cn.fujitsu.com>
a few comments below:
>
...
> +config CGROUP_PERF
> + bool "Enable perf_event per-cpu per-container group (cgroup) monitoring"
> + depends on PERF_EVENTS && CGROUPS
Depending on CGROUPS is already implicated by "if CGROUPS"
> + help
> + This option extends the per-cpu mode to restrict monitoring to
> + threads which belong to the cgroup specificied and run on the
> + designated cpu.
> +
> + Say N if unsure.
> +
> menuconfig CGROUP_SCHED
> bool "Group CPU scheduler"
> depends on EXPERIMENTAL
...
> +static inline int perf_cgroup_connect(int fd, struct perf_event *event,
> + struct perf_event_attr *attr,
> + struct perf_event *group_leader)
> +{
> + struct perf_cgroup *cgrp;
> + struct cgroup_subsys_state *css;
> + struct file *file;
> + int ret = 0, fput_needed;
> +
> + file = fget_light(fd, &fput_needed);
> + if (!file)
> + return -EBADF;
> +
> + css = cgroup_css_from_dir(file, perf_subsys_id);
> + if (IS_ERR(css))
> + return PTR_ERR(css);
> +
> + cgrp = container_of(css, struct perf_cgroup, css);
> + event->cgrp = cgrp;
> +
> + /*
> + * all events in a group must monitor
> + * the same cgroup because a thread belongs
> + * to only one perf cgroup at a time
> + */
> + if (group_leader && group_leader->cgrp != cgrp) {
> + perf_detach_cgroup(event);
This doesn't seem right, because we haven't got the cgroup
refcount.
> + ret = -EINVAL;
> + } else {
> + /* must be done before we fput() the file */
> + perf_get_cgroup(event);
> + }
> + fput_light(file, fput_needed);
> + return ret;
> +}
next prev parent reply other threads:[~2011-01-05 3:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-03 16:20 [PATCH 4/5] perf_events: add cgroup support (v7) Stephane Eranian
2011-01-05 3:13 ` Li Zefan [this message]
2011-01-05 8:32 ` Stephane Eranian
2011-01-05 11:23 ` Peter Zijlstra
2011-01-05 13:01 ` Stephane Eranian
2011-01-05 21:39 ` Stephane Eranian
2011-01-06 10:15 ` Peter Zijlstra
2011-01-10 14:30 ` Stephane Eranian
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=4D23E1D1.3000400@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=acme@redhat.com \
--cc=davem@davemloft.net \
--cc=eranian@gmail.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=perfmon2-devel@lists.sf.net \
--cc=peterz@infradead.org \
--cc=robert.richter@amd.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