Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+8 -4
+8 -4
tools/perf/util/namespaces.c
··· 204 204 return nnsi; 205 205 } 206 206 207 + static refcount_t *nsinfo__refcnt(struct nsinfo *nsi) 208 + { 209 + return &RC_CHK_ACCESS(nsi)->refcnt; 210 + } 211 + 207 212 static void nsinfo__delete(struct nsinfo *nsi) 208 213 { 209 214 if (nsi) { 210 - WARN_ONCE(refcount_read(&RC_CHK_ACCESS(nsi)->refcnt) != 0, 211 - "nsinfo refcnt unbalanced\n"); 215 + WARN_ONCE(refcount_read(nsinfo__refcnt(nsi)) != 0, "nsinfo refcnt unbalanced\n"); 212 216 zfree(&RC_CHK_ACCESS(nsi)->mntns_path); 213 217 RC_CHK_FREE(nsi); 214 218 } ··· 223 219 struct nsinfo *result; 224 220 225 221 if (RC_CHK_GET(result, nsi)) 226 - refcount_inc(&RC_CHK_ACCESS(nsi)->refcnt); 222 + refcount_inc(nsinfo__refcnt(nsi)); 227 223 228 224 return result; 229 225 } 230 226 231 227 void nsinfo__put(struct nsinfo *nsi) 232 228 { 233 - if (nsi && refcount_dec_and_test(&RC_CHK_ACCESS(nsi)->refcnt)) 229 + if (nsi && refcount_dec_and_test(nsinfo__refcnt(nsi))) 234 230 nsinfo__delete(nsi); 235 231 else 236 232 RC_CHK_PUT(nsi);