* [PATCH] ftrace: safe traversal of ftrace_hash hlist
@ 2008-05-24 18:15 Abhishek Sagar
2008-05-27 15:41 ` Thomas Gleixner
0 siblings, 1 reply; 2+ messages in thread
From: Abhishek Sagar @ 2008-05-24 18:15 UTC (permalink / raw)
To: rostedt; +Cc: Ingo Molnar, LKML
Hi Steven,
I noticed that concurrent instances of ftrace_record_ip() have a race between ftrace_hash list traversal during ftrace_ip_in_hash() (before acquiring ftrace_shutdown_lock) and ftrace_add_hash().If it's so then this should fix it.
Signed-off-by: Abhishek Sagar <sagar.abhishek@gmail.com>
---
Accommodate traversal of ftrace_hash hlist with concurrent insertions.
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 89bd9a6..bfba25c 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -201,7 +201,7 @@ ftrace_ip_in_hash(unsigned long ip, unsigned long key)
struct hlist_node *t;
int found = 0;
- hlist_for_each_entry(p, t, &ftrace_hash[key], node) {
+ hlist_for_each_entry_rcu(p, t, &ftrace_hash[key], node) {
if (p->ip == ip) {
found = 1;
break;
@@ -214,7 +214,7 @@ ftrace_ip_in_hash(unsigned long ip, unsigned long key)
static inline void
ftrace_add_hash(struct dyn_ftrace *node, unsigned long key)
{
- hlist_add_head(&node->node, &ftrace_hash[key]);
+ hlist_add_head_rcu(&node->node, &ftrace_hash[key]);
}
static void ftrace_free_rec(struct dyn_ftrace *rec)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ftrace: safe traversal of ftrace_hash hlist
2008-05-24 18:15 [PATCH] ftrace: safe traversal of ftrace_hash hlist Abhishek Sagar
@ 2008-05-27 15:41 ` Thomas Gleixner
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2008-05-27 15:41 UTC (permalink / raw)
To: Abhishek Sagar; +Cc: rostedt, Ingo Molnar, LKML
On Sat, 24 May 2008, Abhishek Sagar wrote:
> Hi Steven,
> I noticed that concurrent instances of ftrace_record_ip() have a
> race between ftrace_hash list traversal during ftrace_ip_in_hash()
> (before acquiring ftrace_shutdown_lock) and ftrace_add_hash().If
> it's so then this should fix it.
Applied. Thanks,
tglx
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-05-27 15:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-24 18:15 [PATCH] ftrace: safe traversal of ftrace_hash hlist Abhishek Sagar
2008-05-27 15:41 ` Thomas Gleixner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox