Skip to content

Commit 71c9ce2

Browse files
beldzhangaxboe
authored andcommitted
io-wq: fix max-workers not correctly set on multi-node system
In io-wq.c:io_wq_max_workers(), new_count[] was changed right after each node's value was set. This caused the following node getting the setting of the previous one. Returned values are copied from node 0. Fixes: 2e48005 ("io-wq: provide a way to limit max number of workers") Signed-off-by: Beld Zhang <[email protected]> [axboe: minor fixups] Signed-off-by: Jens Axboe <[email protected]>
1 parent 9881024 commit 71c9ce2

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

fs/io-wq.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,9 @@ int io_wq_cpu_affinity(struct io_wq *wq, cpumask_var_t mask)
13081308
*/
13091309
int io_wq_max_workers(struct io_wq *wq, int *new_count)
13101310
{
1311-
int i, node, prev = 0;
1311+
int prev[IO_WQ_ACCT_NR];
1312+
bool first_node = true;
1313+
int i, node;
13121314

13131315
BUILD_BUG_ON((int) IO_WQ_ACCT_BOUND != (int) IO_WQ_BOUND);
13141316
BUILD_BUG_ON((int) IO_WQ_ACCT_UNBOUND != (int) IO_WQ_UNBOUND);
@@ -1319,6 +1321,9 @@ int io_wq_max_workers(struct io_wq *wq, int *new_count)
13191321
new_count[i] = task_rlimit(current, RLIMIT_NPROC);
13201322
}
13211323

1324+
for (i = 0; i < IO_WQ_ACCT_NR; i++)
1325+
prev[i] = 0;
1326+
13221327
rcu_read_lock();
13231328
for_each_node(node) {
13241329
struct io_wqe *wqe = wq->wqes[node];
@@ -1327,14 +1332,19 @@ int io_wq_max_workers(struct io_wq *wq, int *new_count)
13271332
raw_spin_lock(&wqe->lock);
13281333
for (i = 0; i < IO_WQ_ACCT_NR; i++) {
13291334
acct = &wqe->acct[i];
1330-
prev = max_t(int, acct->max_workers, prev);
1335+
if (first_node)
1336+
prev[i] = max_t(int, acct->max_workers, prev[i]);
13311337
if (new_count[i])
13321338
acct->max_workers = new_count[i];
1333-
new_count[i] = prev;
13341339
}
13351340
raw_spin_unlock(&wqe->lock);
1341+
first_node = false;
13361342
}
13371343
rcu_read_unlock();
1344+
1345+
for (i = 0; i < IO_WQ_ACCT_NR; i++)
1346+
new_count[i] = prev[i];
1347+
13381348
return 0;
13391349
}
13401350

0 commit comments

Comments
 (0)