From patchwork Sun Jul 22 17:22:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 1224871 Return-Path: X-Original-To: patchwork-spi-devel-general@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by patchwork2.kernel.org (Postfix) with ESMTP id 2C357E0039 for ; Sun, 22 Jul 2012 17:22:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Sszrh-0004la-NB; Sun, 22 Jul 2012 17:22:45 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Sszrg-0004lV-Ns for spi-devel-general@lists.sourceforge.net; Sun, 22 Jul 2012 17:22:44 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of gmail.com designates 209.85.160.47 as permitted sender) client-ip=209.85.160.47; envelope-from=htejun@gmail.com; helo=mail-pb0-f47.google.com; Received: from mail-pb0-f47.google.com ([209.85.160.47]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1Sszrf-0005Z3-CO for spi-devel-general@lists.sourceforge.net; Sun, 22 Jul 2012 17:22:44 +0000 Received: by pbbrq2 with SMTP id rq2so8872535pbb.34 for ; Sun, 22 Jul 2012 10:22:37 -0700 (PDT) Received: by 10.68.229.33 with SMTP id sn1mr29150438pbc.9.1342977757472; Sun, 22 Jul 2012 10:22:37 -0700 (PDT) Received: from dhcp-172-17-108-109.mtv.corp.google.com ([216.239.45.130]) by mx.google.com with ESMTPS id ka5sm8225540pbb.37.2012.07.22.10.22.34 (version=SSLv3 cipher=OTHER); Sun, 22 Jul 2012 10:22:36 -0700 (PDT) Date: Sun, 22 Jul 2012 10:22:32 -0700 From: Tejun Heo To: linux-kernel@vger.kernel.org Subject: [PATCH UPDATED 1/2] kthread_worker: reorganize to prepare for flush_kthread_work() reimplementation Message-ID: <20120722172232.GD5144@dhcp-172-17-108-109.mtv.corp.google.com> References: <20120719211510.GA32763@google.com> <20120719211541.GB32763@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120719211541.GB32763@google.com> User-Agent: Mutt/1.5.20 (2009-06-14) X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (htejun[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1Sszrf-0005Z3-CO Cc: Andy Walls , kvm@vger.kernel.org, ivtv-devel@ivtvdriver.org, Avi Kivity , spi-devel-general@lists.sourceforge.net, Andrew Morton , Linus Torvalds , linux-media@vger.kernel.org X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net >From 9a2e03d8ed518a61154f18d83d6466628e519f94 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Thu, 19 Jul 2012 13:52:53 -0700 Make the following two non-functional changes. * Separate out insert_kthread_work() from queue_kthread_work(). * Relocate struct kthread_flush_work and kthread_flush_work_fn() definitions above flush_kthread_work(). v2: Added lockdep_assert_held() in insert_kthread_work() as suggested by Andy Walls. Signed-off-by: Tejun Heo Acked-by: Andy Walls --- kernel/kthread.c | 42 ++++++++++++++++++++++++++---------------- 1 files changed, 26 insertions(+), 16 deletions(-) diff --git a/kernel/kthread.c b/kernel/kthread.c index 3d3de63..4bfbff3 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -378,6 +378,19 @@ repeat: } EXPORT_SYMBOL_GPL(kthread_worker_fn); +/* insert @work before @pos in @worker */ +static void insert_kthread_work(struct kthread_worker *worker, + struct kthread_work *work, + struct list_head *pos) +{ + lockdep_assert_held(&worker->lock); + + list_add_tail(&work->node, pos); + work->queue_seq++; + if (likely(worker->task)) + wake_up_process(worker->task); +} + /** * queue_kthread_work - queue a kthread_work * @worker: target kthread_worker @@ -395,10 +408,7 @@ bool queue_kthread_work(struct kthread_worker *worker, spin_lock_irqsave(&worker->lock, flags); if (list_empty(&work->node)) { - list_add_tail(&work->node, &worker->work_list); - work->queue_seq++; - if (likely(worker->task)) - wake_up_process(worker->task); + insert_kthread_work(worker, work, &worker->work_list); ret = true; } spin_unlock_irqrestore(&worker->lock, flags); @@ -406,6 +416,18 @@ bool queue_kthread_work(struct kthread_worker *worker, } EXPORT_SYMBOL_GPL(queue_kthread_work); +struct kthread_flush_work { + struct kthread_work work; + struct completion done; +}; + +static void kthread_flush_work_fn(struct kthread_work *work) +{ + struct kthread_flush_work *fwork = + container_of(work, struct kthread_flush_work, work); + complete(&fwork->done); +} + /** * flush_kthread_work - flush a kthread_work * @work: work to flush @@ -436,18 +458,6 @@ void flush_kthread_work(struct kthread_work *work) } EXPORT_SYMBOL_GPL(flush_kthread_work); -struct kthread_flush_work { - struct kthread_work work; - struct completion done; -}; - -static void kthread_flush_work_fn(struct kthread_work *work) -{ - struct kthread_flush_work *fwork = - container_of(work, struct kthread_flush_work, work); - complete(&fwork->done); -} - /** * flush_kthread_worker - flush all current works on a kthread_worker * @worker: worker to flush