linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH rt-tests v1 0/3] Fix a few fallouts
@ 2021-07-04 20:36 Daniel Wagner
  2021-07-04 20:36 ` [PATCH rt-tests v1 1/3] rt-numa: Use sched_getaffinity() instead of pthread_getaffinity_np() Daniel Wagner
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Daniel Wagner @ 2021-07-04 20:36 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

From: Daniel Wagner <dwagner@suse.de>

Another round of small cleanups and fixes.

The first one fixes static builds for armhf host. Patch two is another
of the printf format specifier which I got wrong. No idea why we
didn't see this earlier. Anyway gcc on armhf was not happy. The same
for the third fix. Why the gcc on armhf complains and not on anything
else, is dubios to me.

Daniel Wagner (3):
  rt-numa: Use sched_getaffinity() instead of pthread_getaffinity_np()
  signaltest: Fix printf format specifier
  cyclicdeadline: Fix buffer allocation

 src/lib/rt-numa.c                   | 4 +---
 src/sched_deadline/cyclicdeadline.c | 2 +-
 src/signaltest/signaltest.c         | 6 +++---
 3 files changed, 5 insertions(+), 7 deletions(-)

-- 
2.32.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH rt-tests v1 1/3] rt-numa: Use sched_getaffinity() instead of pthread_getaffinity_np()
  2021-07-04 20:36 [PATCH rt-tests v1 0/3] Fix a few fallouts Daniel Wagner
@ 2021-07-04 20:36 ` Daniel Wagner
  2021-07-04 20:36 ` [PATCH rt-tests v1 2/3] signaltest: Fix printf format specifier Daniel Wagner
  2021-07-04 20:36 ` [PATCH rt-tests v1 3/3] cyclicdeadline: Fix buffer allocation Daniel Wagner
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Wagner @ 2021-07-04 20:36 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

From: Daniel Wagner <dwagner@suse.de>

pthread_getaffinity_np() prevents static builds as glibc does not
expose it for this configuration. Instead use sched_getaffinity()
which is always present and has the exact same semantics.

Fixes: f240656b056b ("rt-tests: cyclictest: Fix -t without a user specified [NUM]")

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/lib/rt-numa.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/lib/rt-numa.c b/src/lib/rt-numa.c
index babcc634d57e..2d34ae36cc03 100644
--- a/src/lib/rt-numa.c
+++ b/src/lib/rt-numa.c
@@ -68,13 +68,11 @@ int cpu_for_thread_sp(int thread_num, int max_cpus, struct bitmask *cpumask)
 int cpu_for_thread_ua(int thread_num, int max_cpus)
 {
 	int res, num_cpus, i, m, cpu;
-	pthread_t thread;
 	cpu_set_t cpuset;
 
-	thread = pthread_self();
 	CPU_ZERO(&cpuset);
 
-	res = pthread_getaffinity_np(thread, sizeof(cpu_set_t), &cpuset);
+	res = sched_getaffinity(0, sizeof(cpu_set_t), &cpuset);
 	if (res != 0)
 		fatal("pthread_getaffinity_np failed: %s\n", strerror(res));
 
-- 
2.32.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH rt-tests v1 2/3] signaltest: Fix printf format specifier
  2021-07-04 20:36 [PATCH rt-tests v1 0/3] Fix a few fallouts Daniel Wagner
  2021-07-04 20:36 ` [PATCH rt-tests v1 1/3] rt-numa: Use sched_getaffinity() instead of pthread_getaffinity_np() Daniel Wagner
@ 2021-07-04 20:36 ` Daniel Wagner
  2021-07-04 20:36 ` [PATCH rt-tests v1 3/3] cyclicdeadline: Fix buffer allocation Daniel Wagner
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Wagner @ 2021-07-04 20:36 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

From: Daniel Wagner <dwagner@suse.de>

The fields are not uint64 just longs, update the printf format
specifiers.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/signaltest/signaltest.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
index 6e8f6b51b003..4d89a1aba9d9 100644
--- a/src/signaltest/signaltest.c
+++ b/src/signaltest/signaltest.c
@@ -393,9 +393,9 @@ static void write_stats(FILE *f, void *data)
 	for (i = 0; i < num_threads; i++) {
 		fprintf(f, "    \"%u\": {\n", i);
 		s = &par->stats[i];
-		fprintf(f, "      \"cycles\": %" PRIu64 ",\n", s->cycles);
-		fprintf(f, "      \"min\": %" PRIu64 ",\n", s->min);
-		fprintf(f, "      \"max\": %" PRIu64 ",\n", s->max);
+		fprintf(f, "      \"cycles\": %ld,\n", s->cycles);
+		fprintf(f, "      \"min\": %ld,\n", s->min);
+		fprintf(f, "      \"max\": %ld,\n", s->max);
 		fprintf(f, "      \"avg\": %.2f,\n", s->avg/s->cycles);
 		fprintf(f, "      \"cpu\": %d\n", par->cpu);
 		fprintf(f, "    }%s\n", i == num_threads - 1 ? "" : ",");
-- 
2.32.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH rt-tests v1 3/3] cyclicdeadline: Fix buffer allocation
  2021-07-04 20:36 [PATCH rt-tests v1 0/3] Fix a few fallouts Daniel Wagner
  2021-07-04 20:36 ` [PATCH rt-tests v1 1/3] rt-numa: Use sched_getaffinity() instead of pthread_getaffinity_np() Daniel Wagner
  2021-07-04 20:36 ` [PATCH rt-tests v1 2/3] signaltest: Fix printf format specifier Daniel Wagner
@ 2021-07-04 20:36 ` Daniel Wagner
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Wagner @ 2021-07-04 20:36 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

From: Daniel Wagner <dwagner@suse.de>

gcc complains with "‘sprintf’ output between 2 and 12 bytes" but
the buffer is only 10 bytes long. Update the buffer size to hold
the complete range of [-2147483648, 2147483646].

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/sched_deadline/cyclicdeadline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index ffefa9e6fecb..8447424273ee 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -1092,7 +1092,7 @@ int main(int argc, char **argv)
 
 	/* Default cpu to use is the last one */
 	if (!all_cpus && !setcpu) {
-		setcpu_buf = malloc(10);
+		setcpu_buf = malloc(12);
 		if (!setcpu_buf)
 			fatal("malloc");
 		sprintf(setcpu_buf, "%d", cpu_count - 1);
-- 
2.32.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-04 20:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-04 20:36 [PATCH rt-tests v1 0/3] Fix a few fallouts Daniel Wagner
2021-07-04 20:36 ` [PATCH rt-tests v1 1/3] rt-numa: Use sched_getaffinity() instead of pthread_getaffinity_np() Daniel Wagner
2021-07-04 20:36 ` [PATCH rt-tests v1 2/3] signaltest: Fix printf format specifier Daniel Wagner
2021-07-04 20:36 ` [PATCH rt-tests v1 3/3] cyclicdeadline: Fix buffer allocation Daniel Wagner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).