From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A3087328639; Mon, 27 Oct 2025 19:09:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761592187; cv=none; b=BKYvhKjSHt9voxitXIPWz+fyf0QbwjqBnsUl3zrlLGSzhbn7sA9AKVlUo74gXtpOPhyEEGyUXxKiubodh4d2ujixMP1T3L32+TsxtxlP7B29YaOaQBWnNu+OMeoWQ86h+Yu6fpA4O0QaUS9u5Q5xPQMnOqGhm7klzjKDLXQ6zR0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761592187; c=relaxed/simple; bh=Jk3vk0WkVz8Mc5jvmhDayM0C3ycd1mmFjoRFrDlT3uY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PV32yjD1KruogGcrgb8NV5eOMna3EmbfCNWy1ijgcfmK9TpyZMngHLdE/tAqk0z8HCO0oVtvbeYJG9Uc3gnnzUzKZI9e5gbaZoqpEk37kzX3NW21SSJUSVKGpJtQDFEXGJiM0rnSh1HYJ5ccGhXccp0tZ6y5Dx2RrC8tM47ZvZA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=sr1SG/sH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="sr1SG/sH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A05FC4CEF1; Mon, 27 Oct 2025 19:09:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761592187; bh=Jk3vk0WkVz8Mc5jvmhDayM0C3ycd1mmFjoRFrDlT3uY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sr1SG/sHJchR/DqJ/FUBlMIXRU08PCrFdd6+m3YiV7KyIEXxVcAs8Mz5z8G6uQRkg 5EcAlR8lMZtIgkCYUev67Qt5Erc2Ygmb+RUyKHyr0UDFaCfNqln2ygdZniZwMf1n0X 5iaDvqLzcmniKvyXqXdW1TeJKEcdcuIEjFLwOl2A= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Thomas Gleixner , Guenter Roeck , Jacob Keller , Anna-Maria Behnsen , Jeongjun Park Subject: [PATCH 6.1 027/157] timers: Replace BUG_ON()s Date: Mon, 27 Oct 2025 19:34:48 +0100 Message-ID: <20251027183502.013783510@linuxfoundation.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251027183501.227243846@linuxfoundation.org> References: <20251027183501.227243846@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Gleixner [ Upstream commit 82ed6f7ef58f9634fe4462dd721902c580f01569 ] 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 Signed-off-by: Jeongjun Park Signed-off-by: Greg Kroah-Hartman --- kernel/time/timer.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1208,7 +1208,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); @@ -1227,7 +1228,8 @@ void add_timer_on(struct timer_list *tim struct timer_base *new_base, *base; unsigned long flags; - BUG_ON(timer_pending(timer) || !timer->function); + if (WARN_ON_ONCE(timer_pending(timer) || !timer->function)) + return; new_base = get_timer_cpu_base(timer->flags, cpu); @@ -2047,8 +2049,6 @@ int timers_dead_cpu(unsigned int cpu) struct timer_base *new_base; int b, i; - BUG_ON(cpu_online(cpu)); - for (b = 0; b < NR_BASES; b++) { old_base = per_cpu_ptr(&timer_bases[b], cpu); new_base = get_cpu_ptr(&timer_bases[b]); @@ -2065,7 +2065,8 @@ int timers_dead_cpu(unsigned int cpu) */ forward_timer_base(new_base); - BUG_ON(old_base->running_timer); + WARN_ON_ONCE(old_base->running_timer); + old_base->running_timer = NULL; for (i = 0; i < WHEEL_SIZE; i++) migrate_timer_list(new_base, old_base->vectors + i);