Linux process causes kernel panic
Vladimir Kondratyev
vladimir at kondratyev.su
Mon Aug 6 15:27:43 UTC 2018
I've got similar panic right after skype start
Disabling of SMAP via loader tunable workarounded the panic for me.
Applying of the patch make skype eating 100%CPU in unkillable state.
tail of ktrace dump
1238 skype CALL linux_gettid
1238 skype RET linux_gettid 101123/0x18b03
1238 skype CALL
linux_sys_futex(0x3301edc,0x84,0x1,0x7fffffff,0x3301ec0,0x2)
1238 skype RET linux_sys_futex 0
1238 skype CALL linux_sys_futex(0x33b0fac,0x80,0x1,0,0x33b0f90,0x1)
1238 skype CALL linux_sys_futex(0x3301edc,0x80,0x1,0,0x3301ec0,0x1)
1238 skype RET linux_sys_futex -1 errno -11 Resource temporarily
unavailable
1238 skype CALL
linux_sys_futex(0x3301ec0,0x81,0x1,0x3301ec0,0x33b02c8,0xffffc168)
1238 skype RET linux_sys_futex 0
1238 skype CALL
linux_sys_futex(0x33b0fac,0x85,0x1,0x1,0x33b0fa8,0x4000001)
-- here it stops --
ddb also shows that process is looping somewhere inside linux_sys_futex()
KDB: enter: manual escape to
debugger
[ thread pid 11 tid 100014
]
Stopped at kdb_enter+0x3b: movq
$0,kdb_why
db> bt
1238
Tracing pid 1238 tid 101049 td
0xfffff80157a64000
cpustop_handler() at cpustop_handler+0x28/frame
0xfffffe00009d6df0
ipi_nmi_handler() at ipi_nmi_handler+0x44/frame
0xfffffe00009d6e10
trap() at trap+0x49/frame
0xfffffe00009d6f20
nmi_calltrap() at nmi_calltrap+0x8/frame
0xfffffe00009d6f20
--- trap 0x13, rip = 0xffffffff80709219, rsp = 0xfffffe00a8c906d0, rbp =
0xfffffe00a8c90750
---
witness_unlock() at witness_unlock+0x139/frame 0xfffffe00a8c90750
__mtx_unlock_flags() at __mtx_unlock_flags+0x5d/frame
0xfffffe00a8c90790
futex_put() at futex_put+0x134/frame
0xfffffe00a8c907c0
linux_sys_futex() at linux_sys_futex+0x609/frame
0xfffffe00a8c90880
ia32_syscall() at ia32_syscall+0x282/frame
0xfffffe00a8c909b0
int0x80_syscall_common() at int0x80_syscall_common+0x9c/frame 0x4000001
On 06.08.2018 15:03, Johannes Lundberg wrote:
> On Sat, Aug 4, 2018 at 3:22 PM Konstantin Belousov <kostikbel at gmail.com>
> wrote:
>
>> On Sat, Aug 04, 2018 at 01:12:17PM +0100, Johannes Lundberg wrote:
>>> No panic over night with that tunable so it seems you're on the right
>>> track.
>> Please try this, on top of r337316.
>>
> Been running boinc client now with 4 linux processes at 100% cpu load with
> this patch for a while. So far so good.
>
>
>> diff --git a/sys/amd64/linux/linux_machdep.c
>> b/sys/amd64/linux/linux_machdep.c
>> index 6c5b014853f..434ea0eac07 100644
>> --- a/sys/amd64/linux/linux_machdep.c
>> +++ b/sys/amd64/linux/linux_machdep.c
>> @@ -78,6 +78,9 @@ __FBSDID("$FreeBSD$");
>> #include <vm/vm_kern.h>
>> #include <vm/vm_map.h>
>>
>> +#include <x86/ifunc.h>
>> +#include <x86/sysarch.h>
>> +
>> #include <amd64/linux/linux.h>
>> #include <amd64/linux/linux_proto.h>
>> #include <compat/linux/linux_emul.h>
>> @@ -88,8 +91,6 @@ __FBSDID("$FreeBSD$");
>> #include <compat/linux/linux_signal.h>
>> #include <compat/linux/linux_util.h>
>>
>> -#include <x86/include/sysarch.h>
>> -
>> int
>> linux_execve(struct thread *td, struct linux_execve_args *args)
>> {
>> @@ -276,3 +277,48 @@ linux_set_cloned_tls(struct thread *td, void *desc)
>>
>> return (0);
>> }
>> +
>> +int futex_xchgl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
>> +int futex_xchgl_smap(int oparg, uint32_t *uaddr, int *oldval);
>> +DEFINE_IFUNC(, int, futex_xchgl, (int, uint32_t *, int *), static)
>> +{
>> +
>> + return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
>> + futex_xchgl_smap : futex_xchgl_nosmap);
>> +}
>> +
>> +int futex_addl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
>> +int futex_addl_smap(int oparg, uint32_t *uaddr, int *oldval);
>> +DEFINE_IFUNC(, int, futex_addl, (int, uint32_t *, int *), static)
>> +{
>> +
>> + return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
>> + futex_addl_smap : futex_addl_nosmap);
>> +}
>> +
>> +int futex_orl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
>> +int futex_orl_smap(int oparg, uint32_t *uaddr, int *oldval);
>> +DEFINE_IFUNC(, int, futex_orl, (int, uint32_t *, int *), static)
>> +{
>> +
>> + return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
>> + futex_orl_smap : futex_orl_nosmap);
>> +}
>> +
>> +int futex_andl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
>> +int futex_andl_smap(int oparg, uint32_t *uaddr, int *oldval);
>> +DEFINE_IFUNC(, int, futex_andl, (int, uint32_t *, int *), static)
>> +{
>> +
>> + return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
>> + futex_andl_smap : futex_andl_nosmap);
>> +}
>> +
>> +int futex_xorl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
>> +int futex_xorl_smap(int oparg, uint32_t *uaddr, int *oldval);
>> +DEFINE_IFUNC(, int, futex_xorl, (int, uint32_t *, int *), static)
>> +{
>> +
>> + return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
>> + futex_xorl_smap : futex_xorl_nosmap);
>> +}
>> diff --git a/sys/amd64/linux/linux_support.s
>> b/sys/amd64/linux/linux_support.s
>> index a9f02160be2..391f76414f2 100644
>> --- a/sys/amd64/linux/linux_support.s
>> +++ b/sys/amd64/linux/linux_support.s
>> @@ -38,7 +38,7 @@ futex_fault:
>> movl $-EFAULT,%eax
>> ret
>>
>> -ENTRY(futex_xchgl)
>> +ENTRY(futex_xchgl_nosmap)
>> movq PCPU(CURPCB),%r8
>> movq $futex_fault,PCB_ONFAULT(%r8)
>> movq $VM_MAXUSER_ADDRESS-4,%rax
>> @@ -49,25 +49,58 @@ ENTRY(futex_xchgl)
>> xorl %eax,%eax
>> movq %rax,PCB_ONFAULT(%r8)
>> ret
>> -END(futex_xchgl)
>> +END(futex_xchgl_nosmap)
>>
>> -ENTRY(futex_addl)
>> +ENTRY(futex_xchgl_smap)
>> movq PCPU(CURPCB),%r8
>> movq $futex_fault,PCB_ONFAULT(%r8)
>> movq $VM_MAXUSER_ADDRESS-4,%rax
>> cmpq %rax,%rsi
>> ja futex_fault
>> + stac
>> + xchgl %edi,(%rsi)
>> + clac
>> + movl %edi,(%rdx)
>> + xorl %eax,%eax
>> + movq %rax,PCB_ONFAULT(%r8)
>> + ret
>> +END(futex_xchgl_smap)
>> +
>> +ENTRY(futex_addl_nosmap)
>> + movq PCPU(CURPCB),%r8
>> + movq $futex_fault,PCB_ONFAULT(%r8)
>> + movq $VM_MAXUSER_ADDRESS-4,%rax
>> + cmpq %rax,%rsi
>> + ja futex_fault
>> +#ifdef SMP
>> + lock
>> +#endif
>> + xaddl %edi,(%rsi)
>> + movl %edi,(%rdx)
>> + xorl %eax,%eax
>> + movq %rax,PCB_ONFAULT(%r8)
>> + ret
>> +END(futex_addl_nosmap)
>> +
>> +ENTRY(futex_addl_smap)
>> + movq PCPU(CURPCB),%r8
>> + movq $futex_fault,PCB_ONFAULT(%r8)
>> + movq $VM_MAXUSER_ADDRESS-4,%rax
>> + cmpq %rax,%rsi
>> + ja futex_fault
>> + stac
>> #ifdef SMP
>> lock
>> #endif
>> xaddl %edi,(%rsi)
>> + clac
>> movl %edi,(%rdx)
>> xorl %eax,%eax
>> movq %rax,PCB_ONFAULT(%r8)
>> ret
>> -END(futex_addl)
>> +END(futex_addl_smap)
>>
>> -ENTRY(futex_orl)
>> +ENTRY(futex_orl_nosmap)
>> movq PCPU(CURPCB),%r8
>> movq $futex_fault,PCB_ONFAULT(%r8)
>> movq $VM_MAXUSER_ADDRESS-4,%rax
>> @@ -85,9 +118,31 @@ ENTRY(futex_orl)
>> xorl %eax,%eax
>> movq %rax,PCB_ONFAULT(%r8)
>> ret
>> -END(futex_orl)
>> +END(futex_orl_nosmap)
>>
>> -ENTRY(futex_andl)
>> +ENTRY(futex_orl_smap)
>> + movq PCPU(CURPCB),%r8
>> + movq $futex_fault,PCB_ONFAULT(%r8)
>> + movq $VM_MAXUSER_ADDRESS-4,%rax
>> + cmpq %rax,%rsi
>> + ja futex_fault
>> + movl (%rsi),%eax
>> +1: movl %eax,%ecx
>> + orl %edi,%ecx
>> + stac
>> +#ifdef SMP
>> + lock
>> +#endif
>> + cmpxchgl %ecx,(%rsi)
>> + clac
>> + jnz 1b
>> + movl %eax,(%rdx)
>> + xorl %eax,%eax
>> + movq %rax,PCB_ONFAULT(%r8)
>> + ret
>> +END(futex_orl_smap)
>> +
>> +ENTRY(futex_andl_nosmap)
>> movq PCPU(CURPCB),%r8
>> movq $futex_fault,PCB_ONFAULT(%r8)
>> movq $VM_MAXUSER_ADDRESS-4,%rax
>> @@ -105,9 +160,51 @@ ENTRY(futex_andl)
>> xorl %eax,%eax
>> movq %rax,PCB_ONFAULT(%r8)
>> ret
>> -END(futex_andl)
>> +END(futex_andl_nosmap)
>> +
>> +ENTRY(futex_andl_smap)
>> + movq PCPU(CURPCB),%r8
>> + movq $futex_fault,PCB_ONFAULT(%r8)
>> + movq $VM_MAXUSER_ADDRESS-4,%rax
>> + cmpq %rax,%rsi
>> + ja futex_fault
>> + movl (%rsi),%eax
>> +1: movl %eax,%ecx
>> + andl %edi,%ecx
>> + stac
>> +#ifdef SMP
>> + lock
>> +#endif
>> + cmpxchgl %ecx,(%rsi)
>> + clac
>> + jnz 1b
>> + movl %eax,(%rdx)
>> + xorl %eax,%eax
>> + movq %rax,PCB_ONFAULT(%r8)
>> + ret
>> +END(futex_andl_smap)
>> +
>> +ENTRY(futex_xorl_nosmap)
>> + movq PCPU(CURPCB),%r8
>> + movq $futex_fault,PCB_ONFAULT(%r8)
>> + movq $VM_MAXUSER_ADDRESS-4,%rax
>> + cmpq %rax,%rsi
>> + ja futex_fault
>> + movl (%rsi),%eax
>> +1: movl %eax,%ecx
>> + xorl %edi,%ecx
>> +#ifdef SMP
>> + lock
>> +#endif
>> + cmpxchgl %ecx,(%rsi)
>> + jnz 1b
>> + movl %eax,(%rdx)
>> + xorl %eax,%eax
>> + movq %rax,PCB_ONFAULT(%r8)
>> + ret
>> +END(futex_xorl_nosmap)
>>
>> -ENTRY(futex_xorl)
>> +ENTRY(futex_xorl_smap)
>> movq PCPU(CURPCB),%r8
>> movq $futex_fault,PCB_ONFAULT(%r8)
>> movq $VM_MAXUSER_ADDRESS-4,%rax
>> @@ -116,13 +213,15 @@ ENTRY(futex_xorl)
>> movl (%rsi),%eax
>> 1: movl %eax,%ecx
>> xorl %edi,%ecx
>> + stac
>> #ifdef SMP
>> lock
>> #endif
>> cmpxchgl %ecx,(%rsi)
>> + clac
>> jnz 1b
>> movl %eax,(%rdx)
>> xorl %eax,%eax
>> movq %rax,PCB_ONFAULT(%r8)
>> ret
>> -END(futex_xorl)
>> +END(futex_xorl_smap)
>> diff --git a/sys/amd64/linux32/linux32_machdep.c
>> b/sys/amd64/linux32/linux32_machdep.c
>> index ce06be57e9f..61ecc87dc77 100644
>> --- a/sys/amd64/linux32/linux32_machdep.c
>> +++ b/sys/amd64/linux32/linux32_machdep.c
>> @@ -58,10 +58,12 @@ __FBSDID("$FreeBSD$");
>> #include <sys/wait.h>
>>
>> #include <machine/frame.h>
>> +#include <machine/md_var.h>
>> #include <machine/pcb.h>
>> #include <machine/psl.h>
>> #include <machine/segments.h>
>> #include <machine/specialreg.h>
>> +#include <x86/ifunc.h>
>>
>> #include <vm/pmap.h>
>> #include <vm/vm.h>
>> @@ -822,3 +824,48 @@ linux_set_thread_area(struct thread *td,
>>
>> return (0);
>> }
>> +
>> +int futex_xchgl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
>> +int futex_xchgl_smap(int oparg, uint32_t *uaddr, int *oldval);
>> +DEFINE_IFUNC(, int, futex_xchgl, (int, uint32_t *, int *), static)
>> +{
>> +
>> + return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
>> + futex_xchgl_smap : futex_xchgl_nosmap);
>> +}
>> +
>> +int futex_addl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
>> +int futex_addl_smap(int oparg, uint32_t *uaddr, int *oldval);
>> +DEFINE_IFUNC(, int, futex_addl, (int, uint32_t *, int *), static)
>> +{
>> +
>> + return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
>> + futex_addl_smap : futex_addl_nosmap);
>> +}
>> +
>> +int futex_orl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
>> +int futex_orl_smap(int oparg, uint32_t *uaddr, int *oldval);
>> +DEFINE_IFUNC(, int, futex_orl, (int, uint32_t *, int *), static)
>> +{
>> +
>> + return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
>> + futex_orl_smap : futex_orl_nosmap);
>> +}
>> +
>> +int futex_andl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
>> +int futex_andl_smap(int oparg, uint32_t *uaddr, int *oldval);
>> +DEFINE_IFUNC(, int, futex_andl, (int, uint32_t *, int *), static)
>> +{
>> +
>> + return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
>> + futex_andl_smap : futex_andl_nosmap);
>> +}
>> +
>> +int futex_xorl_nosmap(int oparg, uint32_t *uaddr, int *oldval);
>> +int futex_xorl_smap(int oparg, uint32_t *uaddr, int *oldval);
>> +DEFINE_IFUNC(, int, futex_xorl, (int, uint32_t *, int *), static)
>> +{
>> +
>> + return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
>> + futex_xorl_smap : futex_xorl_nosmap);
>> +}
>> diff --git a/sys/amd64/linux32/linux32_support.s
>> b/sys/amd64/linux32/linux32_support.s
>> index bba0d8d5e71..981bba9f582 100644
>> --- a/sys/amd64/linux32/linux32_support.s
>> +++ b/sys/amd64/linux32/linux32_support.s
>> @@ -38,7 +38,7 @@ futex_fault:
>> movl $-EFAULT,%eax
>> ret
>>
>> -ENTRY(futex_xchgl)
>> +ENTRY(futex_xchgl_nosmap)
>> movq PCPU(CURPCB),%r8
>> movq $futex_fault,PCB_ONFAULT(%r8)
>> movq $VM_MAXUSER_ADDRESS-4,%rax
>> @@ -49,25 +49,58 @@ ENTRY(futex_xchgl)
>> xorl %eax,%eax
>> movq %rax,PCB_ONFAULT(%r8)
>> ret
>> -END(futex_xchgl)
>> +END(futex_xchgl_nosmap)
>>
>> -ENTRY(futex_addl)
>> +ENTRY(futex_xchgl_smap)
>> movq PCPU(CURPCB),%r8
>> movq $futex_fault,PCB_ONFAULT(%r8)
>> movq $VM_MAXUSER_ADDRESS-4,%rax
>> cmpq %rax,%rsi
>> ja futex_fault
>> + stac
>> + xchgl %edi,(%rsi)
>> + clac
>> + movl %edi,(%rdx)
>> + xorl %eax,%eax
>> + movq %rax,PCB_ONFAULT(%r8)
>> + ret
>> +END(futex_xchgl_smap)
>> +
>> +ENTRY(futex_addl_nosmap)
>> + movq PCPU(CURPCB),%r8
>> + movq $futex_fault,PCB_ONFAULT(%r8)
>> + movq $VM_MAXUSER_ADDRESS-4,%rax
>> + cmpq %rax,%rsi
>> + ja futex_fault
>> +#ifdef SMP
>> + lock
>> +#endif
>> + xaddl %edi,(%rsi)
>> + movl %edi,(%rdx)
>> + xorl %eax,%eax
>> + movq %rax,PCB_ONFAULT(%r8)
>> + ret
>> +END(futex_addl_nosmap)
>> +
>> +ENTRY(futex_addl_smap)
>> + movq PCPU(CURPCB),%r8
>> + movq $futex_fault,PCB_ONFAULT(%r8)
>> + movq $VM_MAXUSER_ADDRESS-4,%rax
>> + cmpq %rax,%rsi
>> + ja futex_fault
>> + stac
>> #ifdef SMP
>> lock
>> #endif
>> xaddl %edi,(%rsi)
>> + clac
>> movl %edi,(%rdx)
>> xorl %eax,%eax
>> movq %rax,PCB_ONFAULT(%r8)
>> ret
>> -END(futex_addl)
>> +END(futex_addl_smap)
>>
>> -ENTRY(futex_orl)
>> +ENTRY(futex_orl_nosmap)
>> movq PCPU(CURPCB),%r8
>> movq $futex_fault,PCB_ONFAULT(%r8)
>> movq $VM_MAXUSER_ADDRESS-4,%rax
>> @@ -85,9 +118,31 @@ ENTRY(futex_orl)
>> xorl %eax,%eax
>> movq %rax,PCB_ONFAULT(%r8)
>> ret
>> -END(futex_orl)
>> +END(futex_orl_nosmap)
>>
>> -ENTRY(futex_andl)
>> +ENTRY(futex_orl_smap)
>> + movq PCPU(CURPCB),%r8
>> + movq $futex_fault,PCB_ONFAULT(%r8)
>> + movq $VM_MAXUSER_ADDRESS-4,%rax
>> + cmpq %rax,%rsi
>> + ja futex_fault
>> + movl (%rsi),%eax
>> +1: movl %eax,%ecx
>> + orl %edi,%ecx
>> + stac
>> +#ifdef SMP
>> + lock
>> +#endif
>> + cmpxchgl %ecx,(%rsi)
>> + clac
>> + jnz 1b
>> + movl %eax,(%rdx)
>> + xorl %eax,%eax
>> + movq %rax,PCB_ONFAULT(%r8)
>> + ret
>> +END(futex_orl_smap)
>> +
>> +ENTRY(futex_andl_nosmap)
>> movq PCPU(CURPCB),%r8
>> movq $futex_fault,PCB_ONFAULT(%r8)
>> movq $VM_MAXUSER_ADDRESS-4,%rax
>> @@ -105,9 +160,51 @@ ENTRY(futex_andl)
>> xorl %eax,%eax
>> movq %rax,PCB_ONFAULT(%r8)
>> ret
>> -END(futex_andl)
>> +END(futex_andl_nosmap)
>> +
>> +ENTRY(futex_andl_smap)
>> + movq PCPU(CURPCB),%r8
>> + movq $futex_fault,PCB_ONFAULT(%r8)
>> + movq $VM_MAXUSER_ADDRESS-4,%rax
>> + cmpq %rax,%rsi
>> + ja futex_fault
>> + movl (%rsi),%eax
>> +1: movl %eax,%ecx
>> + andl %edi,%ecx
>> + stac
>> +#ifdef SMP
>> + lock
>> +#endif
>> + cmpxchgl %ecx,(%rsi)
>> + clac
>> + jnz 1b
>> + movl %eax,(%rdx)
>> + xorl %eax,%eax
>> + movq %rax,PCB_ONFAULT(%r8)
>> + ret
>> +END(futex_andl_smap)
>> +
>> +ENTRY(futex_xorl_nosmap)
>> + movq PCPU(CURPCB),%r8
>> + movq $futex_fault,PCB_ONFAULT(%r8)
>> + movq $VM_MAXUSER_ADDRESS-4,%rax
>> + cmpq %rax,%rsi
>> + ja futex_fault
>> + movl (%rsi),%eax
>> +1: movl %eax,%ecx
>> + xorl %edi,%ecx
>> +#ifdef SMP
>> + lock
>> +#endif
>> + cmpxchgl %ecx,(%rsi)
>> + jnz 1b
>> + movl %eax,(%rdx)
>> + xorl %eax,%eax
>> + movq %rax,PCB_ONFAULT(%r8)
>> + ret
>> +END(futex_xorl_nosmap)
>>
>> -ENTRY(futex_xorl)
>> +ENTRY(futex_xorl_smap)
>> movq PCPU(CURPCB),%r8
>> movq $futex_fault,PCB_ONFAULT(%r8)
>> movq $VM_MAXUSER_ADDRESS-4,%rax
>> @@ -116,13 +213,15 @@ ENTRY(futex_xorl)
>> movl (%rsi),%eax
>> 1: movl %eax,%ecx
>> xorl %edi,%ecx
>> + stac
>> #ifdef SMP
>> lock
>> #endif
>> cmpxchgl %ecx,(%rsi)
>> + clac
>> jnz 1b
>> movl %eax,(%rdx)
>> xorl %eax,%eax
>> movq %rax,PCB_ONFAULT(%r8)
>> ret
>> -END(futex_xorl)
>> +END(futex_xorl_smap)
>>
> _______________________________________________
> freebsd-current at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe at freebsd.org"
More information about the freebsd-current
mailing list