From patchwork Wed Nov 23 20:18:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 25193 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3009144wrr; Wed, 23 Nov 2022 12:22:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf7mK8P8+oNzQyzkmBaOqoAPK0grU11umDA5EWTKynIhhob3gmV0my6VrLtNhcHrCF01HJiL X-Received: by 2002:a05:6402:757:b0:469:f262:f79e with SMTP id p23-20020a056402075700b00469f262f79emr7697563edy.363.1669234958162; Wed, 23 Nov 2022 12:22:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669234958; cv=none; d=google.com; s=arc-20160816; b=F7Na6Jf3SC35rB9VY/Pb/tMbJ8VHaBA9p8PtPmrZUvkztKjFi9lqcsHVAaCVL6JjdM Ivhuov28cpG8hYWvuW0lIojqOkPFWgWO1h839Cl9cOazJ2U7WZEVvkw16JWi2wIFRHNh ia7AaQ5s3wCV8rc63NqvO38JRSu3gq0dpQqUtftWrLn/cX9+KtMzH16WSsIPVLmnkmKv 9ZMsvphivmHrTyhQ3XuWAf4X8t/s0KJRfgx+3Dh7T7q5wywSHVeUZ4TAx8fLgC0d4zFU CYXlHbVKngYGNraEMha6pAixe68gbe6iFXESFSbaEoSYBlYCwzGL8YXy+ppyRhLD0VXV xSvw== 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=1FRJAnaRsIw8Csy6BN8zPa3bMyc93id2b+gcGKDCm00=; b=n+eMlHi3iMP5veL5EWRkXx15/s6Rt8COLvWTEHtfClsba1Sc2ZURNBHoEVUsaH0ykv qikE0NSZ31ZiYNddvr9EOu9+bXDd81uGrGAlBwGlFpXeOvdTuiqfuAzFVkaX9SZyUzOs GRJi+l7INN6qpocwQMZlIQM6/HH40/Us95VCoMQIrrasGXJh8d9KtqJS3kjApYtDC9Gx 6ede9IZgm3OcThGoh6A0GVBUsLdcnOIL6tbpxGW+fErh5hrYQcWhNBbFGW7pQE6tO3my wbCRPsFBM4Qt5TYlP+OJIK/nMJx6bU8Q+d0GRbVksDppnBEjo/MhALzIQa2MyAJTOQeN Mynw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=IXyrE+00; dkim=neutral (no key) header.i=@linutronix.de; 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 cy17-20020a0564021c9100b00463cdad3915si12661415edb.521.2022.11.23.12.22.13; Wed, 23 Nov 2022 12:22:38 -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=IXyrE+00; dkim=neutral (no key) header.i=@linutronix.de; 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 S239772AbiKWUV2 (ORCPT + 99 others); Wed, 23 Nov 2022 15:21:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239393AbiKWUUf (ORCPT ); Wed, 23 Nov 2022 15:20:35 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80F62BEAF7; Wed, 23 Nov 2022 12:18:54 -0800 (PST) Message-ID: <20221123201625.075320635@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669234727; 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=1FRJAnaRsIw8Csy6BN8zPa3bMyc93id2b+gcGKDCm00=; b=IXyrE+00qGqMETjQqESePRw375/eBfj8izUY+WP2S46hkh9EmJWNXjPOa+JUw1RIfSge03 0iJNCFC8v/M6xgGo5GXP+NourJj2LSVZpp2hsQQWYD3YQTrx2ziJhaxNdH/38Tky7VzLqp Q+nCOMmvhlYzxtFjo68G5Mw+ryPSYq9/BNkCyJ88B4DnDVd3GIIoAtuvTMCyC8FWZ1tkdB NXE1IoXRoM6+IC5KXSSjoim3i8EYp27ljTaHMicOqKSifeqf3sTDF2Olci2oKhXvRouSVR AHwIvvmEjdDBZO2xTUHBROdQ+rNxoHrRhetUbi/zA7wJQpEsMTmfda2i3MdX+g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669234727; 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=1FRJAnaRsIw8Csy6BN8zPa3bMyc93id2b+gcGKDCm00=; b=Pu+mkN/t+nhUuX+yQYi202ggUEJnXOuDNTmDeA13+CVO6vt6KpN3+Fqef2TWfYqAxOGPvX 1TsBfIFZ+tCQb9CQ== 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 11/17] Documentation: Replace del_timer/del_timer_sync() References: <20221123201306.823305113@linutronix.de> MIME-Version: 1.0 Date: Wed, 23 Nov 2022 21:18:47 +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?1750319715219430566?= X-GMAIL-MSGID: =?utf-8?q?1750319715219430566?= Adjust to the new preferred function names. Suggested-by: Steven Rostedt Signed-off-by: Thomas Gleixner Reviewed-by: Jacob Keller --- Documentation/RCU/Design/Requirements/Requirements.rst | 2 +- Documentation/core-api/local_ops.rst | 2 +- Documentation/kernel-hacking/locking.rst | 11 +++++------ Documentation/timers/hrtimers.rst | 2 +- Documentation/translations/it_IT/kernel-hacking/locking.rst | 10 +++++----- Documentation/translations/zh_CN/core-api/local_ops.rst | 2 +- 6 files changed, 14 insertions(+), 15 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_delete_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) { - del_timer_sync(&test_timer); + timer_delete_sync(&test_timer); } module_init(test_init); --- a/Documentation/kernel-hacking/locking.rst +++ b/Documentation/kernel-hacking/locking.rst @@ -967,7 +967,7 @@ If you want to destroy the entire collec while (list) { struct foo *next = list->next; - del_timer(&list->timer); + timer_delete(&list->timer); kfree(list); list = next; } @@ -981,7 +981,7 @@ the lock after we spin_unlock_bh(), and the element (which has already been freed!). This can be avoided by checking the result of -del_timer(): if it returns 1, the timer has been deleted. +timer_delete(): if it returns 1, the timer has been deleted. If 0, it means (in this case) that it is currently running, so we can do:: @@ -990,7 +990,7 @@ If 0, it means (in this case) that it is while (list) { struct foo *next = list->next; - if (!del_timer(&list->timer)) { + if (!timer_delete(&list->timer)) { /* Give timer a chance to delete this */ spin_unlock_bh(&list_lock); goto retry; @@ -1005,8 +1005,7 @@ 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. +use timer_delete_sync() (``include/linux/timer.h``) to handle this case. Locking Speed ============= @@ -1334,7 +1333,7 @@ lock. - kfree() -- add_timer() and del_timer() +- add_timer() and timer_delete() Mutex API reference =================== --- a/Documentation/timers/hrtimers.rst +++ b/Documentation/timers/hrtimers.rst @@ -118,7 +118,7 @@ existing timer wheel code, as it is matu was not really a win, due to the different data structures. Also, the hrtimer functions now have clearer behavior and clearer names - such as hrtimer_try_to_cancel() and hrtimer_cancel() [which are roughly -equivalent to del_timer() and del_timer_sync()] - so there's no direct +equivalent to timer_delete() and timer_delete_sync()] - so there's no direct 1:1 mapping between them on the algorithmic level, and thus no real potential for code sharing either. --- a/Documentation/translations/it_IT/kernel-hacking/locking.rst +++ b/Documentation/translations/it_IT/kernel-hacking/locking.rst @@ -990,7 +990,7 @@ Se volete eliminare l'intera collezione while (list) { struct foo *next = list->next; - del_timer(&list->timer); + timer_delete(&list->timer); kfree(list); list = next; } @@ -1003,7 +1003,7 @@ e prenderà il *lock* solo dopo spin_unl di eliminare il suo oggetto (che però è già stato eliminato). Questo può essere evitato controllando il valore di ritorno di -del_timer(): se ritorna 1, il temporizzatore è stato già +timer_delete(): se ritorna 1, il temporizzatore è stato già rimosso. Se 0, significa (in questo caso) che il temporizzatore è in esecuzione, quindi possiamo fare come segue:: @@ -1012,7 +1012,7 @@ rimosso. Se 0, significa (in questo caso while (list) { struct foo *next = list->next; - if (!del_timer(&list->timer)) { + if (!timer_delete(&list->timer)) { /* Give timer a chance to delete this */ spin_unlock_bh(&list_lock); goto retry; @@ -1026,7 +1026,7 @@ rimosso. Se 0, significa (in questo caso Un altro problema è l'eliminazione dei temporizzatori che si riavviano da soli (chiamando add_timer() alla fine della loro esecuzione). Dato che questo è un problema abbastanza comune con una propensione -alle corse critiche, dovreste usare del_timer_sync() +alle corse critiche, dovreste usare timer_delete_sync() (``include/linux/timer.h``) per gestire questo caso. Velocità della sincronizzazione @@ -1372,7 +1372,7 @@ contesto, o trattenendo un qualsiasi *lo - kfree() -- add_timer() e del_timer() +- add_timer() e timer_delete() Riferimento per l'API dei Mutex =============================== --- 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) { - del_timer_sync(&test_timer); + timer_delete_sync(&test_timer); } module_init(test_init);