From: Yonghong Song <yhs@fb.com>
To: "kulkarni@ucla.edu" <kulkarni@ucla.edu>,
"bpf@vger.kernel.org" <bpf@vger.kernel.org>
Subject: Re: Per cgroup accounting of context switches
Date: Sat, 7 Sep 2019 06:38:01 +0000 [thread overview]
Message-ID: <e8c05dab-1d14-4cd4-ad63-2a8f0dbb7ece@fb.com> (raw)
In-Reply-To: <CANZ-dUobRee1NrntgZsnvZN7HmbAgszjX4t4bV5-27sR+fVHWA@mail.gmail.com>
On 9/6/19 9:30 PM, Gautam Kulkarni wrote:
> Hi,
>
> We are evaluating eBPF as a means to account voluntary and
> non-voluntary context switches against cgroups. Currently, this
> information is only present in the task_struct for an individual
> process and not in the cgroup data structure.
>
> With this context, I was looking for recommendation on the following
> possible approaches:
>
> 1. Use the existing tracepoint (trace_sched_switch) as it exists here
> with BPF_PROG_TYPE_TRACEPOINT:
> https://github.com/torvalds/linux/blob/master/kernel/sched/core.c#L3877
> However, based on the trace format, the kernel does not expose
> prev->nivcsw and prev->nvcsw. Due to this, I feel like this approach
> may not be feasible. Is my understanding correct?
You can use BPF_RAW_TRACEPOINT_OPEN and `prev` argument will
be available to bpf programs.
>
> 2. Attach a kprobe to __schedule() and use BPF_PROG_TYPE_KPROBE
> This will allow us access to the prev pointer. From the prev
> (task_struct), we can access the cgroup and use an eBPF map to
> accumulate per cgroup counts of context switches.
>
> 3. Implement a kernel module that attaches a kprobe to __schedule()
> and implement the map in the kprobe handler.
>
> 4. Modify the kernel to have context switch information in task_group.
> Would this be something that would make sense to the community?
>
> I would highly appreciate any feedback on this.
>
> Regards,
> Gautam
>
prev parent reply other threads:[~2019-09-07 6:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-07 4:30 Per cgroup accounting of context switches Gautam Kulkarni
2019-09-07 6:38 ` Yonghong Song [this message]
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=e8c05dab-1d14-4cd4-ad63-2a8f0dbb7ece@fb.com \
--to=yhs@fb.com \
--cc=bpf@vger.kernel.org \
--cc=kulkarni@ucla.edu \
/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).