Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp5382971rwb; Mon, 8 Aug 2022 18:25:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR6FX4VhaBfpcLvVo4SKpVFvK3DnPWk3ILZoJ6qtrjyz87hnEQMg7M7i94zKj6BhmrDvbU5M X-Received: by 2002:a17:907:6da8:b0:730:8ed5:2df8 with SMTP id sb40-20020a1709076da800b007308ed52df8mr15714320ejc.75.1660008359406; Mon, 08 Aug 2022 18:25:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660008359; cv=none; d=google.com; s=arc-20160816; b=mrC3xL8XjghMo41dGIOOb7rEHk2OwNQZ4nxOaVmZfto3fRJ/QSLcqK82We+2oPbTpf pANfbCkByIJeUCASFMvcboYkZTAsMj2RzVNJYgQ1Q/Gx0qVvK7cdo4lOYGlRQl/hi9K0 WJBTLbKEk7FFOQtn1Z4yY6tkpz9A6U2a6wnPAOwB26UTfXKxtAIqWIuEMzP/zSI2EwXe RPAiM3nrXyFtDIlJyQ2U8BQXUmcYa6QVHbJPD3PysNHzQkUBqhS0e0SzaVLo9Wcon8R1 OlvMG+gEu7C+O7wCjKbhnEAhqWbjwxQ2Ff9p2hRk1nIY0CdrMXv2fYeJdDHXx3IrzHsl Mv1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=gli2C5qs1dJYFuJh9nuz9T1X+gr9ufZEuEH0gnaV5bE=; b=j0HpfXsTljJxuYp9bRF8DaH4D+4J3pnwI6CgXpQ+4gsq+KXPbMzEML1Ivo09JZFMQJ a2Aqw+ynPXTy9cm+bxqlSsIa0fBzgoKcDGdWwOu6ptxZaTDmGeb0PGxSo/8ZOCv0CVVl dr9RK2jCoIizlMhgPw8pevCWZ8SBEKMggwo5DvNvvarwmodCZBHoNysaulthb0w8UK7e CaHNJ5k02BSEpYpkqDlrL3rz1oGI1dPPK4AFoAs/hlQKL4KlkDI/ob3Aa1CB+ZXL6dRG b1vxNZWKDnnQx2X0AtOENxX6MZr2Oy2T5xfzy4kETKnDM3cOtbSVZaWrd/3HAqJBAxlw Vw4w== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c11-20020a056402120b00b004406513be73si6084163edw.343.2022.08.08.18.25.34; Mon, 08 Aug 2022 18:25:59 -0700 (PDT) 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 S244516AbiHIBQ3 (ORCPT + 99 others); Mon, 8 Aug 2022 21:16:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236939AbiHIBQZ (ORCPT ); Mon, 8 Aug 2022 21:16:25 -0400 Received: from azure-sdnproxy.icoremail.net (azure-sdnproxy.icoremail.net [52.187.6.220]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 13791C1B for ; Mon, 8 Aug 2022 18:16:21 -0700 (PDT) Received: from ubuntu.localdomain (unknown [218.12.17.53]) by mail-app2 (Coremail) with SMTP id by_KCgDX3PROtfFidi1+Ag--.40181S2; Tue, 09 Aug 2022 09:16:05 +0800 (CST) From: Duoming Zhou To: tglx@linutronix.de, linux-kernel@vger.kernel.org Cc: jstultz@google.com, sboyd@kernel.org, edumazet@google.com, Duoming Zhou Subject: [PATCH v2] timers: fix synchronization rules in comments of del_timer_sync Date: Tue, 9 Aug 2022 09:15:57 +0800 Message-Id: <20220809011557.6472-1-duoming@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: by_KCgDX3PROtfFidi1+Ag--.40181S2 X-Coremail-Antispam: 1UD129KBjvJXoW7CF1DKrWDJw1xtw4xAF4fXwb_yoW8ZFyrp3 y7Krn3GFs5XF4YkFW0vF4ktry3Gws3Jry5CFs7C3y5Zwn2qw1rXF4jqry8ZF47JrWkWFZr ZF1rZr4Ykrn8G3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkS14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc2xSY4AK67AK6w4l 42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJV WUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAK I48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F 4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY 6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUoUDGUUUUU X-CM-SenderInfo: qssqjiasttq6lmxovvfxof0/1tbiAggRAVZdta+OfgAAs7 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 The del_timer_sync() could stop the periodic timer. The root cause is shown below which is a part of code in del_timer_sync: do { ret = try_to_del_timer_sync(timer); if (unlikely(ret < 0)) { del_timer_wait_running(timer); cpu_relax(); } } while (ret < 0); If the timer's handler is running, the try_to_del_timer_sync will return -1. Then, it will loop until the timer is not queued and the timer's handler is not running on any CPU. Although the periodic timer may restart itself in timer's handler, the del_timer_sync could also stop it. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Duoming Zhou --- Changes in v2: - Make commit messages clearer. - Change the annotations about del_timer_sync. kernel/time/timer.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 717fcb9fb14..dd623018dbc 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1375,11 +1375,11 @@ static inline void del_timer_wait_running(struct timer_list *timer) { } * CPUs. * * Synchronization rules: Callers must prevent restarting of the timer, - * otherwise this function is meaningless. It must not be called from - * interrupt contexts unless the timer is an irqsafe one. The caller must - * not hold locks which would prevent completion of the timer's - * handler. The timer's handler must not call add_timer_on(). Upon exit the - * timer is not queued and the handler is not running on any CPU. + * otherwise this function is meaningless. It could also stop periodic timer. + * It must not be called from interrupt contexts unless the timer is an irqsafe + * one. The caller must not hold locks which would prevent completion of the + * timer's handler. Upon exit the timer is not queued and the handler is not + * running on any CPU. * * Note: For !irqsafe timers, you must not hold locks that are held in * interrupt context while calling this function. Even if the lock has -- 2.17.1