[LTP] [PATCH] syscalls/getcpu: Add libc sched_getcpu() detection && fix compiler errors

Cyril Hrubis chrubis@suse.cz
Fri Apr 12 13:46:32 CEST 2019


Hi!
> >> -#if defined(__i386__)
> >> -	return syscall(__NR_getcpu, cpu_id, node_id, cache_struct);
> >> +#ifndef HAVE_SCHED_GETCPU
> >> +	return tst_syscall(__NR_getcpu, cpu_id, node_id, cache_struct);
> >>   #else
> >>   	*cpu_id = sched_getcpu();
> >>   #endif
> > So when __NR_getcpu is not implemented we end up with tst_brk(TCONF,
> > ...) called from the tst_syscall, right? Since AFAIK the getcpu syscall
> > is not implemented on all architectures...
> Yes. It will report TCONF if __NR_getcpu is not implemented.
> 
>  From getcpu manpage, it is not implemented on all architectures as you
> said, I think we can remove sched_getcpu and use __NR_getcpu directly.

Reading the manual pages I think it's correct to fall back to
sched_getcpu() since as far as I can tell platforms that don't support
getcpu syscall have implemented the functionality as vDSO. So unless we
implement vDSO variant of getcpu we have to rely on sched_getcpu().

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list