From patchwork Thu Nov 10 06:41:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 17977 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp760959wru; Wed, 9 Nov 2022 22:43:33 -0800 (PST) X-Google-Smtp-Source: AMsMyM5XD9fahIaYf0J9Ttx7HH+ih8jrAn/9rg8PN0YzQwHQMsD7SFlWbX0bY/HW5tDqYnvT8GxM X-Received: by 2002:a63:571e:0:b0:46a:e819:216c with SMTP id l30-20020a63571e000000b0046ae819216cmr1914058pgb.155.1668062612964; Wed, 09 Nov 2022 22:43:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668062612; cv=none; d=google.com; s=arc-20160816; b=Qij/kCje4Mdu9FASipS5o5iRUXckcf/U/jyFcGRl1jZ6bQywMM2DhcRVzmTgBbOkrE G5opvh83Mnb3ge4KcncauthGI/9rBDF7wE6oJkc0NqBZh+o4nIKorQh246J/qUC9Grjx bcGgWPNMEkd7yVhR/vJCG0AzH0NMe7rpKeVSiTQ+V0JD3RpvIjqQGV39wd/qFXuEYinD XE8rZqjJC3P9m2OebDYmTPwUZmxTZbeaDVudIPOGsIhGmaPeA3EeOl2AZzFGHXv8FzMR Ersyqmk7P0NCtihRVLQ07TBwGEziiVJbzhW7GGhqsNWT9JbKkryFo6rtAOr0tvvyNC0C zN4w== 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=USIGGnTLcfHeRDUrQSyUYnJHzLQZVm2DPknBnEyXSfA=; b=gwCR+D5hikK0r65Sfha+GdpB8uxS71YwMqDl6xwOIV/KdfrsZhaw09wItnDB3cD/cR RoXXhNtXUfhCBZ6LMhrnxCu10DgyTh90VI4cyVB68GkoOEF3eyrgLp3dOcYkqhChgZ0Z XMqY8V0qlHAcmQKQAlUUwancq6nPxZfVdGVgVhZwh8FebXm3EKl3+SNnMfnt4iOJpsMQ 5LKAdZ/X50SpseHQBXQcW+0YvvoTsjarFv0R8VfkP1kTVNX31P8X87NXD7AX+z7VztW7 pHeA6LA0BuoaeNy4SC2clzSLTHkn9l5hSFUth3IKQFMyhmPBCpDPTS49Tbtq8wlzRq9Z vw0Q== 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 p11-20020a1709028a8b00b00176b7e66c9asi17245096plo.155.2022.11.09.22.43.13; Wed, 09 Nov 2022 22:43:32 -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 S232586AbiKJGlp (ORCPT + 99 others); Thu, 10 Nov 2022 01:41:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231893AbiKJGl2 (ORCPT ); Thu, 10 Nov 2022 01:41:28 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CD0D31DCE 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 ams.source.kernel.org (Postfix) with ESMTPS id 04315B820DC for ; Thu, 10 Nov 2022 06:41:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EF23C433B5; Thu, 10 Nov 2022 06:41:11 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.96) (envelope-from ) id 1ot1Fz-009EeN-0S; Thu, 10 Nov 2022 01:41:47 -0500 Message-ID: <20221110064146.981725531@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 10 Nov 2022 01:41:03 -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 , Mark Rutland , Daniel Lezcano , linux-arm-kernel@lists.infradead.org, Marc Zyngier Subject: [PATCH v6 2/6] clocksource/drivers/arm_arch_timer: Do not use timer namespace for timer_shutdown() function 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?1749090422013748462?= X-GMAIL-MSGID: =?utf-8?q?1749090422013748462?= From: "Steven Rostedt (Google)" A new "shutdown" timer state is being added to the generic timer code. One of the functions to change the timer into the state is called "timer_shutdown()". This means that there can not be other functions called "timer_shutdown()" as the timer code owns the "timer_*" name space. Rename timer_shutdown() to arch_timer_shutdown() to avoid this conflict. Link: https://lkml.kernel.org/r/20221106212702.002251651@goodmis.org Link: https://lore.kernel.org/all/20221105060155.409832154@goodmis.org/ Cc: Mark Rutland Cc: Linus Torvalds Cc: Stephen Boyd Cc: Anna-Maria Gleixner Cc: Andrew Morton Cc: Julia Lawall Cc: Daniel Lezcano Cc: Thomas Gleixner Cc: linux-arm-kernel@lists.infradead.org Acked-by: Marc Zyngier Reviewed-by: Guenter Roeck Tested-by: Guenter Roeck Signed-off-by: Steven Rostedt (Google) --- drivers/clocksource/arm_arch_timer.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index a7ff77550e17..9c3420a0d19d 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -687,8 +687,8 @@ static irqreturn_t arch_timer_handler_virt_mem(int irq, void *dev_id) return timer_handler(ARCH_TIMER_MEM_VIRT_ACCESS, evt); } -static __always_inline int timer_shutdown(const int access, - struct clock_event_device *clk) +static __always_inline int arch_timer_shutdown(const int access, + struct clock_event_device *clk) { unsigned long ctrl; @@ -701,22 +701,22 @@ static __always_inline int timer_shutdown(const int access, static int arch_timer_shutdown_virt(struct clock_event_device *clk) { - return timer_shutdown(ARCH_TIMER_VIRT_ACCESS, clk); + return arch_timer_shutdown(ARCH_TIMER_VIRT_ACCESS, clk); } static int arch_timer_shutdown_phys(struct clock_event_device *clk) { - return timer_shutdown(ARCH_TIMER_PHYS_ACCESS, clk); + return arch_timer_shutdown(ARCH_TIMER_PHYS_ACCESS, clk); } static int arch_timer_shutdown_virt_mem(struct clock_event_device *clk) { - return timer_shutdown(ARCH_TIMER_MEM_VIRT_ACCESS, clk); + return arch_timer_shutdown(ARCH_TIMER_MEM_VIRT_ACCESS, clk); } static int arch_timer_shutdown_phys_mem(struct clock_event_device *clk) { - return timer_shutdown(ARCH_TIMER_MEM_PHYS_ACCESS, clk); + return arch_timer_shutdown(ARCH_TIMER_MEM_PHYS_ACCESS, clk); } static __always_inline void set_next_event(const int access, unsigned long evt, From patchwork Thu Nov 10 06:41:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 17979 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp763230wru; Wed, 9 Nov 2022 22:51:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf5FkBx2/A10dqVT+89/+8jKGX8y8jsjy6nYwvabRLowef6YlHZm2JhShQ1Lm1ERkM0Ld09q X-Received: by 2002:a50:bb67:0:b0:466:f299:bb32 with SMTP id y94-20020a50bb67000000b00466f299bb32mr3352291ede.307.1668063066705; Wed, 09 Nov 2022 22:51:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668063066; cv=none; d=google.com; s=arc-20160816; b=Z46gNR1UsTQKWMs2jGJgqjn231xfTiwcClBUkJxu8w2xgNkF2o5+Fc9SiwGZ1PtmKT 3YIR3QJoatue2QlBoChSCGtZuepBWffKCjDcs2uOJRh73IX605HjDBs8SZ11xyIoE4Ht WpZNPQptwlOmfLRfeVMtKl2+mummgJmBZQXUnYIdE0faJwjoHiiIaVvjwW21rHNpdPXd Tmr2DSZr+WTXcpvMdJI00sKvvSx8EJPo4qW1MQ3e4H+qg9UnlViu68ZKNZRvBN7MeUQp Kg1uMVpHk90X6aCjG4IvhLlT22HwOZGup1ZyRxSShx1bHU6K7iINxLubI/ecotEbal6z 6xgg== 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=hJFDSUtYL2/M/HQVNPKLcAcezOB87x2ECTQtO9QflT8=; b=A3McWavrvaynGNlF4rNyoYZNzus+2PrVeju2R/D5LbUbGnFaA4GO7cXM+5pRIxtNC5 juxWd9T4v6yBIRXIURgzqsLibL6bBB9xVTogWtd/b33vrZnm5T9TByzX0htgl4wySRCv ATZRsbGDbHelXx6NmtnTX25tl/hMYnxdo97idl9ieBFLJ6fVyRZNSif00bMppBDgMZKW KuFfNyhozAz6UnxGSkLBvyCedALjiHkPs6VecHV6NOb7SAS23FOU7WpPueHW3zddqRqq wLruWN0krm49jUT5t1ltyKRXzLK8hxr6tuAXkqZt8ef2/HdIzSm8BWQTZNclOxI+XZ5W rmwQ== 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 cr20-20020a170906d55400b007aea5ae3956si1816795ejc.820.2022.11.09.22.50.43; Wed, 09 Nov 2022 22:51:06 -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 S232631AbiKJGlv (ORCPT + 99 others); Thu, 10 Nov 2022 01:41:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232525AbiKJGl1 (ORCPT ); Thu, 10 Nov 2022 01:41:27 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64C6D31DD4 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 ams.source.kernel.org (Postfix) with ESMTPS id 26A7CB820DD for ; Thu, 10 Nov 2022 06:41:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B83B2C43142; Thu, 10 Nov 2022 06:41:11 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.96) (envelope-from ) id 1ot1Fz-009Eev-12; Thu, 10 Nov 2022 01:41:47 -0500 Message-ID: <20221110064147.158230501@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 10 Nov 2022 01:41:04 -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 , Daniel Lezcano Subject: [PATCH v6 3/6] clocksource/drivers/sp804: Do not use timer namespace for timer_shutdown() function 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?1749090898261272617?= X-GMAIL-MSGID: =?utf-8?q?1749090898261272617?= From: "Steven Rostedt (Google)" A new "shutdown" timer state is being added to the generic timer code. One of the functions to change the timer into the state is called "timer_shutdown()". This means that there can not be other functions called "timer_shutdown()" as the timer code owns the "timer_*" name space. Rename timer_shutdown() to evt_timer_shutdown() to avoid this conflict. Link: https://lkml.kernel.org/r/20221106212702.182883323@goodmis.org Link: https://lore.kernel.org/all/20221105060155.592778858@goodmis.org/ Cc: Daniel Lezcano Cc: Linus Torvalds Cc: Stephen Boyd Cc: Anna-Maria Gleixner Cc: Andrew Morton Cc: Julia Lawall Cc: Thomas Gleixner Reviewed-by: Guenter Roeck Tested-by: Guenter Roeck Signed-off-by: Steven Rostedt (Google) --- drivers/clocksource/timer-sp804.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/clocksource/timer-sp804.c b/drivers/clocksource/timer-sp804.c index e6a87f4af2b5..cd1916c05325 100644 --- a/drivers/clocksource/timer-sp804.c +++ b/drivers/clocksource/timer-sp804.c @@ -155,14 +155,14 @@ static irqreturn_t sp804_timer_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } -static inline void timer_shutdown(struct clock_event_device *evt) +static inline void evt_timer_shutdown(struct clock_event_device *evt) { writel(0, common_clkevt->ctrl); } static int sp804_shutdown(struct clock_event_device *evt) { - timer_shutdown(evt); + evt_timer_shutdown(evt); return 0; } @@ -171,7 +171,7 @@ static int sp804_set_periodic(struct clock_event_device *evt) unsigned long ctrl = TIMER_CTRL_32BIT | TIMER_CTRL_IE | TIMER_CTRL_PERIODIC | TIMER_CTRL_ENABLE; - timer_shutdown(evt); + evt_timer_shutdown(evt); writel(common_clkevt->reload, common_clkevt->load); writel(ctrl, common_clkevt->ctrl); return 0; From patchwork Thu Nov 10 06:41:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 17978 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp762934wru; Wed, 9 Nov 2022 22:50:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf68tIgHJx+o9kxPNFQGWU2ZRl3gBltkVJSNnJcG5iSKJgyQ5Q7DJvt0j2vgoE3lhEADO+wx X-Received: by 2002:a17:906:9484:b0:7ae:6c36:3e09 with SMTP id t4-20020a170906948400b007ae6c363e09mr15208596ejx.385.1668063005500; Wed, 09 Nov 2022 22:50:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668063005; cv=none; d=google.com; s=arc-20160816; b=oALEC3tAwgI2Hi1R+GvAS8gJnKNXUiK36X9fvG5Rc6IuOC7C8JJ9/fktY3PUm3+g+Q 6AkJ0QARfCcOQviMewsUVc4DNkBIZpI8xZMdjgpU9M94CEEkJ9wU+AEAc2CdVsHEugQO mK0Kt8oKr7jH7sqyaQbncQZZwMOJG6W4HSNVz23ivGRZy+NSKiVZILuea42svogj2DsM oM6soZ9braGOkpZW1OdKNcfi1abV9Wp6u2nYe3xyoLgp61wW/wZJE84orVAUHQrBaylG cL5OsFZVrzUEudfbLEW9QmKb9e5seHxgQv8GMaI9ZZhA7KxNPjdfYC70TUDO4rnQWsQS Qsqw== 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=NsBX8u9dsy6BhoeXZGwxtixLFdb64Kv7TTwzYwB8Y+8=; b=U2qzDy0CJBS410kWnKQl1f2x2qhG8hTQVVSZczz9v/MT9pJIIYnVnxhNAb5bHM1VnM gZ6p6DemhPGBpN1KvJdHxlt4BUga85kt2nZjPkHLWCJO7fnW9m3pkVJvvBaPhcxI80Q6 mmu7YIfGX24FxwP/1qTivWHZJBVpK2pLDSbtI6K37pQB8/oiKBCgQmKLbDjQycVBggrq aLPrGIIi96oUzyJ8vhoMRytGe9JssTy76DfSRRa1FgflhJ5LwW0U+BcFbJUlU9q8oKMu 2TDfiPWXRxmorkvgbdoqNUMYw3plpcEiNypmF+tBrQQg0mpTA9We2J3d+APVcIoKtvVK Asng== 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 rh7-20020a17090720e700b0077ef3eece57si14077279ejb.144.2022.11.09.22.49.36; Wed, 09 Nov 2022 22:50:05 -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 S232675AbiKJGlz (ORCPT + 99 others); Thu, 10 Nov 2022 01:41:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232547AbiKJGl2 (ORCPT ); Thu, 10 Nov 2022 01:41:28 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B812E2EF72 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 ams.source.kernel.org (Postfix) with ESMTPS id 4A102B820DF for ; Thu, 10 Nov 2022 06:41:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC7C9C43147; Thu, 10 Nov 2022 06:41:11 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.96) (envelope-from ) id 1ot1Fz-009EfT-1e; Thu, 10 Nov 2022 01:41:47 -0500 Message-ID: <20221110064147.343514404@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 10 Nov 2022 01:41:05 -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 4/6] timers: Add timer_shutdown_sync() to be called before freeing timers 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?1749090833884894039?= X-GMAIL-MSGID: =?utf-8?q?1749090833884894039?= From: "Steven Rostedt (Google)" We are hitting a common bug were a timer is being triggered after it is freed. This causes a corruption in the timer link list and crashes the kernel. Unfortunately it is not easy to know what timer it was that was freed. Looking at the code, it appears that there are several cases that del_timer() is used when del_timer_sync() should have been. Add a timer_shutdown_sync() that not only does a del_timer_sync() but will mark the timer as terminated in case it gets rearmed, it will trigger a WARN_ON. The timer_shutdown_sync() is more likely to be used by developers that are about to free a timer, then using del_timer_sync() as the latter is not as obvious to being needed for freeing. Having the word "shutdown" in the name of the function will hopefully help developers know that that function needs to be called before freeing. The added bonus is the marking of the timer as being freed such that it will trigger a warning if it gets rearmed. At least that way if the system crashes on a freed timer, at least we may see which timer it was that was freed. There's some situations that already know that the timer is shutdown and does not need to perform the synchronization (or can not due to its context). For these locations there's timer_shutdown() that only shuts down the timer (prevents it from being rearmed) but does not add checks if the timer is currently running. This code is taken from Thomas Gleixner's "untested" version from my original patch and modified after testing and with some other comments from Linus addressed. As well as some extra comments added. Link: https://lore.kernel.org/all/87pmlrkgi3.ffs@tglx/ Link: https://lkml.kernel.org/r/20221106212702.363575800@goodmis.org Link: https://lore.kernel.org/all/20221105060024.598488967@goodmis.org/ 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) --- include/linux/timer.h | 27 ++++++++++++++++++++++----- kernel/time/timer.c | 43 ++++++++++++++++++++++++++----------------- 2 files changed, 48 insertions(+), 22 deletions(-) diff --git a/include/linux/timer.h b/include/linux/timer.h index 648f00105f58..4d56e20613eb 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h @@ -183,12 +183,29 @@ extern int timer_reduce(struct timer_list *timer, unsigned long expires); extern void add_timer(struct timer_list *timer); extern int try_to_del_timer_sync(struct timer_list *timer); +extern int __del_timer_sync(struct timer_list *timer, bool free); -#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT) - extern int del_timer_sync(struct timer_list *timer); -#else -# define del_timer_sync(t) del_timer(t) -#endif +static inline int del_timer_sync(struct timer_list *timer) +{ + return __del_timer_sync(timer, false); +} + +/** + * timer_shutdown_sync - called before freeing the timer + * @timer: The timer to be freed + * + * Shutdown the timer before freeing. This will return when all pending timers + * have finished and it is safe to free the timer. + * + * Note, after calling this, if the timer is added back to the queue + * it will fail to be added and a WARNING will be triggered. + * + * Returns if it deactivated a pending timer or not. + */ +static inline int timer_shutdown_sync(struct timer_list *timer) +{ + return __del_timer_sync(timer, true); +} #define del_singleshot_timer_sync(t) del_timer_sync(t) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 717fcb9fb14a..111a3550b3f2 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1017,7 +1017,8 @@ __mod_timer(struct timer_list *timer, unsigned long expires, unsigned int option unsigned int idx = UINT_MAX; int ret = 0; - BUG_ON(!timer->function); + if (WARN_ON_ONCE(!timer->function)) + return -EINVAL; /* * This is a common optimization triggered by the networking code - if @@ -1193,7 +1194,8 @@ EXPORT_SYMBOL(timer_reduce); */ void add_timer(struct timer_list *timer) { - BUG_ON(timer_pending(timer)); + if (WARN_ON_ONCE(timer_pending(timer))) + return; __mod_timer(timer, timer->expires, MOD_TIMER_NOTPENDING); } EXPORT_SYMBOL(add_timer); @@ -1210,7 +1212,8 @@ void add_timer_on(struct timer_list *timer, int cpu) struct timer_base *new_base, *base; unsigned long flags; - BUG_ON(timer_pending(timer) || !timer->function); + if (WARN_ON_ONCE(timer_pending(timer) || !timer->function)) + return; new_base = get_timer_cpu_base(timer->flags, cpu); @@ -1266,14 +1269,7 @@ int del_timer(struct timer_list *timer) } EXPORT_SYMBOL(del_timer); -/** - * try_to_del_timer_sync - Try to deactivate a timer - * @timer: timer to delete - * - * This function tries to deactivate a timer. Upon successful (ret >= 0) - * exit the timer is not queued and the handler is not running on any CPU. - */ -int try_to_del_timer_sync(struct timer_list *timer) +static int __try_to_del_timer_sync(struct timer_list *timer, bool free) { struct timer_base *base; unsigned long flags; @@ -1285,11 +1281,25 @@ int try_to_del_timer_sync(struct timer_list *timer) if (base->running_timer != timer) ret = detach_if_pending(timer, base, true); + if (free) + timer->function = NULL; raw_spin_unlock_irqrestore(&base->lock, flags); return ret; } + +/** + * try_to_del_timer_sync - Try to deactivate a timer + * @timer: timer to delete + * + * This function tries to deactivate a timer. Upon successful (ret >= 0) + * exit the timer is not queued and the handler is not running on any CPU. + */ +int try_to_del_timer_sync(struct timer_list *timer) +{ + return __try_to_del_timer_sync(timer, false); +} EXPORT_SYMBOL(try_to_del_timer_sync); #ifdef CONFIG_PREEMPT_RT @@ -1365,10 +1375,10 @@ static inline void timer_sync_wait_running(struct timer_base *base) { } static inline void del_timer_wait_running(struct timer_list *timer) { } #endif -#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT) /** - * del_timer_sync - deactivate a timer and wait for the handler to finish. + * __del_timer_sync - deactivate a timer and wait for the handler to finish. * @timer: the timer to be deactivated + * @free: Set to true if the timer is about to be freed * * This function only differs from del_timer() on SMP: besides deactivating * the timer it also makes sure the handler has finished executing on other @@ -1402,7 +1412,7 @@ static inline void del_timer_wait_running(struct timer_list *timer) { } * * The function returns whether it has deactivated a pending timer or not. */ -int del_timer_sync(struct timer_list *timer) +int __del_timer_sync(struct timer_list *timer, bool free) { int ret; @@ -1432,7 +1442,7 @@ int del_timer_sync(struct timer_list *timer) lockdep_assert_preemption_enabled(); do { - ret = try_to_del_timer_sync(timer); + ret = __try_to_del_timer_sync(timer, free); if (unlikely(ret < 0)) { del_timer_wait_running(timer); @@ -1442,8 +1452,7 @@ int del_timer_sync(struct timer_list *timer) return ret; } -EXPORT_SYMBOL(del_timer_sync); -#endif +EXPORT_SYMBOL(__del_timer_sync); static void call_timer_fn(struct timer_list *timer, void (*fn)(struct timer_list *), From patchwork Thu Nov 10 06:41:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 17981 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp764964wru; Wed, 9 Nov 2022 22:56:13 -0800 (PST) X-Google-Smtp-Source: AMsMyM5sfQKPQt54qy7q00xG1l6gXhzThKwdpFWXNyZpUihZtNoOS9IEUeECyKOi64J/3o94mzTZ X-Received: by 2002:a05:6402:5211:b0:462:3a0e:cd0d with SMTP id s17-20020a056402521100b004623a0ecd0dmr62298225edd.130.1668063373377; Wed, 09 Nov 2022 22:56:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668063373; cv=none; d=google.com; s=arc-20160816; b=giSfZkYKCfAEEgUt4gsnc97bL3qmt4y9P7gEetpvckcisQCEi9zG8J+lo92EmrRp6z 1SgXpG1jmv222Sh/MGjx+DrtWpEIUQqFw59PcczQ7s0F7Q/oH5JcTUbMufklr1Y5FPBy 0AlNnavqob3U1jkV7VhBJZ5wdqkfqListMuPBkmrv1IEDkDeDpeHuZBlT/bPhbG2vLeA rAwKz46K+zWhxfnbsG3wJQKjOyAXJUw+ULrh10LHw3Tbi/xkVAqfSn40mCGBIxlhqyS2 OqD4RKLgcw8gWgZm1e/eO8Ywm4VbZiZZczUzYXBDVSaDDV/pFAT2LSg8nispzq5VKhiR P9zg== 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=zh82lRJhLdejkzcl1qSBp/gh+9EUWOIcf8Tr6Tqg+g4=; b=X6qNdlct6mOss8T8YpGA0uk4i79Xdq1gx6Wuz308XjxJydkzlso1fHifiPZ44BQiWJ wFMdLyT7emD5Gf36WkMtRrPhHW03ycHs2uTINbFOC1NQ/WOdJBdtF8VC2h/BemNDxFkG 2bkUzIXGMf7BBoHc8qK8SsqDAmSiZDccHJCMqvzTgvnSlIZO9lSToJ/PQLJA+7A+P1og IVV2bNhAOTxL8UhhRhjXXU96ufXtj0nPqpcM2Kp7sNf9J2irZBZuYn1vAUOzjow0dwY3 8KNqEXRI/wUHQN8PX4+njaCuaZl3SZ0YKAhHtaR5UqPqNy++ZY3455Qj706/Ab6tOgRf vihw== 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 gb41-20020a170907962900b0077fd6028710si20577728ejc.670.2022.11.09.22.55.40; Wed, 09 Nov 2022 22:56:13 -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 S232638AbiKJGmA (ORCPT + 99 others); Thu, 10 Nov 2022 01:42:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232572AbiKJGl2 (ORCPT ); Thu, 10 Nov 2022 01:41:28 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40FD62180B for ; Wed, 9 Nov 2022 22:41:16 -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 ams.source.kernel.org (Postfix) with ESMTPS id 653B2B820DE for ; Thu, 10 Nov 2022 06:41:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16A11C4314A; 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-009Eg1-2F; Thu, 10 Nov 2022 01:41:47 -0500 Message-ID: <20221110064147.529154710@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 10 Nov 2022 01:41:06 -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 5/6] timers: Add timer_shutdown() to be called before freeing timers 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?1749091219991508808?= X-GMAIL-MSGID: =?utf-8?q?1749091219991508808?= From: "Steven Rostedt (Google)" Before a timer is to be freed, it must be shutdown. But there are some locations were timer_shutdown_sync() can not be called due to the context the object that holds the timer is in when it is freed. For cases where the logic should keep the timer from being re-armed but still needs to be shutdown with a sync, a new API of timer_shutdown() is available. This is the same as del_timer() except that after it is called, the timer can not be re-armed. If it is, a WARN_ON_ONCE() will be triggered. The implementation of timer_shutdown() follows the timer_shutdown_sync() method of using the same code as del_timer() but will pass in a boolean that the timer is about to be freed, in which case the timer->function is set to NULL, just like timer_shutdown_sync(). 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) --- include/linux/timer.h | 35 ++++++++++++++++++++++++++++++++++- kernel/time/timer.c | 21 ++++++++------------- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/include/linux/timer.h b/include/linux/timer.h index 4d56e20613eb..0b959b52d0db 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h @@ -168,12 +168,45 @@ static inline int timer_pending(const struct timer_list * timer) return !hlist_unhashed_lockless(&timer->entry); } +extern int __del_timer(struct timer_list * timer, bool free); + extern void add_timer_on(struct timer_list *timer, int cpu); -extern int del_timer(struct timer_list * timer); extern int mod_timer(struct timer_list *timer, unsigned long expires); extern int mod_timer_pending(struct timer_list *timer, unsigned long expires); extern int timer_reduce(struct timer_list *timer, unsigned long expires); +/** + * del_timer - deactivate a timer. + * @timer: the timer to be deactivated + * + * del_timer() deactivates a timer - this works on both active and inactive + * timers. + * + * The function returns whether it has deactivated a pending timer or not. + * (ie. del_timer() of an inactive timer returns 0, del_timer() of an + * active timer returns 1.) + */ +static inline int del_timer(struct timer_list *timer) +{ + return __del_timer(timer, false); +} + +/** + * timer_shutdown - deactivate a timer and shut it down + * @timer: the timer to be deactivated + * + * timer_shutdown() deactivates a timer - this works on both active + * and inactive timers, and will prevent it from being rearmed. + * + * The function returns whether it has deactivated a pending timer or not. + * (ie. timer_shutdown() of an inactive timer returns 0, + * timer_shutdown() of an active timer returns 1.) + */ +static inline int timer_shutdown(struct timer_list *timer) +{ + return __del_timer(timer, true); +} + /* * The jiffies value which is added to now, when there is no timer * in the timer wheel: diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 111a3550b3f2..7c224766065e 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1240,18 +1240,7 @@ void add_timer_on(struct timer_list *timer, int cpu) } EXPORT_SYMBOL_GPL(add_timer_on); -/** - * del_timer - deactivate a timer. - * @timer: the timer to be deactivated - * - * del_timer() deactivates a timer - this works on both active and inactive - * timers. - * - * The function returns whether it has deactivated a pending timer or not. - * (ie. del_timer() of an inactive timer returns 0, del_timer() of an - * active timer returns 1.) - */ -int del_timer(struct timer_list *timer) +int __del_timer(struct timer_list *timer, bool free) { struct timer_base *base; unsigned long flags; @@ -1262,12 +1251,18 @@ int del_timer(struct timer_list *timer) if (timer_pending(timer)) { base = lock_timer_base(timer, &flags); ret = detach_if_pending(timer, base, true); + if (free) + timer->function = NULL; + raw_spin_unlock_irqrestore(&base->lock, flags); + } else if (free) { + base = lock_timer_base(timer, &flags); + timer->function = NULL; raw_spin_unlock_irqrestore(&base->lock, flags); } return ret; } -EXPORT_SYMBOL(del_timer); +EXPORT_SYMBOL(__del_timer); static int __try_to_del_timer_sync(struct timer_list *timer, bool free) { 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 =============