Skip to contentSkip to conversation

rcu, kasan: Record work creation stack trace with interrupts enabled

PATCH Applied Zqiang 2 participants 2 messages Dec 26, 2021 – Dec 28, 2021 RCU

lore
Share & tools
lore

Zqiang

author
#0 lore raw

PATCH v2 1/1 rcu, kasan: Record work creation stack trace with interrupts enabled

Recording the work creation stack trace for KASAN reports in call_rcu() is expensive, due to unwinding the stack, but also due to acquiring depot_lock inside stackdepot (which may be contended). Because calling kasan_record_aux_stack_noalloc() does not require interrupts to already be disabled, this may unnecessarily extend the time with interrupts disabled.

Therefore, move calling kasan_record_aux_stack() before the section with interrupts disabled.

---
v1->v2:
Make the submitted information clearer.

 kernel/rcu/tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree.c +1 -1
index 9b58bae0527a..36bd3f9e57b3 100644
@@ -3068,8 +3068,8 @@ void 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. */
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 7 lines · Zqiang

Recording the work creation stack trace for KASAN reports in call_rcu() is expensive, due to unwinding the stack, but also due to acquiring depot_lock inside stackdepot (which may be contended). Because calling kasan_record_aux_stack_noalloc() does not require interrupts to already be disabled, this may unnecessarily extend the time with interrupts disabled.

Quoted 5 lines

Therefore, move calling kasan_record_aux_stack() before the section with interrupts disabled.

Applied, thank you both!

Thanx, Paul

Quoted 24 lines

---
v1->v2:
Make the submitted information clearer.

 kernel/rcu/tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree.c +1 -1
index 9b58bae0527a..36bd3f9e57b3 100644
@@ -3068,8 +3068,8 @@ void 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. */
Signature · 1 line
2.25.1