Hi all.

I've got an application running on linux 4.1.18 with Xenomai 2.6.5
  (commit 917dcebb26ec492f276cdc3b55867aa90e01fa12).
The system log contains a lot of these trace:

Jun  3 15:33:09 E0144503 kernel: [ 7529.383453]
  invalid use of FPU in Xenomai context at 0x7f5dcf431580
Jun  3 15:33:09 E0144503 kernel: [ 7529.383461]
  Xenomai: Switching RECV to secondary mode after exception #7 from
  user-space at 0x7f5dcf431580 (pid 5264)

I've tried with and without FPU support in Xenomai Kernel configuration,
and also with Kernel 3.18.20.
How can I resolve this fpu issue?

I provide my system configuration and an example program that does not
use fpu, but msgQueue, like read in other community threads.

Thanks for your support.
Best regards,
Marco Corallini.


==SYSTEM CONFIGURATION==

architecture x86_64

# uname -a
Linux E0144503 4.1.18 #45 SMP Fri May 29 11:34:27 UTC 2020 x86_64 
GNU/Linux

# cat /proc/xenomai/version
2.6.5

# cat /proc/ipipe/version
9
(ipipe-core-4.1.18-x86-9.patch)

# cat /proc/cmdline
BOOT_IMAGE=/boot/bzImage3 root=UUID=9d2a859e-d524-4209-a17a-e43691895689 
ro

# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 76
model name      : Intel(R) Celeron(R) CPU  N3160  @ 1.60GHz
stepping        : 4
microcode       : 0x40a
cpu MHz         : 1599.933
cache size      : 1024 KB
physical id     : 0
siblings        : 4
core id         : 0
cpu cores       : 4
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge 
mca
cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall 
nx
rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology
nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2
ssse3 cx16 xtpr pdcm sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes
rdrand lahf_lm 3dnowprefetch ida arat epb dtherm tpr_shadow vnmi
flexpriority ept vpid tsc_adjust smep erms
bugs            :
bogomips        : 3199.86
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:
... and so on to processor #3

# cat /proc/xenomai/faults
TRAP  CPU0  CPU1  CPU2  CPU3
   0:     0     0     0     0    (Divide error)
   1:     0     0     0     0    (Debug)
   3:     0     0     0     0    (Int3)
   4:     0     0     0     0    (Overflow)
   5:     0     0     0     0    (Bounds)
   6:     0     0     0     0    (Invalid opcode)
   7:    84     0     0     0    (FPU not available)
   8:     0     0     0     0    (Double fault)
   9:     0     0     0     0    (FPU segment overrun)
  10:     0     0     0     0    (Invalid TSS)
  11:     0     0     0     0    (Segment not present)
  12:     0     0     0     0    (Stack segment)
  13:     0     0     0     0    (General protection)
  14:     0     0     0     0    (Page fault)
  15:     0     0     0     0    (Spurious interrupt)
  16:     0     0     0     0    (FPU error)
  17:     0     0     0     0    (Alignment check)
  18:     0     0     0     0    (Machine check)
  19:     0     0     0     0    (SIMD error)

==KGDB==

This is the backtrace of kgdb with breakpoint into function
xnpod_trap_fault().

Entering kdb (current=0xffff88003d511260, pid 564) on processor 0
due to Breakpoint @ 0xffffffff810e110c
[0]kdb> bt
bt
Stack traceback for pid 2951
0xffff88003f35ee40     2951     2705  0    0   S  0xffff88003f35f428  
PROC
[0]kdb> [  371.376161] Xenomai: watchdog triggered -- signaling runaway 
thread 'PROC'
[  371.380186]  ffff88003f35ee40 ffff88003f407bf8 ffffffff810b16b9 
0000000000000000
[  371.384108]  0000000000000000 ffff88003f35ee40 0000000000000000 
ffff88003f407c38
[  371.386669]  ffffffff810b1757 ffff88003f407c38 ff00ffff810ade3d 
00000000ffffffff
[  371.388799] Call Trace:
[  371.389646]  <#DB>  [<ffffffff810b16b9>] kdb_show_stack+0x56/0x6a
[  371.391415]  [<ffffffff810b1757>] kdb_bt1.isra.0+0x8a/0xc9
[  371.392784]  [<ffffffff810b1b10>] kdb_bt+0x37a/0x38b
[  371.393998]  [<ffffffff810ac300>] ? kdb_read+0x2bf/0x830
[  371.395380]  [<ffffffff810afbbe>] kdb_parse+0x487/0x57d
[  371.396632]  [<ffffffff810b0191>] kdb_main_loop+0x42b/0x660
[  371.397793]  [<ffffffff810b246c>] kdb_stub+0x244/0x338
[  371.399239]  [<ffffffff810aa226>] kgdb_cpu_enter+0x17c/0x504
[  371.400887]  [<ffffffff810aa7cc>] kgdb_handle_exception+0x157/0x183
[  371.402361]  [<ffffffff8102a6ed>] __ipipe_trap_prologue+0x103/0x272
[  371.404035]  [<ffffffff81003182>] do_int3+0x23/0x112
[  371.405223]  [<ffffffff816cb235>] int3+0x25/0x50
[  371.406155]  [<ffffffff810e110c>] ? xnpod_remove_hook+0x212/0x212
[  371.407392]  <<EOE>>  [<ffffffff810f5446>] ? 
xnarch_trap_fault+0x20/0x22
[  371.408634]  [<ffffffff815ccb70>] exception_event+0x38/0x42
[  371.411359]  [<ffffffff810b6e0a>] ipipe_trap_hook+0x21/0x23
[  371.412312]  [<ffffffff810b5446>] __ipipe_notify_trap+0x63/0x93
[  371.413333]  [<ffffffff8102a73f>] __ipipe_trap_prologue+0x155/0x272
[  371.414410]  [<ffffffff810b4a90>] ? 
__ipipe_get_current_domain+0x9/0x12
[  371.415638]  [<ffffffff81003765>] do_device_not_available+0x17/0x54
[  371.416697]  [<ffffffff816caeb8>] device_not_available+0x18/0x50
[  371.417773] Xenomai: watchdog triggered -- killing runaway thread 
'PROC'
[  371.418904] sched: RT throttling activated
[  374.741842] invalid use of FPU in Xenomai context at 0x7f54c9d736f8
[  374.743321] Xenomai: Switching RECV to secondary mode after exception 
#7
from user-space at 0x7f54c9d736f8 (pid 2952)
[  389.119196] INFO: rcu_sched detected stalls on CPUs/tasks: { 1}
(detected by 0, t=21002 jiffies, g=1493, c=1492, q=64)
[  389.123466] Task dump for CPU 1:
[  389.123909] swapper/1       R  running task    12280     0      1 
0x00000008
[  389.125144]  0000000000000000 ffff88003f50fb00 ffffffff8107d78b 
ffff88003f2abeb8
[  389.126501]  ffffffff8107d732 0000000000000000 0000000000000000 
ffff88003f2ac000
[  389.127785]  ffff88003f50d4e0 0000000000000202 ffffffff8107d243 
ffff88003f2abed8
[  389.129013] Call Trace:
[  389.129542]  [<ffffffff8107d78b>] ? 
rcu_eqs_exit_common.isra.48+0x26/0xcf
[  389.130655]  [<ffffffff8107d732>] ? 
rcu_eqs_enter_common.isra.47+0xd8/0x10b
[  389.131805]  [<ffffffff8107d243>] ? arch_local_irq_restore+0x14/0x16
[  389.132878]  [<ffffffff8100a2e6>] ? default_idle+0x1c/0x2d
[  389.133803]  [<ffffffff8100aae9>] ? arch_cpu_idle+0xa/0xc
[  389.134739]  [<ffffffff8106af11>] ? cpu_startup_entry+0x26b/0x29b
[  389.135784]  [<ffffffff8102b51e>] ? start_secondary+0xec/0x10a

# fgrep XENO linux-4.1.18/.config
CONFIG_XENOMAI=y
CONFIG_XENO_GENERIC_STACKPOOL=y
CONFIG_XENO_FASTSYNCH=y
CONFIG_XENO_OPT_NUCLEUS=y
CONFIG_XENO_OPT_PERVASIVE=y
# CONFIG_XENO_OPT_PRIOCPL is not set
CONFIG_XENO_OPT_PIPELINE_HEAD=y
CONFIG_XENO_OPT_SCHED_CLASSES=y
# CONFIG_XENO_OPT_SCHED_TP is not set
# CONFIG_XENO_OPT_SCHED_SPORADIC is not set
CONFIG_XENO_OPT_PIPE=y
CONFIG_XENO_OPT_VFILE=y
CONFIG_XENO_OPT_PIPE_NRDEV=32
CONFIG_XENO_OPT_REGISTRY_NRSLOTS=1024
CONFIG_XENO_OPT_SYS_HEAPSZ=2048
CONFIG_XENO_OPT_SYS_STACKPOOLSZ=2024
CONFIG_XENO_OPT_SEM_HEAPSZ=512
CONFIG_XENO_OPT_GLOBAL_SEM_HEAPSZ=512
CONFIG_XENO_OPT_STATS=y
CONFIG_XENO_OPT_DEBUG=y
CONFIG_XENO_OPT_DEBUG_NUCLEUS=y
CONFIG_XENO_OPT_DEBUG_XNLOCK=y
CONFIG_XENO_OPT_DEBUG_QUEUES=y
CONFIG_XENO_OPT_DEBUG_REGISTRY=y
CONFIG_XENO_OPT_DEBUG_TIMERS=y
CONFIG_XENO_OPT_DEBUG_SYNCH_RELAX=y
CONFIG_XENO_OPT_WATCHDOG=y
CONFIG_XENO_OPT_WATCHDOG_TIMEOUT=4
CONFIG_XENO_OPT_SHIRQ=y
CONFIG_XENO_OPT_SELECT=y
CONFIG_XENO_OPT_HOSTRT=y
CONFIG_XENO_OPT_TIMING_PERIODIC=y
CONFIG_XENO_OPT_TIMING_VIRTICK=1000
CONFIG_XENO_OPT_TIMING_SCHEDLAT=0
CONFIG_XENO_OPT_SCALABLE_SCHED=y
# CONFIG_XENO_OPT_TIMER_LIST is not set
CONFIG_XENO_OPT_TIMER_RBTREE=y
CONFIG_XENO_HW_FPU=y
CONFIG_XENO_SKIN_NATIVE=y
CONFIG_XENO_OPT_NATIVE_PERIOD=0
CONFIG_XENO_OPT_NATIVE_PIPE=y
CONFIG_XENO_OPT_NATIVE_PIPE_BUFSZ=1024
CONFIG_XENO_OPT_NATIVE_SEM=y
CONFIG_XENO_OPT_NATIVE_EVENT=y
CONFIG_XENO_OPT_NATIVE_MUTEX=y
CONFIG_XENO_OPT_NATIVE_COND=y
CONFIG_XENO_OPT_NATIVE_QUEUE=y
CONFIG_XENO_OPT_NATIVE_BUFFER=y
CONFIG_XENO_OPT_NATIVE_HEAP=y
CONFIG_XENO_OPT_NATIVE_ALARM=y
CONFIG_XENO_OPT_NATIVE_MPS=y
CONFIG_XENO_OPT_NATIVE_INTR=y
CONFIG_XENO_OPT_DEBUG_NATIVE=y
CONFIG_XENO_SKIN_POSIX=y
CONFIG_XENO_OPT_POSIX_PERIOD=0
CONFIG_XENO_OPT_POSIX_REGISTRY_NRSLOTS=64
CONFIG_XENO_OPT_POSIX_REGISTRY_NRDESCS=128
CONFIG_XENO_OPT_POSIX_NRTIMERS=128
CONFIG_XENO_OPT_POSIX_SHM=y
CONFIG_XENO_OPT_POSIX_INTR=y
CONFIG_XENO_OPT_POSIX_SELECT=y
CONFIG_XENO_OPT_DEBUG_POSIX=y
# CONFIG_XENO_SKIN_PSOS is not set
# CONFIG_XENO_SKIN_UITRON is not set
# CONFIG_XENO_SKIN_VRTX is not set
CONFIG_XENO_SKIN_VXWORKS=y
CONFIG_XENO_OPT_VXWORKS_PERIOD=1000
CONFIG_XENO_OPT_DEBUG_VXWORKS=y
# CONFIG_XENO_OPT_NOWARN_DEPRECATED is not set
# CONFIG_XENO_SKIN_RTDM is not set

==SOURCES==

/* Xenomai Includes */
#include <vxworks/vxworks.h>

/* Standard includes */
#include <pthread.h>  /* POSIX threads and timers */
#include <stdlib.h>   /* Exit status macros and atexit */
#include <sys/mman.h> /* Memory management (mlockall) */
#include <mqueue.h>   /* POSIX message queues */
#include <error.h>    /* GNU error function */
#include <unistd.h>   /* Sleep */

/* Constants */
#define STACK_SIZE     (1024 * 1024 * 8)
#define QUEUE_MSG_SIZE 512
#define QUEUE_MAX_MSGS 10
#define PRIORITY       10
#define WRITE_SIZE     64

/* Global variables */
MSG_Q_ID queue1_rt;
int count = 0;
char send_buffer[QUEUE_MSG_SIZE];
char receive_buffer[QUEUE_MSG_SIZE];

/* Send messages to msgQueue */
void * rt_loop(void * arg){
     while (1){
         count++;
         snprintf(send_buffer, QUEUE_MSG_SIZE, "count: %d", count);
         msgQSend(queue1_rt, send_buffer, WRITE_SIZE, NO_WAIT, 
MSG_PRI_NORMAL);
         usleep(500 * 1000);
     }
     return NULL;
}

/* Wait for data from the rt thread */
void * rt_recv(void * arg){
     while (1){
         msgQReceive(queue1_rt, receive_buffer, QUEUE_MSG_SIZE, 
WAIT_FOREVER);
         printf("received message: %s\n", receive_buffer);
     }
     return NULL;
}

int main(void){
     /* Disable paging for this program's memory */
     int err = mlockall(MCL_CURRENT | MCL_FUTURE);
     if (err) error(EXIT_FAILURE, errno, "could not disable memory 
paging");

     /* Set the scheduling policy of the main program */
     struct sched_param sparam;
     sparam.sched_priority = 0; /* Must be zero for SCHED_OTHER */
     err = pthread_setschedparam(pthread_self(), SCHED_OTHER, &sparam);
     if (err) error(EXIT_FAILURE, err, "error setting schedule 
parameters");

     /* Create a message queue */
     queue1_rt = msgQCreate(QUEUE_MAX_MSGS, QUEUE_MSG_SIZE, 
MSG_Q_PRIORITY);

     taskSpawn("PROC", 50 /* priority */, VX_FP_TASK * 0, STACK_SIZE,
         (FUNCPTR)rt_loop, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
     taskSpawn("RECV", 50 /* priority */, VX_FP_TASK * 0, STACK_SIZE,
         (FUNCPTR)rt_recv, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

     /* Wait for program to be aborted with <ctrl-c> */
     while (1) sleep(1);
     return 0;
}



==MAKEFILE==

CFLAGS  = $(shell xeno-config --skin=vxworks --cflags) \
   $(shell xeno-config --skin=native --cflags) -std=gnu99 -Werror

LDFLAGS = $(shell xeno-config --skin=vxworks --ldflags) \
   $(shell xeno-config --skin=native --ldflags) \
   -Xlinker -rpath $(shell xeno-config --libdir) \
   -lpthread_rt -lnative

all:
   gcc $(CFLAGS) $(LDFLAGS) test_fpu.c -o test_fpu

Reply via email to