[PATCH] rcu: record kasan stack before enter local_irq_save()/restore() critical area

From: Zqiang
Date: Wed Dec 22 2021 - 02:54:47 EST


The kasan_record_aux_stack_noalloc() only record stack, it doesn't need
to be called in local_irq_save()/restore() critical area, and the global
spinlock (depot_lock) will be acquired in this function, When enable
kasan stack, locking contention may increase the time in the critical area.

Signed-off-by: Zqiang <qiang1.zhang@xxxxxxxxx>
---
kernel/rcu/tree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 347dae1876a6..5198e44cb124 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -3030,8 +3030,8 @@ __call_rcu(struct rcu_head *head, rcu_callback_t func)
}
head->func = func;
head->next = NULL;
- local_irq_save(flags);
kasan_record_aux_stack_noalloc(head);
+ local_irq_save(flags);
rdp = this_cpu_ptr(&rcu_data);

/* Add the callback to our list. */
--
2.25.1