bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gautam Kulkarni <thegautam@gmail.com>
To: bpf@vger.kernel.org
Subject: Per cgroup accounting of context switches
Date: Fri, 6 Sep 2019 21:30:26 -0700	[thread overview]
Message-ID: <CANZ-dUobRee1NrntgZsnvZN7HmbAgszjX4t4bV5-27sR+fVHWA@mail.gmail.com> (raw)

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?

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

             reply	other threads:[~2019-09-07  4:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-07  4:30 Gautam Kulkarni [this message]
2019-09-07  6:38 ` Per cgroup accounting of context switches Yonghong Song

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=CANZ-dUobRee1NrntgZsnvZN7HmbAgszjX4t4bV5-27sR+fVHWA@mail.gmail.com \
    --to=thegautam@gmail.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).