From nobody Thu Mar 28 20:22:38 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C315C433FE for ; Thu, 24 Nov 2022 14:16:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230129AbiKXOQv (ORCPT ); Thu, 24 Nov 2022 09:16:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229909AbiKXOQQ (ORCPT ); Thu, 24 Nov 2022 09:16:16 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D2FBEA128; Thu, 24 Nov 2022 06:16:15 -0800 (PST) Date: Thu, 24 Nov 2022 14:16:12 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669299374; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3m874idn9Kx9e+cDUz2vlQYsIll3YBW81NoQQ5r8bsk=; b=G/dfXq6edlvxG9C/fT6VglHmU9INqzm38VDDZPIRBZh4X+kNLKUkFO7cdbeHO6BkL1Z4Qz lZsvypDOLNx6Addn/SD0VYW4Rln82q26xGT6PpBvKNxxh5AQnZyYBTrPqLc8qCxGOjd6Oq 2564ZBvPB5lh04biE+HulMrzUGFMtErjPXMaKQufJKXl5pgHvjw/yy07RC1LkDj7xPpC8Y zG3mgBUhe3/nrgkRwd4weWOdzu6UWgdhpvv4S2OEcJGt6IBYHtoydWQpRWiGUs5E5Wvy9S KEGLjSOgle7iTuhCkHqdp1VeAPEbPXWI1aSuk2FsfyPlFHozjltdeVuIIFCCJQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669299374; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3m874idn9Kx9e+cDUz2vlQYsIll3YBW81NoQQ5r8bsk=; b=MpzUVvc36Us9/tvZ3blPYUP0MQ8JGSToBDfevYG1a2nv+wPjWxpMeGF/jMkVgXbK9W9CDx N9IX8olynxSRcZAw== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] timers: Replace BUG_ON()s Cc: Thomas Gleixner , Guenter Roeck , Jacob Keller , "Anna-Maria Behnsen" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221123201624.769128888@linutronix.de> References: <20221123201624.769128888@linutronix.de> MIME-Version: 1.0 Message-ID: <166929937293.4906.15041698876675319787.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the timers/core branch of tip: Commit-ID: 82ed6f7ef58f9634fe4462dd721902c580f01569 Gitweb: https://git.kernel.org/tip/82ed6f7ef58f9634fe4462dd721902c58= 0f01569 Author: Thomas Gleixner AuthorDate: Wed, 23 Nov 2022 21:18:39 +01:00 Committer: Thomas Gleixner CommitterDate: Thu, 24 Nov 2022 15:09:11 +01:00 timers: Replace BUG_ON()s The timer code still has a few BUG_ON()s left which are crashing the kernel in situations where it still can recover or simply refuse to take an action. Remove the one in the hotplug callback which checks for the CPU being offline. If that happens then the whole hotplug machinery will explode in colourful ways. Replace the rest with WARN_ON_ONCE() and conditional returns where appropriate. Signed-off-by: Thomas Gleixner Tested-by: Guenter Roeck Reviewed-by: Jacob Keller Reviewed-by: Anna-Maria Behnsen Link: https://lore.kernel.org/r/20221123201624.769128888@linutronix.de --- kernel/time/timer.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 190e069..cec37b1 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1193,7 +1193,8 @@ EXPORT_SYMBOL(timer_reduce); */ void add_timer(struct timer_list *timer) { - BUG_ON(timer_pending(timer)); + if (WARN_ON_ONCE(timer_pending(timer))) + return; __mod_timer(timer, timer->expires, MOD_TIMER_NOTPENDING); } EXPORT_SYMBOL(add_timer); @@ -1210,7 +1211,8 @@ void add_timer_on(struct timer_list *timer, int cpu) struct timer_base *new_base, *base; unsigned long flags; =20 - BUG_ON(timer_pending(timer) || !timer->function); + if (WARN_ON_ONCE(timer_pending(timer) || !timer->function)) + return; =20 new_base =3D get_timer_cpu_base(timer->flags, cpu); =20 @@ -2017,8 +2019,6 @@ int timers_dead_cpu(unsigned int cpu) struct timer_base *new_base; int b, i; =20 - BUG_ON(cpu_online(cpu)); - for (b =3D 0; b < NR_BASES; b++) { old_base =3D per_cpu_ptr(&timer_bases[b], cpu); new_base =3D get_cpu_ptr(&timer_bases[b]); @@ -2035,7 +2035,8 @@ int timers_dead_cpu(unsigned int cpu) */ forward_timer_base(new_base); =20 - BUG_ON(old_base->running_timer); + WARN_ON_ONCE(old_base->running_timer); + old_base->running_timer =3D NULL; =20 for (i =3D 0; i < WHEEL_SIZE; i++) migrate_timer_list(new_base, old_base->vectors + i);