[PATCH 02/12] cgroup: rstat: Make cgroup_rstat_cpu_lock name readable

From: Namhyung Kim
Date: Tue Feb 08 2022 - 17:25:21 EST


The raw_spin_lock_init() uses the argument to name its lockdep map.
But passing per_cpu_ptr() macro directly makes it a very very long
name as it expanded like below:

({ do { const void *__vpp_verify = (typeof((&cgroup_rstat_cpu_lock) ...

Let's fix it by passing a local variable instead. With this change,
the name now looks like:

cgrp_rstat_cpu_lock

Cc: Zefan Li <lizefan.x@xxxxxxxxxxxxx>
Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
Cc: cgroups@xxxxxxxxxxxxxxx
Acked-by: Tejun Heo <tj@xxxxxxxxxx>
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
kernel/cgroup/rstat.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c
index 9d331ba44870..371f54a59c38 100644
--- a/kernel/cgroup/rstat.c
+++ b/kernel/cgroup/rstat.c
@@ -286,9 +286,17 @@ void cgroup_rstat_exit(struct cgroup *cgrp)
void __init cgroup_rstat_boot(void)
{
int cpu;
+ raw_spinlock_t *cgrp_rstat_cpu_lock;

- for_each_possible_cpu(cpu)
- raw_spin_lock_init(per_cpu_ptr(&cgroup_rstat_cpu_lock, cpu));
+ for_each_possible_cpu(cpu) {
+ /*
+ * raw_spin_lock_init() uses the argument to name the lock in
+ * lockdep results. Passing per_cpu_ptr() directly created a
+ * cryptic name as the macro was expanded before stringified.
+ */
+ cgrp_rstat_cpu_lock = per_cpu_ptr(&cgroup_rstat_cpu_lock, cpu);
+ raw_spin_lock_init(cgrp_rstat_cpu_lock);
+ }
}

/*
--
2.35.0.263.gb82422642f-goog