In realtime scenario, We do not want to have interference on the isolated cpu cores. but when invoking alloc_workqueue() for percpu wq on the housekeeping cpu, it kick a kworker on the isolated cpu. alloc_workqueue pwq_adjust_max_active wake_up_worker The comment in pwq_adjust_max_active() said: "Need to kick a worker after thawed or an unbound wq's max_active is bumped" So it is unnecessary to kick a kworker for percpu's wq when invoking alloc_workqueue(). this patch only kick a worker based on the actual activation of delayed works.
Showing the changes to kernel/workqueue.c (1 of 1 file). Show all
Unified · Split
| @@ -3728,17 +3728,24 @@ static void pwq_adjust_max_active(struct pool_workqueue *pwq) · 3727 unmodified lines | ||
| 3728 | 3728 | * is updated and visible. |
| 3729 | 3729 | */ |
| 3730 | 3730 | if (!freezable || !workqueue_freezing) { |
| 3731 | + bool kick = false; | |
| 3732 | + | |
| 3731 | 3733 | pwq->max_active = wq->saved_max_active; |
| 3732 | 3734 | |
| 3733 | 3735 | while (!list_empty(&pwq->delayed_works) && |
| 3734 | − pwq->nr_active < pwq->max_active) | |
| 3736 | + pwq->nr_active < pwq->max_active) { | |
| 3735 | 3737 | pwq_activate_first_delayed(pwq); |
| 3738 | + kick = true; | |
| 3739 | + } | |
| 3736 | 3740 | |
| 3737 | 3741 | /* |
| 3738 | 3742 | * Need to kick a worker after thawed or an unbound wq's |
| 3739 | − * max_active is bumped. It's a slow path. Do it always. | |
| 3743 | + * max_active is bumped. In realtime scenarios, always kicking a | |
| 3744 | + * worker will cause interference on the isolated cpu cores, so | |
| 3745 | + * let's kick iff work items were activated. | |
| 3740 | 3746 | */ |
| 3741 | − wake_up_worker(pwq->pool); | |
| 3747 | + if (kick) | |
| 3748 | + wake_up_worker(pwq->pool); | |
| 3742 | 3749 | } else { |
| 3743 | 3750 | pwq->max_active = 0; |
| 3744 | 3751 | } |