Re: init's children list is long and slows reaping children.

Dave Jones
2007-04-10T01:59:33Z

On Mon, Apr 09, 2007 at 05:23:39PM -0700, Andrew Morton wrote:

> I suspect there are quite a few kernel threads which don't really need to
> be threads at all: the code would quite happily work if it was changed to
> use keventd, via schedule_work() and friends. But kernel threads are
> somewhat easier to code for.

Perhaps too easy. We have a bunch of kthreads sitting around that afaict,
are there 'just in case', not because they're actually in use.

10 ? S< 0:00 [khelper]

Why doesn't this get spawned when it needs to?

164 ? S< 0:00 [cqueue/0]
165 ? S< 0:00 [cqueue/1]

I'm not even sure wth these are.

166 ? S< 0:00 [ksuspend_usbd]

Just in case I decide to suspend ? Sounds.. handy.
But why not spawn this just after we start a suspend?

209 ? S< 0:00 [aio/0]
210 ? S< 0:00 [aio/1]

I'm sure I'd appreciate these a lot more if I had any AIO using apps.

364 ? S< 0:00 [kpsmoused]

I never did figure out why this was a thread.

417 ? S< 0:00 [scsi_eh_1]
418 ? S< 0:00 [scsi_eh_2]
419 ? S< 5:28 [scsi_eh_3]
426 ? S< 0:00 [scsi_eh_4]
427 ? S< 0:00 [scsi_eh_5]
428 ? S< 0:00 [scsi_eh_6]
429 ? S< 0:00 [scsi_eh_7]

Just in case my 7-1 in card reader gets an error.
(Which is unlikely on at least 6 of the slots as evidenced by the runtime column.
-- Though now I'm curious as to why the error handler was running so much given
I've not experienced any errors.).
This must be a fun one of on huge diskfarms.

884 ? S< 0:00 [kgameportd]

Just in case I ever decide to plug something into my soundcard.

2179 ? S< 0:00 [kmpathd/0]
2180 ? S< 0:00 [kmpathd/1]
2189 ? S< 0:00 [kmirrord]

Just loading the modules starts up the threads, regardless
of whether you use them. (Not sure why they're getting loaded,
something for me to look into)

3246 ? S< 0:00 [krfcommd]

I don't even *have* bluetooth hardware.
(Yes, the module shouldn't have loaded, but that's another battle..)

> otoh, a lot of these inefficeincies are probably down in scruffy drivers
> rather than in core or top-level code.

You say scruffy, but most of the proliferation of kthreads comes
from code written in the last few years. Compare the explosion of kthreads
we see coming from 2.4 to 2.6. It's disturbing, and I don't see it
slowing down at all.

On the 2-way box I grabbed the above ps output from, I end up with 69 kthreads.
It doesn't surprise me at all that bigger iron is starting to see issues.

Dave

--