Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8955251rwb; Thu, 24 Nov 2022 06:22:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf4CUO6KARFrhyLBr2mt/p6WxHGc65rQBz+tXCMY/oYcxO0AfbMxAoX+pM5W4Cb3uroY5vBL X-Received: by 2002:a63:e20:0:b0:440:6e64:fb02 with SMTP id d32-20020a630e20000000b004406e64fb02mr11799666pgl.84.1669299730576; Thu, 24 Nov 2022 06:22:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669299730; cv=none; d=google.com; s=arc-20160816; b=E0HH+i0897enujfVNZOTUEmhXQa/deTldi26tmfNakpLYstljrQlWp8AUBTLpxh+7I Q0Dw8I+OQKzhDMvbyUSKEq6Z6SfSjM+q9HoHz520qaMKIXUfipXor6YLkhNc1X1ODyc2 jASNZ5nFRhaH+GGlRKO3NtUn+o1VtBghjiURm7xJ66m9MRZWioigA4Cev77B1Sj/8tBs dE2VHUNcKiyG1NbqPSiNwqqb3oeYaBF+g9e5F4dVKq8Tyr96IkFaT+jaYKqGAUadPl7r 6xNKvRJ2WLNUchL2dw9wUdVW6zEU6ceSInLvQriAuvHU/JFBlXNiOQ5puRVFEB0rZRck ANDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:dkim-signature:dkim-signature:date; bh=gF/hDDUQQuamiBo9tk/P8dm4oq4tbevNf7bzKapxWj8=; b=gDbDAkxB6XmEXCjX9YAu9GSegfBV2fP3GPdazX6PyTw3JKqlWKE5lHRrf1xOHeTrC3 APl1pRbNxo7bqMto4tnln0yU2MXuBPLECf4qAXEn3a+3lhmdX/O2qJSYVANefN+VcncU 7VGhMEqVVpWr55tdh7KAl8ahD6ZVq6OZre3wyBj4uI4einHV8aj3zWhHK20KAegPdKRS /9/0hU4NQjfMfS6m6DrT6l7car8j33mlNQt2hXVEFZOoCKP/Sqm2p3IMuIhWUSBgSQTP aIXtMEBzru0fMfAH34D5z/11yJgutkBVNG1NhnfZEpZXBm9mxJYrEU+aE35YWM/CAVmA B1eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=h1Z0Yqw7; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=LflPRjIl; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ob10-20020a17090b390a00b00218592c28casi1335624pjb.33.2022.11.24.06.21.48; Thu, 24 Nov 2022 06:22:10 -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=@linutronix.de header.s=2020 header.b=h1Z0Yqw7; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=LflPRjIl; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230295AbiKXODn (ORCPT + 99 others); Thu, 24 Nov 2022 09:03:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229788AbiKXOD0 (ORCPT ); Thu, 24 Nov 2022 09:03:26 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2C8DECCD3; Thu, 24 Nov 2022 06:00:39 -0800 (PST) Date: Thu, 24 Nov 2022 15:00:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669298438; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gF/hDDUQQuamiBo9tk/P8dm4oq4tbevNf7bzKapxWj8=; b=h1Z0Yqw7yojuggrrs4UWtoOM1khJlf0X5HRDxmwTw/NE1xtaRRCIcVIPpL6cyNeenjvxfI Ya+C8rYblKXQUHnzBxchKEeBgcetJmS88su1r8ahNWwh+I43Q2fj4bddVfiaQuEWtrc0xH 81KQlZIYxyfZTTI2e5QqgwxuGh1IdMAB+LxJLeX9QX2Gd8ewmh2kvbX774cPD9P6oSPvxz Wp/NxV9Q2g11hVJHZATEw+HDRrJJskNyQsqbKn+83r3Nqs2NCtGuOPe1RFuiayenZdiqPy Z8ZUYsDAPupORpOfEEwo9LyW4BcaQtqCbcwtcPWDlWtazLIzMabdG0oq5N9Ksg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669298438; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gF/hDDUQQuamiBo9tk/P8dm4oq4tbevNf7bzKapxWj8=; b=LflPRjIlnkBisnfq9cmgMoN6Iw97sP/+aV3YrbrIjBehaC55j/DPrrXubo/35pb9NizcWi BsdFgArw6psC1GBQ== From: Anna-Maria Behnsen To: Thomas Gleixner cc: LKML , Linus Torvalds , Steven Rostedt , Peter Zijlstra , Stephen Boyd , Guenter Roeck , 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, Jacob Keller Subject: Re: [patch V3 00/17] timers: Provide timer_shutdown[_sync]() In-Reply-To: <20221123201306.823305113@linutronix.de> Message-ID: <55c7744b-8a2c-e2b2-6c3-c2fa7ab978cc@linutronix.de> References: <20221123201306.823305113@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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-bluetooth@vger.kernel.org On Wed, 23 Nov 2022, Thomas Gleixner wrote: > This is the third version of the timer shutdown work. The second version > can be found here: > > https://lore.kernel.org/all/20221122171312.191765396@linutronix.de > > 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. > > The series is also available from git: > > git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git timers > With fix of the last NITs: Reviewed-by: Anna-Maria Behnsen Thanks, Anna-Maria