From: Jens Axboe <jens.axboe@oracle.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, jeff@garzik.org,
benh@kernel.crashing.org, htejun@gmail.com, bzolnier@gmail.com,
alan@lxorguk.ukuu.org.uk
Subject: Re: [PATCH 2/6] workqueue: add support for lazy workqueues
Date: Mon, 24 Aug 2009 10:06:26 +0200 [thread overview]
Message-ID: <20090824080626.GD12579@kernel.dk> (raw)
In-Reply-To: <20090820172027.cdc41d1e.akpm@linux-foundation.org>
On Thu, Aug 20 2009, Andrew Morton wrote:
> On Thu, 20 Aug 2009 12:17:39 +0200
> Jens Axboe <jens.axboe@oracle.com> wrote:
>
> > Lazy workqueues are like normal workqueues, except they don't
> > start a thread per CPU by default. Instead threads are started
> > when they are needed, and exit when they have been idle for
> > some time.
> >
> >
> > ...
> >
> > @@ -280,7 +309,34 @@ static void run_workqueue(struct cpu_workqueue_struct *cwq)
> > trace_workqueue_execution(cwq->thread, work);
> > cwq->current_work = work;
> > list_del_init(cwq->worklist.next);
> > + cpu = smp_processor_id();
> > spin_unlock_irq(&cwq->lock);
> > + did_work = 1;
> > +
> > + /*
> > + * If work->cpu isn't us, then we need to create the target
> > + * workqueue thread (if someone didn't already do that) and
> > + * move the work over there.
> > + */
> > + if ((cwq->wq->flags & WQ_F_LAZY) && work->cpu != cpu) {
> > + struct cpu_workqueue_struct *__cwq;
> > + struct task_struct *p;
> > + int err;
> > +
> > + __cwq = wq_per_cpu(cwq->wq, work->cpu);
> > + p = __cwq->thread;
> > + if (!p)
> > + err = create_workqueue_thread(__cwq, work->cpu);
> > + p = __cwq->thread;
> > + if (p) {
> > + if (work->cpu >= 0)
>
> It's an unsigned int. This test is always true.
>
> > + kthread_bind(p, work->cpu);
>
> I wonder what happens if work->cpu isn't online any more.
That's a good question. The workqueue "documentation" states that it is
the callers responsibility to ensure that the CPU stays online, but I
think that requirement is pretty much ignored. Probably since it'd be
costly to do.
So that bits needs looking into.
--
Jens Axboe
next prev parent reply other threads:[~2009-08-24 8:06 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-20 10:17 [PATCH 0/6] Lazy workqueues Jens Axboe
2009-08-20 10:17 ` [PATCH 1/4] direct-io: unify argument passing by adding a dio_args structure Jens Axboe
2009-08-20 10:17 ` [PATCH 1/6] workqueue: replace singlethread/freezable/rt parameters and variables with flags Jens Axboe
2009-08-20 10:17 ` [PATCH 2/4] direct-io: make O_DIRECT IO path be page based Jens Axboe
2009-08-20 10:17 ` [PATCH 2/6] workqueue: add support for lazy workqueues Jens Axboe
2009-08-20 10:17 ` [PATCH 3/6] crypto: use " Jens Axboe
2009-08-20 10:17 ` [PATCH 3/4] direct-io: add a "IO for kernel" flag to kiocb Jens Axboe
2009-08-20 10:17 ` [PATCH 4/6] libata: use lazy workqueues for the pio task Jens Axboe
2009-08-20 10:17 ` [PATCH 4/5] loop: support O_DIRECT transfer mode Jens Axboe
2009-08-20 10:17 ` [PATCH 5/6] aio: use lazy workqueues Jens Axboe
2009-08-20 10:17 ` [PATCH 4/4] direct-io: get rid of irq flag saving where it isn't needed Jens Axboe
2009-08-20 10:17 ` [PATCH 6/6] sunrpc: use lazy workqueues Jens Axboe
2009-08-21 0:20 ` [PATCH 2/6] workqueue: add support for " Andrew Morton
2009-08-24 8:06 ` Jens Axboe [this message]
2009-08-20 13:19 ` [PATCH 2/4] direct-io: make O_DIRECT IO path be page based Trond Myklebust
2009-08-24 7:58 ` Jens Axboe
2009-08-21 0:12 ` Andrew Morton
2009-08-24 8:00 ` Jens Axboe
2009-08-21 0:03 ` [PATCH 1/4] direct-io: unify argument passing by adding a dio_args structure Andrew Morton
2009-08-24 7:58 ` Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2009-08-20 10:19 [PATCH 0/6] Lazy workqueues Jens Axboe
2009-08-20 10:20 ` [PATCH 2/6] workqueue: add support for lazy workqueues Jens Axboe
2009-08-20 12:01 ` Frederic Weisbecker
2009-08-20 12:10 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090824080626.GD12579@kernel.dk \
--to=jens.axboe@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=benh@kernel.crashing.org \
--cc=bzolnier@gmail.com \
--cc=htejun@gmail.com \
--cc=jeff@garzik.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.