Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2071721rwb; Thu, 17 Nov 2022 06:14:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Iua/MgxicAdBZei9c751DZtnracEa/8p56ObPkRTGh0kw+H8b6g5gKQuPxKc3yCtje4RQ X-Received: by 2002:a17:906:14cf:b0:7af:1233:948d with SMTP id y15-20020a17090614cf00b007af1233948dmr2159387ejc.698.1668694467799; Thu, 17 Nov 2022 06:14:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668694467; cv=none; d=google.com; s=arc-20160816; b=EOApbCh3c3ObKvBjpnU2wcSp+ec+fiaSczLg1AC/o5iBC2XxAg34P+Ef/6LDyS/UC5 HGoeevi4c2iK2CBlq0eNiP0bk/BDxABvDj54fB9FNeMuIMIMd0AHXJ6BKb4sS0NnXPWM EllkLxZHraY+A3DCc2hHcajIkpOLGhEvNUsv2QYxsfcXTQAb1AzHV3r/LOsboc13aFRm vI5htkNJDq6dmlEIM9vuofmQ6PH2OZ4D/J39Wv9/P2+1CqFYpNtH+WnSIUJCpwqNxiUl +9PSsnod81mTlr0mCCr/Ql83+USlshixPqhlDgewPmi3m98bEP2NL6VRbyTr8ojfUt5r 6x7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=ZjZfNJSztqnn5VEU7B/rhp6hd5F3Z1vSOdOLkmK7kWc=; b=HrJZa9Rj6PrZiLNAS1ELvsWD+/uSGKVy7BmHwZn2MuRnnHFfEY2tJzm1Ungidcw06i Oiut4HypU264KXLWayK3LCep2SX2dVawWLEZNByOlTMcNjn1CLYXpP45lCD+XGYkQ2DZ Lhk8Cv57SdQn4JOTUMK1DwLLB99w+y51ovtivuHWiIHFd4QFxJtdIbBfdrDoyiNv79zY f7LTqVC83680YfGxxRm9loPMkXfPoYRGfqQSCsUChk41DsZ7DTn5sc3PmuqqTXkqeX1R 0tAFqEK96oCErndBWHHNftKUwUX3IxG8NmABkrrg8uwsF2yM6tvWnyoJ6qhpcJnPm0ht CFNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mx+QNYoZ; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-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 b14-20020a056402278e00b0045d5e3c7f44si1041489ede.180.2022.11.17.06.13.22; Thu, 17 Nov 2022 06:14:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-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=@gmail.com header.s=20210112 header.b=mx+QNYoZ; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239886AbiKQOKo (ORCPT + 99 others); Thu, 17 Nov 2022 09:10:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234880AbiKQOKo (ORCPT ); Thu, 17 Nov 2022 09:10:44 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EE8263BB0; Thu, 17 Nov 2022 06:10:43 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id j12so1720670plj.5; Thu, 17 Nov 2022 06:10:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=ZjZfNJSztqnn5VEU7B/rhp6hd5F3Z1vSOdOLkmK7kWc=; b=mx+QNYoZMiT/SjOoNhLkfdEZuoTwwQozSQlq6C8ykIrmH12/fVqX3z5m6Iv+Uqg9bF F3EHUhNaKmhpbaeeY4fu97h+uQu/Q6wVoRLdnd4A260Sf5oVKLKrupHZ5lwyuDfP1rVC 5miFNUggU9Y4rg5DkCMhY+gkbCeCwH5iqJmBzn9rdXTubljFQOCA4fLHB7f/og812zsb OTPiRW6nVAS7k8/YzGQgustfkrz4VLskgdlh4c1UTLA92JMK1it2GbGafIYQ2K3e8WRG 9V3xg9qVOJ07TAFwhq9GCMGGpNrE1ozpCkYE0+npJkUh5nxkhYB/LbI5M81y4XTq7rbV Psxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZjZfNJSztqnn5VEU7B/rhp6hd5F3Z1vSOdOLkmK7kWc=; b=oZ7Oe8FHuPDui8z6mBFIawl38c4vVR3pcmgAYYdJqjFXXJPhWVw/cARV95v/1pdCRp qc0V5tZ2e7bccIx7hPMD+xd3s2jReblE3/GF29M+0xTXjjJPWYr9ryckhOYyQZTjYg80 9ldzCHU0N5DKLrl5cx+dMGMtxgHXQlCLjatF/rDVkPF8tuB1D+3AH8/a/sKcj04fXr6a o7gnurxyVHc+u1BglhmRelAJAc+EJ3AUTI9gIE3IdNe+uEpKdfPpvhpC8qSq6lN/X1+E qmiPGun39KaQoP6kOMhz721OYdV0VdhZ7LXLh3LNvI+AIhGtpGmK9G2v/ED42T1757Iz ZGXQ== X-Gm-Message-State: ANoB5pnwDr/9MlVT7GRVyINZz/nTPrL7FGqBe1On70+KfKsLIO56bZvE +r4cLwVKgWwFKw+buxI8A0NGL+6JyEU= X-Received: by 2002:a17:903:234d:b0:187:3d00:7ca4 with SMTP id c13-20020a170903234d00b001873d007ca4mr2910482plh.135.1668694242256; Thu, 17 Nov 2022 06:10:42 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id k38-20020a635a66000000b0046ece12f042sm1032729pgm.15.2022.11.17.06.10.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 06:10:41 -0800 (PST) Sender: Guenter Roeck Date: Thu, 17 Nov 2022 06:10:39 -0800 From: Guenter Roeck To: Thomas Gleixner Cc: LKML , Linus Torvalds , Steven Rostedt , Anna-Maria Behnsen , Peter Zijlstra , Stephen Boyd , 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 Subject: Re: [patch 00/15] timers: Provide timer_shutdown[_sync]() Message-ID: <20221117141039.GA664755@roeck-us.net> References: <20221115195802.415956561@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221115195802.415956561@linutronix.de> X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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-bluetooth@vger.kernel.org On Tue, Nov 15, 2022 at 09:28:32PM +0100, Thomas Gleixner wrote: > Tearing down timers can be tedious when there are circular dependencies to > other things which need to be torn down. A prime example is timer and > workqueue where the timer schedules work and the work arms the timer. > > Steven and the Google Chromebook team ran into such an issue in the > Bluetooth HCI code. > > Steven suggested to create a new function del_timer_free() which marks the > timer as shutdown. Rearm attempts of shutdown timers are discarded and he > wanted to emit a warning for that case: > > https://lore.kernel.org/all/20220407161745.7d6754b3@gandalf.local.home > > This resulted in a lengthy discussion and suggestions how this should be > implemented. The patch series went through several iterations and during > the review of the last version it turned out that this approach is > suboptimal: > > https://lore.kernel.org/all/20221110064101.429013735@goodmis.org > > The warning is not really helpful because it's entirely unclear how it > should be acted upon. The only way to address such a case is to add 'if > (in_shutdown)' conditionals all over the place. This is error prone and in > most cases of teardown like the HCI one which started this discussion not > required all. > > What needs to prevented is that pending work which is drained via > destroy_workqueue() does not rearm the previously shutdown timer. Nothing > in that shutdown sequence relies on the timer being functional. > > The conclusion was that the semantics of timer_shutdown_sync() should be: > > - timer is not enqueued > - timer callback is not running > - timer cannot be rearmed > > Preventing the rearming of shutdown timers is done by discarding rearm > attempts silently. > > As Steven is short of cycles, I made some spare cycles available and > reworked the patch series to follow the new semantics and plugged the races > which were discovered during review. > > The patches have been split up into small pieces to make review easier and > I took the liberty to throw a bunch of overdue cleanups into the picture > instead of proliferating the existing state further. > > The last patch in the series addresses the HCI teardown issue for real. > I applied the series to the top of v6.1-rc5, and also applied the result of running the coccinelle script to auto-convert simple cases. Running this set of patches through my testbed showed no build errors, runtime failures, or warnings. I also backported the series to chromeos-5.15, again applied the coccinelle generated patches, and ran it through a regression test. No failures either. With that, for the series, Tested-by: Guenter Roeck Let me know if I should send individual tags for each patch in the series. Thanks, Guenter