Root Cause Analysis
The soft lockup (CPU#1 stuck for 24s! [kworker/u8:0:13]) is caused by an unnecessarily broad spinlock critical section in nsim_dev_trap_report() (drivers/net/netdevsim/dev.c:778-820), which prevents kernel preemption across heavy SKB allocation, devlink trap reporting, and debugobjects-instrumented slab freeing.
Every NSIM_TRAP_REPORT_INTERVAL_MS (100 ms), nsim_dev_trap_report_work() (drivers/net/netdevsim/dev.c:824-854) acquires devl_trylock(priv_to_devlink(nsim_dev)) and iterates over nsim_dev->port_list. For each running port (netif_running(nsim_dev_port->ns->netdev)), it calls nsim_dev_trap_report(nsim_dev_port) followed by cond_resched().
Inside nsim_dev_trap_report():
spin_lock(&nsim_trap_data->trap_lock) is acquired at line 787 and held across the entire for (i = 0; i < ARRAY_SIZE(nsim_traps_arr); i++) loop (14 traps) until spin_unlock(&nsim_trap_data->trap_lock) at line 819.
- As documented in
nsim_dev_traps_init() (drivers/net/netdevsim/dev.c:881-885) and nsim_dev_devlink_trap_action_set() (drivers/net/netdevsim/dev.c:1086-1088), nsim_trap_data->trap_lock only protects nsim_trap_item->action (nsim_trap_item->trap_ctx is registered once under devl_lock and remains invariant).
- Despite this,
nsim_dev_trap_report() keeps trap_lock held (maintaining preempt_count() >= 1) while executing:
nsim_dev_trap_skb_build() (line 801): alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC) and packet header construction (eth_random_addr(), get_random_bytes(), ip_fast_csum()).
spin_lock_bh(&nsim_dev->fa_cookie_lock) / devlink_trap_report() / spin_unlock_bh(&nsim_dev->fa_cookie_lock) (lines 812-816): updates per-CPU devlink stats and invokes trace_devlink_trap_report() (which can trigger net/core/drop_monitor.c probes).
consume_skb(skb) (line 817): releases the SKB via skb_release_all() -> skb_release_data() -> skb_free_head() -> skb_kfree_head() -> kfree().
Note that nsim_dev->port_list and device/trap teardown are properly serialized by devl_lock() / devl_trylock() and cancel_delayed_work_sync(&nsim_dev->trap_data->trap_report_dw) in nsim_dev_traps_exit() (drivers/net/netdevsim/dev.c:932); there is no use-after-free or list corruption.
2. Non-Preemptible debug_check_no_obj_freed() Overhead and Watchdog Trigger
Because CONFIG_PREEMPT=y is enabled, migration/1 (running softlockup_fn() queued via stop_one_cpu_nowait() from watchdog_timer_fn() in kernel/watchdog.c:823-825) can preempt kworker/u8:0 only when preempt_count() == 0 and interrupts are enabled.
In this report:
- With
CONFIG_DEBUG_OBJECTS_FREE=y and CONFIG_KASAN_INLINE=y, kfree() calls slab_free_hook() -> debug_check_no_obj_freed() -> __debug_check_no_obj_freed() (lib/debugobjects.c:1141-1196) for the NLMSG_GOODSIZE skb->head allocation.
__debug_check_no_obj_freed() iterates across ODEBUG_CHUNK_SIZE (1 << PAGE_SHIFT) chunks in obj_hash (16,384 buckets, ODEBUG_HASH_BITS = 14), acquiring raw_spin_lock_irqsave(&db->lock, flags) and traversing db->list (hlist_for_each_entry_safe(obj, tmp, &db->list, node)).
- CPU#1's registers confirm heavy
obj_hash chain traversal at the time of the interrupt: x20 = ffff80008e659df0 (&db->lock), x21 = dead000000000100 (LIST_POISON1), x22 = dead000000000122 (LIST_POISON2), x23 = 0x1115 (4,373 entries in cnt), and x25 = 0x99bd (39,357 total entries in objs_checked).
- The IRQ trace stamps show
softirqs last enabled at (1089628) at spin_unlock_bh (dev.c:816), followed by hardirqs last enabled at (1089633) inside irqentry_exit_to_kernel_mode_after_preempt() (arch/arm64/kernel/entry-common.c:99). Because trap_lock kept preempt_count() > 0, that interrupt exit could not preempt kworker/u8:0 to run migration/1. Immediately afterwards, at 1089634, el1_interrupt (watchdog_timer_fn()) fired right as raw_spin_unlock_irqrestore(&db->lock, flags) (lib/debugobjects.c:1180, include/linux/spinlock_api_smp.h:210-211) unmasked IRQs before preempt_enable().
- Additionally, on
arm64 (linux,dummy-virt), running_clock() uses local_clock() (kernel/sched/clock.c:508) and kvm_check_and_clear_guest_paused() is a no-op returning false (include/asm-generic/kvm_para.h:12), so any virtualized/emulated execution delay while trap_lock holds preemption disabled directly accumulates against get_softlockup_thresh() (20s).
3. Fix Direction
In nsim_dev_trap_report() (drivers/net/netdevsim/dev.c:787-819), nsim_trap_data->trap_lock only needs to be held while reading nsim_trap_item->action (or trap_lock can be dropped before nsim_dev_trap_skb_build() / devlink_trap_report() / consume_skb(), or replaced with READ_ONCE/WRITE_ONCE for nsim_trap_item->action), so that SKB allocation, trap reporting, and consume_skb() execute in preemptible context.