Summary: | dtrace immediately panics the system if compiled without SMP | ||
---|---|---|---|
Product: | Base System | Reporter: | alex_y_xu |
Component: | kern | Assignee: | Mark Johnston <markj> |
Status: | Closed FIXED | ||
Severity: | Affects Some People | CC: | markj |
Priority: | --- | ||
Version: | CURRENT | ||
Hardware: | amd64 | ||
OS: | Any |
Description
alex_y_xu
2020-01-29 19:13:11 UTC
Hmm, I can't even boot a non-SMP amd64 kernel on head; we panic when adding a thread. I guess this is some fallout from the recent scheduler locking optimizations. That said, I can't quite see the issue from looking at the DTrace code. Which revision are you running? Out of curiosity, why are you using a non-SMP kernel? (In reply to Mark Johnston from comment #1) > Which revision are you running? I used https://download.freebsd.org/ftp/snapshots/VM-IMAGES/13.0-CURRENT/amd64/Latest/FreeBSD-13.0-CURRENT-amd64.qcow2.xz (date 2020-Jan-23 09:41) and https://download.freebsd.org/ftp/snapshots/amd64/13.0-CURRENT/src.txz (date 2020-Jan-23 08:56). My understanding is that these are kept up-to-date, but probably your source copy is newer. > I can't quite see the issue from looking at the DTrace code. I also tried some debugging, but I am not familiar with the FreeBSD kernel. I suspect that the backtrace is not accurate. With FreeBSD 12.1-STABLE, I acquired a backtrace that had some dtrace state=non-zero, then magically become arg=0x0 when it reached dtrace_xcall or thereabouts. Maybe something strange is going on with the registers during the trap and panic though. I didn't get around to trying DDB though. > why are you using a non-SMP kernel? I want to use a non-SMP kernel because I am on a single-CPU VM and I assume that no-SMP kernels are more efficient. On Linux, spinlocks in interrupt-disabled context can be compiled out of the kernel in no-SMP mode. If it's really poorly tested though, there's no particular reason I *can't* use an SMP kernel. (In reply to alex_y_xu from comment #2) Ah, I think the snapshots have invariants-checking disabled, which would explain why you're not seeing the problem during boot. > I want to use a non-SMP kernel because I am on a single-CPU VM and I assume that no-SMP kernels are more efficient. Fair enough. Indeed, mtx_lock_spin() does nothing but disable interrupts in non-SMP FreeBSD kernels (and nothing if they are already disabled). Non-SMP kernels definitely aren't as well tested though. It looks like DTrace has been broken there basically forever: MAXCPU is 256 in kernel modules even when compiled without SMP: #if defined(SMP) || defined(KLD_MODULE) #ifndef MAXCPU #define MAXCPU 256 #endif #else #define MAXCPU 1 #endif ... and smp_rendezvous() and other kernel APIs use pass-by-value for cpuset_t's for a reason that is not clear to me. (In reply to Mark Johnston from comment #3) That would definitely explain why arg suddenly becomes zero, and probably also why dtrace_buffer_activate shifts from action_func to setup_func. The boot-time panic is fixed by r357473, I believe this will fix the DTrace panic, though I haven't yet tested: https://reviews.freebsd.org/D23512 A commit references this bug: Author: markj Date: Wed Feb 5 19:08:22 UTC 2020 New revision: 357585 URL: https://svnweb.freebsd.org/changeset/base/357585 Log: Define MAXCPU consistently between the kernel and KLDs. This reverts r177661. The change is no longer very useful since out-of-tree KLDs will be built to target SMP kernels anyway. Moveover it breaks the KBI in !SMP builds since cpuset_t's layout depends on the value of MAXCPU, and several kernel interfaces, notably smp_rendezvous_cpus(), take a cpuset_t as a parameter. PR: 243711 Reviewed by: jhb, kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D23512 Changes: head/sys/amd64/include/param.h head/sys/arm/include/param.h head/sys/arm64/include/param.h head/sys/i386/include/param.h head/sys/powerpc/include/param.h head/sys/riscv/include/param.h A commit references this bug: Author: markj Date: Wed Feb 5 19:08:46 UTC 2020 New revision: 357586 URL: https://svnweb.freebsd.org/changeset/base/357586 Log: Stop compiling dtrace modules with -DSMP. I believe this is left over from when dtrace was being ported and developed out-of-tree. Now it just ensures that dtrace.ko and a non-SMP kernel have incompatible KBIs. PR: 243711 Sponsored by: The FreeBSD Foundation Changes: head/sys/modules/dtrace/dtrace/Makefile head/sys/modules/dtrace/fasttrap/Makefile Thanks for the report. I think the param.h change will live in head only and not be backported to stable/12, since they change the KBI. |