summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2023-04-17 22:11:58 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-04-17 22:22:12 -0300
commitf94c21dfd02e98aa0fcb9b453a1198e76ede60e7 (patch)
tree43ea9f4439af0eb88d0a9086e08ee86b1549a9a2 /tools
parent4d623903f1ed63a06e469c4ce45231440d1be5b6 (diff)
downloadlinux-f94c21dfd02e98aa0fcb9b453a1198e76ede60e7.tar.gz
linux-f94c21dfd02e98aa0fcb9b453a1198e76ede60e7.tar.bz2
linux-f94c21dfd02e98aa0fcb9b453a1198e76ede60e7.zip
perf namespaces: Introduce nsinfo__refcnt() accessor to avoid accessing ->refcnt directly
To reduces the use of RC_CHK_ACCESS(nsi). Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/namespaces.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/perf/util/namespaces.c b/tools/perf/util/namespaces.c
index 214a8391e07c..2f9fb1e2769c 100644
--- a/tools/perf/util/namespaces.c
+++ b/tools/perf/util/namespaces.c
@@ -204,11 +204,15 @@ struct nsinfo *nsinfo__copy(const struct nsinfo *nsi)
return nnsi;
}
+static refcount_t *nsinfo__refcnt(struct nsinfo *nsi)
+{
+ return &RC_CHK_ACCESS(nsi)->refcnt;
+}
+
static void nsinfo__delete(struct nsinfo *nsi)
{
if (nsi) {
- WARN_ONCE(refcount_read(&RC_CHK_ACCESS(nsi)->refcnt) != 0,
- "nsinfo refcnt unbalanced\n");
+ WARN_ONCE(refcount_read(nsinfo__refcnt(nsi)) != 0, "nsinfo refcnt unbalanced\n");
zfree(&RC_CHK_ACCESS(nsi)->mntns_path);
RC_CHK_FREE(nsi);
}
@@ -219,14 +223,14 @@ struct nsinfo *nsinfo__get(struct nsinfo *nsi)
struct nsinfo *result;
if (RC_CHK_GET(result, nsi))
- refcount_inc(&RC_CHK_ACCESS(nsi)->refcnt);
+ refcount_inc(nsinfo__refcnt(nsi));
return result;
}
void nsinfo__put(struct nsinfo *nsi)
{
- if (nsi && refcount_dec_and_test(&RC_CHK_ACCESS(nsi)->refcnt))
+ if (nsi && refcount_dec_and_test(nsinfo__refcnt(nsi)))
nsinfo__delete(nsi);
else
RC_CHK_PUT(nsi);