public inbox for linux-rt-users@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Wagner <dwagner@suse.de>
To: Clark Williams <williams@redhat.com>, John Kacur <jkacur@redhat.com>
Cc: linux-rt-users@vger.kernel.org, Daniel Wagner <dwagner@suse.de>,
	Peter Xu <peterx@redhat.com>
Subject: [PATCH rt-tests 2/2] oslat: Use cpuset size as upper bound
Date: Wed, 10 Feb 2021 17:54:07 +0100	[thread overview]
Message-ID: <20210210165407.9770-3-dwagner@suse.de> (raw)
In-Reply-To: <20210210165407.9770-1-dwagner@suse.de>

To assign the threads to the correct CPU we need to use the cpuset
size as upper bound for the loop and not the number of threads.

Fixes: 85b0763dacd9 ("oslat: Use parse_cpumask() from rt-numa.h")
Reported-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/oslat/oslat.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c
index d3f659b218b0..62b82098419a 100644
--- a/src/oslat/oslat.c
+++ b/src/oslat/oslat.c
@@ -742,9 +742,12 @@ int main(int argc, char *argv[])
 	n_cores = numa_bitmask_weight(cpu_set);
 
 	TEST(threads = calloc(1, n_cores * sizeof(threads[0])));
-	for (i = 0; i < n_cores; ++i)
-		if (numa_bitmask_isbitset(cpu_set, i) && move_to_core(i) == 0)
+	for (i = 0; n_cores && i < cpu_set->size; i++) {
+		if (numa_bitmask_isbitset(cpu_set, i) && move_to_core(i) == 0) {
 			threads[g.n_threads_total++].core_i = i;
+			n_cores--;
+		}
+	}
 
 	if (numa_bitmask_isbitset(cpu_set, 0) && g.rtprio)
 		printf("WARNING: Running SCHED_FIFO workload on CPU 0 may hang the thread\n");
-- 
2.30.0


  parent reply	other threads:[~2021-02-10 16:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-10 16:54 [PATCH rt-tests 0/2] oslat fixes Daniel Wagner
2021-02-10 16:54 ` [PATCH rt-tests 1/2] oslat: Print version string Daniel Wagner
2021-02-10 17:12   ` Peter Xu
2021-02-10 17:28   ` John Kacur
2021-02-10 17:33     ` Daniel Wagner
2021-02-10 17:53       ` Peter Xu
2021-02-10 18:15         ` Daniel Wagner
2021-02-10 19:26           ` Peter Xu
2021-02-10 17:59       ` John Kacur
2021-02-10 18:21         ` Daniel Wagner
2021-02-10 19:12           ` John Kacur
2021-02-11  4:32             ` John Kacur
2021-02-10 16:54 ` Daniel Wagner [this message]
2021-02-10 17:14   ` [PATCH rt-tests 2/2] oslat: Use cpuset size as upper bound Peter Xu
2021-02-11  4:28   ` John Kacur
2021-02-11 15:24     ` Peter Xu

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=20210210165407.9770-3-dwagner@suse.de \
    --to=dwagner@suse.de \
    --cc=jkacur@redhat.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=peterx@redhat.com \
    --cc=williams@redhat.com \
    /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