Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1313615rwi; Thu, 27 Oct 2022 14:11:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5jHJ/8JDbDQvkuJrXbfRYoYe58SFdaXBxwPxdlWZEITs6NYmQJCGmnKytVJQuWorNvy6bV X-Received: by 2002:a17:906:847b:b0:7a6:2ad9:298 with SMTP id hx27-20020a170906847b00b007a62ad90298mr21767357ejc.90.1666905111140; Thu, 27 Oct 2022 14:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666905111; cv=none; d=google.com; s=arc-20160816; b=nX4PsKr8eWFYsoWG/y2qOLeM12b2ADCst81zN/19fo6qgxtePC4cYP1vxCblN1ppPl 79qirXSuJtQpIMXWZD/+ib4KIhWIsyKD1PEyfIkQkR0OJZCQ7x9KX5/2Z469ZxbgpWiT NrR3Sh2DDITCWstOaABiAx/JtaYv3XGzowzi+YRoSAwuiyfy9A42BlaLhJdzIFusBH7n geOKHDqrm4Oy2mYbOmec5pjREtJBz0wHH7KLqEzbLIeQ4KLrN9eAfetVepPPuGrGfCsC cujGx/QKRm3g7UEg8MKAEzXQo7MjJgZr5xsOW8i73vBxwHBg0vXBSWM6S0MRzEhR7C0a YNcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=n51loZcfNt45zyMRXyPaLiuIdF3pu9IaoZ8EhjTkQdE=; b=iDnSCz+L9BzDXMDXqgKnCcxP/AII2MRKBHO3Tm/qBoo4OuWSkak/V8SRoJdxHapj// I6SrKWX1E8YOiaBze9f3MT4LHUDN+0oXfFXCqa6ufAxfnosBgib0EXJGSV5RguPJERSV RF5CGSQYCkKgFrKfBQzonhXNcvwJV2v2b+2HZkMmLvn1btDm0tqVkrgd0qrTaUO9rMxa o7ExdG4gtDFKJ+kSgsO84QpSASXz770d5TQC9P6Psm5Nb+gazK1GXJi6qiGzeOsqDAQN Pw3gzjfBUjKcEVRwLqbbv8A2m593D+7vDFPGIgI1Q2+G7+z4OTFOdC5c5ej4iTuplR2U EdZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qb11-20020a1709077e8b00b007ab1b8b71a6si2479421ejc.40.2022.10.27.14.11.33; Thu, 27 Oct 2022 14:11:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237295AbiJ0VLZ (ORCPT + 65 others); Thu, 27 Oct 2022 17:11:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236018AbiJ0VLK (ORCPT ); Thu, 27 Oct 2022 17:11:10 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2912A83F2C; Thu, 27 Oct 2022 14:07:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 71D05CE2869; Thu, 27 Oct 2022 21:07:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94B34C433D6; Thu, 27 Oct 2022 21:07:05 +0000 (UTC) Date: Thu, 27 Oct 2022 17:07:20 -0400 From: Steven Rostedt To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Stephen Boyd , Guenter Roeck , Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mirko Lindner , Stephen Hemminger , Martin KaFai Lau , Alexei Starovoitov , Kuniyuki Iwashima , Pavel Begunkov , Menglong Dong , linux-usb@vger.kernel.org, linux-wireless@vger.kernel.org, bridge@lists.linux-foundation.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, lvs-devel@vger.kernel.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, tipc-discussion@lists.sourceforge.net Subject: Re: [RFC][PATCH v2 19/31] timers: net: Use del_timer_shutdown() before freeing timer Message-ID: <20221027170720.31497319@gandalf.local.home> In-Reply-To: References: <20221027150525.753064657@goodmis.org> <20221027150928.780676863@goodmis.org> <20221027155513.60b211e2@gandalf.local.home> <20221027163453.383bbf8e@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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-wireless@vger.kernel.org On Thu, 27 Oct 2022 13:48:54 -0700 Linus Torvalds wrote: > On Thu, Oct 27, 2022 at 1:34 PM Steven Rostedt wrote: > > > > What about del_timer_try_shutdown(), that if it removes the timer, it sets > > the function to NULL (making it equivalent to a successful shutdown), > > otherwise it does nothing. Allowing the the timer to be rearmed. > > Sounds sane to me and should work, but as mentioned, I think the > networking people need to say "yeah" too. > > And maybe that function can also disallow any future re-arming even > for the case where the timer couldn't be actively removed. Well, I think this current use case will break if we prevent the timer from being rearmed or run again if it's not found. But as you said, the networking folks need to confirm or deny it. The fact that it does the sock_put() when it removes the timer makes me think that it can be called again, and we shouldn't prevent that from happening. The debug code will let us know too, as it only "frees" it for freeing if it deactivated the timer and shut it down. > > So any *currently* active timer wouldn't be waited for (either because > locking may make that a deadlock situation, or simply due to > performance issues), but at least it would guarantee that no new timer > activations can happen. > > Because I do like the whole notion of "timer has been shutdown and > cannot be used as a timer any more without re-initializing it" being a > real state - even for a timer that may be "currently in flight". > > So this all sounds very worthwhile to me, but I'm not surprised that > we have code that then knows about all the subtleties of "del_timer() > might still have a running timer" and actually take advantage of it > (where "advantage" is likely more of a "deal with the complexities" > rather than anything really positive ;) Good to hear. This has been a thorn in our side as we keep hitting these crashes in the timer code that look like a timer was freed before it triggered. > > And those existing subtle users might want particular semantics to at > least make said complexities easier. > Yeah, as someone told me recently, "If you let them play long enough without setting out the rules, they will take advantage of everything and it will be extremely hard to get them back in order". -- Steve