public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] task_work: make FIFO task_work list
@ 2013-03-14  7:57 liguang
  2013-03-14  7:57 ` [PATCH 2/2] task_work: check callback if it's NULL liguang
  2013-03-14 14:40 ` [PATCH 1/2] task_work: make FIFO task_work list Oleg Nesterov
  0 siblings, 2 replies; 11+ messages in thread
From: liguang @ 2013-03-14  7:57 UTC (permalink / raw)
  To: viro, oleg, edumazet, linux-kernel; +Cc: liguang

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
---
 kernel/task_work.c |   15 +++------------
 1 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/kernel/task_work.c b/kernel/task_work.c
index 65bd3c9..0bf4258 100644
--- a/kernel/task_work.c
+++ b/kernel/task_work.c
@@ -13,11 +13,12 @@ task_work_add(struct task_struct *task, struct callback_head *work, bool notify)
 		head = ACCESS_ONCE(task->task_works);
 		if (unlikely(head == &work_exited))
 			return -ESRCH;
-		work->next = head;
-	} while (cmpxchg(&task->task_works, head, work) != head);
+		head = head->next;
+	} while (cmpxchg(&head, NULL, work) == head);
 
 	if (notify)
 		set_notify_resume(task);
+
 	return 0;
 }
 
@@ -72,16 +73,6 @@ void task_work_run(void)
 		raw_spin_unlock_wait(&task->pi_lock);
 		smp_mb();
 
-		/* Reverse the list to run the works in fifo order */
-		head = NULL;
-		do {
-			next = work->next;
-			work->next = head;
-			head = work;
-			work = next;
-		} while (work);
-
-		work = head;
 		do {
 			next = work->next;
 			work->func(work);
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-03-15 14:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-14  7:57 [PATCH 1/2] task_work: make FIFO task_work list liguang
2013-03-14  7:57 ` [PATCH 2/2] task_work: check callback if it's NULL liguang
2013-03-14 14:43   ` Oleg Nesterov
2013-03-15  0:20     ` li guang
2013-03-15  1:01       ` Li Zefan
2013-03-15  1:26         ` li guang
2013-03-15  1:43           ` Li Zefan
2013-03-15  2:29             ` li guang
2013-03-14 14:40 ` [PATCH 1/2] task_work: make FIFO task_work list Oleg Nesterov
2013-03-15  0:16   ` li guang
2013-03-15 14:34     ` Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox