Skip to content

Commit 868202e

Browse files
darkgregkh
authored andcommitted
idpf: convert workqueues to unbound
[ Upstream commit 9a5b021 ] When a workqueue is created with `WQ_UNBOUND`, its work items are served by special worker-pools, whose host workers are not bound to any specific CPU. In the default configuration (i.e. when `queue_delayed_work` and friends do not specify which CPU to run the work item on), `WQ_UNBOUND` allows the work item to be executed on any CPU in the same node of the CPU it was enqueued on. While this solution potentially sacrifices locality, it avoids contention with other processes that might dominate the CPU time of the processor the work item was scheduled on. This is not just a theoretical problem: in a particular scenario misconfigured process was hogging most of the time from CPU0, leaving less than 0.5% of its CPU time to the kworker. The IDPF workqueues that were using the kworker on CPU0 suffered large completion delays as a result, causing performance degradation, timeouts and eventual system crash. Tested: * I have also run a manual test to gauge the performance improvement. The test consists of an antagonist process (`./stress --cpu 2`) consuming as much of CPU 0 as possible. This process is run under `taskset 01` to bind it to CPU0, and its priority is changed with `chrt -pQ 9900 10000 ${pid}` and `renice -n -20 ${pid}` after start. Then, the IDPF driver is forced to prefer CPU0 by editing all calls to `queue_delayed_work`, `mod_delayed_work`, etc... to use CPU 0. Finally, `ktraces` for the workqueue events are collected. Without the current patch, the antagonist process can force arbitrary delays between `workqueue_queue_work` and `workqueue_execute_start`, that in my tests were as high as `30ms`. With the current patch applied, the workqueue can be migrated to another unloaded CPU in the same node, and, keeping everything else equal, the maximum delay I could see was `6us`. Fixes: 0fe4546 ("idpf: add create vport and netdev configuration") Signed-off-by: Marco Leogrande <[email protected]> Signed-off-by: Manoj Vishwanathan <[email protected]> Signed-off-by: Brian Vazquez <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Reviewed-by: Pavan Kumar Linga <[email protected]> Tested-by: Krishneil Singh <[email protected]> Signed-off-by: Tony Nguyen <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 8a2f823 commit 868202e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

drivers/net/ethernet/intel/idpf/idpf_main.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
174174
pci_set_master(pdev);
175175
pci_set_drvdata(pdev, adapter);
176176

177-
adapter->init_wq = alloc_workqueue("%s-%s-init", 0, 0,
177+
adapter->init_wq = alloc_workqueue("%s-%s-init",
178+
WQ_UNBOUND | WQ_MEM_RECLAIM, 0,
178179
dev_driver_string(dev),
179180
dev_name(dev));
180181
if (!adapter->init_wq) {
@@ -183,7 +184,8 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
183184
goto err_free;
184185
}
185186

186-
adapter->serv_wq = alloc_workqueue("%s-%s-service", 0, 0,
187+
adapter->serv_wq = alloc_workqueue("%s-%s-service",
188+
WQ_UNBOUND | WQ_MEM_RECLAIM, 0,
187189
dev_driver_string(dev),
188190
dev_name(dev));
189191
if (!adapter->serv_wq) {
@@ -192,7 +194,8 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
192194
goto err_serv_wq_alloc;
193195
}
194196

195-
adapter->mbx_wq = alloc_workqueue("%s-%s-mbx", 0, 0,
197+
adapter->mbx_wq = alloc_workqueue("%s-%s-mbx",
198+
WQ_UNBOUND | WQ_MEM_RECLAIM, 0,
196199
dev_driver_string(dev),
197200
dev_name(dev));
198201
if (!adapter->mbx_wq) {
@@ -201,7 +204,8 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
201204
goto err_mbx_wq_alloc;
202205
}
203206

204-
adapter->stats_wq = alloc_workqueue("%s-%s-stats", 0, 0,
207+
adapter->stats_wq = alloc_workqueue("%s-%s-stats",
208+
WQ_UNBOUND | WQ_MEM_RECLAIM, 0,
205209
dev_driver_string(dev),
206210
dev_name(dev));
207211
if (!adapter->stats_wq) {
@@ -210,7 +214,8 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
210214
goto err_stats_wq_alloc;
211215
}
212216

213-
adapter->vc_event_wq = alloc_workqueue("%s-%s-vc_event", 0, 0,
217+
adapter->vc_event_wq = alloc_workqueue("%s-%s-vc_event",
218+
WQ_UNBOUND | WQ_MEM_RECLAIM, 0,
214219
dev_driver_string(dev),
215220
dev_name(dev));
216221
if (!adapter->vc_event_wq) {

0 commit comments

Comments
 (0)