From: Andi Kleen <andi@firstfloor.org>
To: Arjan van de Ven <arjan@infradead.org>
Cc: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
mingo@elte.hu, fweisbec@gmail.com, linux-scsi@vger.kernel.org,
linux-ide@vger.kernel.org, linux-acpi@vger.kernel.org,
akpm@linux-foundation.org
Subject: Re: [PATCH 1/4] fastboot: Asynchronous function calls to speed up kernel boot
Date: Sun, 04 Jan 2009 20:05:26 +0100 [thread overview]
Message-ID: <87k59aops9.fsf@basil.nowhere.org> (raw)
In-Reply-To: <20090104092857.5fbf6b2d@infradead.org> (Arjan van de Ven's message of "Sun, 4 Jan 2009 09:28:57 -0800")
Arjan van de Ven <arjan@infradead.org> writes:
> +static int async_manager_thread(void *unused)
> +{
> + int max_threads;
> + DECLARE_WAITQUEUE(wq, current);
> + add_wait_queue(&async_new, &wq);
> +
> + while (!kthread_should_stop()) {
> + int tc, ec;
> +
> + /*
> + * Maximum number of worker threads.
> + * Even on the smallest machine we want 8
> + * Scaling by 4 per logical CPU
> + * But no more than 256 to not overload stuff too much
> + * (and yes these are magic numbers that might need tuning)
> + * Calculated dynamic because early on the nr of online cpus
> + * is 1...
> + */
> + max_threads = 4 + 4 * num_online_cpus();
> + if (max_threads > 256)
> + max_threads = 256;
> +
> +
> + set_current_state(TASK_INTERRUPTIBLE);
> +
> + tc = atomic_read(&thread_count);
> + rmb();
> + ec = atomic_read(&entry_count);
> +
> + while (tc < ec && tc < max_threads) {
> + kthread_run(async_thread, NULL, "async/%i", tc);
> + atomic_inc(&thread_count);
> + tc++;
> + }
> +
> + schedule();
Surely the thread should die again boot up? On module load
synchronisity is usually not a problem.
Personally I think it would be better to make this more generic.
Various subsystems have thread pool implementations now, and this
is just another variant that except for the sequence stuff
isn't all that much different. So it would be better to have
a generic worker thread manager that just supports these
barriers too.
-andi
--
ak@linux.intel.com
next prev parent reply other threads:[~2009-01-04 19:04 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-04 17:24 [PATCH 0/4] Fastboot revisited: Asynchronous function calls Arjan van de Ven
2009-01-04 17:28 ` [PATCH 1/4] fastboot: Asynchronous function calls to speed up kernel boot Arjan van de Ven
2009-01-04 18:33 ` Linus Torvalds
2009-01-04 18:40 ` Arjan van de Ven
2009-01-04 18:49 ` Arjan van de Ven
2009-01-04 19:05 ` Andi Kleen [this message]
2009-01-04 19:09 ` Arjan van de Ven
2009-01-04 19:49 ` Andi Kleen
2009-01-04 19:52 ` Andrew Morton
2009-01-04 17:29 ` [PATCH 2/4] fastboot: make scsi probes asynchronous Arjan van de Ven
2009-01-04 18:05 ` Matthew Wilcox
2009-01-04 18:13 ` Arjan van de Ven
2009-01-04 18:38 ` Jaswinder Singh Rajput
2009-01-04 18:44 ` Arjan van de Ven
2009-01-04 17:30 ` [PATCH 3/4] fastboot: make the libata port scan asynchronous Arjan van de Ven
2009-01-04 17:31 ` [PATCH 4/4] fastboot: make ACPI bus drivers probe asynchronous Arjan van de Ven
2009-01-05 2:03 ` Zhao Yakui
2009-01-05 1:58 ` Arjan van de Ven
2009-01-05 2:51 ` Zhao Yakui
2009-01-05 2:51 ` Arjan van de Ven
2009-01-05 5:30 ` Zhao Yakui
2009-01-04 18:16 ` [PATCH 0/4] Fastboot revisited: Asynchronous function calls Linus Torvalds
2009-01-04 18:31 ` Arjan van de Ven
2009-01-04 18:54 ` Linus Torvalds
2009-01-04 19:05 ` Arjan van de Ven
2009-01-04 19:11 ` Linus Torvalds
2009-01-04 19:19 ` Arjan van de Ven
2009-01-05 16:21 ` Alan Cox
2009-01-05 21:13 ` Arjan van de Ven
2009-01-05 21:21 ` Linus Torvalds
2009-01-04 19:11 ` Andi Kleen
2009-01-04 19:46 ` Robert Hancock
2009-01-04 19:27 ` Linus Torvalds
2009-01-04 19:48 ` Arjan van de Ven
2009-01-04 21:44 ` Alan Cox
2009-01-11 13:14 ` Pavel Machek
2009-01-05 6:01 ` Nigel Cunningham
2009-01-05 8:47 ` Frederic Weisbecker
2009-01-05 10:53 ` Arjan van de Ven
2009-01-05 11:18 ` Nigel Cunningham
2009-01-07 2:41 ` Shaohua Li
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=87k59aops9.fsf@basil.nowhere.org \
--to=andi@firstfloor.org \
--cc=akpm@linux-foundation.org \
--cc=arjan@infradead.org \
--cc=fweisbec@gmail.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=torvalds@linux-foundation.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).