From patchwork Thu Nov 10 06:41:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 17976 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp760597wru; Wed, 9 Nov 2022 22:42:16 -0800 (PST) X-Google-Smtp-Source: AMsMyM6uzEmZLHYBOJyLb4sJ1Z2FRsgldXvt4fivKv9BOLmcgXfZCU3a5kQh/AH2JSatyPWTSwCt X-Received: by 2002:a05:6a00:248e:b0:56e:ad31:b976 with SMTP id c14-20020a056a00248e00b0056ead31b976mr28257625pfv.51.1668062536488; Wed, 09 Nov 2022 22:42:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668062536; cv=none; d=google.com; s=arc-20160816; b=OLEd9A5YUk9NOIxmZ8HfXceOOQbcUZsnzt0sPu/C9o5XT3Ul0dUnr8OW8oLaqHtDeS n7ySuUQZrpVo7FFbCCYru37xPLRFsG/NbeZEalnWae4iPsb0U/CLE1wXHtcU95tsUclj g4Tfv6d8/4o54dxXeiPVIf9qMGdGTGZtUer80Vn0jnvstuO8JcA1uDA5NNLHY9OYiIvK CLfsfMzx6dAuPzPVZ/KgDKY1qHmyHpPnC7NowzSoRz6MAkgQ+KYGT+IvhwWa+Tz9FA90 0FviUIWl4PtSnfrsWXCveKFRCRK3mlORT3m5tm8JHZPSmKXyCvggJ2AMPNWqtEQFZoHe kw7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id; bh=pnJJ0g5QVkorS/HdYBDFufzj3bdc2hUrkRi12//IiXo=; b=V7lgcqZol0rZ0c3vsS15NOAwNw47IIlyLe5aqxVzLTAuSZS6a468QShdoPEluDIXNh NF+lxlcvphi8Fg953tvoTUJusw13P/OqJCyyTGHXjTbmiKAoourjueMNWBev7Sw2/wdk KpV6OJv0w3UFAwzqnskpJaL4XSIKKA5MsBpC1jiEU0l8QIw0IPch9iI/nXw4cBw3KRuP OCQdgzWBPbtaicI84sGb/GRoUO8sKlxJMM1VMeyFxBfKQPmAvwTwQa3ZTXIigOLsl671 6OpyAe4a/1S7A0i2G/tYAnZz9PPZoWbdkZKD9Td8/X++HZ7NHzWmXpr7n9a0wj9SkJYj tUhA== ARC-Authentication-Results: i=1; mx.google.com; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w9-20020a634909000000b0046f1082320csi18456153pga.742.2022.11.09.22.42.02; Wed, 09 Nov 2022 22:42:16 -0800 (PST) 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; 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 S232557AbiKJGln (ORCPT + 99 others); Thu, 10 Nov 2022 01:41:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232683AbiKJGl1 (ORCPT ); Thu, 10 Nov 2022 01:41:27 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11D812CDFB for ; Wed, 9 Nov 2022 22:41:14 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9E27A61D9D for ; Thu, 10 Nov 2022 06:41:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E606C4314B; Thu, 10 Nov 2022 06:41:12 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.96) (envelope-from ) id 1ot1Fz-009EgZ-2p; Thu, 10 Nov 2022 01:41:47 -0500 Message-ID: <20221110064147.712934793@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 10 Nov 2022 01:41:07 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Linus Torvalds , Thomas Gleixner , Stephen Boyd , Guenter Roeck , Anna-Maria Gleixner , Andrew Morton , Julia Lawall Subject: [PATCH v6 6/6] timers: Update the documentation to reflect on the new timer_shutdown() API References: <20221110064101.429013735@goodmis.org> MIME-Version: 1.0 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749090342391068666?= X-GMAIL-MSGID: =?utf-8?q?1749090342391068666?= 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. Cc: Linus Torvalds Cc: Thomas Gleixner Cc: Stephen Boyd Cc: Anna-Maria Gleixner Cc: Andrew Morton Cc: Julia Lawall Tested-by: Guenter Roeck Signed-off-by: Steven Rostedt (Google) --- Documentation/RCU/Design/Requirements/Requirements.rst | 2 +- Documentation/core-api/local_ops.rst | 2 +- Documentation/kernel-hacking/locking.rst | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Documentation/RCU/Design/Requirements/Requirements.rst b/Documentation/RCU/Design/Requirements/Requirements.rst index a0f8164c8513..ec6de88846b9 100644 --- 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 unloaded, any attempt to call 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 diff --git a/Documentation/core-api/local_ops.rst b/Documentation/core-api/local_ops.rst index 2ac3f9f29845..0b42ceaaf3c4 100644 --- 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 a basic per cpu counter using static void __exit test_exit(void) { - del_timer_sync(&test_timer); + timer_shutdown_sync(&test_timer); } module_init(test_init); diff --git a/Documentation/kernel-hacking/locking.rst b/Documentation/kernel-hacking/locking.rst index 6805ae6e86e6..eb341b69fd15 100644 --- a/Documentation/kernel-hacking/locking.rst +++ b/Documentation/kernel-hacking/locking.rst @@ -1009,6 +1009,11 @@ 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. +Before freeing a timer, timer_shutdown() or timer_shutdown_sync() should be +called which will keep it from being rearmed, although if it is rearmed, it +will produce a warning. + + Locking Speed =============