realtime: Remove printing of cpu affinity masks in pi-tests
PATCH 1/1 realtime: Remove printing of cpu affinity masks in pi-tests
Hi,
Some tests under realtime/func/pi-tests in LTP display junk values for cpu affinity masks:
Start ./testpi-2
protocol in mutexattr is 1
Thread 14574 started running with priority 10 on CPU 1110536304 Thread 14574 at start pthread pol 2 pri 10 - Got global lock Thread 14575 started running with prio 20 on CPU 1084272752 Thread 14576 started running with prio 30 on CPU 1118929008 Thread 14577 started running with prio 40 on CPU 1127321712 Noise Thread 14578 started running with prio 40 on CPU 1099915376
testpi-1 and testpi-4 also report similar wrong values.
The cause of this problem is the incorrect way in which sched_getaffinity output is used in the tests. I think there is no need to call getaffinity() to know the cpu mask, because we test the return value of setaffinity() before that. The following patch removes all calls to sched_affinity() and removes printing cpu affinity masks.
Thanks,
Sripathi.
testcases/realtime/func/pi-tests/testpi-1.c +3 -7
@@ -91,9 +91,8 @@ void* func_nonrt(void* arg)printf ("Thread %d: Can't set affinity: %d %s\n" , tid, rc,strerror (rc));exit (-1 ); } - rc =sched_getaffinity (0 ,sizeof (mask), &mask); -printf ("Thread %d started running with priority %d on CPU %ld\n" , tid, pthr->priority, (long )mask.__bits); +printf ("Thread %d started running with priority %d\n" , tid, pthr->priority);pthread_mutex_lock (&glob_mutex);printf ("Thread %d at start pthread pol %d pri %d - Got global lock\n" , tid, pthr->policy, pthr->priority);/* Wait for other RT threads to start up */
@@ -127,9 +126,8 @@ void* func_rt(void* arg)printf ("Thread %d: Can't set affinity: %d %s\n" , tid, rc,strerror (rc));exit (-1 ); } - rc =sched_getaffinity (0 ,sizeof (mask), &mask); -printf ("Thread %d started running with prio %d on CPU %ld\n" , tid, pthr->priority, (long )mask.__bits); +printf ("Thread %d started running with prio %d\n" , tid, pthr->priority);pthread_barrier_wait (&barrier);pthread_mutex_lock (&glob_mutex);printf ("Thread %d at start pthread pol %d pri %d - Got global lock\n" , tid, pthr->policy, pthr->priority);
@@ -167,9 +165,8 @@ void* func_noise(void* arg)printf ("Thread %d: Can't set affinity: %d %s\n" , tid, rc,strerror (rc));exit (-1 ); } - rc =sched_getaffinity (0 ,sizeof (mask), &mask); -printf ("Noise Thread %d started running with prio %d on CPU %ld\n" , tid, pthr->priority, (long )mask.__bits); +printf ("Noise Thread %d started running with prio %d\n" , tid, pthr->priority);pthread_barrier_wait (&barrier);for (i=0 ;i<10000 ;i++) {
@@ -209,7 +206,6 @@ int main(int argc, char* argv[]) {printf ("Main Thread: Can't set affinity: %d %s\n" , retc,strerror (retc));exit (-1 ); } - retc =sched_getaffinity (0 ,sizeof (mask), &mask);for (i=0 ;i<argc;i++) {if (strcmp (argv[i],"nopi" ) ==0 ) nopi =1 ; }
testcases/realtime/func/pi-tests/testpi-2.c +3 -7
@@ -91,9 +91,8 @@ void* func_lowrt(void* arg)printf ("Thread %d: Can't set affinity: %d %s\n" , tid, rc,strerror (rc));exit (-1 ); } - rc =sched_getaffinity (0 ,sizeof (mask), &mask); -printf ("Thread %d started running with priority %d on CPU %ld\n" , tid, pthr->priority, (long )mask.__bits); +printf ("Thread %d started running with priority %d\n" , tid, pthr->priority);pthread_mutex_lock (&glob_mutex);printf ("Thread %d at start pthread pol %d pri %d - Got global lock\n" , tid, pthr->policy, pthr->priority);/* Wait for other RT threads to start up */
@@ -127,9 +126,8 @@ void* func_rt(void* arg)printf ("Thread %d: Can't set affinity: %d %s\n" , tid, rc,strerror (rc));exit (-1 ); } - rc =sched_getaffinity (0 ,sizeof (mask), &mask); -printf ("Thread %d started running with prio %d on CPU %ld\n" , tid, pthr->priority, (long )mask.__bits); +printf ("Thread %d started running with prio %d\n" , tid, pthr->priority);pthread_barrier_wait (&barrier);pthread_mutex_lock (&glob_mutex);printf ("Thread %d at start pthread pol %d pri %d - Got global lock\n" , tid, pthr->policy, pthr->priority);
@@ -167,9 +165,8 @@ void* func_noise(void* arg)printf ("Thread %d: Can't set affinity: %d %s\n" , tid, rc,strerror (rc));exit (-1 ); } - rc =sched_getaffinity (0 ,sizeof (mask), &mask); -printf ("Noise Thread %d started running with prio %d on CPU %ld\n" , tid, pthr->priority, (long )mask.__bits); +printf ("Noise Thread %d started running with prio %d\n" , tid, pthr->priority);pthread_barrier_wait (&barrier);for (i=0 ;i<10000 ;i++) {
@@ -208,7 +205,6 @@ int main(int argc, char* argv[]) {printf ("Main Thread: Can't set affinity: %d %s\n" , retc,strerror (retc));exit (-1 ); } - retc =sched_getaffinity (0 ,sizeof (mask), &mask);for (i=0 ;i<argc;i++) {if (strcmp (argv[i],"nopi" ) ==0 ) nopi =1 ;
testcases/realtime/func/pi-tests/testpi-4.c +3 -7
@@ -92,9 +92,8 @@ void* func_nonrt(void* arg)printf ("Thread %d: Can't set affinity: %d %s\n" , tid, rc,strerror (rc));exit (-1 ); } - rc =sched_getaffinity (0 ,sizeof (mask), &mask); -printf ("Thread %d started running with priority %d on CPU %ld\n" , tid, pthr->priority, (long )mask.__bits); +printf ("Thread %d started running with priority %d\n" , tid, pthr->priority);pthread_mutex_lock (glob_mutex);printf ("Thread %d at start pthread pol %d pri %d - Got global lock\n" , tid, pthr->policy, pthr->priority);pthread_barrier_wait (&barrier);
@@ -127,9 +126,8 @@ void* func_rt(void* arg)printf ("Thread %d: Can't set affinity: %d %s\n" , tid, rc,strerror (rc));exit (-1 ); } - rc =sched_getaffinity (0 ,sizeof (mask), &mask); -printf ("Thread %d started running with prio %d on CPU %ld\n" , tid, pthr->priority, (long )mask.__bits); +printf ("Thread %d started running with prio %d\n" , tid, pthr->priority);pthread_barrier_wait (&barrier);pthread_mutex_lock (glob_mutex);printf ("Thread %d at start pthread pol %d pri %d - Got global lock\n" , tid, pthr->policy, pthr->priority);
@@ -167,9 +165,8 @@ void* func_noise(void* arg)printf ("Thread %d: Can't set affinity: %d %s\n" , tid, rc,strerror (rc));exit (-1 ); } - rc =sched_getaffinity (0 ,sizeof (mask), &mask); -printf ("Noise Thread started running with prio %d on CPU %ld\n" , pthr->priority, (long )mask.__bits); +printf ("Noise Thread started running with prio %d\n" , pthr->priority);pthread_barrier_wait (&barrier);for (i=0 ;i<10000 ;i++) {
@@ -209,7 +206,6 @@ int main(int argc, char* argv[]) {printf ("Main Thread: Can't set affinity: %d %s\n" , retc,strerror (retc));exit (-1 ); } - retc =sched_getaffinity (0 ,sizeof (mask), &mask);for (i=0 ;i<argc;i++) {if (strcmp (argv[i],"nopi" ) ==0 ) nopi =1 ; }
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 22 lines · Sripathi Kodi
Hi,
Some tests under realtime/func/pi-tests in LTP display junk values for cpu affinity masks:
Start ./testpi-2
protocol in mutexattr is 1
Thread 14574 started running with priority 10 on CPU 1110536304 Thread 14574 at start pthread pol 2 pri 10 - Got global lock Thread 14575 started running with prio 20 on CPU 1084272752 Thread 14576 started running with prio 30 on CPU 1118929008 Thread 14577 started running with prio 40 on CPU 1127321712 Noise Thread 14578 started running with prio 40 on CPU 1099915376testpi-1 and testpi-4 also report similar wrong values.
The cause of this problem is the incorrect way in which
sched_getaffinityoutput is used in the tests. I think there is no need to callgetaffinity()to know the cpu mask, because we test the return value ofsetaffinity()before that. The following patch removes all calls tosched_affinity()and removes printing cpu affinity masks.
Quoted 6 lines
Thanks,
Sripathi.Signed-off-by Sripathi Kodi <[email protected]>Acked-by Gowrishankar <[email protected]>
Thanks.
Regards--
Subrata
Quoted 136 lines
diff -uprN
ltp_org/testcases/realtime/func/pi-tests/testpi-1.cltp/testcases/realtime/func/pi-tests/testpi-1.ctestcases/realtime/func/pi-tests/testpi-1.c +3
-7@@ -91,9 +91,8 @@ void* func_nonrt(void* arg)printf ("Thread %d: Can't set affinity: %d %s\n" , tid, rc,strerror (rc));exit (-1 ); } - rc =sched_getaffinity (0 ,sizeof (mask), &mask); -printf ("Thread %d started running with priority %d on CPU %ld\n" , tid, pthr->priority, (long )mask.__bits); +printf ("Thread %d started running with priority %d\n" , tid, pthr->priority);pthread_mutex_lock (&glob_mutex);printf ("Thread %d at start pthread pol %d pri %d - Got global lock\n" , tid, pthr->policy, pthr->priority);/* Wait for other RT threads to start up */ @@ -127,9 +126,8 @@ void* func_rt(void* arg)printf ("Thread %d: Can't set affinity: %d %s\n" , tid, rc,strerror (rc));exit (-1 ); } - rc =sched_getaffinity (0 ,sizeof (mask), &mask); -printf ("Thread %d started running with prio %d on CPU %ld\n" , tid, pthr->priority, (long )mask.__bits); +printf ("Thread %d started running with prio %d\n" , tid, pthr->priority);pthread_barrier_wait (&barrier);pthread_mutex_lock (&glob_mutex);printf ("Thread %d at start pthread pol %d pri %d - Got global lock\n" , tid, pthr->policy, pthr->priority);@@ -167,9 +165,8 @@ void* func_noise(void* arg)printf ("Thread %d: Can't set affinity: %d %s\n" , tid, rc,strerror (rc));exit (-1 ); } - rc =sched_getaffinity (0 ,sizeof (mask), &mask); -printf ("Noise Thread %d started running with prio %d on CPU %ld\n" , tid, pthr->priority, (long )mask.__bits); +printf ("Noise Thread %d started running with prio %d\n" , tid, pthr->priority);pthread_barrier_wait (&barrier);for (i=0 ;i<10000 ;i++) {@@ -209,7 +206,6 @@ int main(int argc, char* argv[]) {printf ("Main Thread: Can't set affinity: %d %s\n" , retc,strerror (retc));exit (-1 ); } - retc =sched_getaffinity (0 ,sizeof (mask), &mask);for (i=0 ;i<argc;i++) {if (strcmp (argv[i],"nopi" ) ==0 ) nopi =1 ; }diff -uprN
ltp_org/testcases/realtime/func/pi-tests/testpi-2.cltp/testcases/realtime/func/pi-tests/testpi-2.ctestcases/realtime/func/pi-tests/testpi-2.c +3
-7@@ -91,9 +91,8 @@ void* func_lowrt(void* arg)printf ("Thread %d: Can't set affinity: %d %s\n" , tid, rc,strerror (rc));exit (-1 ); } - rc =sched_getaffinity (0 ,sizeof (mask), &mask); -printf ("Thread %d started running with priority %d on CPU %ld\n" , tid, pthr->priority, (long )mask.__bits); +printf ("Thread %d started running with priority %d\n" , tid, pthr->priority);pthread_mutex_lock (&glob_mutex);printf ("Thread %d at start pthread pol %d pri %d - Got global lock\n" , tid, pthr->policy, pthr->priority);/* Wait for other RT threads to start up */ @@ -127,9 +126,8 @@ void* func_rt(void* arg)printf ("Thread %d: Can't set affinity: %d %s\n" , tid, rc,strerror (rc));exit (-1 ); } - rc =sched_getaffinity (0 ,sizeof (mask), &mask); -printf ("Thread %d started running with prio %d on CPU %ld\n" , tid, pthr->priority, (long )mask.__bits); +printf ("Thread %d started running with prio %d\n" , tid, pthr->priority);pthread_barrier_wait (&barrier);pthread_mutex_lock (&glob_mutex);printf ("Thread %d at start pthread pol %d pri %d - Got global lock\n" , tid, pthr->policy, pthr->priority);@@ -167,9 +165,8 @@ void* func_noise(void* arg)printf ("Thread %d: Can't set affinity: %d %s\n" , tid, rc,strerror (rc));exit (-1 ); } - rc =sched_getaffinity (0 ,sizeof (mask), &mask); -printf ("Noise Thread %d started running with prio %d on CPU %ld\n" , tid, pthr->priority, (long )mask.__bits); +printf ("Noise Thread %d started running with prio %d\n" , tid, pthr->priority);pthread_barrier_wait (&barrier);for (i=0 ;i<10000 ;i++) {@@ -208,7 +205,6 @@ int main(int argc, char* argv[]) {printf ("Main Thread: Can't set affinity: %d %s\n" , retc,strerror (retc));exit (-1 ); } - retc =sched_getaffinity (0 ,sizeof (mask), &mask);for (i=0 ;i<argc;i++) {if (strcmp (argv[i],"nopi" ) ==0 ) nopi =1 ;diff -uprN
ltp_org/testcases/realtime/func/pi-tests/testpi-4.cltp/testcases/realtime/func/pi-tests/testpi-4.ctestcases/realtime/func/pi-tests/testpi-4.c +3
-8@@ -92,9 +92,8 @@ void* func_nonrt(void* arg)printf ("Thread %d: Can't set affinity: %d %s\n" , tid, rc,strerror (rc));exit (-1 ); } - rc =sched_getaffinity (0 ,sizeof (mask), &mask); -printf ("Thread %d started running with priority %d on CPU %ld\n" , tid, pthr->priority, (long )mask.__bits); +printf ("Thread %d started running with priority %d\n" , tid, pthr->priority);pthread_mutex_lock (glob_mutex);printf ("Thread %d at start pthread pol %d pri %d - Got global lock\n" , tid, pthr->policy, pthr->priority);pthread_barrier_wait (&barrier);@@ -127,9 +126,8 @@ void* func_rt(void* arg)printf ("Thread %d: Can't set affinity: %d %s\n" , tid, rc,strerror (rc));exit (-1 ); } - rc =sched_getaffinity (0 ,sizeof (mask), &mask); -printf ("Thread %d started running with prio %d on CPU %ld\n" , tid, pthr->priority, (long )mask.__bits); +printf ("Thread %d started running with prio %d\n" , tid, pthr->priority);pthread_barrier_wait (&barrier);pthread_mutex_lock (glob_mutex);printf ("Thread %d at start pthread pol %d pri %d - Got global lock\n" , tid, pthr->policy, pthr->priority);@@ -167,9 +165,8 @@ void* func_noise(void* arg)printf ("Thread %d: Can't set affinity: %d %s\n" , tid, rc,strerror (rc));exit (-1 ); } - rc =sched_getaffinity (0 ,sizeof (mask), &mask); -printf ("Noise Thread started running with prio %d on CPU %ld\n" , pthr->priority, (long )mask.__bits); +printf ("Noise Thread started running with prio %d\n" , pthr->priority);pthread_barrier_wait (&barrier);for (i=0 ;i<10000 ;i++) {@@ -209,7 +206,6 @@ int main(int argc, char* argv[]) {printf ("Main Thread: Can't set affinity: %d %s\n" , retc,strerror (retc));exit (-1 ); } - retc =sched_getaffinity (0 ,sizeof (mask), &mask);for (i=0 ;i<argc;i++) {if (strcmp (argv[i],"nopi" ) ==0 ) nopi =1 ; } ------------------------------------------------------------------------------Come build with us! The BlackBerry(R) Developer Conference in SF, CA
Quoted 8 lines
is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list