From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 46A9081775 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 3D74881753 Date: Fri, 28 Oct 2022 18:31:49 -0400 From: Steven Rostedt Message-ID: <20221028183149.2882a29b@gandalf.local.home> In-Reply-To: <20221027183511.66b058c4@gandalf.local.home> References: <20221027150525.753064657@goodmis.org> <20221027150928.780676863@goodmis.org> <20221027155513.60b211e2@gandalf.local.home> <20221027163453.383bbf8e@gandalf.local.home> <20221027170720.31497319@gandalf.local.home> <20221027183511.66b058c4@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Bridge] [RFC][PATCH v2 19/31] timers: net: Use del_timer_shutdown() before freeing timer List-Id: Linux Ethernet Bridging List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Linus Torvalds Cc: Alexei Starovoitov , Eric Dumazet , Tony Nguyen , linux-afs@lists.infradead.org, Menglong Dong , bridge@lists.linux-foundation.org, Jesse Brandeburg , lvs-devel@vger.kernel.org, coreteam@netfilter.org, Jakub Kicinski , Paolo Abeni , Guenter Roeck , Martin KaFai Lau , Kuniyuki Iwashima , Thomas Gleixner , Mirko Lindner , linux-nfs@vger.kernel.org, tipc-discussion@lists.sourceforge.net, Stephen Boyd , linux-usb@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, "David S. Miller" , netfilter-devel@vger.kernel.org, Pavel Begunkov Could someone from networking confirm (or deny) that the timer being removed in sk_stop_timer() will no longer be used even if del_timer() returns false? net/core/sock.c: void sk_stop_timer(struct sock *sk, struct timer_list* timer) { if (del_timer(timer)) __sock_put(sk); } If this is the case, then I'll add the following interface: del_timer_sync_shutdown() // the common case which syncs del_timer_shutdown() // the uncommon case, that returns immediately // used for those cases that add extra code to // handle it, like sk_stop_timer() Which has the same semantics as del_timer_sync() and del_timer() respectively, but will prevent the timer from being rearmed again. This way we can convert the sk_stop_timer() to: void sk_stop_timer(struct sock *sk, struct timer_list* timer) { if (del_timer_shutdown(timer)) __sock_put(sk); } We can also add the del_timer_shutdown() to other locations that need to put a timer into a shutdown state before freeing, and where it's in a context that can not call del_timer_sync_shutdown(). -- Steve