Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8906801rwb; Thu, 24 Nov 2022 05:51:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf6LmXILoXToyzk2fnglbpXq6oTQrKUIQQnXbMWOQIMWvG5mdKcPcnrEHNDY32/BPPKSnq/m X-Received: by 2002:a17:906:2693:b0:7aa:57c3:3f26 with SMTP id t19-20020a170906269300b007aa57c33f26mr11661509ejc.195.1669297876507; Thu, 24 Nov 2022 05:51:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669297876; cv=none; d=google.com; s=arc-20160816; b=m9uFhGToqex8VH8FW+dv7hc/5yapvb7b/BWhbt/JVNt/h4FGVc9I9cN0fuLr13CyhB 0m+HXVvV2cV36el/Cmfwk69EocZpd63gJPsYaomD+OZxjkyo91pxn0wQ+Al9y1pWmsjO lxdTx22u8Vq8tneu1PFIrT0O1yfdF/eQ+hAq4aP6pscMEdU98apAPmWHUW+y04WyDzT8 T86DxU4F3DFM96f+KkD524lJJg2ek1vDhWh3HSBkLN5HSsUiH5eec+b7UcQSH7RQXDPC vowJZYfCqm/2OXhpKCO2/opnWIERy+kl4AP0YAVvpfOIuCTTJiWWJM9u+X4mu94CkLBN qinw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:dkim-signature:dkim-signature:date; bh=1dPUZbRDq+w3xgCnVHaPIQvAFpBAuWURnnoA1oTqYfw=; b=mvfdIQo6dayox8jAPuUrDgp7I5OvUYRiMXrfEKajzBBIU4WpiHL4YHWQRh5qnq43Wg 88bszW8DAQXoiCYkBH510VHvwl9VEgPaufImivi3/UgJGr5vhsofUCoq5iQh5976F7Mc QwJ08l9W0a+zSOf9Oxxoiy9FuWTavpklPkj/zMVStEZLB1otAmDAg8xPbG4HM3f/fF8/ Xxdn3LlP97Xu8U2PNM0UPchmlsBWNUmQlKOHMlSoE+owCEchr5jiVlJanE3yLcpeMoKN Tc34umtTWDY11Nxuw19uSS5Ri3XQ3M0V/M4UJxCicheWKm+e/+t+JCsOMueV/txxYnI3 TKjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hoChWmaB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Z8wXuvr0; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v4-20020a50a444000000b0046995c42775si717813edb.148.2022.11.24.05.50.39; Thu, 24 Nov 2022 05:51:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-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=hoChWmaB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Z8wXuvr0; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-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 S229525AbiKXNsG (ORCPT + 99 others); Thu, 24 Nov 2022 08:48:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229960AbiKXNsE (ORCPT ); Thu, 24 Nov 2022 08:48:04 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC9BA1B791; Thu, 24 Nov 2022 05:48:03 -0800 (PST) Date: Thu, 24 Nov 2022 14:48:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669297682; 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: in-reply-to:in-reply-to:references:references; bh=1dPUZbRDq+w3xgCnVHaPIQvAFpBAuWURnnoA1oTqYfw=; b=hoChWmaBUSRzsmSnJk1bQPYhGXlreqbe6wbECUZNgL5vJAHwK6bOKal930Wr0dOfikygao u2Y6+rIOUxHwfxP/tqVqocJpYSl5qFDBl0hMDAO2IgFjyneCf4N7chM1I3uizBRSSqzeZJ KtC/7GdRCs1L5gYOv2Je35011iw608/24FP+Rebtf6PpxXxydoev4BkyI5LtjpRdTxZdWQ QMJCuRGN7MRGWueKt/i3dZkRMiwfUCgsgXOA7rLTJCQcjMv5eJK+WgxfQOOZarm6eXj3py N31e7K5qlDkpf54JunJyXgiVqJqfOJxuCPBZDa9PQQLrq/FsbMO9+G2VzOMDwA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669297682; 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: in-reply-to:in-reply-to:references:references; bh=1dPUZbRDq+w3xgCnVHaPIQvAFpBAuWURnnoA1oTqYfw=; b=Z8wXuvr0mnNlK6lDvqG955a3Y2RoB45dCmmYZN4ZXsPsQrCcOgjlOwegYq1sKObXC/YdHw fLm8uZJqtVxo9ZCA== From: Anna-Maria Behnsen To: Thomas Gleixner cc: LKML , Linus Torvalds , Steven Rostedt , 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: Re: [patch V3 14/17] timers: Add shutdown mechanism to the internal functions In-Reply-To: <20221123201625.253883224@linutronix.de> Message-ID: References: <20221123201306.823305113@linutronix.de> <20221123201625.253883224@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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-bluetooth@vger.kernel.org On Wed, 23 Nov 2022, Thomas Gleixner wrote: > Tearing down timers which have circular dependencies to other > functionality, e.g. workqueues, where the timer can schedule work and work > can arm timers, is not trivial. > > In those cases it is desired to shutdown the timer in a way which prevents > rearming of the timer. The mechanism to do so is to set timer->function to > NULL and use this as an indicator for the timer arming functions to ignore > the (re)arm request. > > Add a shutdown argument to the relevant internal functions which makes the > actual deactivation code set timer->function to NULL which in turn prevents > rearming of the timer. > > 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 > --- > V2: Add missing commata (Steven) > V3: Changelog updates (Anna-Maria) > --- > kernel/time/timer.c | 64 ++++++++++++++++++++++++++++++++++++++++++++-------- > 1 file changed, 55 insertions(+), 9 deletions(-) > > --- a/kernel/time/timer.c > +++ b/kernel/time/timer.c > @@ -1297,14 +1297,21 @@ void add_timer_on(struct timer_list *tim > EXPORT_SYMBOL_GPL(add_timer_on); > > /** > - * __timer_delete - Internal function: Deactivate a timer. > + * __timer_delete - Internal function: Deactivate a timer Some more NIT: You already updated the line a patch before. Maybe remove the dot in the patch before and you get rid of this unneccessary delete/insert of the above line in this hunk. > * @timer: The timer to be deactivated > + * @shutdown: If true, this indicates that the timer is about to be > + * shutdown permanently. > + * > + * If @shutdown is true then @timer->function is set to NULL under the > + * timer base lock which prevents further rearming of the time. In that > + * case any attempt to rearm @timer after this function returns will be > + * silently ignored. > * > * Return: > * * %0 - The timer was not pending > * * %1 - The timer was pending and deactivated > */ > -static int __timer_delete(struct timer_list *timer) > +static int __timer_delete(struct timer_list *timer, bool shutdown) > { > struct timer_base *base; > unsigned long flags; Thanks, Anna-Maria