Some miscellanous fixes
cover Some miscellanous fixes
Just a few miscellanous fixes here, nothing big.
Daniel Wagner (1):
rt-numa: Use sched_getaffinity() instead of pthread_getaffinity_np()
John Kacur (7):
rt-tests: deadline_test: Move va_start forward
rt-tests: deadline_test: Remove deadcode
rt-tests: ptsematest: Remove deadcode
rt-tests: pi_stress: Don't call free on alloca
rt-tests: pip_stress: Add missing paramater in error message
rt-tests: pi_stress: Add missing parameter and fix types
rt-tests: deadline_test: Exit with message if threads less than 1
src/lib/rt-numa.c | 6 ++---- src/pi_tests/pi_stress.c | 12 ++++-------- src/pi_tests/pip_stress.c | 2 +- src/ptsematest/ptsematest.c | 6 ------ src/sched_deadline/deadline_test.c | 13 +++++++------ 5 files changed, 14 insertions(+), 25 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/8 rt-tests: deadline_test: Move va_start forward
If open_cpuset fails then we return without calling va_end Fixing this by moving the call to va_start after that.
--- src/sched_deadline/deadline_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
src/sched_deadline/deadline_test.c +2 -2
@@ -728,12 +728,12 @@ static const char *make_cpuset(const char *name, const char *cpus,int *pids;int i; -va_start (ap, flags); - fd =open_cpuset (path,"tasks" );if (fd <0 )return "open tasks" ; +va_start (ap, flags); + ret =0 ; pids = va_arg(ap, int *);
Signature · 1 line
2.31.1
PATCH 2/8 rt-tests: deadline_test: Remove deadcode
In reply to John KacurRemove deadcode that was probably accidently left in during development.
--- src/sched_deadline/deadline_test.c | 4 ---- 1 file changed, 4 deletions(-)
src/sched_deadline/deadline_test.c +0 -4
@@ -873,10 +873,6 @@ static void destroy_cpuset(const char *name, int print) goto again;fprintf (stderr,"Failed to remove %s\n" , path);perror ("rmdir" ); -if (retry++ <5 ) { -fprintf (stderr,"Trying again\n" ); - goto again; - } } }
Signature · 1 line
2.31.1
PATCH 3/8 rt-tests: ptsematest: Remove deadcode
In reply to John KacurRemove deadcode from ptsematest.c
--- src/ptsematest/ptsematest.c | 6 ------ 1 file changed, 6 deletions(-)
src/ptsematest/ptsematest.c +0 -6
@@ -58,7 +58,6 @@ struct params {void *semathread (void *param) {int mustgetcpu =0 ; -int first =1 ;struct params *par = param;cpu_set_t mask;int policy =SCHED_FIFO ;
@@ -92,11 +91,6 @@ void *semathread(void *param)if (mustgetcpu) par->cpu =get_cpu (); }else { -/* Receiver */ -if (!first) { -pthread_mutex_lock (&syncmutex[par->num]); - first =1 ; - }pthread_mutex_lock (&testmutex[par->num]);/* ... Got the lock: End of latency measurement */
Signature · 1 line
2.31.1
PATCH 4/8 rt-tests: pi_stress: Don't call free on alloca
In reply to John Kacurstrdupa uses alloca to allocate the buffer free should not be used on space allocated with alloca, so remove these.
--- src/pi_tests/pi_stress.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
src/pi_tests/pi_stress.c +1 -4
@@ -1259,10 +1259,8 @@ int process_sched_line(const char *arg) k =strsep (&buf, del); } -if (!id) { -free (buf); +if (!id)return FAILURE ; - }/* We do not validate the options, instead we pass all garbage * to the kernel and see what's happening */
@@ -1280,7 +1278,6 @@ int process_sched_line(const char *arg) retval =FAILURE ; } -free (buf);return retval; }
Signature · 1 line
2.31.1
PATCH 5/8 rt-tests: pip_stress: Add missing paramater in error message
In reply to John KacurAdd missing string __func__ in error message
--- src/pi_tests/pip_stress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/pi_tests/pip_stress.c +1 -1
@@ -254,7 +254,7 @@ long process_shared_mutex_available(void) res =sysconf (_SC_THREAD_PROCESS_SHARED);if (res ==-1 ) {int err = errno;/* save the error number */ -err_msg ("%s: sysconf(_SC_THREAD_PROCESS_SHARED): " ); +err_msg ("%s: sysconf(_SC_THREAD_PROCESS_SHARED): " , __func__);err_exit (err,NULL ); }#else
Signature · 1 line
2.31.1
PATCH 6/8 rt-tests: pi_stress: Add missing parameter and fix types
In reply to John KacurAdd missing parameter in message and correct type.
--- src/pi_tests/pi_stress.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
src/pi_tests/pi_stress.c +3 -4
@@ -668,7 +668,7 @@ void *low_priority(void *arg) }/* initial state */ -pi_debug ("low_priority[%d]: entering start wait (%d)\n" , p->id, +pi_debug ("low_priority[%d]: entering start wait (%ld)\n" , p->id, count++); status =pthread_barrier_wait (&p->start_barrier);if (status && status !=PTHREAD_BARRIER_SERIAL_THREAD ) {
@@ -796,7 +796,7 @@ void *med_priority(void *arg) }/* start state */ -pi_debug ("med_priority[%d]: entering start state (%d)\n" , p->id, +pi_debug ("med_priority[%d]: entering start state (%ld)\n" , p->id, count++); status =pthread_barrier_wait (&p->start_barrier);if (status && status !=PTHREAD_BARRIER_SERIAL_THREAD ) {
@@ -949,8 +949,7 @@ void *high_priority(void *arg) status =pthread_barrier_wait (&p->finish_barrier);if (status && status !=PTHREAD_BARRIER_SERIAL_THREAD ) {pi_error - ("high_priority[%d]: pthread_barrier_wait(finish): %x" , - status); + ("high_priority[%d]: pthread_barrier_wait(finish): %x" , p->id, status);return NULL ; }/* update the group stats */
Signature · 1 line
2.31.1
PATCH 7/8 rt-tests: deadline_test: Exit with message if threads less than 1
In reply to John KacurIf the user tries to run deadline_test with threads less than 1 (zero for example), then exit with an error message.
--- src/sched_deadline/deadline_test.c | 5 +++++ 1 file changed, 5 insertions(+)
src/sched_deadline/deadline_test.c +5 -0
@@ -1817,6 +1817,11 @@ int main(int argc, char **argv)exit (-1 ); } +if (nr_threads <1 ) { +fprintf (stderr,"The number of threads must be at least 1\n" ); +exit (-1 ); + } +if (setcpu) { nr_cpus =calc_nr_cpus (setcpu, &setcpu_buf);if (nr_cpus <0 ) {
Signature · 1 line
2.31.1
PATCH 8/8 rt-numa: Use sched_getaffinity() instead of pthread_getaffinity_np()
In reply to John KacurFrom: Daniel Wagner <[email protected]>
pthread_getaffinity_np() prevents static builds as glibc does not expose it for this configuration. Instead use sched_getaffinity() directly as pthread_getaffinity_np() is just a fancy glibc wrapper around sched_getaffinity().
Static builds helps in situation where the rootfs is minimal and does for example not ship libnuma.
The pthread_getaffinity_np call was introduced by
commit f240656b056b ("rt-tests: cyclictest: Fix -t without a user specified [NUM]")
- Some minor fixes to the description
--- src/lib/rt-numa.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
src/lib/rt-numa.c +2 -4
@@ -68,15 +68,13 @@ 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)); +fatal ("sched_getaffinity failed: %s\n" ,strerror (res)); num_cpus =CPU_COUNT (&cpuset); m = thread_num % num_cpus;
Signature · 1 line
2.31.1