testing/selftests/mqueue: Fix mq_perf_tests to free the allocated cpu set
PATCH 1/1 testing/selftests/mqueue: Fix mq_perf_tests to free the allocated cpu set
The selftest "mqueue/mq_perf_tests.c" use CPU_ALLOC to allocate CPU set. This cpu set is used further in pthread_attr_setaffinity_np and by pthread_create in the code. But in current code, allocated cpu set is not freed. Fix this by adding CPU_FREE after its usage is done.
--- tools/testing/selftests/mqueue/mq_perf_tests.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/mqueue/mq_perf_tests.c +1 -0
@@ -732,6 +732,7 @@ int main(int argc, char *argv[])pthread_attr_destroy (&thread_attr); } +CPU_FREE (cpu_set);if (!continuous_mode) {pthread_join (cpu_threads[0 ], &retval);shutdown ((long )retval,"perf_test_thread()" , __LINE__);
Signature · 1 line
2.35.1
Shuah Khan
maintainerQuoted 6 lines · Athira Rajeev
The selftest "
mqueue/mq_perf_tests.c" useCPU_ALLOCto allocate CPU set. This cpu set is used further inpthread_attr_setaffinity_npand bypthread_createin the code. But in current code, allocated cpu set is not freed. Fix this by addingCPU_FREEafter its usage is done.
Good find.
Quoted 11 lines
Signed-off-by Athira Rajeev <[email protected]>--- tools/testing/selftests/mqueue/mq_perf_tests.c | 1 + 1 file changed, 1 insertion(+)tools/testing/selftests/mqueue/mq_perf_tests.c +0
-0
tools/testing/selftests/mqueue/mq_perf_tests.c int main(int argc, char *argv[]) · line 738
Quoted 7 lines
tools/testing/selftests/mqueue/mq_perf_tests.c +1
-0@@ -732,6 +732,7 @@ int main(int argc, char *argv[])pthread_attr_destroy (&thread_attr); } +CPU_FREE (cpu_set);if (!continuous_mode) {pthread_join (cpu_threads[0 ], &retval);shutdown ((long )retval,"perf_test_thread()" , __LINE__);
CPU_ALLOC() is called very early on in main() and there are a few error paths that exit without calling CPU_FREE. This change doesn't fully fix the problem.
Review the other exit paths where CPU_FREE is needed.
thanks,
-- Shuah
Quoted 33 lines · Shuah Khan
Quoted 5 lines · Athira Rajeev
The selftest "
mqueue/mq_perf_tests.c" useCPU_ALLOCto allocate CPU set. This cpu set is used further inpthread_attr_setaffinity_npand bypthread_createin the code. But in current code, allocated cpu set is not freed. Fix this by addingCPU_FREEafter its usage is done.Good find.
Quoted 9 lines
Signed-off-by Athira Rajeev <[email protected]>--- tools/testing/selftests/mqueue/mq_perf_tests.c | 1 + 1 file changed, 1 insertion(+)tools/testing/selftests/mqueue/mq_perf_tests.c +0
-0tools/testing/selftests/mqueue/mq_perf_tests.c int main(int argc, char *argv[]) · line 737
Quoted 6 lines
tools/testing/selftests/mqueue/mq_perf_tests.c +0
-0@@ -732,6 +732,7 @@ int main(int argc, char *argv[])pthread_attr_destroy (&thread_attr); } +CPU_FREE (cpu_set);if (!continuous_mode) {pthread_join (cpu_threads[0 ], &retval);shutdown ((long )retval,"perf_test_thread()" , __LINE__);
CPU_ALLOC()is called very early on inmain()and there are a few error paths that exit without callingCPU_FREE. This change doesn't fully fix the problem.
Quoted 1 line
Review the other exit paths where
CPU_FREEis needed.
Sure, Thanks for the review.
I will check and post a V2
thanks
Athira
Quoted 3 lines
thanks,
-- Shuah