Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E25DA2C234A for ; Fri, 3 Jul 2026 08:36:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783067804; cv=none; b=uCruiMHc3T4bbWBmAnzDn/HkCA5P9sdf0dyJhAbItZHz7O69/j20Bal+Me1vUnoYsuWfLUqARKFZuMzZi/ikSTR9U7+UR9gP+yjGL+HIe2UM9Kpx4ZCNbuvZjt47kOsYGpFufNrSG/JuLhDxbbqoYnlKB5kLv7VPIq/jt+5JIPU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783067804; c=relaxed/simple; bh=db4VjVfZXOg6Omk7oahaeNyiG1zdOMUf0QIjRPNZVOY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Bt65a1PxTkr3o1riED7xEux2vWj6grDk1bETID1SYVNJqfLOi3XmNSgFIhbgwy42alOFlBfqLjK7M8TpmEJo9vHzIDQ3XEH+X3unbUY3sMy0x1dw0XsWyLZNDCvFUcMO88r2A0zRizn/Zw25UHIFjyObECHlmcSiWhlTSXL7Y8A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 4dd6c8e476ba11f1aa26b74ffac11d73-20260703 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:c141fe74-0f13-484c-8929-82e6d4441d8f,IP:10, URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:10 X-CID-INFO: VERSION:1.3.12,REQID:c141fe74-0f13-484c-8929-82e6d4441d8f,IP:10,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION:r elease,TS:10 X-CID-META: VersionHash:e7bac3a,CLOUDID:610d28ca64a1af9ca80f283cbae5c514,BulkI D:260703163637MPPGU4DH,BulkQuantity:0,Recheck:0,SF:10|38|66|78|102|127|865 |898,TC:nil,Content:0|15|50,EDM:-3,IP:-2,URL:0,File:nil,RT:nil,Bulk:nil,QS :nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,A RC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 4dd6c8e476ba11f1aa26b74ffac11d73-20260703 X-User: tanze@kylinos.cn Received: from desktop-od00ebi.localdomain [(116.128.244.169)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 548599624; Fri, 03 Jul 2026 16:36:36 +0800 From: tanze To: anna-maria@linutronix.de, frederic@kernel.org, tglx@kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH v1] timers: Feed soft lockup watchdog in expire_timers() Date: Fri, 3 Jul 2026 16:36:21 +0800 Message-ID: <20260703083624.80072-1-tanze@kylinos.cn> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit expire_timers() iterates over all expired timers and invokes their callbacks one by one in softirq context. Each individual callback may complete quickly, but when a very large number of timers expire at the same tick, the aggregate time spent in this loop can exceed the soft lockup watchdog threshold, causing a false positive: watchdog: BUG: soft lockup - CPU#0 stuck for 26s! [syz.6.2424:14364] Call Trace: _raw_spin_unlock_irq+0x30/0x50 __run_timers+0x75b/0xb20 run_timer_softirq+0x22/0x40 handle_softirqs+0x20b/0x7f0 __irq_exit_rcu+0x184/0x1d0 sysvec_apic_timer_interrupt+0x72/0x90 generic_exec_single+0xa0/0x530 smp_call_function_single+0x328/0x410 task_function_call+0xee/0x180 perf_install_in_context+0x2df/0x580 __do_sys_perf_event_open+0x1602/0x26e0 do_syscall_64+0x73/0x2c0 This is reproducible by issuing many perf_event_open() syscalls with PERF_COUNT_SW_CPU_CLOCK and a very small sample_period, which creates a large number of software timers that expire simultaneously. The CPU is making forward progress -- executing timer callbacks one after another -- but the watchdog is never reset during the batch. Found by running syzkaller on a local QEMU instance. Add touch_softlockup_watchdog() after each call_timer_fn() invocation in expire_timers(). This resets the watchdog timestamp after every successfully completed callback. If a single callback itself is stuck, the touch_softlockup_watchdog() after it will never be reached, so the watchdog correctly fires for genuine lockups. Signed-off-by: tanze --- kernel/time/timer.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 655a8c6cd84d..7f3369ad8a5c 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -1792,11 +1793,13 @@ static void expire_timers(struct timer_base *base, struct hlist_head *head) if (timer->flags & TIMER_IRQSAFE) { raw_spin_unlock(&base->lock); call_timer_fn(timer, fn, baseclk); + touch_softlockup_watchdog(); raw_spin_lock(&base->lock); base->running_timer = NULL; } else { raw_spin_unlock_irq(&base->lock); call_timer_fn(timer, fn, baseclk); + touch_softlockup_watchdog(); raw_spin_lock_irq(&base->lock); base->running_timer = NULL; timer_sync_wait_running(base); -- 2.43.0