Dear Subrata,
smt_smp_ affinity test case is passing on Fedora but fails on Ubuntu
for the same H/W.On Ubuntu system, after doing strace i observed that
system call sched_getaffinity was returning -1 [ERROR:EINVAL] due to
second argument.
sched_getaffinity(pid, sizeof(unsigned int), &mask1)
Please find attached herewith the patch which fixes the issue.
Thank you,
--
Regards,
Rohit
Signed-off-by: rohit verma ([email protected])
===============================================================================
diff -ruNB
ltp-full-20090731_old/testcases/kernel/sched/hyperthreading/ht_affinity/HTaffinity.c
ltp-full-20090731/testcases/kernel/sched/hyperthreading/ht_affinity/HTaffinity.c
---
ltp-full-20090731_old/testcases/kernel/sched/hyperthreading/ht_affinity/HTaffinity.c
2009-06-23 19:23:55.000000000 +0530
+++
ltp-full-20090731/testcases/kernel/sched/hyperthreading/ht_affinity/HTaffinity.c
2009-08-21 17:10:53.000000000 +0530
@@ -16,6 +16,7 @@
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
+#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -47,7 +48,7 @@
int HT_SetAffinity()
{
- unsigned mask;
+ unsigned int mask;
pid_t pid;
int result=1;
int cpu_count, i, j, k, cpuid;
@@ -161,30 +162,30 @@
int HT_GetAffinity()
{
- unsigned long mask, mask1;
+ unsigned int mask[2], mask1[2];
pid_t pid;
- mask=0x1;
- pid=getpid();
+ mask[0] = 0x1;
+ pid = getpid();
tst_resm(TINFO, "Get affinity through system call.\n");
- sched_setaffinity(pid, sizeof(unsigned int), &mask);
+ sched_setaffinity(pid, sizeof(mask), mask);
sleep(1);
- sched_getaffinity(pid, sizeof(unsigned int), &mask1);
+ sched_getaffinity(pid, sizeof(mask), mask1);
- if (mask == 0x1 && mask == mask1)
+ if (mask[0] == 0x1 && mask[0] == mask1[0])
{
- mask=0x2;
- sched_setaffinity(pid, sizeof(unsigned long), &mask);
+ mask[0] = 0x2;
+ sched_setaffinity(pid, sizeof(mask), mask);
sleep(1);
- sched_getaffinity(pid, sizeof(unsigned int), &mask1);
+ sched_getaffinity(pid, sizeof(mask), mask1);
- if (mask == 0x2 && mask == mask1)
+ if (mask[0] == 0x2 && mask[0] == mask1[0])
return 1;
else
return 0;
@@ -195,29 +196,35 @@
int HT_InheritAffinity()
{
- unsigned long mask;
+ unsigned int mask[2];
pid_t pid;
+ int status;
+ mask[0] = 0x2;
+ pid = getpid();
- mask=0x2;
- pid=getpid();
-
- tst_resm(TINFO, "Inherit affinity from parent process.\n");
-
- sched_setaffinity(pid, sizeof(unsigned int), &mask);
+ sched_setaffinity(pid, sizeof(mask), mask);
sleep(1);
-
- if((pid=fork())==0)
+ pid = fork();
+ if (pid == 0)
{
sleep(1);
- system("ps > /dev/null");
- exit(0);
- }
+ sched_getaffinity(pid, sizeof(mask), mask);
+ if (mask[0] == 0x2)
+ exit(0);
- sched_getaffinity(pid, sizeof(unsigned int), &mask);
+ else
+ exit(1);
+ } else if (pid < 0) {
+ tst_resm(TINFO, "Inherit affinity:fork failed! .\n");
+ return 0;
+ }
+ waitpid(pid, &status, 0);
- if(mask==0x2)
+ if (WEXITSTATUS(status) == 0) {
+ tst_resm(TINFO, "Inherited affinity from parent process.\n");
return 1;
+ }
else
return 0;
}
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list