Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7460568rwb; Tue, 15 Nov 2022 12:39:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf5F6Y2iPJMC2DQHBzeFF+Yt1PMLHfQwpCg9tPicmJD9gRZCo2izDhm8rou1Rz5sXx81ch96 X-Received: by 2002:a17:907:a4c4:b0:7a4:c236:906 with SMTP id vq4-20020a170907a4c400b007a4c2360906mr15272509ejc.318.1668544762821; Tue, 15 Nov 2022 12:39:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668544762; cv=none; d=google.com; s=arc-20160816; b=n6z1SI0fKl9fEG1wQetXRhoixRxXUy+O+/PtBWDfW2MgpMCG6kOcCFhsCWKn5sjDhj YX0ZORkhiExzY3yDdD2zRMlImR3qr/M6jjU7rHSKKkHTkELKyiVIrEFLNBlquZBrUuCn lMDTJ4pHAv9scYajNTwhaLXW/Psl0h7hyFXQ1qzOQ7VRV3qmGiDsxupfdKTNGWhQaaSg gt9svaZKPqhc1GjJtF/qSzTK65GH0d0oWeoB7vv8u6wOrQRO+gbsSg24P1xTzPQ5cNP4 YBVz8Y4zYhzVPQMXoEu9aS+m/3xIjrcAei3mAia+L+b8o3VCgFVIB1mT/om3kcWCGwas Rzlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=kJsB0B8f0qFmQ81lyDCpvVT7DxA3aerH8vXT9O1XEA4=; b=Yt7AlYx6RzugjCp/GAVMhe0M7jyeGi48XwodFulF7uPLOis2mVffcdVmNlK87rB047 tAmYo6lM/aBdS3m9sbsoGw6jtO/35LfDMdZte4cj1Bic+V+yzlKV3Uqq9s5uD8Z+VRs5 F2HO+s7Gfue5/Vk1uMRmuHekLhk903xzRpaeyVMc92VDkQ8gJMlT4c4tQBhjusi4WiiU rYzIDSjtKXajmtBpX1PxfMljD1QJpRr1/ocgGZjX5aSN3A9DK8P1WSiEQYGrsoX4YObf mCsgrP3qJFVZJAJdJ5zcjS7AvFPt0lclYjYSplZ5Rs29MVR1iDZQzktKrHJ+bbJ+VL6/ 8NMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Pu8SGB0c; dkim=neutral (no key) header.i=@linutronix.de header.b="F4IRW1/t"; 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 x7-20020a05640226c700b004520e27e5b9si14675936edd.626.2022.11.15.12.38.57; Tue, 15 Nov 2022 12:39:22 -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=Pu8SGB0c; dkim=neutral (no key) header.i=@linutronix.de header.b="F4IRW1/t"; 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 S238278AbiKOUbS (ORCPT + 99 others); Tue, 15 Nov 2022 15:31:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236982AbiKOUaH (ORCPT ); Tue, 15 Nov 2022 15:30:07 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 667FA30F6D; Tue, 15 Nov 2022 12:28:58 -0800 (PST) Message-ID: <20221115202117.792861106@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668544136; 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: references:references; bh=kJsB0B8f0qFmQ81lyDCpvVT7DxA3aerH8vXT9O1XEA4=; b=Pu8SGB0c4W4WMOpJe5pArorCPiSQIfam8L1S5Y3Jy/MOZU7i/qTWWK04Wv2U0sTLgC41vH MHoPL+Jpgxoh8gNyIFsohKaXUFu8JEOSdN2CoBihJFNzVr/Cs4vzi1ETiRfX5m/SuaSEdO TqvCu2TViqhmsdshMLYVdLLWxEGSdQvruEXbDZnSDq301cajJDI0wiYrpvUkZwvizmSo7F ewcKB/ps/v1ulqAQxxuVDXOXyUGghbSDOLSqf2Ip/0chghKDhJp4PaOk9x+zjtrwEPxTBk PY1ZUTY824R52JGJ/hHQ+a4h6/fI3PA8FHtqV1PGOskSVMDBSQhcYgBjKvgQPQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668544136; 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: references:references; bh=kJsB0B8f0qFmQ81lyDCpvVT7DxA3aerH8vXT9O1XEA4=; b=F4IRW1/tgARIGOV4ZTNZkN6R2tHnpA0BWQ7F+t6okMkuF4n/c+Xhc2P3opbia4Q8r/2MGA CVzmleEVKnlNrPCA== From: Thomas Gleixner To: LKML Cc: Linus Torvalds , Steven Rostedt , Anna-Maria Behnsen , 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 Subject: [patch 14/15] timers: Update the documentation to reflect on the new timer_shutdown() API References: <20221115195802.415956561@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Tue, 15 Nov 2022 21:28:56 +0100 (CET) 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 From: "Steven Rostedt (Google)" In order to make sure that a timer is not re-armed after it is stopped before freeing, a new shutdown state is added to the timer code. The API timer_shutdown_sync() and timer_shutdown() must be called before the object that holds the timer can be freed. Update the documentation to reflect this new workflow. [ tglx: Updated to the new semantics and removed the bogus claim that del_timer_sync() returns the number of removal attempts ] Signed-off-by: Steven Rostedt (Google) Signed-off-by: Thomas Gleixner Tested-by: Guenter Roeck Link: https://lore.kernel.org/r/20221110064147.712934793@goodmis.org --- Documentation/RCU/Design/Requirements/Requirements.rst | 2 +- Documentation/core-api/local_ops.rst | 2 +- Documentation/kernel-hacking/locking.rst | 13 ++++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) --- a/Documentation/RCU/Design/Requirements/Requirements.rst +++ b/Documentation/RCU/Design/Requirements/Requirements.rst @@ -1858,7 +1858,7 @@ unloaded. After a given module has been one of its functions results in a segmentation fault. The module-unload functions must therefore cancel any delayed calls to loadable-module functions, for example, any outstanding mod_timer() must be dealt -with via del_timer_sync() or similar. +with via timer_shutdown_sync(). Unfortunately, there is no way to cancel an RCU callback; once you invoke call_rcu(), the callback function is eventually going to be --- a/Documentation/core-api/local_ops.rst +++ b/Documentation/core-api/local_ops.rst @@ -191,7 +191,7 @@ Here is a sample module which implements static void __exit test_exit(void) { - del_timer_sync(&test_timer); + timer_shutdown_sync(&test_timer); } module_init(test_init); --- a/Documentation/kernel-hacking/locking.rst +++ b/Documentation/kernel-hacking/locking.rst @@ -1003,11 +1003,14 @@ If 0, it means (in this case) that it is Another common problem is deleting timers which restart themselves (by -calling add_timer() at the end of their timer function). -Because this is a fairly common case which is prone to races, you should -use del_timer_sync() (``include/linux/timer.h``) to -handle this case. It returns the number of times the timer had to be -deleted before we finally stopped it from adding itself back in. +calling add_timer() at the end of their timer function). Because this is a +fairly common case which is prone to races, you should use del_timer_sync() +(``include/linux/timer.h``) to handle this case. + +Before freeing a timer, timer_shutdown() or timer_shutdown_sync() should be +called which will keep it from being rearmed. Any subsequent attempt to +rearm the timer will be silently ignored by the core code. + Locking Speed =============