From mboxrd@z Thu Jan 1 00:00:00 1970 From: Petr Mladek Subject: [PATCH v4 12/22] kthread: Use try_lock_kthread_work() in flush_kthread_work() Date: Mon, 25 Jan 2016 16:45:01 +0100 Message-ID: <1453736711-6703-13-git-send-email-pmladek@suse.com> References: <1453736711-6703-1-git-send-email-pmladek@suse.com> Return-path: In-Reply-To: <1453736711-6703-1-git-send-email-pmladek@suse.com> Sender: owner-linux-mm@kvack.org To: Andrew Morton , Oleg Nesterov , Tejun Heo , Ingo Molnar , Peter Zijlstra Cc: Steven Rostedt , "Paul E. McKenney" , Josh Triplett , Thomas Gleixner , Linus Torvalds , Jiri Kosina , Borislav Petkov , Michal Hocko , linux-mm@kvack.org, Vlastimil Babka , linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Petr Mladek List-Id: linux-api@vger.kernel.org Remove code duplication and use the new try_lock_kthread_work() function in flush_kthread_work() as well. Signed-off-by: Petr Mladek --- kernel/kthread.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/kernel/kthread.c b/kernel/kthread.c index 53c4d5a7c723..7193582fe299 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -956,16 +956,12 @@ void flush_kthread_work(struct kthread_work *work) struct kthread_worker *worker; bool noop = false; -retry: - worker = work->worker; - if (!worker) + local_irq_disable(); + if (!try_lock_kthread_work(work, false)) { + local_irq_enable(); return; - - spin_lock_irq(&worker->lock); - if (work->worker != worker) { - spin_unlock_irq(&worker->lock); - goto retry; } + worker = work->worker; if (!list_empty(&work->node)) insert_kthread_work(worker, &fwork.work, work->node.next); -- 1.8.5.6 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org