Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1281172rwi; Thu, 27 Oct 2022 13:44:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM61v3XrMEsFgK8H4CPm7t1iJZVsC1xaDwnF5xCOkEF25WLY5npBPS6+anCD6CUPX9B7M6gv X-Received: by 2002:a17:906:5a4b:b0:78d:8790:d4a1 with SMTP id my11-20020a1709065a4b00b0078d8790d4a1mr43754854ejc.329.1666903492914; Thu, 27 Oct 2022 13:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666903492; cv=none; d=google.com; s=arc-20160816; b=yghfrJPlxY0FKvikZneyMXI9eyjl4TcbEbtkznDs3G7b+49rKoUK3CcCIBFNaH8ds/ W8dHGmkNtPqd4blwb+Y5yMEoT4wT1RguRKj/hM+rvAFPM7Kurf/9fdjfZHlnTfBevyZl oUPypmPKGT2jzh3ww94ns8Gp6HPZJ1aGMq4IAYMjEmejPqW79e+DFZcnieGFsF0RhkwY SUFGLspJ0AlGqfCKWfB4BwqNaeRSgHiyKQrCl/tulZOeD16bFCiNK6daw/KN/RAMvg+i 7/6nJA0BIHStABu1twTrZV/l7dCOJwK5f0ZItAmjQcgsVkCrA+YIM+Hy/FSlAF8j+yFa 00Fg== 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=gAMuF4szvQHdmFGy2/OESe7x1iNYuDzH9szqjxLPSr8=; b=fOFdUYSbY8qzgkLICcUUBPsn18frSWssaAePrG3g4ltlKP4jkmjTuq9rJYrrozfST3 kDnHADb2BjHOA8RBVTl9+CA6eATHiHTZPOBM8gkecCOcQFt2nwPkufb0ZKqizVgU7DgA aE0PjOgpvsB9ULYX/a0nRuIi1WyA3O9DgWDRzooDsm/ZO2oORrl9JUUiaIJaC9fMiWEX o5aUu5vU/UNQq0YjOYYytRX2NaQ91htjAgRyVKLYEUi80LGyIEx0925ofu+LpfFBd4Hw CVN3h+8ryX5iYgSofz9o9kC+AamYoEBdeGbBHW4poDV6swLY/j5X74F2RM4OO2BiAvVO iu5g== 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 hp40-20020a1709073e2800b00780f0b45416si2711693ejc.622.2022.10.27.13.44.26; Thu, 27 Oct 2022 13:44:52 -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 S236083AbiJ0Ues (ORCPT + 65 others); Thu, 27 Oct 2022 16:34:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233652AbiJ0Uer (ORCPT ); Thu, 27 Oct 2022 16:34:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 453DA32076; Thu, 27 Oct 2022 13:34:45 -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 ams.source.kernel.org (Postfix) with ESMTPS id 0160EB827D3; Thu, 27 Oct 2022 20:34:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7EBAC433D7; Thu, 27 Oct 2022 20:34:39 +0000 (UTC) Date: Thu, 27 Oct 2022 16:34:53 -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: <20221027163453.383bbf8e@gandalf.local.home> In-Reply-To: References: <20221027150525.753064657@goodmis.org> <20221027150928.780676863@goodmis.org> <20221027155513.60b211e2@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:15:23 -0700 Linus Torvalds wrote: > On Thu, Oct 27, 2022 at 12:55 PM Steven Rostedt wrote: > > > > I think we need to update this code to squeeze in a del_timer_shutdown() to > > make sure that the timers are never restarted. > > So the reason the networking code does this is that it can't just do > the old 'sync()' thing, the timers are deleted in contexts where that > isn't valid. > > Which is also afaik why the networking code does that whole "timer > implies a refcount to the socket" and then does the > > if (del_timer(timer)) > sock_put() > > thing (ie if the del_timer failed - possibly because it was already > running - you leave the refcount alone). OK, so the above is assuming that the timer is always active, and del_timer() returns if it successfully removed it (where it can call sock_put()), but if del_timer() returns 0, that means the timer is currently running (or about to be), so it doesn't call sock_put(). > > So the networking code cannot do the del_timer_shutdown() for the same > reason it cannot do the del_timer_sync(): it can't afford to wait for > the timer to stop running. > > I suspect it needs something like a new "del_timer_shutdown_async()" > that isn't synchronous, but does that > > - acts as del_timer in that it doesn't wait, and returns a success if > it could just remove the pending case > > - does that "mark timer for shutdown" in that success case > > or something similar. > 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. I think this would work in this case. -- Steve