From mboxrd@z Thu Jan 1 00:00:00 1970 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 D010FC4321E for ; Thu, 24 Nov 2022 13:48:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229997AbiKXNsH (ORCPT ); Thu, 24 Nov 2022 08:48:07 -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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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