Re: [RFC 2/5] workqueue: Warn when a new worker could not be created

From: Tejun Heo
Date: Fri Feb 03 2023 - 14:30:21 EST


On Fri, Feb 03, 2023 at 03:10:28PM +0100, Petr Mladek wrote:
> A solution would be to use a custom printk_ratelimited_wq() that would
> allow printing one message per 2 * wq_watchdog_thresh.
> Something like:
>
> #define printk_ratelimited_wq(fmt, ...) \
> ({ \
> static DEFINE_RATELIMIT_STATE(_rs, 60 * HZ, 1); \
> \
> if (__ratelimit(&_rs)) \
> printk(fmt, ##__VA_ARGS__); \
> })
>
> I admit that it is much easier than __print_create_worker_failure().
>
> The only problem might be that wq_watchdog_thresh might be modified
> at runtime. But it can be solved by sharing the same
> struct ratelimit_state rs in all printk_ratelimited_wq() calls
> and updating it together with wq_watchdog_thresh.
>
> Would you prefer the custom printk_ratelimited_wq(), please?

Yeah, I think so.

Thanks.

--
tejun