Re: [PATCH] workqueue: Make a warning when a pending delay work being re-init

From: Tejun Heo
Date: Wed Nov 15 2023 - 21:58:40 EST


Hello,

On Wed, Nov 15, 2023 at 07:34:27PM +0800, huangzaiyang wrote:
> @@ -310,6 +326,7 @@ static inline unsigned int work_static(struct work_struct *work) { return 0; }
>
> #define __INIT_DELAYED_WORK(_work, _func, _tflags) \
> do { \
> + WARN_ON(delayed_work_pending(_work)); \
> INIT_WORK(&(_work)->work, (_func)); \
> __init_timer(&(_work)->timer, \
> delayed_work_timer_fn, \

As pointed out by others, as we don't know what's in the memory, this
wouldn't really work. This kind of bugs should be caught by
DEBUG_OBJECTS_WORK / DEBUG_OBJECTS_TIMERS, I think. It's not perfect as
those aren't usually turned on but catching this sort of errors does need
tracking some information out of band.

Thanks.

--
tejun