Return-Path: Received: from sfi-mx-1.v28.ch3.sourceforge.com ([172.29.28.121] helo=mx.sourceforge.net) by 335xhf1.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1MvoFA-0003KE-TQ for ltp-list@lists.sourceforge.net; Thu, 08 Oct 2009 08:21:00 +0000 Received: from e28smtp05.in.ibm.com ([59.145.155.5]) by 29vjzd1.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) id 1MvoF1-0003xV-VO for ltp-list@lists.sourceforge.net; Thu, 08 Oct 2009 08:21:00 +0000 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by e28smtp05.in.ibm.com (8.14.3/8.13.1) with ESMTP id n988KdSm014458 for ; Thu, 8 Oct 2009 13:50:39 +0530 Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n988KdEa2867416 for ; Thu, 8 Oct 2009 13:50:39 +0530 Received: from d28av01.in.ibm.com (loopback [127.0.0.1]) by d28av01.in.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id n988Kc3W005802 for ; Thu, 8 Oct 2009 13:50:39 +0530 Date: Thu, 8 Oct 2009 13:50:38 +0530 From: Sripathi Kodi Message-ID: <20091008135038.008f8df7@sripathi.in.ibm.com> Mime-Version: 1.0 Subject: [LTP] [PATCH] realtime: Remove printing of cpu affinity masks in pi-tests List-Id: Linux Test Project General Discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ltp-list-bounces@lists.sourceforge.net To: ltp-list@lists.sourceforge.net Cc: gowrishankar 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. Signed-off-by: Sripathi Kodi Acked-by: Gowrishankar diff -uprN ltp_org/testcases/realtime/func/pi-tests/testpi-1.c ltp/testcases/realtime/func/pi-tests/testpi-1.c --- ltp_org/testcases/realtime/func/pi-tests/testpi-1.c 2009-10-06 23:09:13.000000000 -0700 +++ ltp/testcases/realtime/func/pi-tests/testpi-1.c 2009-10-06 23:10:10.000000000 -0700 @@ -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;ipriority, (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;ipriority, (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