Re: [PATCH V2 4/5] workqueue: Put PWQ allocation and WQ enlistment in the same lock C.S.

From: Tejun Heo
Date: Mon Jul 08 2024 - 14:16:43 EST


Hello,

On Mon, Jul 08, 2024 at 03:54:19PM +0800, kernel test robot wrote:
...
> [ 2.269463][ T1] cpus_read_lock (include/linux/percpu-rwsem.h:53 kernel/cpu.c:488)
> [ 2.273463][ T1] alloc_workqueue (kernel/workqueue.c:5152 kernel/workqueue.c:5730)
> [ 2.273463][ T1] padata_alloc (kernel/padata.c:1007 (discriminator 1))
> [ 2.273463][ T1] pcrypt_init_padata (crypto/pcrypt.c:327 (discriminator 1))
> [ 2.277463][ T1] pcrypt_init (crypto/pcrypt.c:353)
> [ 2.277463][ T1] do_one_initcall (init/main.c:1267)
> [ 2.281464][ T1] do_initcalls (init/main.c:1328 (discriminator 1) init/main.c:1345 (discriminator 1))
> [ 2.281464][ T1] kernel_init_freeable (init/main.c:1364)
> [ 2.285464][ T1] kernel_init (init/main.c:1469)
> [ 2.285464][ T1] ret_from_fork (arch/x86/kernel/process.c:153)
> [ 2.289466][ T1] ret_from_fork_asm (arch/x86/entry/entry_32.S:737)
> [ 2.289466][ T1] entry_INT80_32 (arch/x86/entry/entry_32.S:944)

Ah, this is unfortunate, so pcrypt is allocating a workqueue while holding
cpus_read_lock(), so workqueue code can't do it again as that can lead to
deadlocks if down_write starts after the first down_read. Lai, it looks like
we'd need to switch to workqueue specific locking so that we don't depend on
cpus_read_lock from alloc path.

Thanks.

--
tejun