Received: by 2002:a05:6a10:144:0:0:0:0 with SMTP id 4csp661984pxw; Fri, 8 Apr 2022 18:33:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywsoAibkPPaGNK9n/0pXYKChVi17lYCtdLT6Q1o4Gd/67LWC+51Vbmk5gjNmI5evSvLPA8 X-Received: by 2002:a17:902:8f94:b0:154:839b:809f with SMTP id z20-20020a1709028f9400b00154839b809fmr21742125plo.150.1649468025817; Fri, 08 Apr 2022 18:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649468025; cv=none; d=google.com; s=arc-20160816; b=EYMsi4xowh8c1MzW7sBJpr5/SEa2kRjAUWPdd88IO+vAPo2Nu/Lv1M6eugVnIq9GPm 01D3C4X+l/bH16EKF6BF1htAI4zAbBv1qEynbsT0SZ2Ml7EMOSoIIspQ2JBswE+akcB9 vYeJBYbaOEyoEcbvcW/taFQYfK0Qpfca2s6WSlFb4wDKoyeH94bLLqXKNZAGg4Y9HLpF VSLWepOPNwbfAAZCNsWEfoISCb0yebJmLEWq0r3xHeUdTmrsohuFsMMLsPMZoXtU207H LO7WS5TuTKX/CxNtBddIquB0yKPJODWYM6tqvNNnV4xxlwTfYWbzdoelnYJiJlBvaXKo jTiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Q5GX55YGJpovI3tFOv0T1wHUO+Zd7z6zyy2KhM1F0OY=; b=uC7k1If5cN4bILTLtrfHABCNtQUZNw/O+z+dkmWsfbV12Ax+Q0UfEXDfRyDvtGpXFb WVC4AsPQ0fSOWeWcSf8BaM5vCyL2ysi+gVFVa893Wcd19nKMMs/S8y+esos63h/SIZaV E4KSi0DHV1fapXOz3UhIsRMyZTl1X3ktt1ajCWocsa5H0CQc1ERk+Wb0h1n7VMSO/HJN pjbpdlAzRoZ9lRr5ZczG94syXYrvcocGLRD049ERywWHQP4liJ+MJELjObQj3DGOGp7P ag/j7h2tPxQEBipM7bQLmZtoT67ZZb3s9LMXIscq4dlA/00S9pwaJu4rU/JGxWrtyseJ VIMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=HviJScLp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 t35-20020a632263000000b003995aee3634si2755430pgm.175.2022.04.08.18.33.30; Fri, 08 Apr 2022 18:33:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linux-foundation.org header.s=google header.b=HviJScLp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238183AbiDHRgW (ORCPT + 99 others); Fri, 8 Apr 2022 13:36:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233502AbiDHRgU (ORCPT ); Fri, 8 Apr 2022 13:36:20 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A220C6B0AC for ; Fri, 8 Apr 2022 10:34:16 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id bq30so3492671lfb.3 for ; Fri, 08 Apr 2022 10:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Q5GX55YGJpovI3tFOv0T1wHUO+Zd7z6zyy2KhM1F0OY=; b=HviJScLphHo3UkXhpCiNl1LxhvxjraJCHLTKP36TdiWQBCXsAepTfZ106az+1jbTMS TxcNJGW1ffdm7lvXR9Yakz6GxiyVscti8HdV21rlSjgR7kb0U0oSB4inlUhF/IZ36xad lulzZgxmxMAX+vX56YO5S9ErNW5Pm+FEch74I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Q5GX55YGJpovI3tFOv0T1wHUO+Zd7z6zyy2KhM1F0OY=; b=HXLC4Qb+PLrze0Zes0cjOKA68kS/Lc8tY0Knrn+J9yTSFwd+U6oBUrlWoe7u8yRJkR NzaN1sCtHgtviJsyLB1GnTI/2q1Q+fBeKDV0oD3iPUB2Hwsco2Jllr8OzBoqyETaeMdv E38x91LwgLtZIVJAYTb7G5DuCy6pb8//5jbx54UuSfdhBZA/QrTIuQjv8+k0YXsTtNy+ MEK4cRxbiQ94TNaL8xV7b425nSiMHbS+6iSOVv+PdGXhGYgKJpFRuDvYktVhL9dTK5dU aFlpvdMefppzEOASncdEtFTtl+6fKA6hUMtjaZ5SMyVYHW0/gk2pLQUquojlox09Lcri uH1A== X-Gm-Message-State: AOAM530nLdEFltNWSqyLLVlEB3m54qXLkNRQk7U8uSHeAK0W1WqMBd4G wNh9f/pdbMzqVhJgNitIZAGc6NXp8YfcZPmE X-Received: by 2002:a05:6512:10ce:b0:44a:3f13:9876 with SMTP id k14-20020a05651210ce00b0044a3f139876mr12813247lfg.585.1649439254598; Fri, 08 Apr 2022 10:34:14 -0700 (PDT) Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com. [209.85.167.42]) by smtp.gmail.com with ESMTPSA id i6-20020a198c46000000b0044424910c94sm2514581lfj.113.2022.04.08.10.34.09 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 Apr 2022 10:34:10 -0700 (PDT) Received: by mail-lf1-f42.google.com with SMTP id bq30so3492311lfb.3 for ; Fri, 08 Apr 2022 10:34:09 -0700 (PDT) X-Received: by 2002:ac2:4203:0:b0:448:8053:d402 with SMTP id y3-20020ac24203000000b004488053d402mr12805819lfh.687.1649439249623; Fri, 08 Apr 2022 10:34:09 -0700 (PDT) MIME-Version: 1.0 References: <20220407161745.7d6754b3@gandalf.local.home> <87pmlrkgi3.ffs@tglx> In-Reply-To: <87pmlrkgi3.ffs@tglx> From: Linus Torvalds Date: Fri, 8 Apr 2022 07:33:53 -1000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC][PATCH] timers: Add del_time_free() to be called before freeing timers To: Thomas Gleixner Cc: Steven Rostedt , LKML , jstultz@google.com, Stephen Boyd , Andrew Morton , Peter Zijlstra , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , Eric Dumazet , Guenter Roeck Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no 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-kernel@vger.kernel.org On Fri, Apr 8, 2022 at 12:37 AM Thomas Gleixner wrote: > > So this would become: > > - BUG_ON(!timer->function); > + if (WARN_ON(!timer->function)) > + return -EBROKEN; Yes. But please make it a WARN_ON_ONCE(), just on basic principles. I can't imagine this happening a lot, but at the same time I don't think there's any reason _not_ to just always use WARN_ON_ONCE() for these kinds of "serious bug, but should never happen" situations. Because we don't want some "user can trigger this and spam the logs" situation either. That said, I would actually prefer a name-change: instead of making this about "del_timer_free()", can we please just make this about it being "final". Or maybe "del_timer_cancel()" or something like that? Because the actual _freeing_ will obviously happen later, and the function does nothing of the sort. In fact, there may be situations where you don't free it at all, but just want to be in the situation where you want to make sure there are no pending timers until after you explicitly re-arm it, even if the timer would otherwise be self-arming. (That use-case would actually mean removing the WARN_ON_ONCE(), but I think that would be a "future use" issue, I'm *not* suggesting it not be done initially). I also suspect that 99% of all del_timer_sync() users actually want that kind of explicit "del_timer_final()" behavior. Some may not _need_ it (because their re-arming already checks for "have I shut down?"), but I have this suspicion that we could convert a lot - maybe all - of the current del_timer_sync() users to this and try to see if we could just make it the rule. And then we could actually maybe start removing the explicit "shut down timer" code. See for example "work->canceling" logic for kthreads, which now does double duty (it disables re-arming the timer, _and_ it does some "double cancel work avoidance") Linus