Re: [PATCH] checkpatch: warn about flushing system-wide workqueues

From: Tetsuo Handa
Date: Thu May 05 2022 - 19:29:40 EST


On 2022/05/06 2:32, Tejun Heo wrote:
> Given that we'll need runtime check anyway, why not resurrect the original
> runtime warning but exempt flush_schedule_work() if that's the only thing
> remaining right now (using a special flag or whatever)?

Yes, we will also need runtime check for robustness, for we can't catch usage
like

struct workqueue_struct *my_wq = alloc_workqueue();
if (!my_wq)
my_wq = system_long_wq;
flush_workqueue(my_wq);

using compile time checks.

I found that it is not easy to trigger flush_workqueue() paths. For example,
several modules are using flush_workqueue() only upon module unloading.
Therefore, I'm trying to catch obvious flush_workqueue() paths at compile
time when possible.

> If we're sure that
> we aren't triggering it spuriously, we can ask Andrew to take the warning
> patch into -mm so that it floats on top of everything else and gets pulled
> into the trunk during the coming merge window.

OK, the coming merge window means 5.19.

The original runtime checking will be used anyway. Is "workqueue: Wrap
flush_workqueue() using a macro" OK for you as a compile time check?