Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756040AbbKRNa0 (ORCPT ); Wed, 18 Nov 2015 08:30:26 -0500 Received: from mx2.suse.de ([195.135.220.15]:36454 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932670AbbKRN05 (ORCPT ); Wed, 18 Nov 2015 08:26:57 -0500 From: Petr Mladek 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 Subject: [PATCH v3 12/22] kthread: Use try_lock_kthread_work() in flush_kthread_work() Date: Wed, 18 Nov 2015 14:25:17 +0100 Message-Id: <1447853127-3461-13-git-send-email-pmladek@suse.com> X-Mailer: git-send-email 1.8.5.6 In-Reply-To: <1447853127-3461-1-git-send-email-pmladek@suse.com> References: <1447853127-3461-1-git-send-email-pmladek@suse.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1149 Lines: 41 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 dbd090466e2a..f7caaaca5825 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -933,16 +933,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)) { + 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 from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/