summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYe Liu <liuye@kylinos.cn>2025-09-09 09:33:07 +0800
committerVlastimil Babka <vbabka@suse.cz>2025-09-10 22:52:33 +0200
commit41534d499e50e23571d6b9960498777d93f817ce (patch)
tree52fc80b2081877f6e4aa616f2e36c69b001fca21
parentba7a896427cbade13d30f3c7e18c15e8be243c18 (diff)
mm/slub: Refactor note_cmpxchg_failure for better readability
Use IS_ENABLED() and standard if-else to make the code clearer. Signed-off-by: Ye Liu <liuye@kylinos.cn> Reviewed-by: Harry Yoo <harry.yoo@oracle.com> Reviewed-by: Christoph Lameter (Ampere) <cl@gentwo.org> Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
-rw-r--r--mm/slub.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/mm/slub.c b/mm/slub.c
index 9074ce914e9e..3062f56bf498 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3069,18 +3069,17 @@ static inline void note_cmpxchg_failure(const char *n,
pr_info("%s %s: cmpxchg redo ", n, s->name);
-#ifdef CONFIG_PREEMPTION
- if (tid_to_cpu(tid) != tid_to_cpu(actual_tid))
+ if (IS_ENABLED(CONFIG_PREEMPTION) &&
+ tid_to_cpu(tid) != tid_to_cpu(actual_tid)) {
pr_warn("due to cpu change %d -> %d\n",
tid_to_cpu(tid), tid_to_cpu(actual_tid));
- else
-#endif
- if (tid_to_event(tid) != tid_to_event(actual_tid))
+ } else if (tid_to_event(tid) != tid_to_event(actual_tid)) {
pr_warn("due to cpu running other code. Event %ld->%ld\n",
tid_to_event(tid), tid_to_event(actual_tid));
- else
+ } else {
pr_warn("for unknown reason: actual=%lx was=%lx target=%lx\n",
actual_tid, tid, next_tid(tid));
+ }
#endif
stat(s, CMPXCHG_DOUBLE_CPU_FAIL);
}