mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-24 13:13:57 +08:00
3b5692864d
The usual thing is for a constructor to allocate space for its members, not to require that the caller pass a pre-allocated 'name' and then, at its destructor, to free something not allocated by it. Fix it by making cgroup__new() to receive a const char pointer, then allocate cgroup->name that then can continue to be freed at cgroup__delete(), balancing the alloc/free operations inside the cgroup struct methods. This eases calling evlist__findnew_cgroup() from the custom 'perf trace' cgroup parser, that will only call parse_cgroups() when the '-G cgroup' is passed on the command line after '-e event' entries, when it'll behave just like 'perf stat' and 'perf record', i.e. the previous parse_cgroup() users that mandate that -G only can come after a -e. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Stephane Eranian <eranian@google.com> Cc: Wang Nan <wangnan0@huawei.com> Link: https://lkml.kernel.org/n/tip-4leugnuyqi10t98990o3xi1t@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
30 lines
640 B
C
30 lines
640 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __CGROUP_H__
|
|
#define __CGROUP_H__
|
|
|
|
#include <linux/refcount.h>
|
|
|
|
struct option;
|
|
|
|
struct cgroup {
|
|
char *name;
|
|
int fd;
|
|
refcount_t refcnt;
|
|
};
|
|
|
|
|
|
extern int nr_cgroups; /* number of explicit cgroups defined */
|
|
|
|
struct cgroup *cgroup__get(struct cgroup *cgroup);
|
|
void cgroup__put(struct cgroup *cgroup);
|
|
|
|
struct perf_evlist;
|
|
|
|
struct cgroup *evlist__findnew_cgroup(struct perf_evlist *evlist, const char *name);
|
|
|
|
void evlist__set_default_cgroup(struct perf_evlist *evlist, struct cgroup *cgroup);
|
|
|
|
int parse_cgroups(const struct option *opt, const char *str, int unset);
|
|
|
|
#endif /* __CGROUP_H__ */
|