perf cgroup: Rename close_cgroup() to cgroup__put()

It is not really closing the cgroup, but instead dropping a reference
count and if it hits zero, then calling delete, which will, among other
cleanup shores, close the cgroup fd.

So it is really dropping a reference to that cgroup, and the method name
for that is "put", so rename close_cgroup() to cgroup__put() to follow
this naming convention.

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-sccxpnd7bgwc1llgokt6fcey@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 9450d0d4
...@@ -135,9 +135,8 @@ static int add_cgroup(struct perf_evlist *evlist, char *str) ...@@ -135,9 +135,8 @@ static int add_cgroup(struct perf_evlist *evlist, char *str)
goto found; goto found;
n++; n++;
} }
if (refcount_dec_and_test(&cgrp->refcnt))
free(cgrp);
cgroup__put(cgrp);
return -1; return -1;
found: found:
counter->cgrp = cgrp; counter->cgrp = cgrp;
...@@ -151,7 +150,7 @@ static void cgroup__delete(struct cgroup *cgroup) ...@@ -151,7 +150,7 @@ static void cgroup__delete(struct cgroup *cgroup)
free(cgroup); free(cgroup);
} }
void close_cgroup(struct cgroup *cgrp) void cgroup__put(struct cgroup *cgrp)
{ {
if (cgrp && refcount_dec_and_test(&cgrp->refcnt)) { if (cgrp && refcount_dec_and_test(&cgrp->refcnt)) {
cgroup__delete(cgrp); cgroup__delete(cgrp);
......
...@@ -14,7 +14,8 @@ struct cgroup { ...@@ -14,7 +14,8 @@ struct cgroup {
extern int nr_cgroups; /* number of explicit cgroups defined */ extern int nr_cgroups; /* number of explicit cgroups defined */
void close_cgroup(struct cgroup *cgrp);
void cgroup__put(struct cgroup *cgroup);
int parse_cgroups(const struct option *opt, const char *str, int unset); int parse_cgroups(const struct option *opt, const char *str, int unset);
......
...@@ -1233,7 +1233,7 @@ void perf_evsel__exit(struct perf_evsel *evsel) ...@@ -1233,7 +1233,7 @@ void perf_evsel__exit(struct perf_evsel *evsel)
perf_evsel__free_fd(evsel); perf_evsel__free_fd(evsel);
perf_evsel__free_id(evsel); perf_evsel__free_id(evsel);
perf_evsel__free_config_terms(evsel); perf_evsel__free_config_terms(evsel);
close_cgroup(evsel->cgrp); cgroup__put(evsel->cgrp);
cpu_map__put(evsel->cpus); cpu_map__put(evsel->cpus);
cpu_map__put(evsel->own_cpus); cpu_map__put(evsel->own_cpus);
thread_map__put(evsel->threads); thread_map__put(evsel->threads);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册