After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 663644 - Add support for memory and cpu cgroups in the process list
Add support for memory and cpu cgroups in the process list
Status: RESOLVED FIXED
Product: system-monitor
Classification: Core
Component: process list
git master
Other Linux
: Normal enhancement
: ---
Assigned To: System-monitor maintainers
Depends on:
Blocks:
 
 
Reported: 2011-11-08 18:19 UTC by jbaron
Modified: 2011-12-22 00:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
add cpu/memory cgroup support patch (9.03 KB, application/octet-stream)
2011-11-08 18:19 UTC, jbaron
  Details
Add support for cpu and memory cgroups in process view (9.96 KB, patch)
2011-11-10 19:04 UTC, jbaron
none Details | Review
Path to implement Lennart's single column for cgroups idea (10.22 KB, patch)
2011-11-11 21:16 UTC, jbaron
committed Details | Review
only update the cgroup path when its changed (7.09 KB, patch)
2011-11-23 19:33 UTC, jbaron
committed Details | Review

Description jbaron 2011-11-08 18:19:47 UTC
Created attachment 201021 [details]
add cpu/memory cgroup support patch

I've attached a patch which adds two new columns to the process list - cpu cgroup and memory cgroup columns. Then for each process you can see which cgroup it is assigned to. If you are on an older version of linux, which does not support cgroups, or another os, the cgroups columns wouldn't show up. Please consider this new feature. thanks!

-Jason
Comment 1 Chris Kühl 2011-11-09 22:10:41 UTC
Seems like a nice feature. Could you please provide a git-formatted patch?

I gave it a cursory look and noticed a couple things. 

A few days ago I went through and made the summaries for the columns in the GSettings schema xml file match the column names exactly. This includes capitalization. Please update the patch to be consistent.

Another issue I find is the capitalization of cgroup. Generally it's all lowercase but that would not really fit here. You've chosen 'Cgroup' while I'd say 'CGroup' seems more appropriate. I'd prefer 'Control Group' but feel this requires too much space. So, let's use 'CGroup' unless there's a good reason against it.

Once the git-formatted patch arrives I'll look at it more closely.
Comment 2 Chris Kühl 2011-11-10 08:57:00 UTC
(In reply to comment #1)
> Another issue I find is the capitalization of cgroup. Generally it's all
> lowercase but that would not really fit here. You've chosen 'Cgroup' while I'd
> say 'CGroup' seems more appropriate. I'd prefer 'Control Group' but feel this
> requires too much space. So, let's use 'CGroup' unless there's a good reason
> against it.
> 

I take this back. I've found others using 'Cgroup' and none using 'CGroup'. So, please leave as 'Cgroup'.
Comment 3 Chris Kühl 2011-11-10 15:04:25 UTC
I talked to Lennart today and he said he might have some ideas about how this could be better implemented. I'm CCing him so that he can chime in on the discussion.
Comment 4 jbaron 2011-11-10 19:04:00 UTC
Created attachment 201173 [details] [review]
Add support for cpu and memory cgroups in process view

Ok, I'm attaching an updated patch with:

-updates in GSettings schema xml file to match the column names exactly
-optimization to only call g_strdup() when the cgroup name has changed

thanks.
Comment 5 Lennart Poettering 2011-11-11 11:44:49 UTC
I'd strongly advise not to merge the patch like this. Arbitrarily picking two of the controllers here sounds like a bad idea. Also, in most setups the control group paths in a number of the controllers will be the same for most processes, hence showing the same data for every controller is not particularly useful. And showing information if the control group path is / is probably  not a good idea either and should be suppressed.

My original intention was to extend gnome-system-monitor to show higher-level information only, for example instead of showing which cgroup a process is in, show to which systemd service or systemd session a process belongs. That information is also gathered from the low-level cgroup tree, but distilled into a more high-level value.

That said, I understand that there's interest to show cgroup information independent of systemd's cgroup management. So, to accommodate for that I'd still recommend to coalesce the cgroup information for all trees into a terse string: i.e. suppress showing info for controllers where the process is in the root cgroup, and coalesce information for all controllers where the process is in the same path. Example: if a process is in cgroup /a in "cpu" and also in /a in "memory", but in "/b" for "blkio", and in / in all others (including "cpuset") then create a single "Control Group" field for that with a value like "/a (CPU/Memory), /b (Block IO)". In most cases this logic will have the effect that either the empty string is shown of a process (if it is in the root cgroup), or that a single field is shown, since the fewest processes will be in different cgroups in the various controllers. 

In summary:

a) Only a single column for all cgroup hierarchies, not one for each

b) cover all controllers, not just "cpu" and "memory"

c) suppress information if a process is in the root cgroup

d) coalesce cgroup information for multiple hierarchies if a cgroup is in the same path in them

e) translate the raw kernel controller name into a pretty human readable string, and fall back to the raw kernel controller name if no human readable string is known for the cases where the kernel adds a new controller, which isn't known yet by g-s-m
Comment 6 jbaron 2011-11-11 14:54:07 UTC
ok. Chris, if you like Lennart's suggestion, I can re-post it using the format he has suggested?
Comment 7 Chris Kühl 2011-11-11 15:01:00 UTC
(In reply to comment #6)
> ok. Chris, if you like Lennart's suggestion, I can re-post it using the format
> he has suggested?

Yes, Lennart's *much* more knowledgeable about cgroups than I. So, if this seems clear to you then let's do as Lennart suggests. Also, since we'll have only one column, please use 'Control Group' in the column header.
Comment 8 jbaron 2011-11-11 21:16:35 UTC
Created attachment 201256 [details] [review]
Path to implement Lennart's single column for cgroups idea

Hi,

Ok, here's a patch to implement this idea. I need to do some more testing on it...but it seems to basically work.

Thanks,

-Jason
Comment 9 Chris Kühl 2011-11-20 12:56:15 UTC
(In reply to comment #8)
> Created an attachment (id=201256) [details] [review]
> Path to implement Lennart's single column for cgroups idea
> 
> Hi,
> 
> Ok, here's a patch to implement this idea. I need to do some more testing on
> it...but it seems to basically work.
> 

I'm applying this so that we can get some feedback from tomorrow's development release. I had to make a small change to get it to apply and cleaned up 2 whitespace errors. Please watch those.

I'm considering this the first iteration and am not closing this till you've done your testing.

Cheers
Comment 10 jbaron 2011-11-21 18:40:47 UTC
great. Thanks.

I've got a newer version now, that deals with the case where a controllers are co-mounted, and also optimizes the case where the cgroup has not changed. Should I post a diff on top of the latest tree? Or a replacement patch?

Thanks,

-Jason
Comment 11 Chris Kühl 2011-11-21 19:42:04 UTC
(In reply to comment #10)
> great. Thanks.
> 
<snip>
> Should I post a diff on top of the latest tree? Or a replacement patch?

A git-formatted patch based off master would be great.

Thanks.
Comment 12 Robert Roth 2011-11-21 23:26:14 UTC
The CGROUPS related functionality has been committed to the git repo, see http://git.gnome.org/browse/gnome-system-monitor/commit/?id=2d33adcbc4347c112d57082956b4e199ff7132db. Did the commit fix the problem? If yes, the bug should be set as resolved.
Comment 13 Chris Kühl 2011-11-22 00:19:12 UTC
Robert, we are still working on this. Leave this open for now.
Comment 14 jbaron 2011-11-23 19:33:58 UTC
Created attachment 202020 [details] [review]
only update the cgroup path when its changed

Hi,

This patch only allocates a new string for the cgroup when its changed. It also recognizes more complex cgroup setups, such as co-mounted cgroups.

Thanks,

-Jason
Comment 15 jbaron 2011-12-09 21:15:07 UTC
Hi,

Any thoughts on this patch?

Also, I'm wondering if there is interest in further cgroup support. What I'm thinking is potentially a new cgroup tab. In that tab one could select which controller they are interested in - memory, cpu, etc., via a toggle box, perhaps at the top. Once the desired controller is selected, the relevant cgoups are displayed in a table form much like the process tab, where the first column in the cgroup name. The columns of the table would then have the relevant data for the particular cgroup. So, for instance, for the cpu controller, it would display cpu usage. Thus, one could sort by the cpu usage column and see which cgroup is using the most cpu resources.

Perhaps, others have better ideas?

Thanks,

-Jason
Comment 16 Chris Kühl 2011-12-11 14:26:00 UTC
Review of attachment 202020 [details] [review]:

Looks fine.
Comment 17 Chris Kühl 2011-12-11 14:27:01 UTC
Review of attachment 201256 [details] [review]:

Forgot to mark this as committed. Doing it now.
Comment 18 Chris Kühl 2011-12-11 14:27:02 UTC
Review of attachment 201256 [details] [review]:

Forgot to mark this as committed. Doing it now.
Comment 19 Chris Kühl 2011-12-11 14:31:14 UTC
(In reply to comment #15)
> Hi,
> 
> Any thoughts on this patch?
> 

Committed.

> Also, I'm wondering if there is interest in further cgroup support. What I'm
> thinking is potentially a new cgroup tab. In that tab one could select which
> controller they are interested in - memory, cpu, etc., via a toggle box,
> perhaps at the top. Once the desired controller is selected, the relevant
> cgoups are displayed in a table form much like the process tab, where the first
> column in the cgroup name. The columns of the table would then have the
> relevant data for the particular cgroup. So, for instance, for the cpu
> controller, it would display cpu usage. Thus, one could sort by the cpu usage
> column and see which cgroup is using the most cpu resources.

I'm generally very reluctant to add new tabs. Sounds like this might be better in a stand-alone app. But as I've said before, I'm not really fluent c-groups so perhaps I'm wrong.
Comment 20 jbaron 2011-12-12 18:41:45 UTC
Lennart, 

Any thoughts on gsm cgroup tab vs. separate gui? I've outlined a pretty basic interface in comment #15.

Thanks,

-Jason
Comment 21 Chris Kühl 2011-12-20 11:51:30 UTC
Lennart still appears to be working through his email backlog following his vacation but I talked to him the other day and he was also not in favor of having a cgourps tab in g-s-m.

I'm closing this. Please file another bug if you feel you'd like to add anything else.

Thanks.
Comment 22 Lennart Poettering 2011-12-20 12:50:39 UTC
I am not convinced that it makes sense giving cgroups an entire tab of their own. I mean, cgroups should be exposed and all, but I have my doubts they should get their own tab. I think whatever we show in g-s-m needs to be distilled to the relevant essence, and I don't think showing the full cgroup hierarchies over all controllers would be helpful to achieve that. We shouldn't lose focus here, g-s-m is a general system monitor, and I don't think cgroups are too central for the system to deserve an entire tab of their own.

I think more detailed cgroup explorer tools might be something for a separate project.

That said, I think there might be a couple of higher-level cgroup-related things we might still want to expose in g-s-m. For example, a tab showing the login session with sd_pid_get_session() and the session user (i.e. the owner of a session, which is not influenced by sudo and stuff) with sd_pid_get_owner_uid().

http://0pointer.de/public/systemd-man/sd_pid_get_session.html
Comment 23 Lennart Poettering 2011-12-20 12:55:08 UTC
Oh, and it might even make sense showing seat information, too, via sd_session_get_seat(sd_pid_get_session()).

http://0pointer.de/public/systemd-man/sd_session_is_active.html
Comment 24 Lennart Poettering 2011-12-20 12:56:53 UTC
(those three calls are basically just parsed cgroup information, which is why i suggest this as higher-level cgroup-based info)
Comment 25 Matthias Clasen 2011-12-20 14:51:53 UTC
It is pretty hard to discuss this in a meaningful way without background
information on what extra information and knobs cgroups give us. Also, having a
screenshot of the proposed tab (as well as the new column in the process list)
might help getting an idea what we are talking about here...
Comment 26 Chris Kühl 2011-12-22 00:25:07 UTC
I second Matthias' comment. I also think this discussion would be better in its own bug report.