Re: [PATCH] random: Fix kernel panic due to system_wq use before init

From: Waiman Long
Date: Wed Sep 14 2016 - 15:25:10 EST


On 09/14/2016 03:14 PM, Linus Torvalds wrote:
Ugh, I detest this patch.

My gut feeling is that a driver (even a fairly core one like the
random code) should not have to know these kinds of details like
"schedule_work() needs system_wq to have been initialized".

I'm wondering if we couldn't just initialize "system_wq" earlier.
Right now init_workqueues() is an "early_initcall()", so it's at the
same priority as a number of other random early initcalls. My gut
feeling is that it should be initialized even earlier, with the
scheduler.

Because dammit, we use "schedule_work()" as if it was a pretty core
scheduler thing, and having to have some odd knowledge of system_wq
initialization details in the rest of the kernel sounds really really
wrong.

I don't think the random code is at all special in maybe wanting to
schedule some work despite being an "early" initcall.

Adding Tejun to the cc, and quoting the whole email.

Tejun, comments?

Linus



My patch does not really fix the boot problem as detailed in my follow-up email. It serves mostly to jump start the discussion on the problem that I saw. The schedule_work() call was issued as part of interrupt handling that seems to be started pretty early in the boot process before the early_initcall. I guess it is possible to move the initialization earlier, but I am not sure where will be a good place.

Cheers,
Longman