Re: [PATCHSET wq/for-6.9,6.10] workqueue: Implement disable/enable_work()

From: Tejun Heo
Date: Mon Feb 26 2024 - 13:39:14 EST


Hello,

Sorry about the late reply.

On Thu, Feb 22, 2024 at 12:26:35PM -0800, Allen wrote:
> I do understand the work bits, but I don't fully understand the
> concept of colors
> (work_color, flush_color). A swift overview of it would be highly appreciated.

That's just to group work items for flush_workqueue(). Let's say there are
work items which are queued in sequence, 1 to 8. Let's also say that there
are three flush_workqueue() attempts which take place after work item 2, 4
and 6. Then, the flush colors A, B, C, D are assigned so that:

work items 1 2 3 4 5 6 7 8
flush_workqueue ^ ^ ^
\-----/ \-----/ \-----/ \------~~~
flush_color A B C D

and the flush_workqueue() code waits for its preceding colors to be drained
to implement flushing.

It's just a way to keep track of the number of work items in flight which
were issued before a certain point in time. It's expensive to do that for
arbitrary number of points in time, so it just has N slots for groups and
calls them flush colors.

This shouldn't really matter for the bh conversion given that everyone
operates on individual work item.

Thanks.

--
tejun