From patchwork Wed Nov 23 20:18:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 25191 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3008958wrr; Wed, 23 Nov 2022 12:22:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf6eInNx43xlQazlIy6dwrmFvmg0myx5jGJeZH2Ct1PXnnL1VTOJZf4Uvv3OkDuKANjFgnMB X-Received: by 2002:a17:906:7f92:b0:783:7020:53a7 with SMTP id f18-20020a1709067f9200b00783702053a7mr24654849ejr.736.1669234934496; Wed, 23 Nov 2022 12:22:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669234934; cv=none; d=google.com; s=arc-20160816; b=oUbgLNa78H1EC3vM0p6Ld2ZXXFGu4n/d8GxVyxOxHL74w2znQE9ipGyuP8ks6dRzrK i+HP0TRvauwtAe4a/0FF+sD8KdvorimIFnvaL+FmpVmCA8EaJR+G9OrWNaDkbPb0Ihm7 u9TW7chHQ+/aGKZoz9YGDhr8uHz5prV++bqwmhcWu701bsQxYP38WdN4K7TFrP+NyZSb c/ATn/Sm127i3fB5hB3MCzY5p9yHqqqTdWI9Tyw1yfKCbCtQE8tC3D8WNW6fXafyAyV9 eNJcenrhCl0JXXrb7NQCriev76pg5EyRp9NISrSmbWTEQLdp0CL14TBuLy82pexVpqhL TKew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=0eY7YnzlwSNTQTRTn0uxqikX7ma7laOZXEtpEJOrwxM=; b=F/LNNNqcCv16fIJXWcdOW0zT0Itu6be5tqXdmAscbKOg4Y/Ql0NNz7nvMrIsJWgWnE VbnQmX16WsQMTGV+xN9FADdrKt2Ie9dijNgtqZjZ1GT78phutqioQlNoSUZ1c/QmMaH4 y8KhZD/PAeupyIHF19bu2cj7KgtRmKhtayd7g4ylPTy2i4p8UYnN+WCq5oFshX5rlNOl 5UYHqTKDRzQn0LBE+renlLZAvp8Zw1xbws5givMBzFmCjPr+C6dHgPSfdMbBv07hxPEx SVTIsGJeDb+0EHatskfiaaOOhSFI6ZsaiOxT4oNqVZx19WV1x28KlWx2dumDKpGp1oqh L2LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="4opf8+/G"; 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 xf9-20020a17090731c900b0079330b37fb5si15824804ejb.564.2022.11.23.12.21.48; Wed, 23 Nov 2022 12:22:14 -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="4opf8+/G"; 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 S239727AbiKWUU5 (ORCPT + 99 others); Wed, 23 Nov 2022 15:20:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237373AbiKWUUP (ORCPT ); Wed, 23 Nov 2022 15:20:15 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8D10B043A; Wed, 23 Nov 2022 12:18:44 -0800 (PST) Message-ID: <20221123201624.888306160@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669234723; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=0eY7YnzlwSNTQTRTn0uxqikX7ma7laOZXEtpEJOrwxM=; b=4opf8+/GOXjJNOy6hPzmeTt80WMzIFSy8Am96kclq97AQbJnWOAprC4vzZ1RZ9AbWkSeZk 8zxZ4sxeVeoBFgxABFY7ezWo75DXTTNGhM4D5jOMM2E+O2bn+NeGpqfZXBMXe7fEmBdJvK wTJmhUcJZEEsksW+Dkwxwh463sn4aIwrjxMUuHxBlkF9QQB2GcTpqhScr8KqDSwvF2OQfy 8ahBVUYnd/xMAqaBzHyud1lYvkZsmsdMMFwp5r3zMlwNBcALp9chFIOkhiH4aIdZi99Xj4 l/Rge2vagqPxQK11ZT3jUQu2tE7GP+DsyoC3XzfC0xe7A+phaeCOUeMdBjcw9w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669234723; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=0eY7YnzlwSNTQTRTn0uxqikX7ma7laOZXEtpEJOrwxM=; b=qUhbnPp1lnq6hw/ZiuMuZPtuw5rIwxw31eQbsu7Um9qICRI4gv+9DhpXmFjAUdmwFAtvnr 9j34rhZTb7lka7Cg== From: Thomas Gleixner To: LKML Cc: Linus Torvalds , Steven Rostedt , Anna-Maria Behnsen , Peter Zijlstra , Stephen Boyd , Guenter Roeck , Andrew Morton , Julia Lawall , Arnd Bergmann , Viresh Kumar , Marc Zyngier , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , linux-bluetooth@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, Jacob Keller Subject: [patch V3 08/17] timers: Use del_timer_sync() even on UP References: <20221123201306.823305113@linutronix.de> MIME-Version: 1.0 Date: Wed, 23 Nov 2022 21:18:42 +0100 (CET) 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?1750319690677703056?= X-GMAIL-MSGID: =?utf-8?q?1750319690677703056?= del_timer_sync() is assumed to be pointless on uniprocessor systems and can be mapped to del_timer() because in theory del_timer() can never be invoked while the timer callback function is executed. This is not entirely true because del_timer() can be invoked from interrupt context and therefore hit in the middle of a running timer callback. Contrary to that del_timer_sync() is not allowed to be invoked from interrupt context unless the affected timer is marked with TIMER_IRQSAFE. del_timer_sync() has proper checks in place to detect such a situation. Give up on the UP optimization and make del_timer_sync() unconditionally available. Co-developed-by: Steven Rostedt Signed-off-by: Steven Rostedt Signed-off-by: Thomas Gleixner Tested-by: Guenter Roeck Reviewed-by: Jacob Keller Link: https://lore.kernel.org/all/20220407161745.7d6754b3@gandalf.local.home Link: https://lore.kernel.org/all/20221110064101.429013735@goodmis.org --- include/linux/timer.h | 7 +------ kernel/time/timer.c | 2 -- 2 files changed, 1 insertion(+), 8 deletions(-) --- a/include/linux/timer.h +++ b/include/linux/timer.h @@ -183,12 +183,7 @@ extern int timer_reduce(struct timer_lis extern void add_timer(struct timer_list *timer); extern int try_to_del_timer_sync(struct timer_list *timer); - -#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT) - extern int del_timer_sync(struct timer_list *timer); -#else -# define del_timer_sync(t) del_timer(t) -#endif +extern int del_timer_sync(struct timer_list *timer); extern void init_timers(void); struct hrtimer; --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1396,7 +1396,6 @@ static inline void timer_sync_wait_runni static inline void del_timer_wait_running(struct timer_list *timer) { } #endif -#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT) /** * del_timer_sync - Deactivate a timer and wait for the handler to finish. * @timer: The timer to be deactivated @@ -1477,7 +1476,6 @@ int del_timer_sync(struct timer_list *ti return ret; } EXPORT_SYMBOL(del_timer_sync); -#endif static void call_timer_fn(struct timer_list *timer, void (*fn)(struct timer_list *),