From patchwork Thu Nov 24 14:16:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 25568 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3426151wrr; Thu, 24 Nov 2022 06:21:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf6/5pSz3bHiBrq7D1MYXWy2zygFFoMy9zHBvdL1/u0+lvgjhgCNtPvpSI81i4QJv3ShrGNL X-Received: by 2002:a17:90a:ae16:b0:218:fada:57fd with SMTP id t22-20020a17090aae1600b00218fada57fdmr3436965pjq.12.1669299700114; Thu, 24 Nov 2022 06:21:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669299700; cv=none; d=google.com; s=arc-20160816; b=W9slC3bCP/zQR0iHlRxFNvhzSHg4Afu1O7q0PhKoj8HZDJ6osGGZer3P4qbAp1BVdl Eccbkimn72UartUumUX5OQ0ajhe9fzEpaSo3lHghnRt0ISyzlhDw3vr2TJnf/1RWbynX koC3ncPs4lF1mwuMXwl09avkGfDxaukRc3NDnF1GYJwQNPc3ZDTfeq3WL+JrzsE8CcLn YMZvSarO/Azf9nlmrFXWAb4VfemkjdujBShjSs/FQNDfAs0ctsgn/1QzqR8EKuyCaywi yJs3onB4LPYK1FNK/535TsjjPPyLG9ZU6gUyeoDuZHIJZtGOspclYIDRr9z4swTt3DZR 0mlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=aoV3AFMGO8ondSC4f0jCTV9tLxBQy1OhE1Yrhn7xh+0=; b=nPusdEO6F1QVmekmNxJbwNZ4GtVftVIwR+xiFk5xX6UV847kFqUzUw2YkXJGOCaIo8 eR/H9JdZqxB+N8YymqxHa0alPCcaLS4kFjNLaTCfXuIFbMAadrWsKj70NHVshv6ans9j F166+B2jM/treVdl3tUX7JvFTZ9LBIt1CUau0gJwXXFHbZaaMpVyOZcN6bkwLDTQPoxI aT3b42gsQogpwilVefnrTAivIjlaaQlrZbaJVBDKDGDhmv70fTHz5xzTfOj5KPppJoSa bqqbRYZFa8nadd3lDhXKebQ5MzJMand5XcI1zzHyKO0qiE6Ql1/Uv24wqiwPRqtEJHgs yRTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=md7ONus0; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g24-20020a633758000000b00476e21bc1bdsi379243pgn.162.2022.11.24.06.21.26; Thu, 24 Nov 2022 06:21:40 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=md7ONus0; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230192AbiKXOQT (ORCPT + 99 others); Thu, 24 Nov 2022 09:16:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229933AbiKXOQF (ORCPT ); Thu, 24 Nov 2022 09:16:05 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C12EE0B62; Thu, 24 Nov 2022 06:16:03 -0800 (PST) Date: Thu, 24 Nov 2022 14:16:00 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669299361; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aoV3AFMGO8ondSC4f0jCTV9tLxBQy1OhE1Yrhn7xh+0=; b=md7ONus0jMF1BpPfrBcDMg+sY16nvrhmQvwJUvFELAQ91XOLvDhYjnUfB13KC9EAYqyTyD IvSu9MKAyNBRTP7rFkxi6wiViQOvpXrCMX/C53tBA3vPt49VcC+tHdAPhqS9ESUmlLEbSs SIEMk6x6dPGjgotThXlZSn3VvHaCcTb2gxoP1blGvseeLV/VkuhIcyK/MwDMP1fEakXBXz xcAz0+SeEMd0SchTmxIAE5Bb2hRAiJr0nmcW8ck7npBI1ib1JLbMtzPZ1CuTRQRU+9Y0Jx CfPgmK9cKlCGW1Y3ho39GOryxyrhU+tRB3DZkM/X2x2oA+WiLO5l3i5XGrnzBQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669299361; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aoV3AFMGO8ondSC4f0jCTV9tLxBQy1OhE1Yrhn7xh+0=; b=91Y2vD/SQjt9Pjjp4ojoz7TqzUmtmIyf7s2f8Eq3rXdbqeROicaD8p1jLbTO9iGQgBBh8s JaPxRtHkVlZ/1rBw== From: "tip-bot2 for Steven Rostedt (Google)" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] timers: Update the documentation to reflect on the new timer_shutdown() API Cc: "Steven Rostedt (Google)" , Thomas Gleixner , Guenter Roeck , Jacob Keller , "Anna-Maria Behnsen" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221110064147.712934793@goodmis.org> References: <20221110064147.712934793@goodmis.org> MIME-Version: 1.0 Message-ID: <166929936027.4906.15038032251708772543.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails 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-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?1750387602056372918?= The following commit has been merged into the timers/core branch of tip: Commit-ID: a31323bef2b66455920d054b160c17d4240f8fd4 Gitweb: https://git.kernel.org/tip/a31323bef2b66455920d054b160c17d4240f8fd4 Author: Steven Rostedt (Google) AuthorDate: Wed, 23 Nov 2022 21:18:55 +01:00 Committer: Thomas Gleixner CommitterDate: Thu, 24 Nov 2022 15:09:12 +01:00 timers: Update the documentation to reflect on the new timer_shutdown() API 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 updated the zh_CN version ] Signed-off-by: Steven Rostedt (Google) Signed-off-by: Thomas Gleixner Tested-by: Guenter Roeck Reviewed-by: Jacob Keller Reviewed-by: Anna-Maria Behnsen Link: https://lore.kernel.org/r/20221110064147.712934793@goodmis.org Link: https://lore.kernel.org/r/20221123201625.375284489@linutronix.de --- Documentation/RCU/Design/Requirements/Requirements.rst | 2 +- Documentation/core-api/local_ops.rst | 2 +- Documentation/kernel-hacking/locking.rst | 5 +++++ Documentation/translations/zh_CN/core-api/local_ops.rst | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Documentation/RCU/Design/Requirements/Requirements.rst b/Documentation/RCU/Design/Requirements/Requirements.rst index 546f23a..49387d8 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 timer_delete_sync() or similar. +with via timer_shutdown_sync() or similar. 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 a84f8b0..0b42cea 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) { - timer_delete_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 c5b8678..c756786 100644 --- a/Documentation/kernel-hacking/locking.rst +++ b/Documentation/kernel-hacking/locking.rst @@ -1007,6 +1007,11 @@ 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 timer_delete_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 ============= diff --git a/Documentation/translations/zh_CN/core-api/local_ops.rst b/Documentation/translations/zh_CN/core-api/local_ops.rst index 22493b9..eb5423f 100644 --- a/Documentation/translations/zh_CN/core-api/local_ops.rst +++ b/Documentation/translations/zh_CN/core-api/local_ops.rst @@ -185,7 +185,7 @@ UP之间没有不同的行为,在你的架构的 ``local.h`` 中包括 ``asm-g static void __exit test_exit(void) { - timer_delete_sync(&test_timer); + timer_shutdown_sync(&test_timer); } module_init(test_init);