lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 20 Dec 2019 17:48:02 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     Tejun Heo <tj@...nel.org>
Cc:     Namhyung Kim <namhyung@...nel.org>, Ingo Molnar <mingo@...nel.org>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Jiri Olsa <jolsa@...hat.com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Mark Rutland <mark.rutland@....com>,
        Stephane Eranian <eranian@...gle.com>,
        LKML <linux-kernel@...r.kernel.org>,
        linux-perf-users@...r.kernel.org, Li Zefan <lizefan@...wei.com>,
        Johannes Weiner <hannes@...xchg.org>
Subject: Re: [PATCH 2/9] perf/core: Add PERF_SAMPLE_CGROUP feature

On Fri, Dec 20, 2019 at 07:23:24AM -0800, Tejun Heo wrote:
> On Fri, Dec 20, 2019 at 01:32:46PM +0900, Namhyung Kim wrote:
> > The PERF_SAMPLE_CGROUP bit is to save (perf_event) cgroup information
> > in the sample.  It will add a 64-bit id to identify current cgroup and
> > it's the file handle in the cgroup file system.  Userspace should use
> > this information with PERF_RECORD_CGROUP event to match which cgroup
> > it belongs.
> 
> You don't need PERF_RECORD_CGROUP for that.  Something like the
> following should work.
> 
> 	struct {
> 		struct file_handle fh;
> 		char stor[MAX_HANDLE_SZ];
> 	} fh_store;
> 	struct file_handle *fh = &fh_store;
> 
> 	fh->handle_type = 0xfe; // FILEID_KERNFS
> 	fh->handle_bytes = sizeof(u64);
> 	*(u64 *)fh->f_handle = cgrp_id;
> 
> 	mnt_fd = open('/sys/fs/cgroup', O_RDONLY);
> 	fd = open_by_handle_at(mnt_fd, fh, O_RDONLY);
> 
> 	snprintf(proc_path, PATH_MAX, "/proc/self/fd/%d", fd);
> 	readlink(proc_path, cgrp_path, PATH_MAX);

That assumes the cgroup is still in existence, which might not be the
case I presume.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ