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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-Off-By: KAMEZAWA Hiroyuki <[email protected]>

 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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux