From nobody Fri Dec 19 12:13:28 2025 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA4332F83BA for ; Fri, 10 Oct 2025 15:03:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108588; cv=none; b=B5WxOgkNO/kgsOkW3nompa+BEBIF45eOGn9B1p87lSinFDJpO9TqIw34I2k7FB7dleg4T4jj2lv02mXn4hLkWgSCKD2mxBBydgDqEDl/6Ed7GEmay82pZnpnwrlL88UxCnGbpGRldmer5U0Csjxdr0Hj/I7OqYB3nkxCL7QW/Ns= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108588; c=relaxed/simple; bh=BfuWtJpHFnoUxb8s7xJBVcBtioNVHYkElOeeOAD1d8Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=O5v1KA1SESUrkxB0CZUO24yXKrS4FmqZzkcnXvX41weHk4xfyXGOudALGpnd+F1m1Vrq8oVQRjdOsSegPxDZz0f8Bj/+qCc6KVznH3fQ4FkPTvas/ikmqtkFV3ToKoV0jWBlmgBjuPQyPKZHHU1lNq2WhmcrLdAwimHOAXpooSE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jOJWUjGY; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jOJWUjGY" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-781db5068b8so1854844b3a.0 for ; Fri, 10 Oct 2025 08:03:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760108585; x=1760713385; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rGAsWoT0ij2AF8u7lzQ99aTp0zEqYgQwfONKoWXhuNs=; b=jOJWUjGY7g5vkdEDoSO3DnDTAix7UyGmMzh8e0cJ/t4f9axbWimQr04i3E7aoAoQmh fBeQZnegMtpgC7q+xdRAJaoMK7Y+XxIdLkxoFzLIj4Yrg2t9xf7Saqkgje4gAEU4dHTi r+3wV4FnrKAck7RQp9w1zrtkzvuqAruNl+vs+04ACZFfqzG1uSDnHk6J31jmrhilqf5l Qoaxwi+BhNX8gyn/vYIu/V4gnyDcAF9Kn75IcrxT4d6BZbXzRAQG/+Y4tlkunxWIT4pr 9MPxCCqtkwJRW0k9KsfYrtMOOQsVUu5CeBRVJYaPn7OTte78Y1HFMMaMEYH+Di7Fgj/2 lF3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760108585; x=1760713385; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rGAsWoT0ij2AF8u7lzQ99aTp0zEqYgQwfONKoWXhuNs=; b=h9z7KrgTNbqUsH12oLWSSscxkJUb1RukwIp2maB7W9a2htwyyb8ciLMGOu/S0Blfos PKx/NJkv+R8soQD5PcbRMCtzzX4+rL0T5aCyiar/IYx2GkQxSf8Sc13NdWhH5BLipkeD A++EYwfpPW51WYBSRD6iuQT5NrEFvMI1LXaaieCNNLq8Jyl32paj0YjeR8Sq3143XHXX 7ci2ueO7Ll8pZj/pATHR39aYskTKmIlQuvo7b71amJJku9tjPkUewaOx/+zFFzR6ERJK TJ6fTQhqSDI0RqydqgcqcFvQ2s8JEeKbdFfzfKY2kFUTFZ39kfIMUNa++GbrwEKi9r/e 6NfQ== X-Forwarded-Encrypted: i=1; AJvYcCW+DT43xWQlAjfC6Gs6zKiIc007ZEmngeaSBUL1y9FiD2AznF7agjIZOeX4jT3q4acsDMRG0PAANnU6+7g=@vger.kernel.org X-Gm-Message-State: AOJu0Yzuq+QpG/nKTxU5ML4ty/dItj4mtHCz7+GRyej9Gte3qquux4Fk vJ9AveOdvZ8iAYeAWLj7zMpOTMaYvUUHF04SwxQLfwtqhG/GfT4DXzt8 X-Gm-Gg: ASbGncsqRmSPcoGoZObcOhXbmsTo+Nh/lLUELApUDjoYRtWsC57zMHnaoyRuw4C5dcW jrZp/ZQZLHD4Qm0HsSRFlCstk81xof0Ar6oKt1IZdOPreMQK153u7lnpQu8YEggvwH3YsdIqX8i OaprjP5spLHhrtH2TdIhI9zrvYoFzQ6wvsR6vkrDM3sVbVYxkqZYNgOJo2cF7RAKgXe/9oSw9dV QkRkzVTccEEgMrqerEieO44pv0IIkYK5OcuR0WEHxlrOkh+bzNrFOy6jWK4UbkBkp5Z7SjrixO6 chVHE7k1u4r7zpDhqHt+4B7tGvmclGtmoczYkvLhve1c6AyxhqiVWvrefQ3Z0B+hHkIP66VXjT2 t0fLi7Id3ZCZIDOrT/W4j1ffS9mOlT0iCVkk03mdd48jWo9VNdXsVhl4I98ynZVBYxP6v841+KX ZZV13Q4cM256Z13Q== X-Google-Smtp-Source: AGHT+IG6Mclomm9HYyi1FtTvYUfbr3VX3dwyeq2EoCOUrPpK9DPowb6JOh4ejWKRDTNNO57tGjljAA== X-Received: by 2002:a05:6a21:50f:b0:32d:a8fd:396c with SMTP id adf61e73a8af0-32da8fd3980mr15458796637.35.1760108584393; Fri, 10 Oct 2025 08:03:04 -0700 (PDT) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7992b639cbcsm3266359b3a.18.2025.10.10.08.03.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Oct 2025 08:03:04 -0700 (PDT) From: Jeongjun Park To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, tglx@linutronix.de, Julia.Lawall@inria.fr, akpm@linux-foundation.org, anna-maria@linutronix.de, arnd@arndb.de, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@roeck-us.net, luiz.dentz@gmail.com, marcel@holtmann.org, maz@kernel.org, peterz@infradead.org, rostedt@goodmis.org, sboyd@kernel.org, viresh.kumar@linaro.org, Jacob Keller , Jeongjun Park Subject: [PATCH 6.1.y 01/12] Documentation: Remove bogus claim about del_timer_sync() Date: Sat, 11 Oct 2025 00:02:41 +0900 Message-Id: <20251010150252.1115788-2-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251010150252.1115788-1-aha310510@gmail.com> References: <20251010150252.1115788-1-aha310510@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Thomas Gleixner [ Upstream commit b0b0aa5d858d4d2fe39a5e4486e0550e858108f6 ] del_timer_sync() does not return the number of times it tried to delete the timer which rearms itself. It's clearly documented: The function returns whether it has deactivated a pending timer or not. This part of the documentation is from 2003 where del_timer_sync() really returned the number of deletion attempts for unknown reasons. The code was rewritten in 2005, but the documentation was not updated. Signed-off-by: Thomas Gleixner Reviewed-by: Jacob Keller Reviewed-by: Anna-Maria Behnsen Link: https://lore.kernel.org/r/20221123201624.452282769@linutronix.de Signed-off-by: Jeongjun Park --- Documentation/kernel-hacking/locking.rst | 3 +-- Documentation/translations/it_IT/kernel-hacking/locking.rst | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Documentation/kernel-hacking/locking.rst b/Documentation/kerne= l-hacking/locking.rst index 6805ae6e86e6..b26e4a3a9b7e 100644 --- a/Documentation/kernel-hacking/locking.rst +++ b/Documentation/kernel-hacking/locking.rst @@ -1006,8 +1006,7 @@ Another common problem is deleting timers which resta= rt 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. It returns the number of times the timer had to be -deleted before we finally stopped it from adding itself back in. +handle this case. =20 Locking Speed =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff --git a/Documentation/translations/it_IT/kernel-hacking/locking.rst b/= Documentation/translations/it_IT/kernel-hacking/locking.rst index 51af37f2d621..eddfba806e13 100644 --- a/Documentation/translations/it_IT/kernel-hacking/locking.rst +++ b/Documentation/translations/it_IT/kernel-hacking/locking.rst @@ -1027,9 +1027,7 @@ Un altro problema =C3=A8 l'eliminazione dei temporizz= atori che si riavviano da soli (chiamando add_timer() alla fine della loro esecuzione). Dato che questo =C3=A8 un problema abbastanza comune con una propensione alle corse critiche, dovreste usare del_timer_sync() -(``include/linux/timer.h``) per gestire questo caso. Questa ritorna il -numero di volte che il temporizzatore =C3=A8 stato interrotto prima che -fosse in grado di fermarlo senza che si riavviasse. +(``include/linux/timer.h``) per gestire questo caso. =20 Velocit=C3=A0 della sincronizzazione =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D -- From nobody Fri Dec 19 12:13:28 2025 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44F442F60BC for ; Fri, 10 Oct 2025 15:03:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108591; cv=none; b=nngaPbaArDyiaA+D7tBKbb1UwPqoHZR4LLXbX47FxQaHY8DgnfX/MhgCzWhYiDaWtEful8WepP65DtCX3tU5XYWyXxtHob6qUkT5iVBGGhZ6sRAYsHhfQJYxZ8rXIRDnXH2Oxo+oigI7ojC8ApxeUSPIJeGLwbhVz3UM/ynHqq0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108591; c=relaxed/simple; bh=FgQfbLiyDT66S+sNI1wE/oslfO+pvzybNJFnYppNieM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rTbStsMOTv+BxEPL6ojd1bkUlRIGTtXFLErb5zIBK7By25nbCV3Vc7BUHUeGfyT6EbykV6X/WXLoEr2WSUDgfpJyhrmkaiQfxXQFzKCtbYpwD7YCgKk98SJxVEWxSD8Qez78SrVxQGF3VmopFZuoMwi7wkbyogWumdNNiKMHWMI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RpWrckV/; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RpWrckV/" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-791c287c10dso2066951b3a.1 for ; Fri, 10 Oct 2025 08:03:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760108589; x=1760713389; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=89KuTptWUmkm9h+FhspeGpsBdyDf36NNXIP8b7hhqek=; b=RpWrckV/JP7K3rBXqLxBCPZ3r+/KHE+Zva9B+hQ/IpZyvb9ML8WbUa8q/esCb2fb4y ymlmTU0QbOJlDRiqXD0JpKBUcDmkrAJ9upSO9ZF6NWWmhx3PrAPRz0Ah3/fsPaoVHi59 NK6Pizz6h/bi7LjWTOMf1lSdl/txsUs5vF0zKcEM0JFe2qYLg/eM5lPyM7TZFNMRHhe+ A+cwnS4gZ7o7opxLNINSNzjGJlHOxnFUG4cFW/LnEKqvGqV4dfjCSNYhg3zHCJv6ktl1 l1Dnju47/ug9Zv7TrKZ/cv9mld/mHDw562LCLoXgSN7COm4MzXa90Ye+NiSn/XGoHy/k ok/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760108589; x=1760713389; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=89KuTptWUmkm9h+FhspeGpsBdyDf36NNXIP8b7hhqek=; b=dbAHE8UAlxg8j9qQLqRrIvXPYmd2SoQWvLhQsWybpbGgfa3frAywl77rLMc7DVf4Lk f6qG3+z3In+agAE4EiQRb1i5A4giJB4u6hebDtlvM067az4RRCr6CyrnMotvl+yjjdTk f0bbp2uXl83Gumce23SXwQNTgl7CDCuEdmLYolTsHR/7/kh9RITkVXKmnHs82wUkHG/Z YvHIcFVtfHDv2vAfZp4Cix/xanGyfn+fZXDc45CweOejv1eGSOYAnSuxjaObg3ozLb4W l08wvaSgvbLOq5z1rwsT7wua6c+zrXLl3GG8Jdxuk38knlT7didnFiKN+C9DAill4XqW UPbg== X-Forwarded-Encrypted: i=1; AJvYcCVkJIJj7T/sBYlAr9wAsiBjbP+JoCSe+V/kXg6FIc8+gKMqgB9YCmS+UV+HdTgWv1eN2j2I8ug1KIoDr38=@vger.kernel.org X-Gm-Message-State: AOJu0YwHUgBfH6mgux6R+xPzn/7wswVIGlMSKzMxUGQzayMdAikJF0je 7wyQR7TXY8LEpfgeC7lwXQycwmbztdxqsjXCrOwDyglVqSycEqmBLNJt X-Gm-Gg: ASbGncuj8fzcc122Gh2RFpOmb6fBr0x5TuZMTblTdds/vIXxLXDPMnPAwnUHV9SQpKr nUJ/QTZtLWnwTdFCYdfzMHbqYySobLK0h5h8P+h0xFTbaM9d3f6CYRDCGgRQDIfeK9bG+s1F/F7 uFK1CZr9i6mZM+YSombu2zYrysLfxzWLyWVFYD7soYSq7+r2NC/MBjG6iuzonAt0/EqlMLIbBAp DRk4av51rNNY+BeYgJXL92SMKA8bd0UHmyBIWvLY1cfJFXDJz91IOH/1m6+T2EoJY0AUjvaax49 tApvxVBiehQDhx7tdOJzjiSbhu6NqUMVB/fnoEhVsRyFZInVqcFI3VxMv96xsB1wzm4hl3nrhxb 9PveeLY7d6j/ofp35YFYkQPG2eqIe2spAaIhZfE+MXjgaCL/o7e74S+fAW3ExmIz7TTvjnXL4Xe UCuPI= X-Google-Smtp-Source: AGHT+IGEQqV4pmO4XmsOQ15F9bsuz1pxj5V/e0Gc4K06vCx6p2KIreXiVTGYqdNwaxkJG480WOWOvA== X-Received: by 2002:a05:6a21:50f:b0:32d:a8fd:396c with SMTP id adf61e73a8af0-32da8fd3980mr15459388637.35.1760108589350; Fri, 10 Oct 2025 08:03:09 -0700 (PDT) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7992b639cbcsm3266359b3a.18.2025.10.10.08.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Oct 2025 08:03:09 -0700 (PDT) From: Jeongjun Park To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, tglx@linutronix.de, Julia.Lawall@inria.fr, akpm@linux-foundation.org, anna-maria@linutronix.de, arnd@arndb.de, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@roeck-us.net, luiz.dentz@gmail.com, marcel@holtmann.org, maz@kernel.org, peterz@infradead.org, rostedt@goodmis.org, sboyd@kernel.org, viresh.kumar@linaro.org, Jacob Keller , Jeongjun Park Subject: [PATCH 6.1.y 02/12] ARM: spear: Do not use timer namespace for timer_shutdown() function Date: Sat, 11 Oct 2025 00:02:42 +0900 Message-Id: <20251010150252.1115788-3-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251010150252.1115788-1-aha310510@gmail.com> References: <20251010150252.1115788-1-aha310510@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" [ Upstream commit 80b55772d41d8afec68dbc4ff0368a9fe5d1f390 ] 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 spear_timer_shutdown() to avoid this conflict. Signed-off-by: Steven Rostedt (Google) Signed-off-by: Thomas Gleixner Tested-by: Guenter Roeck Reviewed-by: Guenter Roeck Reviewed-by: Jacob Keller Reviewed-by: Anna-Maria Behnsen Acked-by: Arnd Bergmann Acked-by: Viresh Kumar Link: https://lkml.kernel.org/r/20221106212701.822440504@goodmis.org Link: https://lore.kernel.org/all/20221105060155.228348078@goodmis.org/ Link: https://lore.kernel.org/r/20221110064146.810953418@goodmis.org Link: https://lore.kernel.org/r/20221123201624.513863211@linutronix.de Signed-off-by: Jeongjun Park --- arch/arm/mach-spear/time.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-spear/time.c b/arch/arm/mach-spear/time.c index e979e2197f8e..5371c824786d 100644 --- a/arch/arm/mach-spear/time.c +++ b/arch/arm/mach-spear/time.c @@ -90,7 +90,7 @@ static void __init spear_clocksource_init(void) 200, 16, clocksource_mmio_readw_up); } =20 -static inline void timer_shutdown(struct clock_event_device *evt) +static inline void spear_timer_shutdown(struct clock_event_device *evt) { u16 val =3D readw(gpt_base + CR(CLKEVT)); =20 @@ -101,7 +101,7 @@ static inline void timer_shutdown(struct clock_event_de= vice *evt) =20 static int spear_shutdown(struct clock_event_device *evt) { - timer_shutdown(evt); + spear_timer_shutdown(evt); =20 return 0; } @@ -111,7 +111,7 @@ static int spear_set_oneshot(struct clock_event_device = *evt) u16 val; =20 /* stop the timer */ - timer_shutdown(evt); + spear_timer_shutdown(evt); =20 val =3D readw(gpt_base + CR(CLKEVT)); val |=3D CTRL_ONE_SHOT; @@ -126,7 +126,7 @@ static int spear_set_periodic(struct clock_event_device= *evt) u16 val; =20 /* stop the timer */ - timer_shutdown(evt); + spear_timer_shutdown(evt); =20 period =3D clk_get_rate(gpt_clk) / HZ; period >>=3D CTRL_PRESCALER16; -- From nobody Fri Dec 19 12:13:28 2025 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C53B2F9C3E for ; Fri, 10 Oct 2025 15:03:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108596; cv=none; b=GIeetZ1e0LtVB0VBtN3q+ST7IWCNCGNLl8TPCsO8w4L2Z6Fnfm4uljdmu85m36070Qy76LCV7dNeM/Zr/pOVFsB1wrO4kjfqlkUm+IJKYq52uV+/y+gymF44Br5us6QqeMPoiil7LjqE1H4xXuSAUWKbt/Fk+fItwMa8eNP7YUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108596; c=relaxed/simple; bh=YY7i+ekw8WEClpFqVZfbZbIPcOFXG9mqoVtYSHhdgrE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QgsUE1F4lJy6xtmpIOzbK8EfO3uXp1z6LcmZ9tXmEM7m5ruqFJHBR9v8Wt1kJa1qgmCaGlOwry9WXC2EEAm+TuyhA9p71b/HrJ7QycLbBXHpGLYoyGwtDE6aTH1omRX3EIvn+4o4oHYt9xkopmKgOUoi/bbmAbSTMzUu0o301G0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=H2lX6zS2; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="H2lX6zS2" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-789fb76b466so2060696b3a.0 for ; Fri, 10 Oct 2025 08:03:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760108594; x=1760713394; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Lru4V+cwKFfxLK/nzfZUd/f7wkQ+5dEE9KWoaatQVPo=; b=H2lX6zS254lP6QiTChrWguTZXkBxQe3sQ/Ux3HyneGGx2Z6nWRZS1T/0E7DfiUnOSh tB0JmpvO3/PMfdw7pEsfz5lhF+YvwHZMmxPFpD6oT44nXUdZBWb7TvX0yLS8Iy3l31ql bN0G6x9iB7Z2iWPJ23atcp9ZHC+0MCdOP7roi5FZhUkZ8Xu6vaRzuzj0yDcTy6O0wtv2 k7TczfjpIcun4laPXNizNW9ymMvS7F6AFXEyMn5HukbZUkIa44gcSaj0BXawFoHVU9dE keKKwNunzugLtmAvRmIN/hNQD7o4n1b2pyzmtgK/sx+iWwTlJb2DDtH3nnfWpcqhbc4k 3fOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760108594; x=1760713394; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Lru4V+cwKFfxLK/nzfZUd/f7wkQ+5dEE9KWoaatQVPo=; b=vNCMRgphQfyMOlKiJwqN6lFyDn5L70y8AAcqSotytosJvTbxrBDjF8necg7zz8YOK9 off2mrRP7yyGZR31b4ykoemnLGn2xoPt7cy5Jr90mtqPKTZP5cJRnPK8mUFSt2sjfJV6 8v94OJYFqDgM+3daGKNU6KKvTdo/XTQqC5nWJYye8czn0AHfUsUxp1RaRcmzO9Dvhp/y 2m8juSyKtMj7GuYctD2pg5OkdBeMyMDkC+TrcEcPLJw6wJZbJZAZ9U08kTJfBrmLBNtW dnfYXjweFCz7q8xvqjS1TuMr3VETpCbY9qYBZjNmCbucQeLANDOC7fM6Y/kfzSuj1EJM Nxtw== X-Forwarded-Encrypted: i=1; AJvYcCUbl2XjVLlH6P3dTpYmYoc0bLwDNqeAXH4BoVLb9vn3E41FzyJcxroZXj+QGCkhiP7/GuNHjYm2QyfogOQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yz+XAGdRa4SJ5WrRrkCCu1uS19nxMqaDUYbSbeB0FlOb7vTkZ/X WoqdrSE4RAwTDx7Bcv6b4nlHEh1lgnh7gy7W7f2V2Xc+ot3ImxhqYzId X-Gm-Gg: ASbGnctHZpmSr5qRjfuiBfWpAs3ELQSmcLoNfKjP4A6fGwUop5tKDZjB0HhuMu37v7a HSKT6wHmYWhJ2z705KRCp8BpF0YpN2cEOWGhg6hc8n9QsTADmJ+45mWzcqLz5TDuIARgGtPEgiO LQemBaF5UYMHrYJGfIGBevD1jAyL8WCGflHnjF3QjNoZFbvhfVmRfwz3cM82W8qaIpV/V1Z+NDJ SqImHSUjtzj0bHRr7A0BXYNY4Pv+qqadVmWJW2/HNVyKEvRVSHJDSiRZdSQHr8T0jumnoXT5lrP gQ0Dny2dGSV5NUTbblxCNQZNTHyxo8gOumsGpM5phmKhnEgHUdzRVg/jXE20glpx/52KDoBIi+0 9HqKiQXt1WeEgObkwiE8sld3a08IQnwsJ2Z+cgzjRggegxBdV8zfGPZy9LEW7PCyzmx5u X-Google-Smtp-Source: AGHT+IHDmtdSQ4BVOHtxe7GHClewheJPvHGauzysjfnwSn3tHptitjBMctHoN7F9QTbHybnsnanBLA== X-Received: by 2002:a05:6a00:391a:b0:77e:8130:fda with SMTP id d2e1a72fcca58-79385ddc9f9mr15581102b3a.13.1760108594064; Fri, 10 Oct 2025 08:03:14 -0700 (PDT) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7992b639cbcsm3266359b3a.18.2025.10.10.08.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Oct 2025 08:03:13 -0700 (PDT) From: Jeongjun Park To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, tglx@linutronix.de, Julia.Lawall@inria.fr, akpm@linux-foundation.org, anna-maria@linutronix.de, arnd@arndb.de, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@roeck-us.net, luiz.dentz@gmail.com, marcel@holtmann.org, maz@kernel.org, peterz@infradead.org, rostedt@goodmis.org, sboyd@kernel.org, viresh.kumar@linaro.org, Jacob Keller , Jeongjun Park Subject: [PATCH 6.1.y 03/12] clocksource/drivers/arm_arch_timer: Do not use timer namespace for timer_shutdown() function Date: Sat, 11 Oct 2025 00:02:43 +0900 Message-Id: <20251010150252.1115788-4-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251010150252.1115788-1-aha310510@gmail.com> References: <20251010150252.1115788-1-aha310510@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" [ Upstream commit 73737a5833ace25a8408b0d3b783637cb6bf29d1 ] 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. Signed-off-by: Steven Rostedt (Google) Signed-off-by: Thomas Gleixner Tested-by: Guenter Roeck Reviewed-by: Guenter Roeck Reviewed-by: Jacob Keller Reviewed-by: Anna-Maria Behnsen Acked-by: Marc Zyngier Link: https://lkml.kernel.org/r/20221106212702.002251651@goodmis.org Link: https://lore.kernel.org/all/20221105060155.409832154@goodmis.org/ Link: https://lore.kernel.org/r/20221110064146.981725531@goodmis.org Link: https://lore.kernel.org/r/20221123201624.574672568@linutronix.de Signed-off-by: Jeongjun Park --- 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 fee1c4bf1021..ddcbf2b19651 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); } =20 -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; =20 @@ -701,22 +701,22 @@ static __always_inline int timer_shutdown(const int a= ccess, =20 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); } =20 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); } =20 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); } =20 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); } =20 static __always_inline void set_next_event(const int access, unsigned long= evt, -- From nobody Fri Dec 19 12:13:28 2025 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D318E2F9DA5 for ; Fri, 10 Oct 2025 15:03:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108601; cv=none; b=jZnriiQaqEo8CYdD2BsRAO1RN2ZBMuuErXYIp92oBTzujC/o2XLF5kG+SCXn4u8oje6BwTmyP2JX5e8LmOl1jCM6jeQVQEN3QifnDkNn0WUHFcUkDB/+b02X1a42rvDI2CDF+YFPEtj5DtHXjdXjvdCe4og5QBaqDaosfWSMwfs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108601; c=relaxed/simple; bh=kyxULOv2H236l1ucHIwcTRr5nnWT32c4Zye+wWGrJ6s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qmE8SHFQT+AgMdxliljenDC/jVSOoP3W0SLCH08vU74HmLqfRDkceYnqaiUwb4Wbtbwf5AsusV1+zoXs3bMWNirqbrxQpS2nLY+b6vj5qAdCQKQ1SRPiTI5D4Y60/iqA5NA6kH7fhRud/9jGlBT5PLVazv46AyP+IlGeHwNBsWo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Su+5/5Ih; arc=none smtp.client-ip=209.85.210.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Su+5/5Ih" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-78af743c232so2072289b3a.1 for ; Fri, 10 Oct 2025 08:03:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760108599; x=1760713399; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=scjH6AQBXgOEyOguxVYTHq5LOFFjJgFpmI1fsS6Z7tY=; b=Su+5/5IhGDJljNWqvdLuLQXyqkbWvf2cbmnmjD7zjzywNoFV80FhOQIm/b1p1OfZBO vk35gqHf8PUvH/ZZZHgIP2CqeRLDHJsFqgGadCIn/QPG9BdjsEyUeONZUs5FXCQVI7RC RG25CKozBZaN7DTNR3oeC9qh2I1a9rbdjMu7EXSaSX7/uUvdAaEcqJBsqS3cTqqrUOu1 6U02NccwfSNp51o9E7nod/5yynsZc2sWPPERn1Vdb5j+zTCejT4bOhSggOC7uprHxnxZ v7ZZwhwP9IXbF2Ijr+rUpD+wAcq1rD+2wN9oHLUK/ZsYoo6T9wHP1XBuaxfpPIS5m9Rc 20Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760108599; x=1760713399; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=scjH6AQBXgOEyOguxVYTHq5LOFFjJgFpmI1fsS6Z7tY=; b=W9xprgZ8SPLaQHG9gbhlnwdTYrIhMTrJZv8qxjz4NgQYOK83exKgX7tMKGiM3uYlX9 uDF3oCI89SWHkQwdgWyCxAobW1+TszgFooatEveoeM3DFMbf93+zF4QnCmWsbKLsXsKK bMf8balwZXoNKYBW+xpXxCod+4ZOV6LDYw44rpqI/sXCO8WqMPNhXyyxoXOlJJb78hlt 4kO3kLFeIcT5FZcuEl1fHYuwBNOhAeF5Gw8ev2PwqleZ9rITRGwunZdu5ABT+HH4Ri/9 vQ8cGoRrF4NYxgnzj8CZ0NkMVXNWwSTFSzY8Q9EjSin1nAf6+KeViyvgJxPKNhu7GXSm CGlw== X-Forwarded-Encrypted: i=1; AJvYcCWC4wnNNn9ndc0JvF9IBXEwOlWh8MdEaEOtg2jLOfTfAz9RevEGuohXuaRu0W+tj/4+0kJBpQ8GHFmSft4=@vger.kernel.org X-Gm-Message-State: AOJu0YyxfRimbDUHJTWeuNwxGiN6YG1GCp2Y5dPdsCDB3TD4gv7TN66l 7X5Y/cw/zwlux9C2kJWdZSmKWO9w3Ev2vDatGXLQbT5hx6+Q9NHD5dbn X-Gm-Gg: ASbGncvvphU7nN3GBc0Etmy25D2iVTnmpDbIGV9wHrcMGMqT7h4T/vGHKrAi+R8t86O NjHr6cmy5wQpYsqVbDOiij1HhtLL6g0htLDPb/7VNAY63vQltSzG2fSvECvbzvJyOfctJwBgrgV zFaIgd3/EGCSYyKGNnTgzIOhjmnYUyoMci1x2tRP57flvxWT4QbnCBwfos+yRoaCkj/WTPuD/Me +pARnNpg/JT8JkaObHTUihWMRJi1ZFR5UvATZb5zM5lOsJMtxZfYfVEbqiaZ1kqjhUD9nMvDcVh jsvQgJLWThS2/FXMcD0tima+hAnaU4M0V56PNZUZUQi8RbHSTRRscvXUv14PekwRKCatkG1DShH AgVvv0QSMmbrcXuVGuDJrWmNBMHgZOmmfHABFUkujv6rRGBIFx1wIOjF33TYH5NXerAuj X-Google-Smtp-Source: AGHT+IE1TkwVHA7tUUhpnxMC0Ew+qral7pJWbGGXX+m1f8imGiLvrl15HPVZo6jvgfFxLbQ7GCafnA== X-Received: by 2002:a05:6a20:7d8a:b0:2fb:62bb:dec with SMTP id adf61e73a8af0-32da83db679mr15075982637.39.1760108598855; Fri, 10 Oct 2025 08:03:18 -0700 (PDT) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7992b639cbcsm3266359b3a.18.2025.10.10.08.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Oct 2025 08:03:18 -0700 (PDT) From: Jeongjun Park To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, tglx@linutronix.de, Julia.Lawall@inria.fr, akpm@linux-foundation.org, anna-maria@linutronix.de, arnd@arndb.de, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@roeck-us.net, luiz.dentz@gmail.com, marcel@holtmann.org, maz@kernel.org, peterz@infradead.org, rostedt@goodmis.org, sboyd@kernel.org, viresh.kumar@linaro.org, Jacob Keller , Jeongjun Park Subject: [PATCH 6.1.y 04/12] clocksource/drivers/sp804: Do not use timer namespace for timer_shutdown() function Date: Sat, 11 Oct 2025 00:02:44 +0900 Message-Id: <20251010150252.1115788-5-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251010150252.1115788-1-aha310510@gmail.com> References: <20251010150252.1115788-1-aha310510@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Steven Rostedt (Google)" [ Upstream commit 6e1fc2591f116dfb20b65cf27356475461d61bd8 ] 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. Signed-off-by: Steven Rostedt (Google) Signed-off-by: Thomas Gleixner Tested-by: Guenter Roeck Reviewed-by: Guenter Roeck Reviewed-by: Jacob Keller Reviewed-by: Anna-Maria Behnsen Link: https://lkml.kernel.org/r/20221106212702.182883323@goodmis.org Link: https://lore.kernel.org/all/20221105060155.592778858@goodmis.org/ Link: https://lore.kernel.org/r/20221110064147.158230501@goodmis.org Link: https://lore.kernel.org/r/20221123201624.634354813@linutronix.de Signed-off-by: Jeongjun Park --- 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, voi= d *dev_id) return IRQ_HANDLED; } =20 -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); } =20 static int sp804_shutdown(struct clock_event_device *evt) { - timer_shutdown(evt); + evt_timer_shutdown(evt); return 0; } =20 @@ -171,7 +171,7 @@ static int sp804_set_periodic(struct clock_event_device= *evt) unsigned long ctrl =3D TIMER_CTRL_32BIT | TIMER_CTRL_IE | TIMER_CTRL_PERIODIC | TIMER_CTRL_ENABLE; =20 - timer_shutdown(evt); + evt_timer_shutdown(evt); writel(common_clkevt->reload, common_clkevt->load); writel(ctrl, common_clkevt->ctrl); return 0; -- From nobody Fri Dec 19 12:13:28 2025 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D27F2FA0D3 for ; Fri, 10 Oct 2025 15:03:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108606; cv=none; b=CHJpf/Hw5F/pShwWaYYtYQyCfykBN/Pex+s0t+RAU8HMKfoIeGy6OTc9yZt2mPk9+FsMI+sTfFJFTthDAKtdlEu+PGnG7JDKLY0/yKhlN03KDJBjhL5ui6/Z7BJTiLkF7RFIro6C3ZvndS7iIijojcmxohpxL1WIUGxgZCXIWVA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108606; c=relaxed/simple; bh=p4TRIPhh7eCXg4oL8eEB5Ly0L/lmhP7XDzG06yVs7As=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=imozT/xrbpM6PO6VlkEXCjLRoIGyse/XsQSwr8qqshL87y7OeuJ0+tiTBoIvJSgy7f4n5e6QbN7Ii0SNsfGFPGI+OeQIRaPWRdR3OmCDWjRwslu8l4GnCZeDXva6ZXZbERQeomtIJ/blCHDgNiDbjtK1IbG/NKsFOV+MssyI3cA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lrfMpSKU; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lrfMpSKU" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-78af9ebe337so1707606b3a.1 for ; Fri, 10 Oct 2025 08:03:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760108604; x=1760713404; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pWjvp+vOFGL8T/NXTev+NZf62jPu9HyIJqL4GkC+d9Y=; b=lrfMpSKUbUjEpAhkOdhyxOzbwWCStTQD5zINmPlgCaAjvcDQNF8b6fqSOzagx+8xrL yn4rCuIJnksruMQkHfOJxaxTNFJKkRL3QfYMVFNwLW11Fuf6ToX6EHivKBDbyqN0HWNv wndMKDHC/YrMBQK5ZGhAuP7r7mba9cc1xDXYr7VWrTnTTCiSnEx0UFoSGO6pMnore1sg SaaORTKpLNnHa2JXAe0hTiXD/uiPd39mkzaKA5j7jWTNvvolT5t3CFIxDsKhqeOEY8h/ fWdSEGTjIRIOVr+LC0My0gzVc4cTYtncixbekm3uiazrk/cipyZSFCqcFOeNxwGDF5nF H4fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760108604; x=1760713404; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pWjvp+vOFGL8T/NXTev+NZf62jPu9HyIJqL4GkC+d9Y=; b=hHaxi9rJqSp5Oud9dZiFw8hLSaErGDC1UiGIZVY6rlNqJ7L8BCbhtU+zSLLZ2cv8SW YKFqGfw08xg4LI/icNTfaQXWRpiC16qv/wML+2L4KiwtBM0ECYwU5OfDw0Ak0qyb6I51 iioTpEXD1h6sc34rilBHn4yNokQtT698/StKZz598IzkLiDOi412R5bJ4lnHalkRcFrU Ll1bS8bxgLy7KB8ofHyfeiI4Fd1DAw3jIYhNXn8hzMySfTXhHJCh2BSwvRAihNNETtRh hgmPeWDpzkL0nHV37JKYmR4iR7K6XJVaMHa9BC3t/IpdbXa/LxNWDf3BtodwOy+8qQNI WK8A== X-Forwarded-Encrypted: i=1; AJvYcCWkqtweJbVqnXhrAf0T7n5f+Yx+U+PPprXr01oFkXhuiZ3lYrsow7qphTXQyKTuFTV9POQdiwjbFEG3HSQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxVkTkz4C+RSnHhUkqQ98WZzb4rpnCQBFFBYqQZ9VSqwKUG5xMs AN+lQwRX6K1Duj4xUDfX52ye6rX0Nm95E6DBMvLutHOlq2yvtwQLBe0Q X-Gm-Gg: ASbGncuuxwF9yUmAMm6vZ/e1oTeADV5MDjTp8Ezo95fRQCHocDC/on/mY1zh0zJSadQ LXYO+EiG04H7Z5PEwdDpdbBKILkV98cEvfqPEoVfaqRZzSCYhhSk0SJYmbY9zdib5TKPU93FOXI zOMblAlGGbIXrk6mMuURoMkH0UWartEorgWCvQEYw6Fo2Q8Ea1DJhulN+xDsittkcj6nuQA9qwi XSyYGbVz0+ftVy5yOVzpDz6SCmuBdlXPQXb7Ofhm0VLUT3buNzgAXWa/u3w41+b3NqYR8aPp0qS CMoHnQrbyYHGKYYIEmWQAEnTXYLyWBOCasYKaGZcen0MTMJnjraFugie4djMHQnrWinIjdJaYuM +M7rq16NI75705TXAHMgK1wwGWaZyhIi0zadc21DVtoO52aj0R5ymOhHxexnPl1cfc3D/02khZ+ YyOAc= X-Google-Smtp-Source: AGHT+IELW+N04rDkMObEwVIfZgJNbEyKA3LpK3B2L+BmTESRw/chxA53UDFR+d8y2R41yQMRdNNmzQ== X-Received: by 2002:a05:6a00:992:b0:78c:99a8:b748 with SMTP id d2e1a72fcca58-79382a7d3femr15159457b3a.0.1760108603729; Fri, 10 Oct 2025 08:03:23 -0700 (PDT) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7992b639cbcsm3266359b3a.18.2025.10.10.08.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Oct 2025 08:03:23 -0700 (PDT) From: Jeongjun Park To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, tglx@linutronix.de, Julia.Lawall@inria.fr, akpm@linux-foundation.org, anna-maria@linutronix.de, arnd@arndb.de, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@roeck-us.net, luiz.dentz@gmail.com, marcel@holtmann.org, maz@kernel.org, peterz@infradead.org, rostedt@goodmis.org, sboyd@kernel.org, viresh.kumar@linaro.org, Jacob Keller , Jeongjun Park Subject: [PATCH 6.1.y 05/12] timers: Replace BUG_ON()s Date: Sat, 11 Oct 2025 00:02:45 +0900 Message-Id: <20251010150252.1115788-6-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251010150252.1115788-1-aha310510@gmail.com> References: <20251010150252.1115788-1-aha310510@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Thomas Gleixner [ Upstream commit 82ed6f7ef58f9634fe4462dd721902c580f01569 ] The timer code still has a few BUG_ON()s left which are crashing the kernel in situations where it still can recover or simply refuse to take an action. Remove the one in the hotplug callback which checks for the CPU being offline. If that happens then the whole hotplug machinery will explode in colourful ways. Replace the rest with WARN_ON_ONCE() and conditional returns where appropriate. Signed-off-by: Thomas Gleixner Tested-by: Guenter Roeck Reviewed-by: Jacob Keller Reviewed-by: Anna-Maria Behnsen Link: https://lore.kernel.org/r/20221123201624.769128888@linutronix.de Signed-off-by: Jeongjun Park --- kernel/time/timer.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index e09852be4e63..7094b916c854 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1208,7 +1208,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); @@ -1227,7 +1228,8 @@ void add_timer_on(struct timer_list *timer, int cpu) struct timer_base *new_base, *base; unsigned long flags; =20 - BUG_ON(timer_pending(timer) || !timer->function); + if (WARN_ON_ONCE(timer_pending(timer) || !timer->function)) + return; =20 new_base =3D get_timer_cpu_base(timer->flags, cpu); =20 @@ -2047,8 +2049,6 @@ int timers_dead_cpu(unsigned int cpu) struct timer_base *new_base; int b, i; =20 - BUG_ON(cpu_online(cpu)); - for (b =3D 0; b < NR_BASES; b++) { old_base =3D per_cpu_ptr(&timer_bases[b], cpu); new_base =3D get_cpu_ptr(&timer_bases[b]); @@ -2065,7 +2065,8 @@ int timers_dead_cpu(unsigned int cpu) */ forward_timer_base(new_base); =20 - BUG_ON(old_base->running_timer); + WARN_ON_ONCE(old_base->running_timer); + old_base->running_timer =3D NULL; =20 for (i =3D 0; i < WHEEL_SIZE; i++) migrate_timer_list(new_base, old_base->vectors + i); -- From nobody Fri Dec 19 12:13:28 2025 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D20BD2F90D3 for ; Fri, 10 Oct 2025 15:03:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108611; cv=none; b=dwNjBsE9PJz0ir6mB41J/kLWCVC5kRVRgSxcSf2V0UMcM+yGo9OJd7a/6mDZ4S1Tdta9rbj0F4EUpvok3irubbaXk5wwnMqIUwftzGZJv7UjdS3h6y2DiFbxo4xNySrC/6Vn+GE/oGh9F7GVxfAO2L1z130FrKMNdajnXaAmiTo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108611; c=relaxed/simple; bh=upWSCwkwQ09Z4avIiv+Y6wEsIG3+TFZ3n19V8cmDwBA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Yclwu6k3FVNn1IYgRoxP/jmsdfCQkZ6a4oxJS01VHHBeRK8SZp34UZiFwuvU/E0vzIdY7b/O+/KglW6Hl9N4ZRMA0uOvoSa2o57qoDMQqgIqyhCHjkFUiPvxamScaYj+kcBkjXWLQG3GXOg9k5dlgup67OytzuyO1hJLY6YevoU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=j3ebBdV0; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="j3ebBdV0" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-78f3bfe3f69so2090920b3a.2 for ; Fri, 10 Oct 2025 08:03:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760108609; x=1760713409; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NwuFHJSwTOh44O6o4YH5Gva/YZZ2KpNq4JaQIOiJzpU=; b=j3ebBdV0f27NllV4M84Aq5WqvJyjERzw16JkhpGOL3fG3nabFHCrKsrnzZxeNe13gg DLCiJ28c5VWw/7XfTLM74iQ1Jj13Uj5RS/2ZQoaP6hIcu/Wpfn5YB206GlQWlz6R2pfK Hvm8W1ghvLER5NYgbb5M4YvsP8aPISqhxnXOBcO9Hljo2qVpODyCGcjvQecSuFgsvmUQ 7IR839Cfs5pW4SZe+TmYG+IyN7BhJZFFOJw6TvVuDu3r6GZgf8sR1GvbSz61QYUXWody oHY8izBg+tUysRGLohk9B4WMiF7jb8EUSIsRHufAviBFUzC6IHyf5ElKlUGlU3yixcjy MDbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760108609; x=1760713409; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NwuFHJSwTOh44O6o4YH5Gva/YZZ2KpNq4JaQIOiJzpU=; b=RSi6qaedCjoKMtXzoA7gWlYvutQ9uwlUdqzs+hXwdG9bUvQ7tS+zF1KResmdbM2eH8 FCQVC6+dmWGSQU2RmGjJQ7KESOzOtFJKQ2cKHrczgPDXu1BzAF4pZ+QHEGIkDXLobB6F M2B5hBVOXl+lRTIgMUOpHDH5MhMBQ6VL9RSFMWdGammPMBajOueME9sGldC50syZ8Hiu 1WghI1PG7B8w2vriMOAKgutKwDl1KKQbaEbCbAs6YWcsPrQ+4o+lXdIui6c0Q1U9k/df m/fcJJr5AYEZAXltOwPaJa4PQNceqi/FxrWPHm8flUmtbZsREhx1nu0JAK0AvbpBmkk2 IW8A== X-Forwarded-Encrypted: i=1; AJvYcCVeooudAywcLgbMnc7FeziFQXfASBuCDEqWW1Y54635LkGFmMIFmibthtIvFLlZKaYKwC2BEmfKdIecEJ8=@vger.kernel.org X-Gm-Message-State: AOJu0Yxd9/brr5J8A605v4ClWFKJL+6qLza3pCKZ/9AU4T6F8pCzJocR aL/40Mix+LA5IgCpqHTYkZ9zFn7LqOZM5E45nFhIQVT1Q75qd70pr4Pe X-Gm-Gg: ASbGncuTLgchnW6qaqoqy7tgMY/loeW4zItbK7qXT4uRCfYr0VbALNWBnu5p+u86Pvi 7XyQsPqd3knDj8eOl9QReaMUM1jU0nZqHObfVveFNR08cbzcV3aXrsBo7p+Kt9DBq54lB5luTRk 3cnOQBjpPkIzJKCE4Q/UEhsSEHgnOTYCsBglGB52sI/T/AXD43PWKEWdNmi9ti0YqOCl+r70pzO aTtEn2Cyo3a0QbZQewTF9bH/EGkN8S7Evzi2X82KCh0VBD4N54pC+07+Rje8309jOA5ialZByyd LhpTKBbf4wXDXjCqMAjzzY7vek1a4wRLfo8axshqwYdYWx6m19atTapEh38hNw7XUU3ExmKf5m1 PMwbeJuagVkM5Is/OTy9UJrZLj4DBYib6B/MeXByAoApTxBkGfhwaw4z2sr7fzXJGrdxpcq/Glt 91BEU= X-Google-Smtp-Source: AGHT+IGrDwmfrnVEm5D4rgTHSnbaTxomjsjy9CWkSu2xSVcHS1XWQn3WGuYclGMtqODR1Njkj+ffLA== X-Received: by 2002:a05:6a00:3e08:b0:781:1f28:eadd with SMTP id d2e1a72fcca58-7938763716amr12015599b3a.20.1760108608457; Fri, 10 Oct 2025 08:03:28 -0700 (PDT) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7992b639cbcsm3266359b3a.18.2025.10.10.08.03.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Oct 2025 08:03:28 -0700 (PDT) From: Jeongjun Park To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, tglx@linutronix.de, Julia.Lawall@inria.fr, akpm@linux-foundation.org, anna-maria@linutronix.de, arnd@arndb.de, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@roeck-us.net, luiz.dentz@gmail.com, marcel@holtmann.org, maz@kernel.org, peterz@infradead.org, rostedt@goodmis.org, sboyd@kernel.org, viresh.kumar@linaro.org, Jacob Keller , Jeongjun Park Subject: [PATCH 6.1.y 06/12] Documentation: Replace del_timer/del_timer_sync() Date: Sat, 11 Oct 2025 00:02:46 +0900 Message-Id: <20251010150252.1115788-7-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251010150252.1115788-1-aha310510@gmail.com> References: <20251010150252.1115788-1-aha310510@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Thomas Gleixner [ Upstream commit 87bdd932e85881895d4720255b40ac28749c4e32 ] Adjust to the new preferred function names. Suggested-by: Steven Rostedt Signed-off-by: Thomas Gleixner Reviewed-by: Jacob Keller Reviewed-by: Anna-Maria Behnsen Link: https://lore.kernel.org/r/20221123201625.075320635@linutronix.de Signed-off-by: Jeongjun Park --- .../RCU/Design/Requirements/Requirements.rst | 2 +- Documentation/core-api/local_ops.rst | 2 +- Documentation/kernel-hacking/locking.rst | 11 +++++------ Documentation/timers/hrtimers.rst | 2 +- .../translations/it_IT/kernel-hacking/locking.rst | 10 +++++----- .../translations/zh_CN/core-api/local_ops.rst | 2 +- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Documentation/RCU/Design/Requirements/Requirements.rst b/Docum= entation/RCU/Design/Requirements/Requirements.rst index a0f8164c8513..546f23abeca3 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_delete_sync() or similar. =20 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..a84f8b0c7ab2 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 cp= u counter using =20 static void __exit test_exit(void) { - del_timer_sync(&test_timer); + timer_delete_sync(&test_timer); } =20 module_init(test_init); diff --git a/Documentation/kernel-hacking/locking.rst b/Documentation/kerne= l-hacking/locking.rst index b26e4a3a9b7e..c447d55fa080 100644 --- a/Documentation/kernel-hacking/locking.rst +++ b/Documentation/kernel-hacking/locking.rst @@ -967,7 +967,7 @@ you might do the following:: =20 while (list) { struct foo *next =3D list->next; - del_timer(&list->timer); + timer_delete(&list->timer); kfree(list); list =3D next; } @@ -981,7 +981,7 @@ the lock after we spin_unlock_bh(), and then try to free the element (which has already been freed!). =20 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:: =20 @@ -990,7 +990,7 @@ do:: =20 while (list) { struct foo *next =3D 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 @@ do:: 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 =20 Locking Speed =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D @@ -1334,7 +1333,7 @@ lock. =20 - kfree() =20 -- add_timer() and del_timer() +- add_timer() and timer_delete() =20 Mutex API reference =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff --git a/Documentation/timers/hrtimers.rst b/Documentation/timers/hrtim= ers.rst index c1c20a693e8f..7ac448908d1f 100644 --- a/Documentation/timers/hrtimers.rst +++ b/Documentation/timers/hrtimers.rst @@ -118,7 +118,7 @@ existing timer wheel code, as it is mature and well sui= ted. Sharing code 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 dire= ct 1:1 mapping between them on the algorithmic level, and thus no real potential for code sharing either. =20 diff --git a/Documentation/translations/it_IT/kernel-hacking/locking.rst b/= Documentation/translations/it_IT/kernel-hacking/locking.rst index eddfba806e13..b8ecf41273c5 100644 --- a/Documentation/translations/it_IT/kernel-hacking/locking.rst +++ b/Documentation/translations/it_IT/kernel-hacking/locking.rst @@ -990,7 +990,7 @@ potreste fare come segue:: =20 while (list) { struct foo *next =3D list->next; - del_timer(&list->timer); + timer_delete(&list->timer); kfree(list); list =3D next; } @@ -1003,7 +1003,7 @@ e prender=C3=A0 il *lock* solo dopo spin_unlock_bh(),= e cercher=C3=A0 di eliminare il suo oggetto (che per=C3=B2 =C3=A8 gi=C3=A0 stato eliminato= ). =20 Questo pu=C3=B2 essere evitato controllando il valore di ritorno di -del_timer(): se ritorna 1, il temporizzatore =C3=A8 stato gi=C3=A0 +timer_delete(): se ritorna 1, il temporizzatore =C3=A8 stato gi=C3=A0 rimosso. Se 0, significa (in questo caso) che il temporizzatore =C3=A8 in esecuzione, quindi possiamo fare come segue:: =20 @@ -1012,7 +1012,7 @@ esecuzione, quindi possiamo fare come segue:: =20 while (list) { struct foo *next =3D 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 @@ esecuzione, quindi possiamo fare come segue:: Un altro problema =C3=A8 l'eliminazione dei temporizzatori che si riavviano da soli (chiamando add_timer() alla fine della loro esecuzione). Dato che questo =C3=A8 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. =20 Velocit=C3=A0 della sincronizzazione @@ -1372,7 +1372,7 @@ contesto, o trattenendo un qualsiasi *lock*. =20 - kfree() =20 -- add_timer() e del_timer() +- add_timer() e timer_delete() =20 Riferimento per l'API dei Mutex =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D diff --git a/Documentation/translations/zh_CN/core-api/local_ops.rst b/Docu= mentation/translations/zh_CN/core-api/local_ops.rst index 41e4525038e8..22493b9b829c 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=E4=B9=8B=E9=97=B4=E6=B2=A1=E6=9C=89=E4=B8=8D=E5=90= =8C=E7=9A=84=E8=A1=8C=E4=B8=BA=EF=BC=8C=E5=9C=A8=E4=BD=A0=E7=9A=84=E6=9E=B6= =E6=9E=84=E7=9A=84 ``local.h`` =E4=B8=AD=E5=8C=85=E6=8B=AC ``asm-g =20 static void __exit test_exit(void) { - del_timer_sync(&test_timer); + timer_delete_sync(&test_timer); } =20 module_init(test_init); -- From nobody Fri Dec 19 12:13:28 2025 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 486162FAC05 for ; Fri, 10 Oct 2025 15:03:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108616; cv=none; b=CHFHkTB2Tt4a8e3aDMrErFGSTqJuk2l50aGtsw4nio/rvF/U02wziQwCcP08EpkbyZJSIFi9U52YR8ZfP2SQoFnEq4kX9Hca3wlNUinQAwdRIr7fhebFX+sx7W4D6EjozmtbCD1FmsOiHEEGtg+TJYe2T+U2m2GGGvf5yLdwECs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108616; c=relaxed/simple; bh=A7NZvw6BwM3JH9LFTZM0pkj7MM2Mf/KMJNxtIByaxbs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=moxFD0aDz4TL6Ak6EMT7XosPRARdmDFrH3bWUHQDmR8UpUV9EunWWcG0dXbovWztGB1AqaPyA0u2p9ea59EJeH0nHLAG+oNlhGFcG4oMB5vTVVJUvIxi5VNL6kX7qcPiQXZTiHEm2xJutpZ77QnTRuzPxKYpdZPV2eH+eD214ZA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=e6warcY/; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e6warcY/" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-781206cce18so2342647b3a.0 for ; Fri, 10 Oct 2025 08:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760108613; x=1760713413; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HIvAwaANSEMHidUC241SU/ATL2QFU3HABzkGaIq1H88=; b=e6warcY/j+AhOFiEH4LxHlRbQra3smYT+AJbRdxXjSayLeYaTRub0OiFUHuEIS52nb Mi0FnAxiiAmFgaI8swivggiAWSufyciL59z+wXYbN3JeF3mA7m5g9MRmxqI4f9WbPCda ufYyXRiROflhNoEN91DU/Eud0MU+xoPfw/LNgFOp3b5SuNoVOYzKLM8VULC0Ayn0Rp/B cuqAy1ztcUNMIqHBSTGaxzCfzwY5FmiBC1kR2R0Gs9BsrWTUXNczFRGZJRaPmBWUEklt umGnkTKc1zcC6A4r8p8imJXOURI4ySBbkmIgcgZ8XhDb2ZxtlmfOp7xmzf7AsPcmADGq 5WSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760108613; x=1760713413; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HIvAwaANSEMHidUC241SU/ATL2QFU3HABzkGaIq1H88=; b=O+ZQB2oMiE6wIztndMnM0Nmcw4hZmKiawRuOeP/AnbJulDmhiV3KI6LenSB2Ok0FN/ Flyr2hthm8VBBAZb5E5+oaV1nFb1ePYa6Aj39TQuEP8FhLDBSsBd8BdO+/dFdrq6viyt GArjASpcpsDtbjLpYsLQmEaWKXrjbOIccl4GptmZfL9wDNil4u96NJZm58mDHf3vPc4B SPAVvyBq86JK08PdYb+Xc5K8YUWFuf//BitBjGBkIR7NJ2JyR8U9hF+YFw6nrdINv8hW 2DCgpPGVY1XgXx9+eEE4Kx0dRgu99KpnDaJ5CfEY7hO3q36ESGh2MZUpANg3lkn20wQT G9fg== X-Forwarded-Encrypted: i=1; AJvYcCUIlsoPilZhJF6ANSt3RR61dg9b1roxKxjOHnfcnzYqBc5w3XnP2FpS4nZ1WlSncopFwpVQm2+tmj5T0UY=@vger.kernel.org X-Gm-Message-State: AOJu0YxSWozs6GcAbNJhuX6+ow/vAjYzgEKG7IDNi730XF4pUmTZVwr8 a1uRnuG/iNh2UjgMquzW86XNsorYxVFf6e7Y6nc6YqbxovBQQDgiKGEr X-Gm-Gg: ASbGncuy/LoKk9Q8wIuOLeRINCZxK5UP/yM72J3m+RkXIni7igTObQ3/vi4ycCHynCA gkGqRR9kBa1TO8x8mNiARPk6XfKCSgrhuhAQzsa3bctZqv9iFAlAyBsKDnOk1WKkpTiQl+ObEnS XcziDIz6AKnsOcZbbtF2yiSfT/F6IDcv4JCGP5bhYWSaalP22os9I7EEgYMql15pvUmTeO+x93J 0DOgqNbfPhMtoawmNxQGBRIl62ItuLH3n/pXjYEy63x3XghfzGf/qNrjTvnhEz+XHrFPo8g+/SX 65TGdzdzKXdSNNzWYGIIJ9J9x85blJ9ihKrdUzpFsXAi5tIGcojSgtQhdReG78DCv56x/UGzDn5 HHCtLD57VG5U8ZUnFBC7QKZTDodRWH5vdxEVc8w07+b/JNFCQHz/LkmfbUqywgQYhoIOg1Gt5yL P/4ww= X-Google-Smtp-Source: AGHT+IFN002D5LEzhcshovKTWIIkwy/kzSyTHAsoxU09irX5bD+tuMRXLGgMawISEMPJETPlzJXvNA== X-Received: by 2002:a05:6a20:6a22:b0:246:3a6:3e47 with SMTP id adf61e73a8af0-32da8e2ba5cmr14348517637.12.1760108613238; Fri, 10 Oct 2025 08:03:33 -0700 (PDT) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7992b639cbcsm3266359b3a.18.2025.10.10.08.03.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Oct 2025 08:03:32 -0700 (PDT) From: Jeongjun Park To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, tglx@linutronix.de, Julia.Lawall@inria.fr, akpm@linux-foundation.org, anna-maria@linutronix.de, arnd@arndb.de, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@roeck-us.net, luiz.dentz@gmail.com, marcel@holtmann.org, maz@kernel.org, peterz@infradead.org, rostedt@goodmis.org, sboyd@kernel.org, viresh.kumar@linaro.org, Jacob Keller , Jeongjun Park Subject: [PATCH 6.1.y 07/12] timers: Silently ignore timers with a NULL function Date: Sat, 11 Oct 2025 00:02:47 +0900 Message-Id: <20251010150252.1115788-8-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251010150252.1115788-1-aha310510@gmail.com> References: <20251010150252.1115788-1-aha310510@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Thomas Gleixner [ Upstream commit d02e382cef06cc73561dd32dfdc171c00dcc416d ] Tearing down timers which have circular dependencies to other functionality, e.g. workqueues, where the timer can schedule work and work can arm timers, is not trivial. In those cases it is desired to shutdown the timer in a way which prevents rearming of the timer. The mechanism to do so is to set timer->function to NULL and use this as an indicator for the timer arming functions to ignore the (re)arm request. In preparation for that replace the warnings in the relevant code paths with checks for timer->function =3D=3D NULL. If the pointer is NULL, then discard the rearm request silently. Add debug_assert_init() instead of the WARN_ON_ONCE(!timer->function) checks so that debug objects can warn about non-initialized timers. The warning of debug objects does not warn if timer->function =3D=3D NULL. = It warns when timer was not initialized using timer_setup[_on_stack]() or via DEFINE_TIMER(). If developers fail to enable debug objects and then waste lots of time to figure out why their non-initialized timer is not firing, they deserve it. Same for initializing a timer with a NULL function. Co-developed-by: Steven Rostedt Signed-off-by: Steven Rostedt Signed-off-by: Thomas Gleixner Tested-by: Guenter Roeck Reviewed-by: Jacob Keller Reviewed-by: Anna-Maria Behnsen Link: https://lore.kernel.org/all/20220407161745.7d6754b3@gandalf.local.home Link: https://lore.kernel.org/all/20221110064101.429013735@goodmis.org Link: https://lore.kernel.org/r/87wn7kdann.ffs@tglx Signed-off-by: Jeongjun Park --- kernel/time/timer.c | 57 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 7094b916c854..3b6624cd9507 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1017,7 +1017,7 @@ __mod_timer(struct timer_list *timer, unsigned long e= xpires, unsigned int option unsigned int idx =3D UINT_MAX; int ret =3D 0; =20 - BUG_ON(!timer->function); + debug_assert_init(timer); =20 /* * This is a common optimization triggered by the networking code - if @@ -1044,6 +1044,14 @@ __mod_timer(struct timer_list *timer, unsigned long = expires, unsigned int option * dequeue/enqueue dance. */ base =3D lock_timer_base(timer, &flags); + /* + * Has @timer been shutdown? This needs to be evaluated + * while holding base lock to prevent a race against the + * shutdown code. + */ + if (!timer->function) + goto out_unlock; + forward_timer_base(base); =20 if (timer_pending(timer) && (options & MOD_TIMER_REDUCE) && @@ -1070,6 +1078,14 @@ __mod_timer(struct timer_list *timer, unsigned long = expires, unsigned int option } } else { base =3D lock_timer_base(timer, &flags); + /* + * Has @timer been shutdown? This needs to be evaluated + * while holding base lock to prevent a race against the + * shutdown code. + */ + if (!timer->function) + goto out_unlock; + forward_timer_base(base); } =20 @@ -1128,8 +1144,12 @@ __mod_timer(struct timer_list *timer, unsigned long = expires, unsigned int option * mod_timer_pending() is the same for pending timers as mod_timer(), but * will not activate inactive timers. * + * If @timer->function =3D=3D NULL then the start operation is silently + * discarded. + * * Return: - * * %0 - The timer was inactive and not modified + * * %0 - The timer was inactive and not modified or was in + * shutdown state and the operation was discarded * * %1 - The timer was active and requeued to expire at @expires */ int mod_timer_pending(struct timer_list *timer, unsigned long expires) @@ -1155,8 +1175,12 @@ EXPORT_SYMBOL(mod_timer_pending); * same timer, then mod_timer() is the only safe way to modify the timeout, * since add_timer() cannot modify an already running timer. * + * If @timer->function =3D=3D NULL then the start operation is silently + * discarded. In this case the return value is 0 and meaningless. + * * Return: - * * %0 - The timer was inactive and started + * * %0 - The timer was inactive and started or was in shutdown + * state and the operation was discarded * * %1 - The timer was active and requeued to expire at @expires or * the timer was active and not modified because @expires did * not change the effective expiry time @@ -1176,8 +1200,12 @@ EXPORT_SYMBOL(mod_timer); * modify an enqueued timer if that would reduce the expiration time. If * @timer is not enqueued it starts the timer. * + * If @timer->function =3D=3D NULL then the start operation is silently + * discarded. + * * Return: - * * %0 - The timer was inactive and started + * * %0 - The timer was inactive and started or was in shutdown + * state and the operation was discarded * * %1 - The timer was active and requeued to expire at @expires or * the timer was active and not modified because @expires * did not change the effective expiry time such that the @@ -1200,6 +1228,9 @@ EXPORT_SYMBOL(timer_reduce); * The @timer->expires and @timer->function fields must be set prior * to calling this function. * + * If @timer->function =3D=3D NULL then the start operation is silently + * discarded. + * * If @timer->expires is already in the past @timer will be queued to * expire at the next timer tick. * @@ -1228,7 +1259,9 @@ void add_timer_on(struct timer_list *timer, int cpu) struct timer_base *new_base, *base; unsigned long flags; =20 - if (WARN_ON_ONCE(timer_pending(timer) || !timer->function)) + debug_assert_init(timer); + + if (WARN_ON_ONCE(timer_pending(timer))) return; =20 new_base =3D get_timer_cpu_base(timer->flags, cpu); @@ -1239,6 +1272,13 @@ void add_timer_on(struct timer_list *timer, int cpu) * wrong base locked. See lock_timer_base(). */ base =3D lock_timer_base(timer, &flags); + /* + * Has @timer been shutdown? This needs to be evaluated while + * holding base lock to prevent a race against the shutdown code. + */ + if (!timer->function) + goto out_unlock; + if (base !=3D new_base) { timer->flags |=3D TIMER_MIGRATING; =20 @@ -1252,6 +1292,7 @@ void add_timer_on(struct timer_list *timer, int cpu) =20 debug_timer_activate(timer); internal_add_timer(base, timer); +out_unlock: raw_spin_unlock_irqrestore(&base->lock, flags); } EXPORT_SYMBOL_GPL(add_timer_on); @@ -1541,6 +1582,12 @@ static void expire_timers(struct timer_base *base, s= truct hlist_head *head) =20 fn =3D timer->function; =20 + if (WARN_ON_ONCE(!fn)) { + /* Should never happen. Emphasis on should! */ + base->running_timer =3D NULL; + continue; + } + if (timer->flags & TIMER_IRQSAFE) { raw_spin_unlock(&base->lock); call_timer_fn(timer, fn, baseclk); -- From nobody Fri Dec 19 12:13:28 2025 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 132672FB093 for ; Fri, 10 Oct 2025 15:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108620; cv=none; b=fgI5pKPOghy9Q+nnY6JXg811xisDwuDO1ybJ6lKnchEGOBmUD/PflkpYmQwYKv6ez0qWX34mPi5OaYjc8ZugPVC8ByOlvESYZ8nfyHj6VRm7pjqenfUzodIrX/gTb7QuzhI8SiqdH2x4Znk75ygZtqiQ/vR/OaV+HbxyQCYAWYI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108620; c=relaxed/simple; bh=FfeWAFL01yrxGNZ9KQqmQL8U/+v/91/EffrzfYdxZZA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qDwT9hGaSpjOFhFjYtqE6R1+fOLKGzzg3dzYpVKdIjLqUuZ+Itp7DPLpagXHoaOXwFOCo3p5JKy0YnVZyWG11gW8q3ho0CKm5c4tAbRPPhmD46AHivzaOf6WLmZ5EcGMGyc/MFhEwBCkVUSg6pc9TeiLkevfc/Vi78+ePHd4aqw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PwMKTOWj; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PwMKTOWj" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-782e93932ffso2066210b3a.3 for ; Fri, 10 Oct 2025 08:03:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760108618; x=1760713418; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=j0bNeek1LW81/KG2/Q/uicdT1bV3tR+ITFKGtccSqSg=; b=PwMKTOWjlKiSl8aZ4Tlq2h2zXpGg1JGTXK+2+563ZeXzobtQwUekS+fZ6BRV/ryzIE ppH+oHxz7/46gEn1NADzkUBktoRhQyDNMICbXNroThOcPE4sL76b63ns+fsaueVqhGm9 F0iSIW0DYN/LatDho76W58TtqfbzaN2AOpRZCACsHNH43sr/GY2OQb91KukM4QxBP9+k LiVa29UQdMiYwcsvGbX2pCvOPZfq3PGRDwyjswKcjYEIuq3IQlos3Pza52wMqN6B71vK BkbNaqQvpW257zoB0e0Dgubf/14DC4z+uzsGYx5+yrIv3HxVvAUPVdmkzgKxkXQPtKIY 8GNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760108618; x=1760713418; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j0bNeek1LW81/KG2/Q/uicdT1bV3tR+ITFKGtccSqSg=; b=JQOONGyDM3oV73vbIbtRxRKumc+cZPy5wI5Mpw6QzuLlQqRgu5vuQvo9Nntcaj5Z/5 5aPnJ5HMXhvUWnrTWW5qiZ2ZenEFudXbAPpn4CLEUBH9mv/J9R7xXP1qIdfJYHR8i5+m NMN1HVf7WtBwXQmAA2Kb97Sq4JSR98vHuMvDAmoPp8ltNrtHJ4m6YVkHnYMHJr+Sghu9 8jVAh/73UQqxOsSs4yTsuzgS4UziJp5VYlu3oPglNmY0ay4+VkvwCj/oR7SD2syKeN8G m6O0adhZtDgceS2zGjJ9s5oTka4AImgWyTijjjpOwE+dy4KrRU7onLLxDW9ZJ/vjrAnn Z70Q== X-Forwarded-Encrypted: i=1; AJvYcCVjQtJQyibI4Ppl4Pg3sZXo6N9hqlG9gWLL2EHJRB9lRCpb8GRcARqUcFZt40n+yc9lrWFL/zlIoUQwdGE=@vger.kernel.org X-Gm-Message-State: AOJu0Yxninh9LtjHWxjM/33iVn7hWwzmFhSD1bUpvQS870FfuQLgmuM5 zXIn7W28LfwDM9p/d17zPBntw3Rp5QRlFSgwXKH22CE5xCN5ZBetIu3b X-Gm-Gg: ASbGncu2Jyj4qGN5FM/K1ysILZ9iiVDabBkW2fgL6nZ6OS3wAJCwJVX7zZOzLlnJPsG EI0ge9ygIOfFBiTaPWy1g+mKvPQNHyq/Jmi+bdlq1HlcyFpBFo/OeJG/807ncn9E7HWr1m9ONMs scRqGHJG14vnhR5x3rN08oBn3wA/lJWMJ8jzn80ZfYoZ0z+BpZzrb6xx++ONGxDTXJOf0aFhq0S MDkar9WSmkjzo9Co1IxJ2Nwx9jt9FfQSQm7jKpaLY6m7bRAJ/GPrfmjKh6xbSKuXgYQlNWYafpf 2pKDP6iO6BboKuyBJd3g074lBuXhI5LJmBXdbKY0aKue/bmC+bVFOSbpwmTclHnJNHLkhjwz2/T +cGjREjWvTn8nVn+S2SnYkCYlZT7m8291T7ieuTvuwPeW75pHD+N3IfOt4KRvyqjuPbAC1bU7d8 HDiL70ZCAPP/Iwhg== X-Google-Smtp-Source: AGHT+IESNC8RkQTBaynIxPs6OR43ASsf0mjK4WexzZ/IzmWVAMQfi+tV6noR5/B9CBVHAqdLTCbbEg== X-Received: by 2002:a05:6a00:3c84:b0:781:1e80:f0c6 with SMTP id d2e1a72fcca58-79387440a4dmr15774554b3a.17.1760108617993; Fri, 10 Oct 2025 08:03:37 -0700 (PDT) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7992b639cbcsm3266359b3a.18.2025.10.10.08.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Oct 2025 08:03:37 -0700 (PDT) From: Jeongjun Park To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, tglx@linutronix.de, Julia.Lawall@inria.fr, akpm@linux-foundation.org, anna-maria@linutronix.de, arnd@arndb.de, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@roeck-us.net, luiz.dentz@gmail.com, marcel@holtmann.org, maz@kernel.org, peterz@infradead.org, rostedt@goodmis.org, sboyd@kernel.org, viresh.kumar@linaro.org, Jacob Keller , Jeongjun Park Subject: [PATCH 6.1.y 08/12] timers: Split [try_to_]del_timer[_sync]() to prepare for shutdown mode Date: Sat, 11 Oct 2025 00:02:48 +0900 Message-Id: <20251010150252.1115788-9-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251010150252.1115788-1-aha310510@gmail.com> References: <20251010150252.1115788-1-aha310510@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Thomas Gleixner [ Upstream commit 8553b5f2774a66b1f293b7d783934210afb8f23c ] Tearing down timers which have circular dependencies to other functionality, e.g. workqueues, where the timer can schedule work and work can arm timers, is not trivial. In those cases it is desired to shutdown the timer in a way which prevents rearming of the timer. The mechanism to do so is to set timer->function to NULL and use this as an indicator for the timer arming functions to ignore the (re)arm request. Split the inner workings of try_do_del_timer_sync(), del_timer_sync() and del_timer() into helper functions to prepare for implementing the shutdown functionality. No functional change. Co-developed-by: Steven Rostedt Signed-off-by: Steven Rostedt Signed-off-by: Thomas Gleixner Tested-by: Guenter Roeck Reviewed-by: Jacob Keller Reviewed-by: Anna-Maria Behnsen Link: https://lore.kernel.org/all/20220407161745.7d6754b3@gandalf.local.home Link: https://lore.kernel.org/all/20221110064101.429013735@goodmis.org Link: https://lore.kernel.org/r/20221123201625.195147423@linutronix.de Signed-off-by: Jeongjun Park --- kernel/time/timer.c | 143 ++++++++++++++++++++++++++++---------------- 1 file changed, 92 insertions(+), 51 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 3b6624cd9507..0b76a2ab42e3 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1298,20 +1298,14 @@ void add_timer_on(struct timer_list *timer, int cpu) EXPORT_SYMBOL_GPL(add_timer_on); =20 /** - * timer_delete - Deactivate a timer + * __timer_delete - Internal function: Deactivate a timer * @timer: The timer to be deactivated * - * The function only deactivates a pending timer, but contrary to - * timer_delete_sync() it does not take into account whether the timer's - * callback function is concurrently executed on a different CPU or not. - * It neither prevents rearming of the timer. If @timer can be rearmed - * concurrently then the return value of this function is meaningless. - * * Return: * * %0 - The timer was not pending * * %1 - The timer was pending and deactivated */ -int timer_delete(struct timer_list *timer) +static int __timer_delete(struct timer_list *timer) { struct timer_base *base; unsigned long flags; @@ -1327,25 +1321,37 @@ int timer_delete(struct timer_list *timer) =20 return ret; } -EXPORT_SYMBOL(timer_delete); =20 /** - * try_to_del_timer_sync - Try to deactivate a timer - * @timer: Timer to deactivate + * timer_delete - Deactivate a timer + * @timer: The timer to be deactivated * - * This function tries to deactivate a timer. On success the timer is not - * queued and the timer callback function is not running on any CPU. + * The function only deactivates a pending timer, but contrary to + * timer_delete_sync() it does not take into account whether the timer's + * callback function is concurrently executed on a different CPU or not. + * It neither prevents rearming of the timer. If @timer can be rearmed + * concurrently then the return value of this function is meaningless. * - * This function does not guarantee that the timer cannot be rearmed right - * after dropping the base lock. That needs to be prevented by the calling - * code if necessary. + * Return: + * * %0 - The timer was not pending + * * %1 - The timer was pending and deactivated + */ +int timer_delete(struct timer_list *timer) +{ + return __timer_delete(timer); +} +EXPORT_SYMBOL(timer_delete); + +/** + * __try_to_del_timer_sync - Internal function: Try to deactivate a timer + * @timer: Timer to deactivate * * Return: * * %0 - The timer was not pending * * %1 - The timer was pending and deactivated * * %-1 - The timer callback function is running on a different CPU */ -int try_to_del_timer_sync(struct timer_list *timer) +static int __try_to_del_timer_sync(struct timer_list *timer) { struct timer_base *base; unsigned long flags; @@ -1362,6 +1368,27 @@ int try_to_del_timer_sync(struct timer_list *timer) =20 return ret; } + +/** + * try_to_del_timer_sync - Try to deactivate a timer + * @timer: Timer to deactivate + * + * This function tries to deactivate a timer. On success the timer is not + * queued and the timer callback function is not running on any CPU. + * + * This function does not guarantee that the timer cannot be rearmed right + * after dropping the base lock. That needs to be prevented by the calling + * code if necessary. + * + * Return: + * * %0 - The timer was not pending + * * %1 - The timer was pending and deactivated + * * %-1 - The timer callback function is running on a different CPU + */ +int try_to_del_timer_sync(struct timer_list *timer) +{ + return __try_to_del_timer_sync(timer); +} EXPORT_SYMBOL(try_to_del_timer_sync); =20 #ifdef CONFIG_PREEMPT_RT @@ -1438,45 +1465,15 @@ static inline void del_timer_wait_running(struct ti= mer_list *timer) { } #endif =20 /** - * timer_delete_sync - Deactivate a timer and wait for the handler to fini= sh. + * __timer_delete_sync - Internal function: Deactivate a timer and wait + * for the handler to finish. * @timer: The timer to be deactivated * - * 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 callback - * function. 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. - * - * For !irqsafe timers, the caller must not hold locks that are held in - * interrupt context. Even if the lock has nothing to do with the timer in - * question. Here's why:: - * - * CPU0 CPU1 - * ---- ---- - * - * call_timer_fn(); - * base->running_timer =3D mytimer; - * spin_lock_irq(somelock); - * - * spin_lock(somelock); - * timer_delete_sync(mytimer); - * while (base->running_timer =3D=3D mytimer); - * - * Now timer_delete_sync() will never return and never release somelock. - * The interrupt on the other CPU is waiting to grab somelock but it has - * interrupted the softirq that CPU0 is waiting to finish. - * - * This function cannot guarantee that the timer is not rearmed again by - * some concurrent or preempting code, right after it dropped the base - * lock. If there is the possibility of a concurrent rearm then the return - * value of the function is meaningless. - * * Return: * * %0 - The timer was not pending * * %1 - The timer was pending and deactivated */ -int timer_delete_sync(struct timer_list *timer) +static int __timer_delete_sync(struct timer_list *timer) { int ret; =20 @@ -1506,7 +1503,7 @@ int timer_delete_sync(struct timer_list *timer) lockdep_assert_preemption_enabled(); =20 do { - ret =3D try_to_del_timer_sync(timer); + ret =3D __try_to_del_timer_sync(timer); =20 if (unlikely(ret < 0)) { del_timer_wait_running(timer); @@ -1516,6 +1513,50 @@ int timer_delete_sync(struct timer_list *timer) =20 return ret; } + +/** + * timer_delete_sync - Deactivate a timer and wait for the handler to fini= sh. + * @timer: The timer to be deactivated + * + * 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 callback + * function. 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. + * + * For !irqsafe timers, the caller must not hold locks that are held in + * interrupt context. Even if the lock has nothing to do with the timer in + * question. Here's why:: + * + * CPU0 CPU1 + * ---- ---- + * + * call_timer_fn(); + * base->running_timer =3D mytimer; + * spin_lock_irq(somelock); + * + * spin_lock(somelock); + * timer_delete_sync(mytimer); + * while (base->running_timer =3D=3D mytimer); + * + * Now timer_delete_sync() will never return and never release somelock. + * The interrupt on the other CPU is waiting to grab somelock but it has + * interrupted the softirq that CPU0 is waiting to finish. + * + * This function cannot guarantee that the timer is not rearmed again by + * some concurrent or preempting code, right after it dropped the base + * lock. If there is the possibility of a concurrent rearm then the return + * value of the function is meaningless. + * + * Return: + * * %0 - The timer was not pending + * * %1 - The timer was pending and deactivated + */ +int timer_delete_sync(struct timer_list *timer) +{ + return __timer_delete_sync(timer); +} EXPORT_SYMBOL(timer_delete_sync); =20 static void call_timer_fn(struct timer_list *timer, -- From nobody Fri Dec 19 12:13:28 2025 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 229FD2FB0A9 for ; Fri, 10 Oct 2025 15:03:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108625; cv=none; b=lhxJ6+dAB+TA7j87lA3DpdBhBPwPy4zavHJxwjScHb7W5qvuOip6sr/xcMrY80VlJlOuniHCCj7mqvww/wLtYKV8Q85FjvGVcydZMf4Fag6eC5Wlj/nGgZSzO/94XOQecGi4XtIcIoe6/UqM/qFakCERfHU6MQr+sRVtPUmtdRU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108625; c=relaxed/simple; bh=7nNzz17kSCCmlWDu86ZhyMKFITWZeFxpgwAsgGFQJqQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CJJaBATRh1H2MqYdHMZGbahXUJGYaZJWL34HeC0+KRNYQWe04tcd3yuDXtn+y8e124ypnvT+orKkK6BMS+KIleb73QoOSCSrmqzkVfwa8CMV/Tb34qQXTAT7c6pR1T4FmAHcBqb6DXypy151bzxaChKdbu0GOoMecrraZXRL72k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fV1MeqoC; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fV1MeqoC" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-789fb76b466so2061264b3a.0 for ; Fri, 10 Oct 2025 08:03:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760108623; x=1760713423; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=x1WOyKHAoHX8FrQxrc3Dl9TiChr0cIqUNlYEGeUOx2A=; b=fV1MeqoCo9+XinoqwRCcfrBmPcA0nfxE+n3HmKJKHYGn2O3+8JNqAvleRmenjusiaD 50K+UkC8gIhwD/ZwqbwnTl3GsN5G3S11YZvWdCQAnEyUfITWr0QYUlz7rEvJtue4Cuqo 0H9XLt35S+9Bvz0UZi9U9lkY/AG5Tn2Cdk8B5AojhcPEILTEbaGeqfDnENXcXTPSNxy1 fN37EdJ49EFQ/6tj5h+Xvu7F94bxbW/EdvRVJGxARZGmDo0CuoIbMf+oQDfxZw6ggkpO wA3H9y7/WFjejyzXhJcTQkORnKRQOSzty82+27X6DzoVoMHGgN8iXvGnGBGAopDsr0fz qLNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760108623; x=1760713423; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x1WOyKHAoHX8FrQxrc3Dl9TiChr0cIqUNlYEGeUOx2A=; b=cWsI9iEQaRCJjqw/e7nvhRDdDAMxMpB3lLcdbQp2x/P/C5ZfEMxaPSjcSx0HNkSfwl eVNx7gn1K+f+dk/vIYJVfyhbQbKgNPJ0yNFpkpXsFE88K0udoNTt515jA1lBMxfTBFJ9 tVLAu5nkvKb80QiKde6eeG5ASVOwCkbm0GLVaCNpDMm2DhXyhTxpx0uwiPymEzq/zeYX FRd83KO57LoeS5kil0bgp4wvOCIjLFnMaJGobVGdI0skKhxJXlj8okpfbnRdkTBEWHjI 2bvukOkS0rI3XXP6G9dG7yQsgb/iU/MXvTauMn2W+t38teqBeA0FOnFh9oYASO5TJH6c XO6w== X-Forwarded-Encrypted: i=1; AJvYcCWOMfK/M1AoYGRHzXJc8Mlj/jX78eeh/Sbmw/ueodHIOpOr+dPIZ67y7Hr50EB41vlSBZKtZ6fPWqbPZWU=@vger.kernel.org X-Gm-Message-State: AOJu0YwUbAuNBo1Q2UIzzde/m8d6XX0ka+HbWsXeZqhAdclRwIjgrZt8 gdqt4oQHcxKKzNkA7y1UHYaPsCHTLsIlztJOGAGmuf2L4OjH8rEh/7i6 X-Gm-Gg: ASbGncteVIxKGb9AJ7ObM0K/W4PyQZif7IMnuW4nqCE702RxyNZpdMy8IzlPpxHighM JDKAWjA7r1dF2cUTuD9gfojRhXiF0rS+9MP0v6/vnrqR1kPkvJFTQTf6btl9WyJw81GzcG+KSye xY7I4vaHzdGOLiT1JfBCLdkVCLsukyoUEeFoKX9sCXiTf6lc52wkJZn3yx0LRO5LPKFyvMyMGef 8XLL9awvzI9r+wGeSyqvo2yML6lHnlnULhOg53WD1aUiXsCZkCbujA5G4XWQs4BdPDtiEmKw1lg y/xH1muMEneevuV/CfpedWxSqQ48Q6wQ742jSqrYC0Kax2IgA63QZaz8Kn+tLBQr8p41zEiSoLH A3XmYdwhZXKha2m/YxP/gy16/CVH8fMl0jbbXDtA3xJEJ9j3ED69CI4/32OvMjdgXten4 X-Google-Smtp-Source: AGHT+IHrduPK+iiS9nbHl2XLfSpxtFJG0LliAypgacWlL77CyWlc81OQiQGuYb3a2zEvexULQddNrg== X-Received: by 2002:a05:6a00:17a7:b0:781:8832:9159 with SMTP id d2e1a72fcca58-79385709429mr12871804b3a.4.1760108622956; Fri, 10 Oct 2025 08:03:42 -0700 (PDT) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7992b639cbcsm3266359b3a.18.2025.10.10.08.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Oct 2025 08:03:42 -0700 (PDT) From: Jeongjun Park To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, tglx@linutronix.de, Julia.Lawall@inria.fr, akpm@linux-foundation.org, anna-maria@linutronix.de, arnd@arndb.de, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@roeck-us.net, luiz.dentz@gmail.com, marcel@holtmann.org, maz@kernel.org, peterz@infradead.org, rostedt@goodmis.org, sboyd@kernel.org, viresh.kumar@linaro.org, Jacob Keller , Jeongjun Park Subject: [PATCH 6.1.y 09/12] timers: Add shutdown mechanism to the internal functions Date: Sat, 11 Oct 2025 00:02:49 +0900 Message-Id: <20251010150252.1115788-10-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251010150252.1115788-1-aha310510@gmail.com> References: <20251010150252.1115788-1-aha310510@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Thomas Gleixner [ Upstream commit 0cc04e80458a822300b93f82ed861a513edde194 ] Tearing down timers which have circular dependencies to other functionality, e.g. workqueues, where the timer can schedule work and work can arm timers, is not trivial. In those cases it is desired to shutdown the timer in a way which prevents rearming of the timer. The mechanism to do so is to set timer->function to NULL and use this as an indicator for the timer arming functions to ignore the (re)arm request. Add a shutdown argument to the relevant internal functions which makes the actual deactivation code set timer->function to NULL which in turn prevents rearming of the timer. Co-developed-by: Steven Rostedt Signed-off-by: Steven Rostedt Signed-off-by: Thomas Gleixner Tested-by: Guenter Roeck Reviewed-by: Jacob Keller Reviewed-by: Anna-Maria Behnsen Link: https://lore.kernel.org/all/20220407161745.7d6754b3@gandalf.local.home Link: https://lore.kernel.org/all/20221110064101.429013735@goodmis.org Link: https://lore.kernel.org/r/20221123201625.253883224@linutronix.de Signed-off-by: Jeongjun Park --- kernel/time/timer.c | 62 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 0b76a2ab42e3..b46614e14da1 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1300,12 +1300,19 @@ EXPORT_SYMBOL_GPL(add_timer_on); /** * __timer_delete - Internal function: Deactivate a timer * @timer: The timer to be deactivated + * @shutdown: If true, this indicates that the timer is about to be + * shutdown permanently. + * + * If @shutdown is true then @timer->function is set to NULL under the + * timer base lock which prevents further rearming of the time. In that + * case any attempt to rearm @timer after this function returns will be + * silently ignored. * * Return: * * %0 - The timer was not pending * * %1 - The timer was pending and deactivated */ -static int __timer_delete(struct timer_list *timer) +static int __timer_delete(struct timer_list *timer, bool shutdown) { struct timer_base *base; unsigned long flags; @@ -1313,9 +1320,22 @@ static int __timer_delete(struct timer_list *timer) =20 debug_assert_init(timer); =20 - if (timer_pending(timer)) { + /* + * If @shutdown is set then the lock has to be taken whether the + * timer is pending or not to protect against a concurrent rearm + * which might hit between the lockless pending check and the lock + * aquisition. By taking the lock it is ensured that such a newly + * enqueued timer is dequeued and cannot end up with + * timer->function =3D=3D NULL in the expiry code. + * + * If timer->function is currently executed, then this makes sure + * that the callback cannot requeue the timer. + */ + if (timer_pending(timer) || shutdown) { base =3D lock_timer_base(timer, &flags); ret =3D detach_if_pending(timer, base, true); + if (shutdown) + timer->function =3D NULL; raw_spin_unlock_irqrestore(&base->lock, flags); } =20 @@ -1338,20 +1358,31 @@ static int __timer_delete(struct timer_list *timer) */ int timer_delete(struct timer_list *timer) { - return __timer_delete(timer); + return __timer_delete(timer, false); } EXPORT_SYMBOL(timer_delete); =20 /** * __try_to_del_timer_sync - Internal function: Try to deactivate a timer * @timer: Timer to deactivate + * @shutdown: If true, this indicates that the timer is about to be + * shutdown permanently. + * + * If @shutdown is true then @timer->function is set to NULL under the + * timer base lock which prevents further rearming of the timer. Any + * attempt to rearm @timer after this function returns will be silently + * ignored. + * + * This function cannot guarantee that the timer cannot be rearmed + * right after dropping the base lock if @shutdown is false. That + * needs to be prevented by the calling code if necessary. * * Return: * * %0 - The timer was not pending * * %1 - The timer was pending and deactivated * * %-1 - The timer callback function is running on a different CPU */ -static int __try_to_del_timer_sync(struct timer_list *timer) +static int __try_to_del_timer_sync(struct timer_list *timer, bool shutdown) { struct timer_base *base; unsigned long flags; @@ -1363,6 +1394,8 @@ static int __try_to_del_timer_sync(struct timer_list = *timer) =20 if (base->running_timer !=3D timer) ret =3D detach_if_pending(timer, base, true); + if (shutdown) + timer->function =3D NULL; =20 raw_spin_unlock_irqrestore(&base->lock, flags); =20 @@ -1387,7 +1420,7 @@ static int __try_to_del_timer_sync(struct timer_list = *timer) */ int try_to_del_timer_sync(struct timer_list *timer) { - return __try_to_del_timer_sync(timer); + return __try_to_del_timer_sync(timer, false); } EXPORT_SYMBOL(try_to_del_timer_sync); =20 @@ -1468,12 +1501,25 @@ static inline void del_timer_wait_running(struct ti= mer_list *timer) { } * __timer_delete_sync - Internal function: Deactivate a timer and wait * for the handler to finish. * @timer: The timer to be deactivated + * @shutdown: If true, @timer->function will be set to NULL under the + * timer base lock which prevents rearming of @timer + * + * If @shutdown is not set the timer can be rearmed later. If the timer can + * be rearmed concurrently, i.e. after dropping the base lock then the + * return value is meaningless. + * + * If @shutdown is set then @timer->function is set to NULL under timer + * base lock which prevents rearming of the timer. Any attempt to rearm + * a shutdown timer is silently ignored. + * + * If the timer should be reused after shutdown it has to be initialized + * again. * * Return: * * %0 - The timer was not pending * * %1 - The timer was pending and deactivated */ -static int __timer_delete_sync(struct timer_list *timer) +static int __timer_delete_sync(struct timer_list *timer, bool shutdown) { int ret; =20 @@ -1503,7 +1549,7 @@ static int __timer_delete_sync(struct timer_list *tim= er) lockdep_assert_preemption_enabled(); =20 do { - ret =3D __try_to_del_timer_sync(timer); + ret =3D __try_to_del_timer_sync(timer, shutdown); =20 if (unlikely(ret < 0)) { del_timer_wait_running(timer); @@ -1555,7 +1601,7 @@ static int __timer_delete_sync(struct timer_list *tim= er) */ int timer_delete_sync(struct timer_list *timer) { - return __timer_delete_sync(timer); + return __timer_delete_sync(timer, false); } EXPORT_SYMBOL(timer_delete_sync); =20 -- From nobody Fri Dec 19 12:13:28 2025 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20DA62FB0BD for ; Fri, 10 Oct 2025 15:03:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108630; cv=none; b=oJ5Wp/VwOFyFA0UBy88KszhwXtXvRRYwZXObw8wF2swGh44GbWemuI7Nf2j6DcOOVc7YozTW2K3WVwgcjcb9XQNUa9jDsePTnnVGJKA9F/wFwdm/YzegE2cazSbLRHpMSi6P7c/owuT4dM/qP39txM9B5bE/f4EosJOCkQjYbmc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108630; c=relaxed/simple; bh=J7+paRiPLaCD/c+KTz8seNjK8t39KhNj40mTnjX9HD0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TFid+WGNMQVssakDUvmxBbH1+7udutO8BSFDwHLeI7lZuUqWxcFp1VNqEpaMQWX0M5+EuFy7eJWw+cNQZR+8VezlDKZzJR6BMlIaNFhIdAvH+PUQgi6IAqtF9eV/aMpU+sJq7w7sfj5HfqXqTatVMcEpsyNRGarlymTYaIX4CPs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=J2bCTEbu; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="J2bCTEbu" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-33274fcf5c1so2478850a91.1 for ; Fri, 10 Oct 2025 08:03:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760108628; x=1760713428; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rkZJqZ3kQT2WglZ48UatqwsWbUOwu2gzPSjhRt06PHw=; b=J2bCTEbuT/xgJxk9A96X4yJjVIpMD2i5KUhf3bZdOKu2r9sCjNqGcMkk1MjWI/pQaE ul1D8u7IUbb+jmX3IoxYs080x1WQOLqJduOxhhd3Pv5rxHSwDEAYf7GepUlZKZFjvHj6 S+PK4hkIaw0RLwusBiPJy0GaJHCH4Z8QiS/zl3fJCT9WXNfza3xHEQLnD5gzzEpCamf7 Neb7vmH5MX+kwQmuJv46ksQxH+wet9bdSnglVgTd8nmks6byc+u6eUsLalLqsuYQVGO4 bF4DaZlngf+W7zt9or6azR6ruCTlPfmKHMwCJx+XC9Wk7vetoorDdGqhrtdd+Cw+qj17 HVaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760108628; x=1760713428; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rkZJqZ3kQT2WglZ48UatqwsWbUOwu2gzPSjhRt06PHw=; b=aE+2jRmGBNsdJkUyzss6h6nMiuSEWALbWbF83olT3PvQLxe2kxdRycwujDOCuTll4n YzfeOcE8vKpkN4JCTMU+GLClFJQmEzt+r1UHOoQgPmd1CGN2SMjm3t0yy4te29v4QyRe 80obBNkyErHjBPcfP9h/vpIustu6DTgqsH4NBWev6AtBDx7YR3Zf4Y0cZmmQ100j9atc 8CWVSZ4T0ZAw14148jN/cXu7mbQAKKKnYVkL6PjNiQgqZUM1V4tg0V2gxnuTCYf3y9ft kUfR/ILFbTHwb5xREJxV2yhDu/An3vx6T8LGataIccR7cG0L8eKp9gVMncjmB9ZpvynM wq4Q== X-Forwarded-Encrypted: i=1; AJvYcCXKOF1gurCQHzKDjpqUwTuCm/v0m8sBvG/5Jwka+Hn9yvh0F/cuJJtV6jhYcPkqcMgo9X4gTSG53pJ5FGE=@vger.kernel.org X-Gm-Message-State: AOJu0YxvuWTkhaXR3pLLFSQeXwUhVPnIdvNkdRRAPN92A40ZPNq6Y3Bf EbIKrxejlN55QZVrCDautbxWjQ3kCrD2Q62SIAhptADIB3Z+o5kPxvKD X-Gm-Gg: ASbGnctNuNHEtAm0cmpIrrUxCE7M2Gz6wxLkUXQiMfRxLfFeRM1O5WI5waNcbhpEcAR xKfFijow1gh7G10pkXxWa7Pld8Ad+OUtTc2LvDTd9hwS78xIC7RYnXrECUWPEV8oi2cgzTn5FB9 PhDs5/Ky70etDCdgz23kXEsyaUwerv8l4M1t4eu5aeCXgwe4a5zTVhRfHKvUYcuMG5EJeu/hdei yL25BW2ZfOAW+pucwvU/2zB8fWJoy0Md9bh9Cane62ovk8yqh06XunOwP3a6mhj0h0QJs06oxqa MkGcBG7sEa3ti6XPJCzak9pC7NN61KXd8jNN8fQOySTn3YZcDXsFArTkLNo/B6WlKcQnj3THThi 6Mn3xxdmGcnXYLGdYyx5GQdcpLC2c8Fskbj3yAQne6At+WqiU6pgB7sE7nS2UpspDi45ujVsH19 +IsEA= X-Google-Smtp-Source: AGHT+IHczjaTgP4/pfpS/l/3EBov9boHLxVTpFJ6LfHIqXB5t2YuOsq75pLWvu6/yWJavDCuN/2ueA== X-Received: by 2002:a17:90b:4c4b:b0:339:9a71:efd8 with SMTP id 98e67ed59e1d1-33b513a24demr15370525a91.37.1760108627701; Fri, 10 Oct 2025 08:03:47 -0700 (PDT) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7992b639cbcsm3266359b3a.18.2025.10.10.08.03.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Oct 2025 08:03:47 -0700 (PDT) From: Jeongjun Park To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, tglx@linutronix.de, Julia.Lawall@inria.fr, akpm@linux-foundation.org, anna-maria@linutronix.de, arnd@arndb.de, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@roeck-us.net, luiz.dentz@gmail.com, marcel@holtmann.org, maz@kernel.org, peterz@infradead.org, rostedt@goodmis.org, sboyd@kernel.org, viresh.kumar@linaro.org, Jacob Keller , Jeongjun Park Subject: [PATCH 6.1.y 10/12] timers: Provide timer_shutdown[_sync]() Date: Sat, 11 Oct 2025 00:02:50 +0900 Message-Id: <20251010150252.1115788-11-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251010150252.1115788-1-aha310510@gmail.com> References: <20251010150252.1115788-1-aha310510@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Thomas Gleixner [ Upstream commit f571faf6e443b6011ccb585d57866177af1f643c ] Tearing down timers which have circular dependencies to other functionality, e.g. workqueues, where the timer can schedule work and work can arm timers, is not trivial. In those cases it is desired to shutdown the timer in a way which prevents rearming of the timer. The mechanism to do so is to set timer->function to NULL and use this as an indicator for the timer arming functions to ignore the (re)arm request. Expose new interfaces for this: timer_shutdown_sync() and timer_shutdown(). timer_shutdown_sync() has the same functionality as timer_delete_sync() plus the NULL-ification of the timer function. timer_shutdown() has the same functionality as timer_delete() plus the NULL-ification of the timer function. In both cases the rearming of the timer is prevented by silently discarding rearm attempts due to timer->function being NULL. Co-developed-by: Steven Rostedt Signed-off-by: Steven Rostedt Signed-off-by: Thomas Gleixner Tested-by: Guenter Roeck Reviewed-by: Jacob Keller Reviewed-by: Anna-Maria Behnsen Link: https://lore.kernel.org/all/20220407161745.7d6754b3@gandalf.local.home Link: https://lore.kernel.org/all/20221110064101.429013735@goodmis.org Link: https://lore.kernel.org/r/20221123201625.314230270@linutronix.de Signed-off-by: Jeongjun Park --- include/linux/timer.h | 2 ++ kernel/time/timer.c | 66 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/include/linux/timer.h b/include/linux/timer.h index e338e173ce8b..9162f275819a 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h @@ -184,6 +184,8 @@ extern void add_timer(struct timer_list *timer); extern int try_to_del_timer_sync(struct timer_list *timer); extern int timer_delete_sync(struct timer_list *timer); extern int timer_delete(struct timer_list *timer); +extern int timer_shutdown_sync(struct timer_list *timer); +extern int timer_shutdown(struct timer_list *timer); =20 /** * del_timer_sync - Delete a pending timer and wait for a running callback diff --git a/kernel/time/timer.c b/kernel/time/timer.c index b46614e14da1..4f39025ac933 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1362,6 +1362,27 @@ int timer_delete(struct timer_list *timer) } EXPORT_SYMBOL(timer_delete); =20 +/** + * timer_shutdown - Deactivate a timer and prevent rearming + * @timer: The timer to be deactivated + * + * The function does not wait for an eventually running timer callback on a + * different CPU but it prevents rearming of the timer. Any attempt to arm + * @timer after this function returns will be silently ignored. + * + * This function is useful for teardown code and should only be used when + * timer_shutdown_sync() cannot be invoked due to locking or context const= raints. + * + * Return: + * * %0 - The timer was not pending + * * %1 - The timer was pending + */ +int timer_shutdown(struct timer_list *timer) +{ + return __timer_delete(timer, true); +} +EXPORT_SYMBOL_GPL(timer_shutdown); + /** * __try_to_del_timer_sync - Internal function: Try to deactivate a timer * @timer: Timer to deactivate @@ -1595,6 +1616,9 @@ static int __timer_delete_sync(struct timer_list *tim= er, bool shutdown) * lock. If there is the possibility of a concurrent rearm then the return * value of the function is meaningless. * + * If such a guarantee is needed, e.g. for teardown situations then use + * timer_shutdown_sync() instead. + * * Return: * * %0 - The timer was not pending * * %1 - The timer was pending and deactivated @@ -1605,6 +1629,48 @@ int timer_delete_sync(struct timer_list *timer) } EXPORT_SYMBOL(timer_delete_sync); =20 +/** + * timer_shutdown_sync - Shutdown a timer and prevent rearming + * @timer: The timer to be shutdown + * + * When the function returns it is guaranteed that: + * - @timer is not queued + * - The callback function of @timer is not running + * - @timer cannot be enqueued again. Any attempt to rearm + * @timer is silently ignored. + * + * See timer_delete_sync() for synchronization rules. + * + * This function is useful for final teardown of an infrastructure where + * the timer is subject to a circular dependency problem. + * + * A common pattern for this is a timer and a workqueue where the timer can + * schedule work and work can arm the timer. On shutdown the workqueue must + * be destroyed and the timer must be prevented from rearming. Unless the + * code has conditionals like 'if (mything->in_shutdown)' to prevent that + * there is no way to get this correct with timer_delete_sync(). + * + * timer_shutdown_sync() is solving the problem. The correct ordering of + * calls in this case is: + * + * timer_shutdown_sync(&mything->timer); + * workqueue_destroy(&mything->workqueue); + * + * After this 'mything' can be safely freed. + * + * This obviously implies that the timer is not required to be functional + * for the rest of the shutdown operation. + * + * Return: + * * %0 - The timer was not pending + * * %1 - The timer was pending + */ +int timer_shutdown_sync(struct timer_list *timer) +{ + return __timer_delete_sync(timer, true); +} +EXPORT_SYMBOL_GPL(timer_shutdown_sync); + static void call_timer_fn(struct timer_list *timer, void (*fn)(struct timer_list *), unsigned long baseclk) -- From nobody Fri Dec 19 12:13:28 2025 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCD962FB62C for ; Fri, 10 Oct 2025 15:03:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108635; cv=none; b=pxebjIDU1RIgyXQOM6/RbnaUbWjYm0DP9VfqSPzWrl+nmt7xHVaKXLbVpmgPpRVkbaukd9ZX6MLdOTXDPz4USUUn5aw9gnqXmANLY+lCXHW+icYxgVM8mINTwuETssHatwVdS5rzsho00aljxXCB1QkvhZR5ZW+svnalZxM0zso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108635; c=relaxed/simple; bh=e1DK8j+FiXmlj1eFN8Izgd5UcqsQJns59AycqwDqK3Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=rPo1C4UUYtk7/DWq516HV7bIrsuCX1S6RpdMe4+dU8lH1un2F88TRplNJJOlTYM9rzfccTcaAIMPy9HoUh64Y0C+s21ivqOXPbU8lQnNeAYlZFdiF95NUMUMSAiLNOo0NlVXopEr7mUk3h4Jg4gkSD81v9myEZCYDIP8u2HkR10= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=M8yg2lEK; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="M8yg2lEK" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-781001e3846so2139517b3a.2 for ; Fri, 10 Oct 2025 08:03:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760108633; x=1760713433; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UGmuQqZjeUhbRmxIHTmmKtGFb/p0zxMormCTfTuA8dI=; b=M8yg2lEK0eQ8LABS4EHF3G0aJHw0OO9hjmn7LMbj8YoIrf0ZAKiZClHet5XquX34p8 VLhGv3r26y59xEjMUaR8ZT+Y+CJhhYp88SbYQ7vRAMD/afi0Edq2C9UtCjNssYRHFMWO RMSDJRpubVBdpm4j79o5URT4OI+Qjz4r2cO+5aKxT9GjiuUVHQ0VIM3T/0txvVCj3YNI ZG3kG79jddBzjBzycdS8wPMbCAc69wDV2O1QXYB5c8NYXsbRzM+mBj7BZLjKm3FsbqHH onm5sHpkwst+yp1/g32p0gLMnlqrc1OTS0khf0bJGPRGtB49u1jx6eH/vLsGLSlBYlgB GbBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760108633; x=1760713433; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UGmuQqZjeUhbRmxIHTmmKtGFb/p0zxMormCTfTuA8dI=; b=pVqk5Gr6yjVn+cjWtADopKbwfa4AUFBdKMy0pKnzbPTNQ6hc1FkzmF0RblWUlHx2eD 1DUFxariu9NqnhX28aBGKH/Il8Tsv1WLmyLnoUkiFsp7rtnQkipAgU1LLJgiHPpBzDba x4SksiuyADZx8kIGqYH9E1p3et7rkA9ESVqwarRc4eN5zErjiyqWCW4V84rMWfw+4z/T DRgJ3fOLxbsE8Puvl05Ok256yjlW8UxMKfw8mpQWcFYzrC2XoY1b3PO1ttknPruNMpb6 bwU3F3ShVXk36o7Hf65t002mfuN3ZYBoqfZQmeE6WzpbYpRlct5fU7z5c5m/ghz704WE 8ZaA== X-Forwarded-Encrypted: i=1; AJvYcCVNQ+88TgIVZfx+yJFKDwWF8KWwDQs3dnaDyOUjJjKhagFwSbRFVcHln4mejB/xs0S2/2nz4Mqeh37VQ1g=@vger.kernel.org X-Gm-Message-State: AOJu0Ywbq9kf4S2WQgfuqMAhWzN77r275qYsWsjpGhU63gQWvARv8Asn sgLxLLNsu2btU8CDMdJ3kptNyCB5rAJPq88lnqw18a5T96uwe5xrTsHD X-Gm-Gg: ASbGnctnj7nJE9yed+zoHxDew9ajAQPQedKNHfCn926TpNOCike6XKPngskvKiH+Ahz DhheEAcdjaLNhXLQNYnLVFZUTIzLBrI3aD/Xm7tIaGL/A59x3nOSjPzqM5F2Nd+D2ad/3X+Oo8k sYDb6EHqGcwTlIlrcb7tWgrKuFCojSDHYt1R4rLOYqPfE9BfEI/FicZMxg/drRXRXeq2fYpYdeC 0s/UjwWgmpVvQ2QCv4kCfvBGnM1DP4BJHvS8kp/2Q3wSnMS+6uQYwiENE6PqyYQPOJTBr+faT/A KP64i3U0aCHlVfTliZD24dhLywdecRmtcVjn7Dv6UG2isDgp8i2SSRKDTIdxPQ0Z1AhjAPX9Ta/ KTonIaySAmj/N36IvQd73oPDi6UUPMOZzDhaAef2Uy43ZNWDdFWD2hidGxhoE9bxaxuRN X-Google-Smtp-Source: AGHT+IGjzwugYg2s6sAV1EGo1X7orkT1LFT21fxzMkAVvt7JQEZDZ/htyUsq6DK7NaGUctCAjKtjzA== X-Received: by 2002:a05:6a00:1495:b0:776:20c2:d58b with SMTP id d2e1a72fcca58-79387435d86mr15675430b3a.24.1760108632753; Fri, 10 Oct 2025 08:03:52 -0700 (PDT) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7992b639cbcsm3266359b3a.18.2025.10.10.08.03.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Oct 2025 08:03:52 -0700 (PDT) From: Jeongjun Park To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, tglx@linutronix.de, Julia.Lawall@inria.fr, akpm@linux-foundation.org, anna-maria@linutronix.de, arnd@arndb.de, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@roeck-us.net, luiz.dentz@gmail.com, marcel@holtmann.org, maz@kernel.org, peterz@infradead.org, rostedt@goodmis.org, sboyd@kernel.org, viresh.kumar@linaro.org, Jacob Keller , Jeongjun Park Subject: [PATCH 6.1.y 11/12] timers: Update the documentation to reflect on the new timer_shutdown() API Date: Sat, 11 Oct 2025 00:02:51 +0900 Message-Id: <20251010150252.1115788-12-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251010150252.1115788-1-aha310510@gmail.com> References: <20251010150252.1115788-1-aha310510@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: "Steven Rostedt (Google)" [ Upstream commit a31323bef2b66455920d054b160c17d4240f8fd4 ] 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 Signed-off-by: Jeongjun Park --- 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/Docum= entation/RCU/Design/Requirements/Requirements.rst index 546f23abeca3..49387d823619 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. =20 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 a84f8b0c7ab2..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 cp= u counter using =20 static void __exit test_exit(void) { - timer_delete_sync(&test_timer); + timer_shutdown_sync(&test_timer); } =20 module_init(test_init); diff --git a/Documentation/kernel-hacking/locking.rst b/Documentation/kerne= l-hacking/locking.rst index c447d55fa080..3bbb11ba647a 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 functi= on). Because this is a fairly common case which is prone to races, you should use timer_delete_sync() (``include/linux/timer.h``) to =20 +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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/Documentation/translations/zh_CN/core-api/local_ops.rst b/Docu= mentation/translations/zh_CN/core-api/local_ops.rst index 22493b9b829c..eb5423f60f17 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=E4=B9=8B=E9=97=B4=E6=B2=A1=E6=9C=89=E4=B8=8D=E5=90= =8C=E7=9A=84=E8=A1=8C=E4=B8=BA=EF=BC=8C=E5=9C=A8=E4=BD=A0=E7=9A=84=E6=9E=B6= =E6=9E=84=E7=9A=84 ``local.h`` =E4=B8=AD=E5=8C=85=E6=8B=AC ``asm-g =20 static void __exit test_exit(void) { - timer_delete_sync(&test_timer); + timer_shutdown_sync(&test_timer); } =20 module_init(test_init); -- From nobody Fri Dec 19 12:13:28 2025 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C29592F83C2 for ; Fri, 10 Oct 2025 15:03:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108640; cv=none; b=cCJ5I4T+NXtSZDGS8PktnyHgPjPSDsJxPyHtbfaRpmTPa11Arn71hxWb1NokddmzGrLnZV0pTGvIh46lJjHUSXTbQE9LS3imWp0zC9TxD6MAEhA9DbXBajVqe+ZTyGUnJ3AWVNhI11HzC1AASiA0aeJz0KOpAQIzQrrdC2TsjWc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760108640; c=relaxed/simple; bh=wtM3KGXEQuicJ8O+1w9NeLqs1Q3c/AYVobYXG6O4xkU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Crm69TFVHRszOXRaoSpbl6r0ukYNmIQrGQkngvdbsqAnTzFqcxp3PEneeWUtJPQMywFk5w8yj+jcm7tRuNlukQ0XX01MLd/kSkV/h1boaB5Qpf7XNBDxDWHV3K8+8ROBNRFp6pdm1/mhoQdAJnYYNQQu5MG7LAi5aq2d+nwDPXg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mAsA5XFC; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mAsA5XFC" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-796f9a8a088so1954695b3a.1 for ; Fri, 10 Oct 2025 08:03:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760108638; x=1760713438; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=avVd2rCSlmy3mzSueRF3eaj+JsVil8OR/Q+bsjGDE3A=; b=mAsA5XFCTxYVzysL5NVpD1wZXp+XChV0uF2ldflFpa+zYSSukIxbSNlJ0La6Ye0GQ6 8pti4wD1xjGtiAKABlc4OBOCYVFPGcXrk0TUIYYRSmy0nTmziep8oDRwAgCogmIiGDpr kmYX8NHduTUiv2YbDSCg93l8rPIhtjUS/SbW4X/fOz6KQyMSyDvEozgOM6o4qshmoT5h VZUfng6v+E5oN+UJT1ywO5764iWQq5NeG1e391o0r/1Kc4Df4L4n2/sZALKMnGUtfhf8 VcpjtZz1sW6jIQCoryQs8RQ1/5uA1Wk/ZaGBygN0y7D/2+aR0lWOTuahdah7MyCyFjVm lKnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760108638; x=1760713438; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=avVd2rCSlmy3mzSueRF3eaj+JsVil8OR/Q+bsjGDE3A=; b=d/oCsPN8PqTJQ0YtIx9L+0Oe2g/REwQg6Qjw+ZmNpEvDevr5drP/1xIXP2ztngeYal oCP5m/0aQeIqekbpQNz0FuOKm820Zu1KZ467VDeqAu2TSwUYjaliXMxkYPFN4YtOURkC fXJjWXoJlDEFkpE484MqkRH2zKey1psUxHLXMEPLpiQPq5QIVAHfj2GVp2x6ckiRNraT JlD5DCMvOLnqCwGfjpU+PHu7ut+kpiXzFWBMihcwNE6nmqpsBF3XvKz+1Fy2POE27mXW MMzYaK69uytzVwuklFnEIX0wmqwZDZNgyrfLaoJMkpg1/koDJ7sIPSbB9pIVDdyk9bnH ocGA== X-Forwarded-Encrypted: i=1; AJvYcCWDOrhV//YyZK4BGS61pJnGVlJSZJgts3/WjEUHP5GTMK+0acXeSy90e83wJ1FuCpSNAgu5lgSlj0G4k7U=@vger.kernel.org X-Gm-Message-State: AOJu0Yy20cNAfHVVU4RXgVakCoLvsyIOUxvx3H9RgLHap51w9Ei9r8nx rMrcpF2A9itRaKCbgWYeQZ8BBEAkDt00Y4bYRa6KQ33kmmHtze7tgY20 X-Gm-Gg: ASbGncuiArJE6luVqRD79uQ+QgYFH5W1WSNY2BX8ta3Yvkm2bfrMqdTmR1/Wt4eC3PF ds66YJsZMezGro5tmT2Ze+U0WbLcMStNeznaU2fw7lr4uvmAwzt2urvhiNfoVlsXaXWT/04a2jO jDoph5erayRNqmMUdf5Fu6nH1IfDXEvNCRQSP4YpYvri7VHet3tEKSJyj75Q3UuzjG/3O1UilXO liP/0Xw6t1CHWw6wqeZtJn60SuJnG0Ypx3DABlRcWCFQockE6NDArMmdPhmo7A33N4Z6o+HiCKF gyEqh6xcSRpIA3FJjb8jQpvLOLxTf6Y02wqwaoiBCM6Gojpxg2MqJdMA762JF0bHSdHwZyJJKda CZpLsI9A6xmm97+2B8YryiyQ5RC/Xfr3mc0ONtfqynLHxgWFpDiO4UeAhjQHBUm06w6SOw3PwU6 fJuic= X-Google-Smtp-Source: AGHT+IFXN/diK2DPzXd7rBmdO25/OaDRNzyiRkMUMQPIXVhrYKhY4WRAMZUZSE4jYyFbxCO9D8yEqw== X-Received: by 2002:a05:6a20:2451:b0:24a:b9e:4a6c with SMTP id adf61e73a8af0-32da845e56amr16399655637.44.1760108637682; Fri, 10 Oct 2025 08:03:57 -0700 (PDT) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7992b639cbcsm3266359b3a.18.2025.10.10.08.03.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Oct 2025 08:03:57 -0700 (PDT) From: Jeongjun Park To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, tglx@linutronix.de, Julia.Lawall@inria.fr, akpm@linux-foundation.org, anna-maria@linutronix.de, arnd@arndb.de, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@roeck-us.net, luiz.dentz@gmail.com, marcel@holtmann.org, maz@kernel.org, peterz@infradead.org, rostedt@goodmis.org, sboyd@kernel.org, viresh.kumar@linaro.org, Jacob Keller , Jeongjun Park Subject: [PATCH 6.1.y 12/12] Bluetooth: hci_qca: Fix the teardown problem for real Date: Sat, 11 Oct 2025 00:02:52 +0900 Message-Id: <20251010150252.1115788-13-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251010150252.1115788-1-aha310510@gmail.com> References: <20251010150252.1115788-1-aha310510@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Thomas Gleixner [ Upstream commit e0d3da982c96aeddc1bbf1cf9469dbb9ebdca657 ] While discussing solutions for the teardown problem which results from circular dependencies between timers and workqueues, where timers schedule work from their timer callback and workqueues arm the timers from work items, it was discovered that the recent fix to the QCA code is incorrect. That commit fixes the obvious problem of using del_timer() instead of del_timer_sync() and reorders the teardown calls to destroy_workqueue(wq); del_timer_sync(t); This makes it less likely to explode, but it's still broken: destroy_workqueue(wq); /* After this point @wq cannot be touched anymore */ ---> timer expires queue_work(wq) <---- Results in a NULL pointer dereference deep in the work queue core code. del_timer_sync(t); Use the new timer_shutdown_sync() function to ensure that the timers are disarmed, no timer callbacks are running and the timers cannot be armed again. This restores the original teardown sequence: timer_shutdown_sync(t); destroy_workqueue(wq); which is now correct because the timer core silently ignores potential rearming attempts which can happen when destroy_workqueue() drains pending work before mopping up the workqueue. Fixes: 72ef98445aca ("Bluetooth: hci_qca: Use del_timer_sync() before freei= ng") Signed-off-by: Thomas Gleixner Tested-by: Guenter Roeck Reviewed-by: Jacob Keller Reviewed-by: Anna-Maria Behnsen Acked-by: Luiz Augusto von Dentz Link: https://lore.kernel.org/all/87iljhsftt.ffs@tglx Link: https://lore.kernel.org/r/20221123201625.435907114@linutronix.de Signed-off-by: Jeongjun Park --- drivers/bluetooth/hci_qca.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 66f416f59a8d..204ba1de624d 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -710,9 +710,15 @@ static int qca_close(struct hci_uart *hu) skb_queue_purge(&qca->tx_wait_q); skb_queue_purge(&qca->txq); skb_queue_purge(&qca->rx_memdump_q); + /* + * Shut the timers down so they can't be rearmed when + * destroy_workqueue() drains pending work which in turn might try + * to arm a timer. After shutdown rearm attempts are silently + * ignored by the timer core code. + */ + timer_shutdown_sync(&qca->tx_idle_timer); + timer_shutdown_sync(&qca->wake_retrans_timer); destroy_workqueue(qca->workqueue); - del_timer_sync(&qca->tx_idle_timer); - del_timer_sync(&qca->wake_retrans_timer); qca->hu =3D NULL; =20 kfree_skb(qca->rx_skb); --