getcpu01: Reinstate node_id test
PATCH v3 1/1 getcpu01: Reinstate node_id test
Presently the node_id is only checked on i386 and it is broken. The sched_getcpu call was substituted for getcpu when available. sched_getcpu does not have the node_id parameter, it's not the same thing as getcpu.
Also we can check the node_id on any platform which has NUMA. Which includes more than just x86.
---
V2:
* Removed all the ifdefs
* Use libc getcpu when available
* Remove kernel version check
V3:
* Add back the kernel version check bc it conflicts with other patch
configure.ac | 1 + include/lapi/sched.h | 7 ++++++ testcases/kernel/syscalls/getcpu/getcpu01.c | 28 +++------------------ 3 files changed, 11 insertions(+), 25 deletions(-)
configure.ac +1 -0
@@ -101,6 +101,7 @@ AC_CHECK_FUNCS_ONCE([ \ fstatat \ getauxval \ getcontext \ + getcpu \ getdents \ getdents64 \ io_pgetevents \
include/lapi/sched.h +7 -0
@@ -70,6 +70,13 @@ static inline void clone3_supported_by_kernel(void) } } +#ifndef HAVE_GETCPU +static inline int getcpu (unsigned *cpu,unsigned *node) +{ +return tst_syscall (__NR_getcpu, cpu, node,NULL ); +} +#endif +#ifndef SCHED_DEADLINE # define SCHED_DEADLINE 6#endif
testcases/kernel/syscalls/getcpu/getcpu01.c +3 -25
@@ -11,26 +11,12 @@#define _GNU_SOURCE#include <dirent.h> #include <errno.h> -#include <sched.h> #include <stdio.h> #include <stdlib.h> #include <sys/types.h> -#include "lapi/syscalls.h" -#include "lapi/cpuset.h" #include "tst_test.h" -#include "config.h" - -static inline int get_cpu (unsigned *cpu_id, - unsigned *node_id LTP_ATTRIBUTE_UNUSED, - void *cache_struct LTP_ATTRIBUTE_UNUSED) -{ -#ifndef HAVE_SCHED_GETCPU -return tst_syscall (__NR_getcpu, cpu_id, node_id, cache_struct); -#else - *cpu_id =sched_getcpu (); -#endif -return 0 ; -} +#include "lapi/cpuset.h" +#include "lapi/sched.h" static unsigned int max_cpuid (size_t size,cpu_set_t * set) {
@@ -78,7 +64,6 @@ realloc:return cpu_max; } -#ifdef __i386__static unsigned int get_nodeid (unsigned int cpu_id) {DIR *directory_parent, *directory_node;
@@ -119,33 +104,26 @@ static unsigned int get_nodeid(unsigned int cpu_id) }return node_id; } -#endif static void run (void ) {unsigned int cpu_id, node_id =0 ;unsigned int cpu_set; -#ifdef __i386__unsigned int node_set; -#endif cpu_set =set_cpu_affinity (); -#ifdef __i386__ node_set =get_nodeid (cpu_set); -#endif -TEST (get_cpu (&cpu_id, &node_id,NULL )); +TEST (getcpu (&cpu_id, &node_id));if (TST_RET ==0 ) {if (cpu_id != cpu_set)tst_res (TFAIL ,"getcpu() returned wrong value" " expected cpuid:%d, returned value cpuid: %d" , cpu_set, cpu_id); -#ifdef __i386__else if (node_id != node_set)tst_res (TFAIL ,"getcpu() returned wrong value" " expected node id:%d returned node id:%d" , node_set, node_id); -#endif else tst_res(TPASS, "getcpu() returned proper" " cpuid:%d, node id:%d", cpu_id,
Signature · 5 lines
2.38.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hello,
Quoted 10 lines · Richard Palethorpe via ltp
Presently the
node_idis only checked on i386 and it is broken. Thesched_getcpucall was substituted for getcpu when available.sched_getcpudoes not have thenode_idparameter, it's not the same thing as getcpu.Also we can check the
node_idon any platform which has NUMA. Which includes more than just x86.Signed-off-by Richard Palethorpe <[email protected]>Cc Cyril Hrubis <[email protected]>
Maybe this is a bit impatient (although v2 was submitted some time ago), but no response, so merged.
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp