[RFC][PATCH] ps command race fix take2 [3/4] profile fix

From: KAMEZAWA Hiroyuki
Date: Tue Aug 22 2006 - 04:36:24 EST


oprofile driver touches task->tasks.
But it doesn't have to use task->tasks, just list_head is needed.

Signed-Off-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>

drivers/oprofile/buffer_sync.c | 6 +++---
include/linux/sched.h | 4 ++++
2 files changed, 7 insertions(+), 3 deletions(-)

Index: linux-2.6.18-rc4/include/linux/sched.h
===================================================================
--- linux-2.6.18-rc4.orig/include/linux/sched.h
+++ linux-2.6.18-rc4/include/linux/sched.h
@@ -808,6 +808,10 @@ struct task_struct {
struct list_head ptrace_children;
struct list_head ptrace_list;

+#if defined(CONFIG_OPROFILE) || defined(CONFIG_OPROFILE_MODULE)
+ struct list_head dead_tasks;
+#endif
+
struct mm_struct *mm, *active_mm;

/* task state */
Index: linux-2.6.18-rc4/drivers/oprofile/buffer_sync.c
===================================================================
--- linux-2.6.18-rc4.orig/drivers/oprofile/buffer_sync.c
+++ linux-2.6.18-rc4/drivers/oprofile/buffer_sync.c
@@ -51,7 +51,7 @@ static int task_free_notify(struct notif
unsigned long flags;
struct task_struct * task = data;
spin_lock_irqsave(&task_mortuary, flags);
- list_add(&task->tasks, &dying_tasks);
+ list_add(&task->dead_tasks, &dying_tasks);
spin_unlock_irqrestore(&task_mortuary, flags);
return NOTIFY_OK;
}
@@ -446,8 +446,8 @@ static void process_task_mortuary(void)

spin_unlock_irqrestore(&task_mortuary, flags);

- list_for_each_entry_safe(task, ttask, &local_dead_tasks, tasks) {
- list_del(&task->tasks);
+ list_for_each_entry_safe(task, ttask, &local_dead_tasks, dead_tasks) {
+ list_del(&task->dead_tasks);
free_task(task);
}
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/