Skip to contentSkip to conversation

xenomai 3.1/ipipe-core-4.19.128-cip28-arm-10.patch

DISCUSSION Robert Berger 3 participants 13 messages Jul 6, 2020 – Jul 13, 2020

lore
Share & tools
lore
#0 lore raw

Hi,

Now I am a bit puzzled ;)

I rebuilt the rootfs against 4.14.x kernel headers, at least so I think ;)

bitbake -s | grep headers
linux-libc-headers :4.19-r0

nativesdk-linux-libc-headers :4.19-r0

... but still get the same syscall error:

root@multi-v7-ml:~# /usr/bin/smokey --run=16
[  448.996933] [Xenomai] bad syscall <0x197>
posix_mutex OK
root@multi-v7-ml:~#

0x197 is not present in a 4.19 kernel, so the error makes sense, but who calls it? It looks like something in the posix_mutex test triggers it.

Regards,

Robert

#1 lore raw
Quoted 18 lines · On Mon., Jul. 6, 2020, 7:29 p.m. Robert Berger via Xenomai <…

Hi,

Now I am a bit puzzled ;)

I rebuilt the rootfs against 4.14.x kernel headers, at least so I think ;)

bitbake -s | grep headers
linux-libc-headers :4.19-r0

nativesdk-linux-libc-headers :4.19-r0

... but still get the same syscall error:

root@multi-v7-ml:~# /usr/bin/smokey --run=16
[  448.996933] [Xenomai] bad syscall <0x197>
posix_mutex OK
root@multi-v7-ml:~#
Quoted 7 lines

0x197 is not present in a 4.19 kernel, so the error makes sense, but who calls it? It looks like something in the posix_mutex test triggers it.

Regards,

Robert

Hi,
I'll take a look this week with a build I've been testing the ipipe with.

Greg

Quoted 1 line
#2 lore raw

Hi,

Please find my comments in-line

Quoted 7 lines · Greg Gallagher

Hi,
  I'll take a look this week with a build I've been testing the ipipe
with.

Greg

Thanks!

I am happy to test whatever you tell me.

What I am trying to figure out is whether it's a xenomai or a Yocto problem;)

Regards,

Robert

#3 lore raw
In reply to Greg Gallagher

Hi Greg,

I digged a bit deeper and it looks like although I tell Yocto/BitBake to use 4.19.x kernel headers it auto generates this:

/unix/sysv/linux/arm/arch-syscall.h:#define __NR_clock_nanosleep_time64 407

Will try something more drastic to see what happens.

Regards,

Robert

#4 lore raw

Hi,

Quoted 7 lines · Robert Berger

Hi Greg,

I digged a bit deeper and it looks like although I tell Yocto/BitBake to use 4.19.x kernel headers it auto generates this:

/unix/sysv/linux/arm/arch-syscall.h:#define __NR_clock_nanosleep_time64 407

I tested on the none cip branch 4.19.128 ipipe-arm (since i had that on hand) and it passes with no issue. I'll test again on the latest cip 4.19.y ipipe-arm branch later tonight but I don't expect to get the above error. It looks like this syscall exists in the 5.4 kernel but not the 4.19 one (as you mentioned before). I haven't had a chance to look into this too deeply but from the little bit I've looked at, it seems that in the newer kernels there's been some changes around clock_nanosleep. Yocto seems to be expecting that the kernel you are using is going to be 5.4 and is generating headers based on that. So apps think that 407 is a valid system call but our 4.19 kernel doesn't know what system call that is. I don't have a lot of yocto experience but you could try moving to an older yocto branch that supports 4.19 kernels and see what happens.

-Greg

Quoted 6 lines

Will try something more drastic to see what happens.

Regards,

Robert

#5 lore raw

Hi,

My comments are in-line

Quoted 6 lines · Greg Gallagher

Yocto seems to be expecting that the
kernel you are using is going to be 5.4 and is generating headers based on that. So apps think that 407 is a valid system call but our 4.19 kernel doesn't know what system call that is. I don't have a lot of yocto experience but you could try moving to an older yocto branch that supports 4.19 kernels and see what happens.

Well ;)

Every OE/YP release comes with some default kernel version and one would think the kernel headers of this kernel version are used to build the glibc, which kind of is the case, but it's 2 different recipes.

So although I use kernel version 4.19.x to apply the xenomai patch it still uses 5.4 kernel headers by default. I knew that and added my own 4.19 kernel-headers recipe. But it looks like it was not used to build glibc, since I see some auto generated file with the 407 syscall.

I am still fighting trying to build a glibc with 4.19 kernel headers (which I think I managed).

I'll keep you updated.

Quoted 2 lines

-Greg

Thanks,

Robert

Quoted 7 lines
Quoted 7 lines

Will try something more drastic to see what happens.

Regards,

Robert

#6 lore raw
In reply to Greg Gallagher

Hi,

I just had a chat on the Yocto IRC and they claim, that I should not rebuild glibc against different kernel headers. That's yet another no no ;)

Which version of glibc do you use?

I have version 2.31.

01:38:11) RP: RobertBerger: one llbc can be run against multiple kernels and multiple kernel versions
(01:39:26) rber@freenode: Yep, but I thought it's built against a kernel version/some number of syscalls and you can upgrade the kernel underneath, but not downgrade (01:40:26) rber@freenode: If you downgrade the kernel potentially syscalls are being called which are not available in the old kernel.
(01:41:27) RP: RobertBerger: that isn't how it works
(01:41:42) rber@freenode: Ah OK ;)
(01:41:50) rber@freenode: So you say it's a runtime thing?
(01:42:46) RP: RobertBerger: the libc adapts to the kernel version its running against. That kernel is in the range of "latest linux kernel when the libc was released" to OLDEST_KERNEL (01:43:07) rber@freenode: OK

Regards,

Robert

#7 lore raw
In reply to Greg Gallagher

It looks like either we hit a glibc issue, or something is not clear to me in the xenomai test case.

The glibc has a fallback for the unknown syscall. clock_nanosleep_time64

Is this what the xenomai testcase tries to tell us?

Than that is not an error, but fine;)

Regards,

Robert

#8 lore raw

HI,

Quoted 4 lines · Robert Berger

It looks like either we hit a glibc issue, or something is not clear to me in the xenomai test case.

I'm using glibc 2.25. The other thing to keep in mind is that the message isn't coming from the Linux kernel, it's coming from Cobalt. So it's possible cobalt is having some issues with a newer libc. I'll have time tonight to sit down with ftrace and see if I can get a better idea of what's going on.

Quoted 10 lines

The glibc has a fallback for the unknown syscall. clock_nanosleep_time64

Is this what the xenomai testcase tries to tell us?

Than that is not an error, but fine;)

Regards,

Robert

-Greg

#9 lore raw

Hi,

My comments are in-line.

Quoted 6 lines · Greg Gallagher

I'm using glibc 2.25. The other thing to keep in mind is that the message isn't coming from the Linux kernel, it's coming from Cobalt. So it's possible cobalt is having some issues with a newer libc. I'll have time tonight to sit down with ftrace and see if I can get a better idea of what's going on.

I traced the issue a bit more down.

The problematic testcase is protect_trylock (posix-mutex.c:1063) since it calls __real_usleep()(lib/cobalt/wrappers.c:553); which causes [Xenomai] bad syscall <0x197>

So yes, it looks like it's a combination of Cobalt and a new glibc.

I am really surprised that no one else stumbled across this issue, since I can't even remember which Yocto Version used 4.19 or older kernel headers.

My hack to use 4.19 kernel headers didn't help, since, as you say, it does not seem to be related to this issue.

So I guess the ball is in Xenomai land ;)

Having said that I am happy to test whatever you come up with and I guess I could also provide some remote test setup where you can play and see the issue.

Regards,

Robert

#10 lore raw

Hi,

Quoted 30 lines · Robert Berger

Hi,

My comments are in-line.

Quoted 6 lines · Greg Gallagher

I'm using glibc 2.25. The other thing to keep in mind is that the message isn't coming from the Linux kernel, it's coming from Cobalt. So it's possible cobalt is having some issues with a newer libc. I'll have time tonight to sit down with ftrace and see if I can get a better idea of what's going on.

I traced the issue a bit more down.

The problematic testcase is protect_trylock (posix-mutex.c:1063) since it calls __real_usleep()(lib/cobalt/wrappers.c:553); which causes [Xenomai] bad syscall <0x197>

So yes, it looks like it's a combination of Cobalt and a new glibc.

I am really surprised that no one else stumbled across this issue, since I can't even remember which Yocto Version used 4.19 or older kernel headers.

My hack to use 4.19 kernel headers didn't help, since, as you say, it does not seem to be related to this issue.

So I guess the ball is in Xenomai land ;)

Quoted 7 lines

Having said that I am happy to test whatever you come up with and I guess I could also provide some remote test setup where you can play and see the issue.

Regards,

Robert

I tested the latest ipipe-arm 4.19.y-cip branch using the latest gcc from Linaro (7.5) and I can't reproduce the error. I'm assuming it's because it's still using a 2.25 libc. To investigate further I'll have to build a newer tool chain and try the test again. I'll have time later this week to continue the investigation. For now it seems using libc 2.25 avoids the error.

thanks

Greg

#11 lore raw
In reply to Robert Berger
Quoted 8 lines · Robert Berger via Xenomai

It looks like either we hit a glibc issue, or something is not clear to me in the xenomai test case.

The glibc has a fallback for the unknown syscall. clock_nanosleep_time64

Is this what the xenomai testcase tries to tell us?

Than that is not an error, but fine;)

If glibc is probing the existence of the new syscall by calling it, we may silence the warning path. To my current reading, it must have been triggered from a Xenomai thread in primary domain - are we sure that this is correct behavior? Could you set a breakpoint on glibc call and provide a backtrace?

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
#12 lore raw

Hi,

My comments are in-line.

Quoted 11 lines · Jan Kiszka
Quoted 8 lines · Robert Berger via Xenomai

It looks like either we hit a glibc issue, or something is not clear to me in the xenomai test case.

The glibc has a fallback for the unknown syscall. clock_nanosleep_time64

Is this what the xenomai testcase tries to tell us?

Than that is not an error, but fine;)

If glibc is probing the existence of the new syscall by calling it, we may silence the warning path. To my current reading, it must have been triggered from a Xenomai thread in primary domain - are we sure that this is correct behavior? Could you set a breakpoint on glibc call and provide a backtrace?

When clock_nanosleep() is called from Linux the glibc first calls the clock_nanosleep_time64() syscall (which fails on a 4.19 kernel and succeeds on a 5.4 kernel). In case it fails glibc calls the old clock_nanosleep() syscall and all is good.

The problem here is that the testcase protect_trylock (posix-mutex.c:1063) calls __real_usleep()(lib/cobalt/wrappers.c:553); which causes [Xenomai] bad syscall <0x197>.

I guess __real_usleep should call the real POSIX implementation.

__weak
int __real_usleep(useconds_t usec)

{
        return usleep(usec);
}

usleep calls __nanosleep and this seems to cause the bad syscall.

Thread 1 "smokey" hit Breakpoint 3, usleep (useconds=useconds@entry=1) at ../sysdeps/posix/usleep.c:26
26 struct timespec ts = { .tv_sec = (long int) (useconds / 1000000),
(gdb) bt

#0  usleep (useconds=useconds@entry=1) at ../sysdeps/posix/usleep.c:26
#1  0xb6f81140 in __real_usleep (usec=usec@entry=1) at wrappers.c:555
#2  0x00418bf8 in protect_trylock () at posix-mutex.c:933
#3  run_posix_mutex (t=<optimized out>, argc=<optimized out>, argv=<optimized out>) at posix-mutex.c:1063
#4  run_posix_mutex (t=<optimized out>, argc=<optimized out>, argv=<optimized out>) at posix-mutex.c:1027
#5  0x004041c4 in main (argc=1, argv=0x438750) at main.c:34
(gdb) l
21      #include <unistd.h>
22
23      int
24      usleep (useconds_t useconds)
25      {

26 struct timespec ts = { .tv_sec = (long int) (useconds / 1000000),
27 .tv_nsec = (long int) (useconds % 1000000) * 1000ul };
28
29 /* Note the usleep() is a cancellation point. But since we call
30 nanosleep() which itself is a cancellation point we do not have
(gdb) n
32 return __nanosleep (&ts, NULL);
(gdb) n

[ 2168.741990] [Xenomai] bad syscall <0x197>

protect_trylock () at posix-mutex.c:935
935 if (!__T(ret, pthread_mutex_trylock(&mutex)))
(gdb)

Just FYI this code with usleep() seems to work without xenomai:

int my_usleep(unsigned int millisec)

{
        int rc;
        rc = usleep(millisec);
        if (rc < 0) {
                perror("my_usleep: ");
        }
        return rc;
}

int main(int argc, char *argv[])

{
        argc = argc;
        argv = argv;

        unsigned int millisec = 1;
        int rc;

        rc = my_usleep(millisec);

        exit(rc);
}
Quoted 3 lines

Jan

Regards,

Robert