From patchwork Wed Nov 23 20:18:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 25199 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3009797wrr; Wed, 23 Nov 2022 12:24:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf4YXS5Q85zVRJTFSfe0leeUKJA0/G1htYBddtpY3B5NyxnfV7xFLA1giS4EKT6wPVd3wqeP X-Received: by 2002:a17:902:a703:b0:187:137c:b2ea with SMTP id w3-20020a170902a70300b00187137cb2eamr10381562plq.52.1669235061186; Wed, 23 Nov 2022 12:24:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669235061; cv=none; d=google.com; s=arc-20160816; b=t3OTqJbCXRADbtWd+XkS/zVN1imQ45iCY/Ul4+yTQkps6UjTt73hpHF4Lu5iemAGC9 d5FSQreHzgwT4n1Rj8HlBGzwd3r0sAqz8cA3UoJxJM6Uqyij6VWaHH1j4Stvan7vUbMK 19FEWCB780yKoUDrM6BcpEDcbO/j1iqXBW0XIHI92QkyePAMQy1S+SzCm/O1kk6Q3rkl W1tPL0KzbBzy1OwZSXwqjoFTnxi63RzLcTGVAS1Dk9VEhaPP2wZ4DZAV3PXpLE2t/hNi Wpt8H5O6Odu+0Xkl/FtPvMa83yMM8zhY0C5VrNhfXYJ6JUBPSZkjIqIEtfpIY7eFfOIX 9l+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:content-transfer-encoding:mime-version :references:subject:cc:to:from:dkim-signature:dkim-signature :message-id; bh=8mCfHxFOZzbOCsR313/bDzGhRTnb1fj4Q7VlJBNG0jE=; b=A08Rd/csDXMcV7LBDycHxqh+HXb2hV1Zp4ZEZd5NqlJOIUA34+IRV9IMrUqkb/WlJx rHZIUWV2zxttO/r7sLvGby/15gIA0/NkLY95h6NKUnAXhVsOABRLS4gZXiV78DLdY5Gk NwpPGZ8b6vP4M3h+8MRxzIX3ehBpIusRTKKCBxvZQUxaqFtP7gcWgCiWqJ7rECdjNwhl wbM1r9DbLcugshDltAXNUfu7E5GZPGB1Ql0MO1v8zn4W1Ae4L4uMa0NqX0ocRrstiLGA DHlViI2xarseP/quFhrm4oK0EYtOGzMr5apAhi70y6HALDeVuae0ErPiE3O0aX1ZojJU hH3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=gsOHJxPe; dkim=neutral (no key) header.i=@linutronix.de header.b=nN2gBcA8; 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 cp8-20020a056a00348800b0057253eb694bsi15980350pfb.214.2022.11.23.12.24.07; Wed, 23 Nov 2022 12:24:21 -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=gsOHJxPe; dkim=neutral (no key) header.i=@linutronix.de header.b=nN2gBcA8; 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 S239572AbiKWUWS (ORCPT + 99 others); Wed, 23 Nov 2022 15:22:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239592AbiKWUVX (ORCPT ); Wed, 23 Nov 2022 15:21:23 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56D0AC78CC; Wed, 23 Nov 2022 12:19:11 -0800 (PST) Message-ID: <20221123201625.375284489@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669234735; 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: content-transfer-encoding:content-transfer-encoding: references:references; bh=8mCfHxFOZzbOCsR313/bDzGhRTnb1fj4Q7VlJBNG0jE=; b=gsOHJxPeeeijJQ12VQfyqzGPX8xgyqZ96mWswxQCmi0j/GQ/N8eEa/pq5VJHwopx9L3PEG LB5I2kBB3h2QVSODmoCyUGI/dS7geEHzN74Ak1KEo9W5UkS/hf6yV8lITtey/5T7dJTemI KleqRuSumcCg2MAH+nAd6Bpi+YQ4wVPn8xj1+IvaSmpzZ13efp5MdqdCTa2mjb3d+MGJcC F9j8c9wv+5EJV9gOoPhtkzPnqEUEsGXHea+yEPHZeKkeKWOb5pJsPaVTKjLPzucEKimo4l 3YyEaUFT7VqhaItBqAyU2VfCbZp9nc0nECPk9TQsmRXmvABOWcbborbkjpn1FQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669234735; 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: content-transfer-encoding:content-transfer-encoding: references:references; bh=8mCfHxFOZzbOCsR313/bDzGhRTnb1fj4Q7VlJBNG0jE=; b=nN2gBcA8qa+c86/g9eNv5e51qKePiLEGDO3stJq4tkr3jZGsTDWvbRhR0cOUM6VloCC2XF P8Ox1KfFtz+yQJBA== 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, Jacob Keller Subject: [patch V3 16/17] timers: Update the documentation to reflect on the new timer_shutdown() API References: <20221123201306.823305113@linutronix.de> MIME-Version: 1.0 Date: Wed, 23 Nov 2022 21:18:55 +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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750319823538319323?= X-GMAIL-MSGID: =?utf-8?q?1750319823538319323?= 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 updated the zh_CN version ] Signed-off-by: Steven Rostedt (Google) Signed-off-by: Thomas Gleixner Tested-by: Guenter Roeck Reviewed-by: Jacob Keller 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 | 5 +++++ Documentation/translations/zh_CN/core-api/local_ops.rst | 2 +- 4 files changed, 8 insertions(+), 3 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 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 --- 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) { - timer_delete_sync(&test_timer); + timer_shutdown_sync(&test_timer); } module_init(test_init); --- a/Documentation/kernel-hacking/locking.rst +++ b/Documentation/kernel-hacking/locking.rst @@ -1007,6 +1007,11 @@ calling add_timer() at the end of their 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 ============= --- 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之间没有不同的行为,在你� static void __exit test_exit(void) { - timer_delete_sync(&test_timer); + timer_shutdown_sync(&test_timer); } module_init(test_init);