From patchwork Thu Nov 24 14:16:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 25577 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3426571wrr; Thu, 24 Nov 2022 06:22:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf79msFOWFLOV1MFU4udpYsMZ65OWPi4GrD3A4hv/OjtytkOR23PVmzyOM/ia/uydygg8Eyz X-Received: by 2002:a17:907:8dcc:b0:7b2:b5aa:f1e0 with SMTP id tg12-20020a1709078dcc00b007b2b5aaf1e0mr15444190ejc.54.1669299744784; Thu, 24 Nov 2022 06:22:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669299744; cv=none; d=google.com; s=arc-20160816; b=tLIKz6fIt7Gm8wvbjW8F60b+2X3RC8wQn+A/T/eHLigu3LAs2Z4Y8GTJuSz4BbO7R2 e5ymhehD5BoccfFbVDokb4wCAIvS9wcqaeSL+A8DLLYiWKXwShlaADilfKyuaSN0ZtVn YLY5rK6F/dyVaSrWwd5L+O3V6oBmUT7dp65/NhGStEvo3DOemf/0atSXUfFdrDIBN2Ac smNt2YjXXiGJQldlRYMK4kbJacJsqIF2ZSQdLg3ucSqOFhvKTZqbLC+a5d1IJtdndYlt F0zbZng+XczrWJtAquS5SyIYwcxcQtPOMRZxMomdxNeOm2EXgFPaHxJHvxSCG9SoJYl1 Hisw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=3m874idn9Kx9e+cDUz2vlQYsIll3YBW81NoQQ5r8bsk=; b=MFtPEli8WnExKvj6l1CyI++7aB+18bkWIftLpqODyinJnXT3aoF/F2wMdTGB5t13rz HRErpVVNMSmGJ6tVrvHUQkvXWdBME74YE9xST0yaMgjgWRSgpSwHZZMLg3WMye6fDRL8 MMBhzBmZ8PTq2H8ULCLjR/uQqbu7Q3zmd4jB8kJA4CJ8FyeJM5DELB/eUYh6cqdIwAJa jXEF7FnKA4NdqrlOht4U2/+6iUCDmG4pmDrtVukYiEXqZznLkbeTpoXx0ZUMlOXLHgey DBozaR1oawz7PmScECyLlQNrITYBvXDCbVYU5vkaleBG6GTCgXtnKNgZX5CY/LpE9924 ZHEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="G/dfXq6e"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv19-20020a17090760d300b00787c0e9818csi1161873ejc.568.2022.11.24.06.22.00; Thu, 24 Nov 2022 06:22:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="G/dfXq6e"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230080AbiKXOQu (ORCPT + 99 others); Thu, 24 Nov 2022 09:16:50 -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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750319674644272710?= X-GMAIL-MSGID: =?utf-8?q?1750387649682250033?= The following commit has been merged into the timers/core branch of tip: Commit-ID: 82ed6f7ef58f9634fe4462dd721902c580f01569 Gitweb: https://git.kernel.org/tip/82ed6f7ef58f9634fe4462dd721902c580f01569 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; - 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); @@ -2017,8 +2019,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]); @@ -2035,7 +2035,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);