public inbox for [email protected]
 help / color / mirror / Atom feed
From: beld zhang <[email protected]>
To: [email protected]
Subject: fix max-workers not correctly set on multi-node system
Date: Tue, 2 Nov 2021 13:36:37 -0400	[thread overview]
Message-ID: <CAG7aomWpq3Gt9z9uqAQ5VCA_6pXgvVrL47yVx88xzX6bbotUXw@mail.gmail.com> (raw)

in io-wq.c: io_wq_max_workers(), new_count[] was changed right after
each node's value was set.
this cause the next node got the setting of the previous one,
following patch fixed it.

returned values are copied from node 0.

Signed-off-by: Beld Zhang <[email protected]>
---
diff --git a/fs/io-wq.c b/fs/io-wq.c
index c51691262208..b6f903fa41bd 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -1308,7 +1308,8 @@ int io_wq_cpu_affinity(struct io_wq *wq,
cpumask_var_t mask)
  */
 int io_wq_max_workers(struct io_wq *wq, int *new_count)
 {
-    int i, node, prev = 0;
+    int i, node;
+    int prev[IO_WQ_ACCT_NR];

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

+    for (i = 0; i < IO_WQ_ACCT_NR; i++)
+        prev[i] = 0;
+
     rcu_read_lock();
     for_each_node(node) {
         struct io_wqe *wqe = wq->wqes[node];
@@ -1327,13 +1331,16 @@ int io_wq_max_workers(struct io_wq *wq, int *new_count)
         raw_spin_lock(&wqe->lock);
         for (i = 0; i < IO_WQ_ACCT_NR; i++) {
             acct = &wqe->acct[i];
-            prev = max_t(int, acct->max_workers, prev);
+            if (node == 0)
+                prev[i] = max_t(int, acct->max_workers, prev[i]);
             if (new_count[i])
                 acct->max_workers = new_count[i];
-            new_count[i] = prev;
         }
         raw_spin_unlock(&wqe->lock);
     }
+    for (i = 0; i < IO_WQ_ACCT_NR; i++)
+        new_count[i] = prev[i];
+
     rcu_read_unlock();
     return 0;
 }

             reply	other threads:[~2021-11-02 17:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-02 17:36 beld zhang [this message]
2021-11-02 18:35 ` fix max-workers not correctly set on multi-node system Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAG7aomWpq3Gt9z9uqAQ5VCA_6pXgvVrL47yVx88xzX6bbotUXw@mail.gmail.com \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox