[systemd-devel] [RFC 2/2] bootchart: add cgroup option

Lennart Poettering lennart at poettering.net
Wed Apr 23 13:13:12 PDT 2014


On Fri, 28.03.14 17:07, WaLyong Cho (walyong.cho at samsung.com) wrote:

Sounds useful.

> ---
>  src/bootchart/bootchart.c    |    9 ++++++++-
>  src/bootchart/bootchart.conf |    1 +
>  src/bootchart/bootchart.h    |    2 ++
>  src/bootchart/store.c        |   25 +++++++++++++++++++++++++
>  src/bootchart/svg.c          |    5 +++--
>  5 files changed, 39 insertions(+), 3 deletions(-)
> 
> diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c
> index 9f72d98..1c87085 100644
> --- a/src/bootchart/bootchart.c
> +++ b/src/bootchart/bootchart.c
> @@ -78,6 +78,7 @@ bool initcall = true;
>  bool arg_relative = false;
>  bool arg_filter = true;
>  bool arg_show_cmdline = false;
> +bool arg_show_cgroup = false;
>  bool arg_pss = false;
>  int samples;
>  int arg_samples_len = 500; /* we record len+1 (1 start sample) */
> @@ -113,6 +114,7 @@ static void parse_conf(void) {
>                  { "Bootchart", "PlotEntropyGraph", config_parse_bool,   0, &arg_entropy     },
>                  { "Bootchart", "ScaleX",           config_parse_double, 0, &arg_scale_x     },
>                  { "Bootchart", "ScaleY",           config_parse_double, 0, &arg_scale_y     },
> +                { "Bootchart", "Cgroup",           config_parse_bool,
> 0, &arg_show_cgroup },

Please do not abbreviate this option, please use "ControlGroup" here.

> +static void get_cgroup_name(int pid, struct ps_struct *ps) {
> +        _cleanup_fclose_ FILE *cg = NULL;
> +        char filename[PATH_MAX], *line = NULL;
> +        int r, fd;
> +
> +        sprintf(filename, "%d/cgroup", pid);
> +        fd = openat(procfd, filename, O_RDONLY);
> +        if (fd == -1)
> +                return;
> +
> +        cg = fdopen(fd, "r");
> +        if (!cg)
> +                return;
> +
> +        r = read_one_line_from_file_if_has(cg, &line, "name=systemd:/");
> +        if (r < 0)
> +                return;
> +
> +        strncpy(ps->cgroup, line, sizeof(ps->cgroup));
> +        free(line);
> +}
> +

Please use cg_pid_get_path() for this instead.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list