From: Tejun Heo <htejun@gmail.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Jeff Garzik <jeff@garzik.org>, Jens Axboe <jens.axboe@oracle.com>,
Mark Lord <liml@rtr.ca>,
linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org,
Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [PATCH] libata: use single threaded work queue
Date: Thu, 20 Aug 2009 00:53:54 +0900 [thread overview]
Message-ID: <4A8C2012.6090809@gmail.com> (raw)
In-Reply-To: <20090819162147.16aeb2db@lxorguk.ukuu.org.uk>
Hello, Alan.
Alan Cox wrote:
> Somewhat simpler for the general case would be to implement
Yeah, it would be great if there's a much simpler solution. Latency
based one could be a good compromise.
> create_workqueue(min_threads,max_threads, max_thread_idle_time);
> queue_work_within();
>
> at which point you can queue work to the workqueue but with a per
> workqueue timing running so you know when you might need to create a new
> thread if the current work hasn't finished. Idle threads would then sleep
> and either expire or pick up new work - so that under load we don't keep
> destructing threads.
Are work threads per workqueue? Combined with per-cpu binding,
dynamic thread pool per workqueue can get quite messy. All three
factors end up getting multiplied - ie. #cpus * pool_size which can be
enlarged by the same work hopping around * #workqueues.
> That might need a single thread (for the system) that does nothing but
> create workqueue threads to order. It could manage the "next workqueue
> deadline" timer and thread creation.
Another problem is that if we apply this to the existing default
workqueue which is used by many different supposed-to-be-short works
in essentially batch mode, we might end up enlarging cache footprint
by scheduling unnecessarily many threads, which, in tight situations,
might show up as small but noticeable performance regression.
> The threads would then pick up their work queue work. There is an
> intrinsic race where if we are just on the limit we might create a
> thread just as there is no work to be done - but it would be rare
> and would just then go away.
Agreed. As long as the pool size is reduced gradually maybe with some
buffer, I don't think this would be an issue.
> I see no point tring to fix ata when applying sanity to the workqueue
> logic would sort a lot of other cases out nicely.
About the same problem exists for in-kernel media presence polling.
Currently, I'm thinking about creating a worker thread per any device
which requires polling. It isn't too bad but it would still be far
better if I can just schedule a work and don't have to worry about
managing concurrency.
Thanks.
--
tejun
next prev parent reply other threads:[~2009-08-19 15:54 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-19 11:25 [PATCH] libata: use single threaded work queue Jens Axboe
2009-08-19 11:59 ` Jeff Garzik
2009-08-19 12:04 ` Jens Axboe
2009-08-19 12:14 ` Mark Lord
2009-08-19 12:23 ` Jens Axboe
2009-08-19 13:22 ` Jeff Garzik
2009-08-19 13:28 ` Jeff Garzik
2009-08-19 14:11 ` Tejun Heo
2009-08-19 15:21 ` Alan Cox
2009-08-19 15:53 ` Tejun Heo [this message]
2009-08-19 16:15 ` Alan Cox
2009-08-19 16:58 ` Tejun Heo
2009-08-19 17:23 ` Alan Cox
2009-08-20 12:46 ` Tejun Heo
2009-08-20 11:39 ` Stefan Richter
2009-08-20 12:11 ` Stefan Richter
2009-08-19 22:22 ` Benjamin Herrenschmidt
2009-08-20 12:47 ` Tejun Heo
2009-08-20 12:48 ` Tejun Heo
2009-08-20 14:28 ` James Bottomley
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=4A8C2012.6090809@gmail.com \
--to=htejun@gmail.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=benh@kernel.crashing.org \
--cc=jeff@garzik.org \
--cc=jens.axboe@oracle.com \
--cc=liml@rtr.ca \
--cc=linux-ide@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).