From nobody Mon Dec 1 22:05:06 2025 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 BA225285406 for ; Fri, 28 Nov 2025 16:05:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764345955; cv=none; b=cw6Iqng/udPpJW3HRBqDuXE/5nfd3Gl2X+P4e8RylUfJZDJSLuQzmhSPtWvsCLfZww44cAz+wbWlIXKuFSWBV9evdT2uBwJjLhuocGR3LpoZkDeIe+4/+N13/EtIpu19ZjsGm+MR+jQDug4+FQFE40JTpCuR7/7AWJ8BoZD9Bo8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764345955; c=relaxed/simple; bh=BfuWtJpHFnoUxb8s7xJBVcBtioNVHYkElOeeOAD1d8Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=nwKEAgP1N3SKeKg3PGIw893uuel/z+Y9aCo4k1DEOSXrUYdM0dwoIiwVUhvxvDr89Zy/kQ7Llg51IxULG/Cy7s1rSCMxRSVqOp/ytisqzi0aW9cjqW7yDbEkrIcqJXEXznhYUEnFyxMqMBdQZGvs4jMLUCyxPBMltqR5Unq4hQ0= 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=ZIp7FjUJ; arc=none smtp.client-ip=209.85.210.174 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="ZIp7FjUJ" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-7baf61be569so2417610b3a.3 for ; Fri, 28 Nov 2025 08:05:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764345953; x=1764950753; 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=ZIp7FjUJ2K0go7vjjinxJFHzyZlBRz/ZV0MiR/VJUaJxe7yVtl9coSWY1KQfil1Alh v7/Xj/TIkg+09AA9lGvxcjPvrWjwrVcNwGf9LXE4XjTxIxjxACblZNge+GvcVYQiCUrM 1ds2/q8smKNYPGbQRrfel5/RiDDi9KLSMG9BaCO298eDRDr3lYlb0yn5CFYgO71A36J3 XzcBgPY0sILL5GWIdba78nGV2bia6FH5RF8qHK7efLK4bdUb90lyty7NnVyLyTE8JOLv scr6qyIUiO9r+ckVYl9VfOvuyPv8cLypXLBoncy0Q06QMY2dOlXKcAf7m7w23KpLXQIj sfHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764345953; x=1764950753; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=rGAsWoT0ij2AF8u7lzQ99aTp0zEqYgQwfONKoWXhuNs=; b=LMFzgTMTmFEZp+j4zz9X7QCpsFZHABH7xVyy8veTyzF29Lr+V6cov4J+CWXdFjUO48 KhP+oDaBBlK6UlABEnnmx9an5CqzTYlWqgvbuJzcJd16w05yuy2QfBrXFZRfl9rivCGH tQFle7RNQZyUtn/Ysqwx+Aj2Vy+/NaikUgPnwZ9HM+Tw88ZQdr/QXzp3Uzyx3oA53c/4 GD2HJAMvrxlOEmm479mJYOY/Dfftk71T3WcU8UqnhlyYiIV9J868rp82R7e0Gc8lAAEU oqQKfPY6pWJyMScjQZYHrlIEBKqgdSR4pz7Y/uS5hQ2GIeisASDtAre8MWD1oaKO0Ou0 iWlg== X-Forwarded-Encrypted: i=1; AJvYcCU2gyNh2f/B1rQyi3+PtZd37nFNWP86HHy0zVL1awRXWEGX+94PU+IB3tDdvgBOqoEvB/jnKvG8kX4/2kc=@vger.kernel.org X-Gm-Message-State: AOJu0Yzl8yz6bZDOofpnpmp6IPSlRecmXNbTR4y88lpyFKCXno4RHber axhhP/0nbwirkaTzkeeJwh4O6XgR31RiC3n188bZsWDRxBYdP+GbPBmx X-Gm-Gg: ASbGncvW58MXf09ld6LDlPlaeCUv1lA/WRXn5flG+8e1GJUYIuX00/P20QHyHAEcOLR ruxZSBAURIo3b+fdvExRPW6SR75bhiFvCt6bQHg5jDyWywZEmFHBTmN3cXoa5V3a2Odr3euHOjZ O2Ti3MS6H165EW7XAcI0yM2kRUH9qd8DH1aNq/Kd7qb3OpbVMfoul0FMd3Ob6Eff8BWYZmAT6V3 K8faZ9X/7trbleIkX0NRu8fn7yEAHTyt0xeNpw85irSS+zHQVbvcymZJLBCgXAiERS6nzRgw8sv VdfmE1oBb0tfPClj3xxqFmIN4xQhXu2ysPh6DKUMtDg1ZpEwJQIFn9Mr/fZ7ZY/fAcf0S6R2hQ4 hgkonm+BZCVsccVUt/pqywcr4FG4TkBieyaXcYdOVKL7Tnyb+c5RHHFhOvI0PCqa4AdsDw2HmJu O3pcEsYsWXuFO9hQJAd9wtpLuRZcUX8qX1etztt+KoVWHiZPpG X-Google-Smtp-Source: AGHT+IHy5Mo29j/CWbee5Q6OSCJW+TSTmTNfb4OAc8LY3nxwbKHubZG/p57p57Ap+fsLvqvjiDlwdQ== X-Received: by 2002:a05:6a20:4328:b0:350:fa56:3f45 with SMTP id adf61e73a8af0-36150f033c0mr33804804637.35.1764345952577; Fri, 28 Nov 2025 08:05:52 -0800 (PST) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7d15f26f11fsm5408499b3a.50.2025.11.28.08.05.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 08:05:52 -0800 (PST) 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, aha310510@gmail.com, linux-staging@lists.linux.dev, Jacob Keller Subject: [PATCH 5.15.y 01/14] Documentation: Remove bogus claim about del_timer_sync() Date: Sat, 29 Nov 2025 01:05:26 +0900 Message-Id: <20251128160539.358938-2-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128160539.358938-1-aha310510@gmail.com> References: <20251128160539.358938-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 Mon Dec 1 22:05:06 2025 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (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 EA1D5280318 for ; Fri, 28 Nov 2025 16:05:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764345961; cv=none; b=Nm/HqJCUAIXHQolcwPMjJwqY129wRiZj5TDtc5vwect40/tguK9zNVKrVuUxFoZ0Woj02gOk7GQ2kwh9u6Nh5qEyEgbqht+UQ+FYwxce+hHcglypr70t4nXqj2m0kfU/MzWVFTbl/4bEDTuuWne/pSCI7++IW06yZNsSleEmzmo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764345961; c=relaxed/simple; bh=FgQfbLiyDT66S+sNI1wE/oslfO+pvzybNJFnYppNieM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=s+JVFskdZ12dBEnpD1Xde35aghj9RkiyOFMlbCotB/cFjl8G54f0DyKBuIylYLwJDsTU82BNJ9Wdw+zcamyHA4tVDmnuyiJZYZ9HJSSVza6H/ad2TOQAks3LcKqjE3HLubsfXrFz5CBs3dPAMcX7dU6yLMcyq1D6rD/i421XA7E= 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=UVsshIDi; arc=none smtp.client-ip=209.85.210.181 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="UVsshIDi" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-7bb3092e4d7so2101529b3a.0 for ; Fri, 28 Nov 2025 08:05:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764345958; x=1764950758; 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=UVsshIDiMTeVetzWcr46lZWBkHx5enSo+AAFgzbi5/pbetdKdEdL2LPflg7bmTqEVO npp/7O0T+IPGSzY5kZ6nLE6nAfYVqumDxspQr4yxnoIfPHZAa992pkpNlPGAjYu9COeg sTRNThIoaXK8yNO6mJGcGzMm0TT6r0VNwsnlSj0QX+IWgiUGKdPwbee0qGuKaOQ+pATz 0/Le1ChtWm1VN3eOOKipDtUMm/XWN/4C1FroPL4oNOXgLP4wVDJjGR3TEwbtiFcGgZVo pcbVs1G9qid4+LbrxPKzNNG/C7qDgZhMS8K3iPoy2xg9P3LBAmDe4hXWg0r/yVQHVzem HNOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764345958; x=1764950758; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=89KuTptWUmkm9h+FhspeGpsBdyDf36NNXIP8b7hhqek=; b=BQPJ2KxE4sWlzCs2sD3ADv4JcxH8UhK32pivTvK6EVqnjz0FPqLU9ldGtMBJBYS9lj RlEnT+UiCyZ0WtcIJ+xtN21VXGzF2SwXU0NIkDIDqYDz+e9eN+TkCYSgXueeztVpsxgX 6mmM5CH7syvGZH+dlRPfg8BgILdRi+RkUXDaMjCtVFs1JmZn/FUPulxseGzOT6yYaRF+ tf2249Zs+TIXuokJocnNLsKBVAEIBSyNIo4hJ5B7BQ8SQMwmlg89AKssY3vTqhtUYDIf a1HrKhu+BjAkXKYMtUk2cZejaJkhgflyRZ+FmNkP0khk6kIwnMzrEGdJ0jz/e2yubNnQ YZEA== X-Forwarded-Encrypted: i=1; AJvYcCUzrpAaWK0grR6AV6v45nrlyl4MeS9HvUhhJKr1603nfasblI6ZlwoqzrCzSwA2KskHbsAlpQU9uOaFbvs=@vger.kernel.org X-Gm-Message-State: AOJu0Yy46410B3qYFfS9z1PansJZ+UsgJ2WPiDBIpE107vTtc/idTdc1 xSmwcsQgqhlTMwwma8EspApw4H/D4SZcG60TWfgekgMlw3/mcA+ZEvit X-Gm-Gg: ASbGncumXYusPi8sDkEccisFwp+dSu3O7CfP1pbJD7rMLD71ydfz8dcRh2qyvpat7bh XKPl+PoKn5iy8ywbcjaCDBn6FubjjnkocHzA8FHa0qFXgJ/hMVXXI/kLx5E9PZafNTZS8cVVElG rnIhtgRKCleX1pnT2TWEtPVzw9sSNoTfSN2xx7pQxy1bGbaziQbuWI7mLwy5VbsPhmBItJ8k3mf PAy0fkR5AomkP2NITpsiThgLTkp18BRh8Cbavmwwa4nO0ZsGPQkEQqfwonlfBGRH+g7ixdGLEk2 du9MYQvU1eFmbmhaGTGcnewhD383EjnIJO4wL1Or25+F5GKriHjivauDf1+ihr5DrOgYSlkXRjp dfB3qXYHwPuCiTV94Yv50FiV4rsVtCgwgQhKn/ZsQeUyvb1k6RsPE+2T6/WujMEGZezxlXNeMPs 0KyXj+5P2U3N5HNmkAzjylyJXifLQzBIr1ljV7lg== X-Google-Smtp-Source: AGHT+IF0Q8QvQVgk/GlOhROATsy4H0jZvj77M4n2inngSNShmeeB6QTjv1ds/QlTk5r7jRniqk/a7w== X-Received: by 2002:a05:6a21:99a5:b0:35d:53dc:cb64 with SMTP id adf61e73a8af0-3614ee0a109mr30924321637.54.1764345957992; Fri, 28 Nov 2025 08:05:57 -0800 (PST) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7d15f26f11fsm5408499b3a.50.2025.11.28.08.05.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 08:05:57 -0800 (PST) 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, aha310510@gmail.com, linux-staging@lists.linux.dev, Jacob Keller Subject: [PATCH 5.15.y 02/14] ARM: spear: Do not use timer namespace for timer_shutdown() function Date: Sat, 29 Nov 2025 01:05:27 +0900 Message-Id: <20251128160539.358938-3-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128160539.358938-1-aha310510@gmail.com> References: <20251128160539.358938-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 Mon Dec 1 22:05:06 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 6DD632900A8 for ; Fri, 28 Nov 2025 16:06:04 +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=1764345967; cv=none; b=ooazzE8g5epORkhLpEEXOMlLDwytOyBy4StDRw/vg4I2PmLHTCkGUZvFu5UjtU2r009QBlr3yaQWQj06giBbCNZJUnfT8xImNR3w/wlkjfrGGG/7gycQhEyu4sF5nJFVv1EhVk0w1rIxp5870X71A0qtyc6gxRxWTW8DeUe6sgA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764345967; c=relaxed/simple; bh=YY7i+ekw8WEClpFqVZfbZbIPcOFXG9mqoVtYSHhdgrE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ovKsFvdUOmcoReE7wQhPZFjpGpAPzZL6kgAP4CrJVr5uEpHmiH/MFXp/G1F0fRnkBuJmIz/2JEvSOeY9cfrwnR4OIJI9zkMYwthfSDZ63fIp0kgZmHCV5mgs17o+VLde8aF84UDRMdtuJmhG5/KMncEKLg8O2pfCXWqGMVGhKLE= 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=QSVWatJd; 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="QSVWatJd" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-7aa9be9f03aso1777513b3a.2 for ; Fri, 28 Nov 2025 08:06:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764345964; x=1764950764; 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=QSVWatJdQOzmUezAOc32ZH0M3/HAPWABCph9Uu2t2OE8NaVxreBhIAdD9FWj1TomRy BOErNd5sD5m4b549B7NOOR6yueHQ1atWchkQ1P6u9nmD607PTEctMYr/1Llp4n+HEbn5 1UdFcap54P7mVQbCdvwyg/kznLTItf/9YnG6Q1QzoaDN4fJwQF2Rr8iD1crFQTjjZXzR xPWDARJI7hixToZN0fiFAo+4J55QPok+oguDdDZS/jJrenHTnwwhHxMOjwD4Ese/RBDd rvwDPKREk5KoAvvGmkuVEN3/98MEPaQ51U61otD9lVnOMTKu5fTFYmRd/XmzXuHydszP WL5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764345964; x=1764950764; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Lru4V+cwKFfxLK/nzfZUd/f7wkQ+5dEE9KWoaatQVPo=; b=LOFCe3gOHP7ozh2ZwP6DWk5aHOqBdTuwG+4CS80ZCfI2MahbruazCiWBAo3ascdjhd 8aYwus+6zlSFELTzaicG6iFPNUYdk8jl6B2gqD5hFv3xicfSJjTCDW3ZZZs8JBNjWSKm VGo8qDRUFBsDOWmvy+rcK1FXnb96Qv76yOC2rEf788xsnBhnFh+8PCDMD03+mCaqPDKe JBqPQR9lL05tvHk19udJuX47/Og0jt9pN7j6+2lvtBU6o0vzBRoCNGI34s7vvPv2Er+A 6SAqMY8VRXO2fkZqfNK37LRBT+oFpUhI5G/WJAn5bcoBd7SwAXHaAXXoDmNryN0Huxfq 7m3A== X-Forwarded-Encrypted: i=1; AJvYcCW9GuupECe6lVsrV+z+QPPwOc5kFYDfGiaAi2VBVfPeZzORlBOE988o9V6GAux1m6Uqnx36AgI1HJfi9sM=@vger.kernel.org X-Gm-Message-State: AOJu0Yzawuki7s5iXpiepqFXdkcFzwUxFNj+HDnIQRoaUa66FXADFCBQ Hq4CLrtC8HN/U8YqNJHLemLIwhVvnYKA/wBa29W5jm+P1PeyRGeOpR3d X-Gm-Gg: ASbGncutWIjEZoNEUKjdydtPRskR/Dbn0RFUwhW0f6cTnTHlmQpCLLkCpXCELcq2NZu vW77W1ZVBCNRBliRgswdrtA0WD13dlH7+mtp7fuWDoQ2PAI7NMr7jvkJgDEoVT8dC3r9Mg4GwEG DPh7QodWzRkJZGHiAC0/H9eQKRyUmn7R6zZgAJSohkoSNk2xknn1slnEIbfrQ0T1dMzgpgU+D1A cyNRQPMs6DOdrlynw36GSRBF0w/ZL8t5nUefzVw/5tM1SU6fFmFg+EsWqpbHcMjaCdhDsPhUGWJ XSQw+SopS5GCEk1a9Z3iJFrRJrq9RF+aud+mUccstj/YVHqZHv8K8oYQ6XUeLtibnZv1Jo5az7/ URhXvHcN4ia8MZjV+Hx/FN4Zv4DO/CMt1KjQSugDJMblsPohwTCwCOOmLJs+W2Hu0RWDoTnWynn /FDH0pMfHYWE0CbDD3GFtCrXIsctN1voQHf08XAA== X-Google-Smtp-Source: AGHT+IExmbTt0di4gnbgeXwjl0MdJHHrgB9GIijfMB5lD+egrT6JfkOALPfqqLh5IPKK0ig7n/DpYw== X-Received: by 2002:a05:6a00:1383:b0:7b9:7349:4f0f with SMTP id d2e1a72fcca58-7c58988f7camr27966972b3a.0.1764345963342; Fri, 28 Nov 2025 08:06:03 -0800 (PST) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7d15f26f11fsm5408499b3a.50.2025.11.28.08.05.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 08:06:02 -0800 (PST) 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, aha310510@gmail.com, linux-staging@lists.linux.dev, Jacob Keller Subject: [PATCH 5.15.y 03/14] clocksource/drivers/arm_arch_timer: Do not use timer namespace for timer_shutdown() function Date: Sat, 29 Nov 2025 01:05:28 +0900 Message-Id: <20251128160539.358938-4-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128160539.358938-1-aha310510@gmail.com> References: <20251128160539.358938-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 Mon Dec 1 22:05:06 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 02AC0299949 for ; Fri, 28 Nov 2025 16:06:09 +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=1764345971; cv=none; b=qSsjqXPiw/QxJDPlLgpQ0/iUlvVEmY6g2ywWGQkVWBZ/yCZo5pzricY6vPqkzSXjSej5I20FZFjffLsvAZl+F++RwplzDGXUKS3mvFAqj8ZPSHWRzS0zdok6fhfRfHMA9QFrrZ3kPniJyKzlyEnqD4opSjV/SIunezeMXtZWbE0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764345971; c=relaxed/simple; bh=kyxULOv2H236l1ucHIwcTRr5nnWT32c4Zye+wWGrJ6s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RZ3yDN0tzzdAiR1Ae2Ex1zfzYyCg1ZNkiTpDtKBz99W6aIV79FKzkcpoKEP8jB6x+LTpKroQLie91odWRP5t6cqPwjWAVfU60M2UMi62BUY7JEvWDzAoBjvvk4nTm/pMT39YsvqwZtyPxy2du8Dz76rcss1IYIL7maMiVDrDoFw= 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=eyM8s1BT; 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="eyM8s1BT" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-7aab061e7cbso2375406b3a.1 for ; Fri, 28 Nov 2025 08:06:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764345969; x=1764950769; 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=eyM8s1BTMyX1oGBZTd2t1P1Sx1RuTJrbg+m0cp5NyI2sJYl1ugBXBoKpIw2rpIQmwa Lds5c1D+utJR3kPxXcuFKgEWZu97e07x05cY7Ls4ufsOGq9EJTtw9U/RmU77tDD9bm0T ex7NBkL4LlXZlBMS1dhTL0eLMVlgshUzDujvTzXcI2Ps34gbfyhWpWR44a0HAOsL/1iE di931BFELJCQKjZvHPkdakotzHWI/d/HR06uV4drCQRpcNcav2uvPAHGEx7We1VoS4ei 7SjWggvfV7dYefyAWWxc4X4P1STNylUQA6JqTjD5VDys+qhSSqQmpnGqN8E749ZkN3UE CseQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764345969; x=1764950769; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=scjH6AQBXgOEyOguxVYTHq5LOFFjJgFpmI1fsS6Z7tY=; b=UB5VO9k4/7vx2dc1iW0hflFtPInHkJQCHBeQ1MSz4vfKzOg/o+bQDRAK4cyGaWK9WY vGtwIFd8SmxZl6xhb7FC+oHBcuOpQXzA3ZEr9c5iwieUPtT5A4nkN3xiwXC4g1Cty8cj nsSEf7VHsF+ve3fZGnoewb2vcb0ETT8ryNIr8F/53qGMmlltlR8jbnu5GAvzIsQODrg1 v9eqpK87G7b0ldseOLJ2lvJ9c4SIiSZ4Y4gCooyhuh66eD0AevaAkftEtnxFRiKCXyRH vXntO1tBonBzUZns7jEkmAYzbB7NyfIc6LCpGBwX3ci88N5TCDTagommIM2WNxgPVEwR EOQw== X-Forwarded-Encrypted: i=1; AJvYcCXehrXb+D04TUNyBjky1KA5NLFgBHZReGfSS/l+LbKTV1leRb2whlPAGDyl9f4w1/A6N8Anm2XIoTAFOQI=@vger.kernel.org X-Gm-Message-State: AOJu0YzEcPyEpRj+6VhuEubYwuguZZu8ALofNc2/u/1vO3Qs2zPCaVgV HhNg9fBpAEyGsmOu8P2ssVX417dyb8iILko1T/JuqyDJHEq/LSAFMAw05RrRpRvrrwpLp4gI X-Gm-Gg: ASbGncsuLAigdzuy7xzN9+LP1KCvYxmyMddORQaHRegt/MixzIMXarH93Dh376xsEq6 T3ducB3hJW83bUVOoXWj3VvlkcJA/zQrFr3tLh4AzsRODG6N65SkLBryy2LAHKdOab0PItWM59O 91rVH1035VcshYGKq1Jv/MVnoaGliwl2/56u014UJkT0RjjuE4cpLpwTXxqKxh740bafX06TtXZ DTVPR4R/nDKDfTZjDbbDLrJkqbStz3RDuHiZkLJrtLZ4oo6zQoMuDE0+MJbWLW6qQOi3DHNbb2T 7ryJQlTyeDbp6YRkUdIJkny1AeXltYz3tQyksw6b6REOove4DOpvbei8Ld2K4Y2siTkqaYFzd83 TWCodCJX4tpD2JVeOR8RVxVezVmAe/wgxJuDyqvRN3rZGDqaUN1bl1ugK0UYxlU5saBs0+K+Cxt g6VgF7j0+bZzj5f+sm5bchcbho36N33rGMtdRBWA== X-Google-Smtp-Source: AGHT+IHAtGLDzEpjYjWhaB+rR7Dys+EF0UdlOe5GiYObNTvZAonn+cDCVIEt6kBF0Ch2hk5wj+FaCw== X-Received: by 2002:a05:6a00:b91:b0:7ab:5d1b:2d18 with SMTP id d2e1a72fcca58-7c58e6047eamr29577558b3a.26.1764345968898; Fri, 28 Nov 2025 08:06:08 -0800 (PST) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7d15f26f11fsm5408499b3a.50.2025.11.28.08.06.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 08:06:08 -0800 (PST) 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, aha310510@gmail.com, linux-staging@lists.linux.dev, Jacob Keller Subject: [PATCH 5.15.y 04/14] clocksource/drivers/sp804: Do not use timer namespace for timer_shutdown() function Date: Sat, 29 Nov 2025 01:05:29 +0900 Message-Id: <20251128160539.358938-5-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128160539.358938-1-aha310510@gmail.com> References: <20251128160539.358938-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 Mon Dec 1 22:05:06 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 7BEF832C320 for ; Fri, 28 Nov 2025 16:06:15 +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=1764345977; cv=none; b=jGZ3HPdfPG6RfURKwQ8+iYgTWuRv2oDKIQKU4C+4XCUS67fKIvixvu6pjesmju7mas9+LwWYXQHn2S9zDLQJz5wMvkuSSO0IZrExe8C2JrhGMVXWR/81xFuSzOBB2fEsb1qPzpmu4eeLLpmrSMPR/I7VJT/UPgJ9HEnbdQ0nBuQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764345977; c=relaxed/simple; bh=HhT6z2DVcZ8yTv/m6DHxcDKqHPAmK3H4JJhD4dhIVH0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dASrakCUWTIRUlMC3mHmZJjY1jpKkge0Tj+M5gR/kUObfy+QmihdX3wheTj9maKoakFRAUubzCgpa7QEdW1dbUrybkJ9ONN3SGtPf1lC5oZObjRgM+zg5XHE1qecdfTlFECCApYbyBlTLpCikcaE/+fS12ka9jG7SWH3u5+U2W4= 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=QDAJp0YI; 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="QDAJp0YI" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-7b80fed1505so2458015b3a.3 for ; Fri, 28 Nov 2025 08:06:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764345975; x=1764950775; 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=2Ivwth3bvYn00MIlpqUjU3pfVj9NAWsfF7rOKTWPDVU=; b=QDAJp0YInzlKue+cv1quVOhF5wjp2MQKtZ25y/ab5AoqQoFav8QSfIRN3qgbtLzhZC mDrqmxkT33Ui8Fd0wqq6Mh+qngVGG0Qdbk5ZWOSRBAmbI0qrPE2zXwCJXrODPhk20lxf 9mFDcy8dWatGATCSftKHWFTdBc3Mw95YAgws3p6r76TpR21oAGcq1pTOsirQvv27DaRo TRf3RD+VYD4eKo6vMTDXF7Ysj7H+N2bJjVCst4f9gwpm1lDLCB6XJLb7uM6LHjR99zh/ inyGu3LBpma3g/U3T4DWJ3V7xBcjqXpO3KZ4+N+zqYvHFMB/ZD7dY2QKLNm9y+Ug2Omy mjuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764345975; x=1764950775; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=2Ivwth3bvYn00MIlpqUjU3pfVj9NAWsfF7rOKTWPDVU=; b=Ec5ehw7VyDfzOry3lMCqKwDPEpJ0say8SuhRzR1Ymc2IQF92YUmVeRCnSPT+IsyG9F LoHZIg70gkZsOmTk1dx5adziN3X2Z1Pzi+F3AH5FVerQ/AAYuWjy5BJDgEMbaVqCbZf6 ept6K9LNi852E1/X6lVJGB7bb3E3H/TV7QxWpPmvhXbAmGHu/eyG8snq3tAhExQfNi5m Z7Hj4OwoFiqi+2BuT0Qkykrx5LYgRiFC5UCs0NgI3s+d3Ek0wLtfCslW+T3rj7wXJqgT h5bT2EGV804Y2WrOd769vT2SL49mfMAdUk9wy0qLUIiT6eLo7FjBvQXhGv0ppFLUjZ7y 4SDQ== X-Forwarded-Encrypted: i=1; AJvYcCXy8iAmVpo/QSynZIwYWYlLVXQ/tyJTTREHWFNdbUIkURRJC9FionDg4wFp+yUUJ9iLPNLi6kheYxoSwcI=@vger.kernel.org X-Gm-Message-State: AOJu0Yy34IHFdlAfQxvDSD43Y7oVd8Gd6NSsaEx5qKyzHO7aK9PbdQ51 7DrlUpc0NeEWN5fJACzhGPdV4+0gVSwid5eoBoZ3hMOZip394B8YR5NO X-Gm-Gg: ASbGncunZyMZcvFNViO6rAzjJLCN8BCNTLacqBWd0xf1NZdxfGNTixvGyOW5ywV4WPa KQpWLszSIlKwk1xs8ORx5rwTygVRAVfUA6gptGtSFsncrrYm1RMQ63dJQPqV+XFle9mYQThGiED YG5KNTmThrq8ANl77XJYfB2QX7bEaWW0xOHJ0Ar96Ux7jemso3rCDBlnIs9UEw2mIiHUHHTcV3K 7V8VljsQgwrAaNtTTTbP0Zos5aCczDi9yp/n/VkuoA5WhmRVVNn6Xq/qabPtQrlJnK45xu7zDsh gA3YjiqZWOfmTwnCuUGYYsj3OjmJx3bTZBzwRPklJKEJuTnQoMUt2o4ACd5kqcVWvaqBi29Q6Ek TaAHlh/eqBpJCZmBZzXKeyMcx1WJHDjOIvO9aHB/sIcub/s8amPLUIa7iD1B/9+55vBO3ElGz1L hGrk5J5HaKfzNjSW4KDP3qRiD0lOBVHfnZNmdCqQ== X-Google-Smtp-Source: AGHT+IFt9S/vPqjUM0mz+GQlgswc6/I0j11kLNLh5CdF1ZTntqzS++PULCgN0F0Q/MhhEDQPVXOPYQ== X-Received: by 2002:a05:6a00:3e29:b0:783:c2c4:9aa5 with SMTP id d2e1a72fcca58-7c58effc088mr29961873b3a.32.1764345974342; Fri, 28 Nov 2025 08:06:14 -0800 (PST) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7d15f26f11fsm5408499b3a.50.2025.11.28.08.06.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 08:06:13 -0800 (PST) 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, aha310510@gmail.com, linux-staging@lists.linux.dev, Jacob Keller Subject: [PATCH 5.15.y 05/14] timers: Get rid of del_singleshot_timer_sync() Date: Sat, 29 Nov 2025 01:05:30 +0900 Message-Id: <20251128160539.358938-6-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128160539.358938-1-aha310510@gmail.com> References: <20251128160539.358938-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 9a5a305686971f4be10c6d7251c8348d74b3e014 ] del_singleshot_timer_sync() used to be an optimization for deleting timers which are not rearmed from the timer callback function. This optimization turned out to be broken and got mapped to del_timer_sync() about 17 years ago. Get rid of the undocumented indirection and use del_timer_sync() directly. No functional change. 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.706987932@linutronix.de Signed-off-by: Jeongjun Park --- drivers/char/tpm/tpm-dev-common.c | 4 ++-- drivers/staging/wlan-ng/hfa384x_usb.c | 4 ++-- drivers/staging/wlan-ng/prism2usb.c | 6 +++--- include/linux/timer.h | 2 -- kernel/time/timer.c | 2 +- net/sunrpc/xprt.c | 2 +- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/char/tpm/tpm-dev-common.c b/drivers/char/tpm/tpm-dev-c= ommon.c index 56e56a09cc90..c3fbbf4d3db7 100644 --- a/drivers/char/tpm/tpm-dev-common.c +++ b/drivers/char/tpm/tpm-dev-common.c @@ -157,7 +157,7 @@ ssize_t tpm_common_read(struct file *file, char __user = *buf, out: if (!priv->response_length) { *off =3D 0; - del_singleshot_timer_sync(&priv->user_read_timer); + del_timer_sync(&priv->user_read_timer); flush_work(&priv->timeout_work); } mutex_unlock(&priv->buffer_mutex); @@ -264,7 +264,7 @@ __poll_t tpm_common_poll(struct file *file, poll_table = *wait) void tpm_common_release(struct file *file, struct file_priv *priv) { flush_work(&priv->async_work); - del_singleshot_timer_sync(&priv->user_read_timer); + del_timer_sync(&priv->user_read_timer); flush_work(&priv->timeout_work); file->private_data =3D NULL; priv->response_length =3D 0; diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-n= g/hfa384x_usb.c index 0d869b5e309c..8687e0bf3315 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -1116,8 +1116,8 @@ static int hfa384x_usbctlx_complete_sync(struct hfa38= 4x *hw, if (ctlx =3D=3D get_active_ctlx(hw)) { spin_unlock_irqrestore(&hw->ctlxq.lock, flags); =20 - del_singleshot_timer_sync(&hw->reqtimer); - del_singleshot_timer_sync(&hw->resptimer); + del_timer_sync(&hw->reqtimer); + del_timer_sync(&hw->resptimer); hw->req_timer_done =3D 1; hw->resp_timer_done =3D 1; usb_kill_urb(&hw->ctlx_urb); diff --git a/drivers/staging/wlan-ng/prism2usb.c b/drivers/staging/wlan-ng/= prism2usb.c index 4b08dc1da4f9..83fcb937a58e 100644 --- a/drivers/staging/wlan-ng/prism2usb.c +++ b/drivers/staging/wlan-ng/prism2usb.c @@ -171,9 +171,9 @@ static void prism2sta_disconnect_usb(struct usb_interfa= ce *interface) */ prism2sta_ifstate(wlandev, P80211ENUM_ifstate_disable); =20 - del_singleshot_timer_sync(&hw->throttle); - del_singleshot_timer_sync(&hw->reqtimer); - del_singleshot_timer_sync(&hw->resptimer); + del_timer_sync(&hw->throttle); + del_timer_sync(&hw->reqtimer); + del_timer_sync(&hw->resptimer); =20 /* Unlink all the URBs. This "removes the wheels" * from the entire CTLX handling mechanism. diff --git a/include/linux/timer.h b/include/linux/timer.h index e78521bce565..3c166b4f704d 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h @@ -198,8 +198,6 @@ static inline int del_timer_sync(struct timer_list *tim= er) return timer_delete_sync(timer); } =20 -#define del_singleshot_timer_sync(t) del_timer_sync(t) - extern void init_timers(void); struct hrtimer; extern enum hrtimer_restart it_real_fn(struct hrtimer *); diff --git a/kernel/time/timer.c b/kernel/time/timer.c index d4ce3ebe2c8c..6cd908cfbad4 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1912,7 +1912,7 @@ signed long __sched schedule_timeout(signed long time= out) timer_setup_on_stack(&timer.timer, process_timeout, 0); __mod_timer(&timer.timer, expire, MOD_TIMER_NOTPENDING); schedule(); - del_singleshot_timer_sync(&timer.timer); + del_timer_sync(&timer.timer); =20 /* Remove the timer from the object tracker */ destroy_timer_on_stack(&timer.timer); diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 2db834318d14..2bccb5a90934 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -1160,7 +1160,7 @@ xprt_request_enqueue_receive(struct rpc_task *task) spin_unlock(&xprt->queue_lock); =20 /* Turn off autodisconnect */ - del_singleshot_timer_sync(&xprt->timer); + del_timer_sync(&xprt->timer); } =20 /** -- From nobody Mon Dec 1 22:05:06 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 6DCEF32ED53 for ; Fri, 28 Nov 2025 16:06:20 +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=1764345981; cv=none; b=GIVQm6QfMKgVKc/szA90yfjRbHf33CM6sHFRnCe8cJFJuXhJsikZF0LSKo0iqF5SJw9f6ke9ZvIRIFPZQQOWInHKLR80n4IwjbhL+pGNyYq3s88kXXkqWYbb7BX4zGjARpiTdUEn7qcgghgdKzyyxKs2EjxvHoHw2W1RIj9FDkQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764345981; c=relaxed/simple; bh=p4TRIPhh7eCXg4oL8eEB5Ly0L/lmhP7XDzG06yVs7As=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ot1XWpArZt/WVUPYYS3An6M1lCRLfyxSJiWqyriGcLJSpwMCwmzOqs0/g5hTbSpogWzEXQc+GPDCa4KiT389tc8pQ6mGGaA3tj2uVdjBe07MQu8NcGeONVPju3ORwA2w7Ff1gCtRHQTp2UVbB4X/FIOK84nCZ/IAjrLESw9flEo= 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=frEHY2mJ; 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="frEHY2mJ" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-7ba55660769so1739184b3a.1 for ; Fri, 28 Nov 2025 08:06:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764345980; x=1764950780; 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=frEHY2mJ7l5Rncm3cA/ZaOD3JYo++2nO6VWFcYAaLZxferXeZuUWGub4VehRO3fS/X KzzK2Jn1cVofOekGtlHP1DuNbasOSfNRKYbacrIaRmpgqLOOeYTt4PcbYQYrjicnw6fQ VAOBYFzPnk5839WRKjsDS2tAsnk3WiKZWv4B8v66YHKGjY8xljGP5cbFTEtI80kMn2pb 5Cs23tHv+JaycJk9XeZAOMIJY+MBeHel8aLZZWfMFAQ7MtiWtOJXlYcZy0Fi5MkogeAM zS38vMZ18ux0zWNWQouAKEaEG/WLTv6TW7/nejB2h++AQCh795zvCnmNqAonm+doVAbR RGPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764345980; x=1764950780; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=pWjvp+vOFGL8T/NXTev+NZf62jPu9HyIJqL4GkC+d9Y=; b=KaPEdNbIt8sVvrRfHEI+yGaUg6On5EA8hm5EW5HozIZ6OYGMYL00JjQcPhi4+Q1q4/ HtzsrTZgmQ960asKArDzFXpTaskVAdHZOzmyTDUGXhPHu5FIK8aN0yUN2QDDKEU9pR2T co+WRoYq6f3tBaSv7/uOEgOAi76NzY9TpQeTke4CWjg9g7qMEa+FhIgkRNYSy9Sm6/0B b+LvCeLOyLuBvAHoiJbx7KbAe7hV7CgTA2tVyGW1VLS2LIdgWqWAQZmoZdghr7kdpxDL fCGNFaB+vLlxVcd/aEVyblRDkuCtxBQLH2x0UAmMxp0SMEs3JDhY45ASkaJAbR9nPc5H t4ng== X-Forwarded-Encrypted: i=1; AJvYcCVCPTp+YuCy3eaEDGNnun+SK5F2WwMKDbBoEOyP3TdJp2dl/PynmfrZ24ZXSRCnCvft7JBvusnlC3vLe5k=@vger.kernel.org X-Gm-Message-State: AOJu0Ywm05Zsu2Kyw3dXtmxb8C8g2Uv91WCGyXbfFjkm4M8Ty6aR3YNS VRaRZaaXmZaTxDhLVeomuxF0Pw4kg3eIyQhQokmgNtnVXB/Z6S+SUJgl X-Gm-Gg: ASbGncuD5Sfmguu6iItsoR5KpUGgTg6fEHBo2u6NjgCy5elk7CUYgtrV++vqlFnEN1b TTJ8dQAF326HtFgefOsXiridZCKgXIb3RGKI0OROKwTSts7wwk+M6ivz4trZt6AqHfM2RNr759N ONhoLZKjJN9VQS0AhTl1Dozrqdh9wZTSj5aTW/psB2FjL8mTEe/IMFEhqqjCI7C2RcWJy+Wy3nW 2DnYUC8AEWE5nMMlbjJ0QvnrDdYcC9psbV8meXpRuoqyZmZg6HdneU/oqOTbfLd3GlYpYiiKSzh Jb/iD8XCvOrLCikf1rqtfq3bXpbC4BmGddbG4LfosIZcaoZswkBf2jFqKfFLgn9y2NrmcHWJFZD mfMvV3D6Ph9L12E96xDoU0jqngyP4cHM7evG6jKCgtMZ4W/8un0xgtfnpMpVeoag8OGy/a7xrgX /+ARxt6m/wwSx/uSwINxB7H5lJw9n0erpNomICNA== X-Google-Smtp-Source: AGHT+IFapLhQU9fdniLElMhOTBueBGSZ5wz5zku4Mw2lynCB6SmbEsu5fwwc8sIpEraRjt+Qk/oxxw== X-Received: by 2002:a05:6a00:181d:b0:7a2:8111:780a with SMTP id d2e1a72fcca58-7c58c2b1851mr32051480b3a.2.1764345979249; Fri, 28 Nov 2025 08:06:19 -0800 (PST) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7d15f26f11fsm5408499b3a.50.2025.11.28.08.06.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 08:06:18 -0800 (PST) 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, aha310510@gmail.com, linux-staging@lists.linux.dev, Jacob Keller Subject: [PATCH 5.15.y 06/14] timers: Replace BUG_ON()s Date: Sat, 29 Nov 2025 01:05:31 +0900 Message-Id: <20251128160539.358938-7-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128160539.358938-1-aha310510@gmail.com> References: <20251128160539.358938-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 Mon Dec 1 22:05:06 2025 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (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 F15A732F767 for ; Fri, 28 Nov 2025 16:06:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764345987; cv=none; b=JHEPpbD+mQTsuyAGBL0uMYrbzM2SIRhcfkIz7jwBALJGiT8zkyBlEECUWujy50rAGbQuPSKaLlQKkXVEMRllAs7KyRr2RPiHI/qPP2vHsjB6YU9Z0YJQdy+vy5JZQcgyYePlQOFVnDlYNaB1Y9dVxbbCkX22h8EqUCrXaYY5hm0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764345987; c=relaxed/simple; bh=xUOfVR4rsP4k4iSxfTxt28P2aCRP7f27RFLz88rROqo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jbFsMI79zx+w7/GQsgg+/TvHMU9zynszAIYw9BvJkWUP0ShdSc09GVKNDFrEUtKlB8qnLrUqic+Ecn3BTryw5/fA0LO/YjKSlqH1pBrx3EKuF67JU8r87k5smfHljqcumeF9cU/M6N7bLxlvsYpYrqHHnRIWm+Wu7LmNnBuJ7eg= 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=GONYey7a; arc=none smtp.client-ip=209.85.210.181 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="GONYey7a" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-7b75e366866so1013537b3a.2 for ; Fri, 28 Nov 2025 08:06:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764345985; x=1764950785; 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=5aRj16inyvCNx7XEzEMiTg0hEspzqpDmbN1/ltb1rWU=; b=GONYey7aKY1Qli2QU187NYWEtijrZYSSrGDyDZuvBWIXX3wPFvjFAq+dNrVsgy6Y1+ JIrpusGVJZfLpWhf34s+nNQ913aNP76l0V65Zf+45ZFze9OtXanXOSHSv3Hcx5FvzGeB b9dL2tuXLzlBQXJAsbgRQ+1UMrHJKKj4AHLcTsRIAm+lsauWgWxAWaioTbHgjOwxmEVf bKRn/mkrQ1aPGyxDxyeoelB3cOSoTwiqITvyw62mqxLRdxoa2bex/T4iKogfQzm4elyV IwX+0h4nPo8mUep/HKJaRVuVJYXewWPdphBZUQRBievnctv5tdOW8oROQJHEcrXLXyaY lnPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764345985; x=1764950785; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=5aRj16inyvCNx7XEzEMiTg0hEspzqpDmbN1/ltb1rWU=; b=NmB0X68DxPEe3EFGIJzh4MT/LDvXGecszYUlZPuz/s9g9iZikJ41rxdSB6GQxaYjA3 GqyqaSu4S6CyEdOtDYe8SFNTe8dWkBxF2wHd9DjsQReA1je3DBkZrteDuJV8KYEAIIBE O5UnDgV9e7HIN0XRm2JQias2AZXCLscAFLMz6uM5r3UKMzI6Rz66GNoLO+jgjDJdhUdr iI1Ax+dF7l4SFfPLtN12AfFdIwj5Tw3BaJHTxwtmrFXX9Q3VLy7LEvglkMJHR/2XsjIC 491YnIPLxTOP0+ujWBEzcBRkMCOvQJlIg5MhIETBMIhKr0dI1q1jA3hvUDGXrkM0cpFD NWrw== X-Forwarded-Encrypted: i=1; AJvYcCVBdDECjWRmbNqEjqbMIyD4GwwXGmL6v4vzVDN4Nt4HYUB2QOHMdUw5JSdjAW1BbR2/gSyTa5nV5SIQ+jo=@vger.kernel.org X-Gm-Message-State: AOJu0YzC6/emHF83crHzJgos54rRnAE9CM2O53orVTH5soZjVZ5aL5Qb 6bxz8VA2EcCcP1AKBbEJXFcpXlrTuy0lLKeIzyI6+v9YZvVhGMwZtmJe X-Gm-Gg: ASbGnctuLuJncap4hkOb0iRWZYdwIIFFM6HblnlY2VtoX9rihvFFwbP9IuCdcDx7qhu JLccUMHtKvmHrHd76yKQpldTLjYv6mMvL7tEPSME2OZ8Eo5yt5sbOQ7ATjd28CW/SQDxYKOHJ8O xyPGCpa7wIqFaz+nAh+Bu5RvxieHeI+gCltdDfXDYHzvmBtj1E46xR3qfeSyw5GEfSeosoLFY9m et14dPkkFrGkI7IrApThJGzv4CQyD1fBOmXURx2iyBGBbQ1yq1lp4B9nrGMQP344nNIJ41H4Xsd dvAULiILG2l0mx8X2WfigGwDDgcxX3dBnquJJ91lM1sCZsV461OnJTtVlir0fM3JBiLboyAGT7h 4VdFnRNglT1i81IxqzusdjkmPhd5R1Zxb8giok2ualUJoQ0sP56Dj3IVSmrUnKPszCOXrvezyCW EcJzA+Ez+X4qsgRDRs+ClIJiE6wtJBijCrUI9LEg== X-Google-Smtp-Source: AGHT+IEztlvGKlUoqD0g25lCC8MUysNRG6xtAj50T9YwNqBxGNZ27/ROzosGghSBWQujOhn5Z/L7rQ== X-Received: by 2002:a05:6a00:987:b0:7b8:7c1a:7f60 with SMTP id d2e1a72fcca58-7ca8977c27emr17931768b3a.12.1764345984715; Fri, 28 Nov 2025 08:06:24 -0800 (PST) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7d15f26f11fsm5408499b3a.50.2025.11.28.08.06.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 08:06:23 -0800 (PST) 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, aha310510@gmail.com, linux-staging@lists.linux.dev, Jacob Keller Subject: [PATCH 5.15.y 07/14] timers: Rename del_timer() to timer_delete() Date: Sat, 29 Nov 2025 01:05:32 +0900 Message-Id: <20251128160539.358938-8-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128160539.358938-1-aha310510@gmail.com> References: <20251128160539.358938-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 bb663f0f3c396c6d05f6c5eeeea96ced20ff112e ] The timer related functions do not have a strict timer_ prefixed namespace which is really annoying. Rename del_timer() to timer_delete() and provide del_timer() as a wrapper. Document that del_timer() is not for new code. Signed-off-by: Thomas Gleixner Tested-by: Guenter Roeck Reviewed-by: Steven Rostedt (Google) Reviewed-by: Jacob Keller Reviewed-by: Anna-Maria Behnsen Link: https://lore.kernel.org/r/20221123201625.015535022@linutronix.de Signed-off-by: Jeongjun Park --- include/linux/timer.h | 15 ++++++++++++++- kernel/time/timer.c | 6 +++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/linux/timer.h b/include/linux/timer.h index 551fa467726f..e338e173ce8b 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h @@ -169,7 +169,6 @@ static inline int timer_pending(const struct timer_list= * timer) } =20 extern void add_timer_on(struct timer_list *timer, int cpu); -extern int del_timer(struct timer_list * timer); extern int mod_timer(struct timer_list *timer, unsigned long expires); extern int mod_timer_pending(struct timer_list *timer, unsigned long expir= es); extern int timer_reduce(struct timer_list *timer, unsigned long expires); @@ -184,6 +183,7 @@ extern void add_timer(struct timer_list *timer); =20 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); =20 /** * del_timer_sync - Delete a pending timer and wait for a running callback @@ -198,6 +198,19 @@ static inline int del_timer_sync(struct timer_list *ti= mer) return timer_delete_sync(timer); } =20 +/** + * del_timer - Delete a pending timer + * @timer: The timer to be deleted + * + * See timer_delete() for detailed explanation. + * + * Do not use in new code. Use timer_delete() instead. + */ +static inline int del_timer(struct timer_list *timer) +{ + return timer_delete(timer); +} + extern void init_timers(void); struct hrtimer; extern enum hrtimer_restart it_real_fn(struct hrtimer *); diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 60e538b566e3..2b5e8c26b697 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1257,7 +1257,7 @@ void add_timer_on(struct timer_list *timer, int cpu) EXPORT_SYMBOL_GPL(add_timer_on); =20 /** - * del_timer - Deactivate a timer. + * timer_delete - Deactivate a timer * @timer: The timer to be deactivated * * The function only deactivates a pending timer, but contrary to @@ -1270,7 +1270,7 @@ EXPORT_SYMBOL_GPL(add_timer_on); * * %0 - The timer was not pending * * %1 - The timer was pending and deactivated */ -int del_timer(struct timer_list *timer) +int timer_delete(struct timer_list *timer) { struct timer_base *base; unsigned long flags; @@ -1286,7 +1286,7 @@ int del_timer(struct timer_list *timer) =20 return ret; } -EXPORT_SYMBOL(del_timer); +EXPORT_SYMBOL(timer_delete); =20 /** * try_to_del_timer_sync - Try to deactivate a timer -- From nobody Mon Dec 1 22:05:06 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 5A53D2C0F89 for ; Fri, 28 Nov 2025 16:06:31 +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=1764345993; cv=none; b=NXuXMjOUoC2dzYT4IreB0ntSAgkVNaPRhI4IXfjNVxWnOw/ulNMGPvVfc9KbFFq6X2qNgUk/MIpCMb+8zleqtNfBVd6VlG2Psxq0baB2WbN/2vqC42I/5xF8aZmLMfZZP/Tq7MxCSYpfkOnC5kpTnfJTVZfhJmBM+KokFqyndRo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764345993; c=relaxed/simple; bh=upWSCwkwQ09Z4avIiv+Y6wEsIG3+TFZ3n19V8cmDwBA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=SWxLAoPLE4YJHBS4too7krbp0YMo4YyMsxQWW5LPFUt3uho1Q9OtKrDBc5O3sZtroM9FG14D9f6qKNGkUnLNgzbmrqCAgETd/JO9TPK7wqTmctfZ/UpCRkdEnJuscF2Q9UMZr66z/IiniyRopnXhBdsuZCV2n6CMIq4yGFBaPjE= 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=EcQPz8uG; 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="EcQPz8uG" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-7aab7623f42so2212381b3a.2 for ; Fri, 28 Nov 2025 08:06:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764345990; x=1764950790; 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=EcQPz8uGQl4K+txb3Y9EM2dWKSUYXg6OdmgUo3d6PJ4cH2DlBvOHkRBqQnEXN8cvhC 3D/HSsJoU9IceNabHiudkyVLNmzgv/DkxytcDhQN4thfvuwDCadGgF9F+JWCG6QgAFZ8 /xxvDFP0S15gRiX9gpEUpYdo/2aERv2edG37L/4COtKaU43u4JlfL3/IKJANIvIL6YN6 Q8sLulTac8U9M5dHSgjJ6WHZL1uko0Zr2bAFKTUkSeZcffOoHhPShxbCU6WUP1UVnFyt twfb93Bg1b45IqzxsT5UsNWXLcEradh4CO9zttXwhe9qSul4+raj95xhrKMXieIcob3+ wBuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764345990; x=1764950790; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=NwuFHJSwTOh44O6o4YH5Gva/YZZ2KpNq4JaQIOiJzpU=; b=v/oHtVPa4/2uSG+2KHaXAHbMDYiD8Ham1ouHxFshSVe9xcqqC+i3Cn2eVslIBLIQj8 nmQ5v0rOQRMPEeWR2DmUps+5OjpP3cHOl1fHw93UUhC0E+6hTVhGZx+jDAg4ZPbeDQhd 1wOY3rbdKwwgHjvh+pjP09XFY3PCTj6a/qFqOt/WHVKKdbyJoWuLi07q3xMYbLDpMYRv 5s94DNSCZgTw/RIl0Ttken7AmA+pHipujnRBWyQ6R2WUr17lCpG/8ShT3a0h2lvHZ5iK IK+ahSW4P72Nh3Oibeu24DSKHYU3XZmc9PqGdQ4gCI23TaiNbrbhzO7Ihu3cVFiU0eqs kGig== X-Forwarded-Encrypted: i=1; AJvYcCXHNAUZ6eOwyL75yHCuILRQBEHfn9KmUp9QOAp36x7WAqXYN8A8GO+Pz+ZVD91vJfFpyM32+ECWTO+rM14=@vger.kernel.org X-Gm-Message-State: AOJu0Yz+WzE12L+kwWfXqhNQbCQczT+6TWmi9exDYaAez7leKtmDdlEo GDKWZJqAtzLUiSKmB7Fpa41LwXUPGhlxUob8j7D7Ktz2f8RIfftcm+Lb X-Gm-Gg: ASbGncs2ekJd9QFQdPQfd0SFojdqPl5tBrvwdzsQHP/ILF4UXs7B5npplNdPRYk7jnq xRNT0QIHFLvzun3zG+rRiZN5QPrs3S521mWM7Tx129kb1uFezy9xKlk19frAHRW/a/U2f2blLst 9dfWHB88NvuG4ePNbUfgf0Dd0GRhevOKUnOOzySAHW77sMy0Wy+S5r5DcP1jdhoWi4GdlWS8JRu MWsJyCZqnAOTkrMUbqw/AQSr+ajmv7Lt6z4l5TTTJTzzuLadqXg7VnK+6NyEjlvmUkXvumk5Xhf CRAsbqgAGyT/tTAF0RPknRQ7OCNzP9QQQa0vu7OsTHqCqYgXx96d7S260i4ajh/BIhxvJTUvxTf kyV8NBhpPL1pMkzqyBn61YaiNtqlhFsPXcA9sMsdJ1GxYrRn8Ydv/+IPTdqXb717w+Jhc+I4gr/ W1+QAL1OpEdGdbyeenAY9L39KACLVRXguK8DkPtw== X-Google-Smtp-Source: AGHT+IHkZ+vfxp4JqrSHcbC8AyzXlNJ0OxaL9SKjjazgTqeaBUUhfQyzRwIoWRt7hmUNiS6wX+LdAw== X-Received: by 2002:a05:6a20:430f:b0:361:2f3e:cac2 with SMTP id adf61e73a8af0-3614eda843dmr33153993637.33.1764345989932; Fri, 28 Nov 2025 08:06:29 -0800 (PST) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7d15f26f11fsm5408499b3a.50.2025.11.28.08.06.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 08:06:29 -0800 (PST) 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, aha310510@gmail.com, linux-staging@lists.linux.dev, Jacob Keller Subject: [PATCH 5.15.y 08/14] Documentation: Replace del_timer/del_timer_sync() Date: Sat, 29 Nov 2025 01:05:33 +0900 Message-Id: <20251128160539.358938-9-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128160539.358938-1-aha310510@gmail.com> References: <20251128160539.358938-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 Mon Dec 1 22:05:06 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 78502330322 for ; Fri, 28 Nov 2025 16:06:36 +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=1764345998; cv=none; b=j6NeoVxNHnPWLwvGwoNraVcKoe0G9N4Jo+DDfJC0JezvS0DGBS56H0Pc/llLQZqRYYWn6XcfNusyMkTPRomF35HHYnc6tWBpNdgOZOcQ79xv4T1tV4DFP4MmrmX29O8q9pDKeO/jA7m3sPxEemcIQD2qzUwOcVTPoZ0BlWkRWXs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764345998; c=relaxed/simple; bh=A7NZvw6BwM3JH9LFTZM0pkj7MM2Mf/KMJNxtIByaxbs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bRE/IJKhqMK80fmzMlh1laNKHQRx1osPekbjhS387BtJYY3SWr1xaR/rCumgj/4KvW4SzwYVkIDj6Ez1qNn1Mxxy53zE+Y2b8sJb+mk+1Cs7NDPQcWsNFJ2H/MzfGv1FY1+H3t2f+kudYg7XuferHutfeOL1xcgKpktwtJnDAgE= 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=MYhaCsCl; 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="MYhaCsCl" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-7d26a7e5639so1683874b3a.1 for ; Fri, 28 Nov 2025 08:06:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764345996; x=1764950796; 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=MYhaCsClS+WoMgwkCexc+jqHtqfk7wjuxPEoGMCoz2gXOmavZWF7YsM8gpzZiQxQhK irmoW7CEl/8DsjX+V44wwhQ6pxDgF1zw5PXWcBGJk+aOwhbYaWq6JNr6IKCJsiLCQ/xJ 1itMMAFkdTzQLpticTdw3aI+0SP4p2voGWLjhXVOA4a7mabh/yw/byuh8XjRHlshShzn l4IVaGSdYMg3l6A9/cSvhqoxkn+9iLfHnsYXv6nogtdBK9sUhySnXPt2MAe8p39gDcxC 8ATnf6GfNpoRSzYkFs7ZPhhnF2tf3LlleTxb0QOdBVjNhOZFdkd3wGCw5b95OEnZeyjO W6ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764345996; x=1764950796; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=HIvAwaANSEMHidUC241SU/ATL2QFU3HABzkGaIq1H88=; b=KzV9ygHNj8pB5HMV3O20n8qDPBi3J0+NbHwgI4TS6wEkgD0yS9CZdwL+OjhX7p5G5l BpMU8rPjtrBzoXZ8kGb8Ka2wqJyZr/bSaxw6WS2wsG88udR3qg+nV5Nw8q29StZIpXkI n3EBmFXAl+iUOocsOwk7FoWI8m8VMH0u45CA+ubv2BuII7bzlegh0/MYWeTrYTDvjrsx +0iQr39bG5EAX7rku8+eHhtsm2Q7hUavonjayup84GZemBC5q0JNNiwWM70nv0Qodlvq RfRxMLotmIyGK/uRUckbFgs7mGuZtgUjwcPvyUYf/hjrat0P1L7F6AN2nXUBaybXduyH 6R9g== X-Forwarded-Encrypted: i=1; AJvYcCXYhB9hPqYjIPhBETS9w7+t+O9xAmx7IGfanseFSIm5zEv85TLhuVZktpYaOYzihBq4+usqXymZzJwAcQM=@vger.kernel.org X-Gm-Message-State: AOJu0YyJQyqMvpN7Ugfe58AnofU3mnk4kJn76MK3JhA9Nh5x6/1NE4ik 4t9f4lejOc9aH2QW0Mem8f31xqf85op8tJQqVJTQg0/+FlX53ozBkNV/ X-Gm-Gg: ASbGncsx/CMLDs24+pv7itYr3g1ob8cPXhtFSb+J4p7psJEp/UgD96hfdzGU1vPtR2V oNlRF2qvLEw2kh/aMgPDkS8XGqOMITLu7aMqHlvQa8duEZ3ZMK1mPVLcTAcA/pTAeGYe+uIm6E+ 3jyiejwGVtu1Qhw8N+HoPYW38fAkeuOgtg1bBYzByYAw5WyQIo0JVApHV4OLCvjLSwexxKX0xv5 SiKIpSUa0Q90ftvbDHxeVrhKD7M8arKFVoYkvWF+xXckySHW3mVEU3jtlV0aeviQmlFcMPFxBVd WMj0c6Q4/8d/scsH4srTLNofgz7z/ZFAUicOhPJyQfpa+LKiet2WBYcWomuBHUoorITr3LharlT +BWxb/YiiVSwotfCaEt0Q26u0IoFP92PFUCOjErxFSgOtH7pWpR7J5MnTTrLCfJfQ654P+irBDD KRUjnAnU/YZzKLujXrJq/lSbeCczgaWAuYobq/uQ== X-Google-Smtp-Source: AGHT+IFLg5ORPm0TEtuxOShEmNUFI7ZjoXaSp/U/kqJZNCs3wbN4/+zsI460r5w0wy7yoJqUDfaS3A== X-Received: by 2002:a05:6a20:1592:b0:35d:d477:a7ff with SMTP id adf61e73a8af0-3614eb798e6mr32656783637.21.1764345995543; Fri, 28 Nov 2025 08:06:35 -0800 (PST) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7d15f26f11fsm5408499b3a.50.2025.11.28.08.06.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 08:06:34 -0800 (PST) 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, aha310510@gmail.com, linux-staging@lists.linux.dev, Jacob Keller Subject: [PATCH 5.15.y 09/14] timers: Silently ignore timers with a NULL function Date: Sat, 29 Nov 2025 01:05:34 +0900 Message-Id: <20251128160539.358938-10-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128160539.358938-1-aha310510@gmail.com> References: <20251128160539.358938-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 Mon Dec 1 22:05:06 2025 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (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 88082330B10 for ; Fri, 28 Nov 2025 16:06:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764346003; cv=none; b=rrsF6SsnNDwK1wHbxYg95+N916ZyxRqyf78WW4q7ul0HFsn3VL+oj18dQA1WNzQjuAiyQH3OHP3MzkmXsFlZIsSEgCAmkoRyIM7dx8YigjGhmy59Wgvo9OCzao2vtVVfbI7NGmvPlYzkrfgijjOXhXPdJL3vWMzcpWYzgCR9Qrs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764346003; c=relaxed/simple; bh=FfeWAFL01yrxGNZ9KQqmQL8U/+v/91/EffrzfYdxZZA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZjXVirkBrmW24jcwKIurNMDkFAWpDrkBUBvJTXySXe1MPGHFT8/o7NUl9VCA3xoDkyKibYVpKr+0Ml/rzudHfc/ar2h5eoy/v1V175SKwNBCXdMS01T1OonWmQICyLPs12BNdTdKESlLx+XOlW1RwoQbHMzIFOvi33FxflNc4Mg= 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=btCE0S4t; arc=none smtp.client-ip=209.85.216.50 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="btCE0S4t" Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-3437c093ef5so2188182a91.0 for ; Fri, 28 Nov 2025 08:06:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764346001; x=1764950801; 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=btCE0S4tzM5oYyo56TYoRMXM5D8yThvODRP9kxt18z2gOB49QPdUHz2RDDT5sdjK2T kS5d+asqJmu23eIDRrqvLnIi/5kIDE0IAJtxI9Xbq/A3wysx7ktf/WS2ILWvBVR1T87A 6L4X54VWPbg9joOCODmnAudEhsZ7/OkaZn4lRodV9XNrmAiBSHJQCeiGdU9CRYJUhjrV vAS+Zi+iaJxnTN0C2J1cR+TyIf9vdtHVqdkr4AP1HIG4ig3UIFz+lxAe5dfHnYWd0tGe pAh2J2cgyYLwQ8Wc5BWHipC2w8OeVt58Bt5fauGO1GxdWHjCmaCJBfNHUg8w9iljNkgF gZrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764346001; x=1764950801; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=j0bNeek1LW81/KG2/Q/uicdT1bV3tR+ITFKGtccSqSg=; b=RiVAm+W7hPzkfZ5yEVkmOX3H+cH7Xye2cabc6WEi+nKmihYYLZId2Aky0fRzi27l/R VRjUb3k5xUh8+U6/kKTRkBHPeQx2AagS/ziHk5Y7QFP9vqYk0Ucg2VAUaJfF8JRX5DHf C/AMTgYwiFZYtSNvn4Vvy+/zn3K2ThpnvI8jIH/3oPl4qHqDgHRz+lWYrkbY1GKK1G/c CbXIXGgwhAKLaQnPhKKKDVhwTyTSouM4C4RilVkCj24KAWzpYfNFdBE+E0Vtiv5ei3gm juU0bIK5+Xdw/DQQ3mcTrAbOexnuYz24UiiEise5wFYp3i0qfGD7k73Fv0ghHX+jdrDZ jOwA== X-Forwarded-Encrypted: i=1; AJvYcCUhtxvQ51DfYmYVhkYEyA+ZjzkHFA8jWIpRV6+AIw/Kkf8nJnTz/nBinf6wR7YCURJCa7OhK9ngbgMe9lI=@vger.kernel.org X-Gm-Message-State: AOJu0Yy7HAU6wWEHUMy1TdIAVWSI6w6Aklq1feR8rfnhhVKYNOfwwoUG FvJq3+WKNFjeALhlhBM+Ji86GAhlPeCWOKaJ1t+bjaH3cfYTXgvN9iEW X-Gm-Gg: ASbGnctbkVrr9dKkXms/qgM5RPeKn1FoWypvwWdDnNRKUjIeO/YFzrmJBKg/MiQdN3x m4q1mG/OnnuvfIjaNqzwfO3vcMV9tpbZiGTvLsVhdIMlNQCbwRyfHTmPOC6rFFYnm0YRIcVB4vI 0VXXNZ2cHSFSIduKWLVer18eYeD+H1XYr5LV48eJ75wy44f6Cp3eEazjYgu/Ll7kqgCwu2vJDBw rzAgHWAL1EaC9VVP4O32O/RtcQ0yeu17oPHCo7Lo+rM33Pkh3Xfo7KpXLBscJAyD9NLj7dvCb1J /Q7kXal0lePxcL76cvsA0VLNaT3AeJp0ahginP/CQWawWJKb264YZaTS0wwkGRm07JzguRwdStZ lAroiQy7rgk1ZzjxPnyV028nks/gcjV8I5APymtr+VlWNpk6ZQlyqnnFKQ8bDnbNeXLZVd7A0bC gcTuAlAKp5RyMBDA7w4mDN3Lpzood7OJLUadaxAw== X-Google-Smtp-Source: AGHT+IGMMK/ksK1xGTlKIL49CG15hI1qCc5kwWuiMLMNCyhPjSNUAFybYnQmIenfoilVz4fFQ6RaXg== X-Received: by 2002:a17:90b:1c86:b0:33f:eca0:47c6 with SMTP id 98e67ed59e1d1-34733f23531mr24238024a91.30.1764346000442; Fri, 28 Nov 2025 08:06:40 -0800 (PST) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7d15f26f11fsm5408499b3a.50.2025.11.28.08.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 08:06:39 -0800 (PST) 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, aha310510@gmail.com, linux-staging@lists.linux.dev, Jacob Keller Subject: [PATCH 5.15.y 10/14] timers: Split [try_to_]del_timer[_sync]() to prepare for shutdown mode Date: Sat, 29 Nov 2025 01:05:35 +0900 Message-Id: <20251128160539.358938-11-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128160539.358938-1-aha310510@gmail.com> References: <20251128160539.358938-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 Mon Dec 1 22:05:06 2025 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (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 1DF78330B3D for ; Fri, 28 Nov 2025 16:06:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764346008; cv=none; b=az5aykff9XlLnKr/7xEVGeqbzcwjcZ2hkzzZOB1X6eU3F7SKyRmVwn5TTToUEpUNz2uooTgJfvgNWM1G8V9e7VuUopnDsAX8Isdr9mVB7jFtYXdsrB7BsKK4vBzkilA9VHcyPBZO3sznHdz/LSoNhGxLdXkg36FChO14Mc65NMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764346008; c=relaxed/simple; bh=7nNzz17kSCCmlWDu86ZhyMKFITWZeFxpgwAsgGFQJqQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CAHrljeXk30W/80V8Z2cjt6tsfwCW2BJMXxoO+iwC5jFDJu7NxJ21x7H4sf2CSQuh/ao0pKGkqmmgA3JM45dYGclI1U+/N962m3iVGXMfGToxMPNq93g2eUOQ02tfZBvd+lwbluBXD0er+WOpUdMRfQuEnUnJXn8Mx8B0GyMKKU= 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=S4ETs3x6; arc=none smtp.client-ip=209.85.210.173 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="S4ETs3x6" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-7aab061e7cbso2376253b3a.1 for ; Fri, 28 Nov 2025 08:06:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764346006; x=1764950806; 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=S4ETs3x6kBPPUpXtx6VSoW6Dd/28zDOIEBTsCsNuda5Wr54WpiXNQ1EFe6UB/SqTJe bcjbXXFCRy2n9oFffXSVOPz/l/6AYr4GXsYxflRZSs+GTt8FtjH6Z/h4WP4VZbQ8KcWa ir0C2IanVTfin1oMFboTVb+FR1xxhupSdscPakDV6fgF+Qzl97RJdcNrGeoYJJdQWxrg bfQ8P+Ez/t7BJdg1xq/AJUBt0JmnPluJ+4LlNaKflv+zJwklixfeZVbRbx9z8g/hVdzT 0ewCtUwPUseWsvZheGVn2lltGCStTmpJ2hUZL9iJbppSnIp4IEtNhu4JzlqpjiJMggKt tCYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764346006; x=1764950806; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=x1WOyKHAoHX8FrQxrc3Dl9TiChr0cIqUNlYEGeUOx2A=; b=pUo2asi7UMq9IqVu9IWabugJoDoJGSUYc6MUie7ERM8UAFQao18Cox6HG8Njgy6NvR 4j57IObVW5CCl/w4sWOkgyEKY36QlJcNio1D2jj3chJdprQXd5/pohcuqH0/PWdUF49/ jj58vzN6AlJabthrp54Hz8GGSO5DemosEx1/ObsXmi/40in53J6x6eEKqIti10DjEe/f L6ZTYd9Kbp4tqrUptFHQ+ASkLegMR/sWNbXCPIkI/NaokrXhEfFTsUz7omi5anZgY1fG eq47URCp1RPM8QX9mRSdST6MVxGZbJQSnRVu3bicDNER3PPT2d9OXv9ewFOyHQTnOD/a z5ng== X-Forwarded-Encrypted: i=1; AJvYcCWPj2BdusTGt034cj3yeALER72wXbPPxKpcxcevX8WU5iLEL38ld0Mc8nk8Wdn1aQqvpnGEr/67rrVd1Io=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6ZX7+GU6YD0ZT0j8vVPG6Fq7Htov61nJumjwZmJkfj92Zs7vG m+No1n0EWAw5ng1J9znpmgZVv+siNpGwq+b7Bi0Vm2/aQA6bvE11oOAE X-Gm-Gg: ASbGnctBIeyU8YLTqKRtDFIIcc0tZo3L3N2lTu7yTexKsRj38Vy6hXlKLXpAFEPYtJb smieWESEUTlEJPUsDRPJlt8+9y674SBQAWO0XnmvimfroM6I1u3cJbUOuQPq4XZv55yvtiXOPcw 9huw2kGWraMd7qKZ3OcUkV/w5o7JGREJfRrJRbF3c86Wk58xICx++RlBIN8M7/2rp667Qk00vQQ vrcoedAmj2AlCtFWXgVMZxkIt5btOUQlk8TE50SKAUovCwR8Ml0q2ZmeeEkSvB4J+1PYiWoqJIs 3kahrxWAMncuxWs5Ndvv3A/mVZN6cAHalJlrb0f8Tk5PFr0rm2T3IAqOS7naTzS/q09XtOTBaFa /X8Wk4DggffpGGMl/+VSJRwKcJj8f+Xo99EOFj27PfoNwouU9tPmICu7B+4Vz/5GAdVoC2h0scM ILXpaHleWvT313o1AoAN1Ck+a0YFQUi+eFX8MlOw== X-Google-Smtp-Source: AGHT+IE3aYPKQhA3JTw9tSf5TPOec0+aL0hUx34xQqnLoed5SBOn8rW6c+/UgrHXUkcaMJPKba4Qkg== X-Received: by 2002:a05:6a20:e291:b0:2df:8271:f095 with SMTP id adf61e73a8af0-3614ecbf7e9mr33783469637.24.1764346006160; Fri, 28 Nov 2025 08:06:46 -0800 (PST) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7d15f26f11fsm5408499b3a.50.2025.11.28.08.06.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 08:06:45 -0800 (PST) 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, aha310510@gmail.com, linux-staging@lists.linux.dev, Jacob Keller Subject: [PATCH 5.15.y 11/14] timers: Add shutdown mechanism to the internal functions Date: Sat, 29 Nov 2025 01:05:36 +0900 Message-Id: <20251128160539.358938-12-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128160539.358938-1-aha310510@gmail.com> References: <20251128160539.358938-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 Mon Dec 1 22:05:06 2025 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 F346B330D51 for ; Fri, 28 Nov 2025 16:06:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764346013; cv=none; b=LXyo/0LqZUjrowdOpbC+7coTTKzVgFD20KN4aF19qUwZKPvko272QwBaLwapJT+EbhK35ZM3L4dT0KLQP6yOtTP0sfEc7qNa1e2CKln4JkHOYpfl+bYdpwKw0Vib3EXH/8CVr0fG011povtGKJIKODzTvT17VX/3ETWqMWewvj0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764346013; c=relaxed/simple; bh=J7+paRiPLaCD/c+KTz8seNjK8t39KhNj40mTnjX9HD0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=haN4KbYIwPPWVHsT5PaaCWsUe21j56qmErfpNzuccN4dTFDsZNbKMofGAuO60GeEeb/Zaz/ijUIN99cDCLXSq2p6OlaGFR7dbFlcP1Yjzbu2WqTtKHpaxUQxNe2OXufqxhPx+4PNPVfo+ePxOEv8vVQzHYfvlXXzQuWeyftfuF4= 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=alwvx1Tw; arc=none smtp.client-ip=209.85.210.174 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="alwvx1Tw" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-7ba92341f83so3177139b3a.0 for ; Fri, 28 Nov 2025 08:06:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764346011; x=1764950811; 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=alwvx1TwCnRD/Z4eW6RYq8k3jMVm6tTmLDibhQuny4iz9EJM0JWSOCoY3OKhsTUA7j mvhjIkYV68nAsTxbnNHRStg6RzEYk2VEU9MouhiE+9d/tvPaW0bN1zJEaux74N6iaJBY 1iU4lYvcFk7zKDKxjftlBdXPLBUiH8nsYVp9ecxwd+zxEtJWHSmsfdlsbBWiX6jv/PGF SUpJrh+j4+Ap+xH7hu3w3U/aVvlUR+9HPfLO+8GzQSJO3pvue+7uYPsYjzg74vuEWqvQ D13AYCbb4+uMCQUDKt429vK7sfVlFUgafuBSiwfKEFAibKpMv5DQ6DGGuY9p2LnhKry0 ks8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764346011; x=1764950811; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=rkZJqZ3kQT2WglZ48UatqwsWbUOwu2gzPSjhRt06PHw=; b=bEAHNQ5lyOxxLbEUfsua9VAsT2rGcyisa9QBL0gQAAKOcbVL20bxZXdBb3QjP2zvmw eF4v+2MHTul8KVF9UyuM5A3H4eNUHwGwCCA5yBoTdiI9k7N7cdnj+fyiFajhvEFITeB/ V510yORDcanPcKVW9ZJWgn9tEwUh9iV0uirPuCgmz3+wgJ1jzoHyYp6U6RFOS/NaoB8o b3AqDPtXdLk4iAeXbAHIh1SVnizfJePhut6PKoSes0wC63/3rVHnsd6v4gQjkxCLc6H6 k5K8rBK/FZi3vQFSmHTUphS16rY3L4AZlUUDnlCS7K5sDGn5EEWd0zHbZzz/X40i6vyw iMVg== X-Forwarded-Encrypted: i=1; AJvYcCUZetmdjd6pV+Gg4fK/g2IOu6JBt9M2D65GFb8CuFAD1hNu1LwrqDI9YwEcWiqusVtJO2YtWl7Zbu2PZL0=@vger.kernel.org X-Gm-Message-State: AOJu0YyEYd4qr6riCYChiMDVHjMOS6OzXUfRUvlsvv2iP3EVuAAUC+5a rdaCx1Q8HRxJu1VSNc9lVcgW7QTJZzNbsJcgSjwdrBBci+CquSB+E/INOMNQvXFXtvPwZw== X-Gm-Gg: ASbGncvGOTLWZawoZwcHrB5QJ92d0NH6tU+8uLF76Zgp194F9Luf5diBvJeX3B9evwm ++gpaJEXrSsl404BbOZUIfKWqd6Ubk85wBI2LBTWwRlw9eXKk0I6shzO6SGa7dlnHDV7Hd8Wxtx d7GmtQe0VrqRwaJ8whvyvqpYkCm9H+4KR7Caf6JWU3p8QNW3GxoA5ubRL30iapQCiZwcM3gCzgW ci/jhlQHkd9t+UnZucY3IDLIEIVxyHm9VnEEKgCJtB5XJ3ZFv8CFVjpXoGEYW3Da9D1eN0ZWJJe O9U4hrym004FJqiHKcj8tDCbiHkvAHE+USNp0h07tVYrTeDTEyyrVAipDOR7fpvmkxbYTkTMkwh pT20PR/kiCu//sSDwjvR8sjesUuGTnMTuO8q4Fnr66Bh7fVFlteuBfY7mMRwFx7B0pWv2ORlPE9 2ROwZD+Bi3v3F/Iyox7SWPs8FsRCXvekDxALpmdw== X-Google-Smtp-Source: AGHT+IFe/WzAJ4YhXxjHwL8WErLggbUzDU+xEOEqWM7cgEhnUCfU8qyTm7b6vv30SmypDB6nYkwQ6g== X-Received: by 2002:a05:6a00:1828:b0:7ad:386e:3b6d with SMTP id d2e1a72fcca58-7ca8975fbecmr18947035b3a.21.1764346011056; Fri, 28 Nov 2025 08:06:51 -0800 (PST) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7d15f26f11fsm5408499b3a.50.2025.11.28.08.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 08:06:50 -0800 (PST) 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, aha310510@gmail.com, linux-staging@lists.linux.dev, Jacob Keller Subject: [PATCH 5.15.y 12/14] timers: Provide timer_shutdown[_sync]() Date: Sat, 29 Nov 2025 01:05:37 +0900 Message-Id: <20251128160539.358938-13-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128160539.358938-1-aha310510@gmail.com> References: <20251128160539.358938-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 Mon Dec 1 22:05:06 2025 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 E79C633121C for ; Fri, 28 Nov 2025 16:06:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764346018; cv=none; b=WZWd9xw3HnydzEQkxGNNll/pxC2/4qFQpZl5aaJ2lDtJcfrpUBLXRBDKM/fx/cZ5YHwOKRyQNHCsRkpfICigT/VglRGmtm43X2DlwMx7Gl/t6rF2Unyw8dm/mmsEpLNt8WEB0l3O3PfxxAB36ZzGsxoQxn9lQk5NaDs0C7X3bUg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764346018; c=relaxed/simple; bh=e1DK8j+FiXmlj1eFN8Izgd5UcqsQJns59AycqwDqK3Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=sME5ZYMrAxfJl8KAUoDZtOMK03Qa9TlIlCtpCPZMRpHEZbuuBI2TNfnZWiKBBkNJZCYzqR6zGf1+vFMu4AVQaBCKfNR1qm0r/mtXU3kgPvOoMt/k7mQAsZa+dNSs3iXpOgbXI7Qb28jfVVrnVa9bWqZDvD8Y82BONs7ebSba7qI= 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=LSnVXrK4; arc=none smtp.client-ip=209.85.210.170 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="LSnVXrK4" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-7b8bbf16b71so2530610b3a.2 for ; Fri, 28 Nov 2025 08:06:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764346016; x=1764950816; 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=LSnVXrK4JYlK6lRi5kmSnpAEVKJ3fgpaHieT6TZE7N0mgytIO/j70w4IlnjO6dfhpx gy8/koJ1ahOd/dk0FX2m8mCUxD7JuFETywbRf2NGWfhHnuNU5PbBKopK+82HytLYAsN9 WivnVxOHNZHbwXLGlv3bI/tzi94Ok77hoKVwqBNxwosi4NxN3YWBBqPwwF8AnE/IEuXe 5shUCM4+3PVWPLRE9K1ceAjr522rn+er6XW5NjA+ZDZW4JaA7oJe5swMEq3nx1ytDTrO AM63RH6OPXazZsZkN6ijLctn8qt+oIDBR3dfx7yTzcHBO5OKJiWV+50rBV/Nx2518gAQ cPsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764346016; x=1764950816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=UGmuQqZjeUhbRmxIHTmmKtGFb/p0zxMormCTfTuA8dI=; b=YKhyIi6v5wrjAwaYXNATUm3kKpe3VEJ2pvJTcV569EskEEzk4/BLHiDoL3Ll8pucNa Iu9xLMlVNhNygN9qnHcnq3Eez8S5j2pZo3rmTBRWPfv+3RVYMGpYRYq5lCvqfUyXTsLR 7gGpmci1UBM1G9tBZ7Uft4uyciO3Sn5XE9miMyz8bA5uhIH5kgStBH7fm4H0aG9/k3L6 KiAlKggSujN2A9sknpK2oVsJY4nfQ0yjjbhOswz/+jA3jKKBHEk+AkSRSEdgEYYOa1ek bXNwSGZD2rEzPQovvd3Ga2aV9DLMclTHBIae9S2PjDZFCCTy23AXR9aVwnh9KTRCoufD bnKQ== X-Forwarded-Encrypted: i=1; AJvYcCUGvpcmKlTof5b+BF8DYART9abrJC1WBQ0HeFIy2xNx2jmk3inK4p1npCsWD08MiMcX1w2505p0FK98vkA=@vger.kernel.org X-Gm-Message-State: AOJu0YztF9CZeqX8/5CubKrPobx6KIxoCzBDhFZsrLxwQF09x7n+7QaW v+D4T5hdlI/nXphfF2/yZUA25Nmb4RYwAYwmkRUdn7rQT1RSR2xEUrZR X-Gm-Gg: ASbGncsUPndIEKffz5woRoyKmHqunrP/M0l2uKL3RLmTIp0FL/ApW7oYzFHZysWqPc1 UBhtVG29tUFS518eNjVVXScapHfHW/caSjb4Y9zPYT+/0fi+gdTRxOAYQzEuxbb7L7WI4UZZr78 vck60DIDTHhcvBFvE4++/loZO8wAtMChFa8qVgOP8o5zsGOGZzgqb9ND8wb/Z1TJkwFeo78Tcge cN1hrCmRjG3T/miVdCdtT+JL7gEjMXYVRsT7T3tMyOxuGpewJCoi4Mek3mEC/JxPqUGzGXzEB4x N6bepMNIsLrBpdce5H95yVcS2SAfA4JfDqs9RgG2XEdad3PAECy+dVINyx5hBX7hzdQvkXFb4dN NbMO5FA/9KsLSGV3oF7G+ZYphVwsw/GZdLqHzsj/BvKnhYHM2hPFtAps5YJHCz6Pudt8//Vm6nt nLnv7eq+rQSW26G9XS6174bCeZdLxaydjiTHGrbA== X-Google-Smtp-Source: AGHT+IGqQi/OiFjS5pDqCveMxUEGU2hbXLOMS4pWdjHOTPjXEVY9szwG71GV7vAeUueeEkA+Bqs+sw== X-Received: by 2002:a05:6a21:33a3:b0:35e:4b35:3669 with SMTP id adf61e73a8af0-3614ed962d0mr30665526637.31.1764346016068; Fri, 28 Nov 2025 08:06:56 -0800 (PST) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7d15f26f11fsm5408499b3a.50.2025.11.28.08.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 08:06:55 -0800 (PST) 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, aha310510@gmail.com, linux-staging@lists.linux.dev, Jacob Keller Subject: [PATCH 5.15.y 13/14] timers: Update the documentation to reflect on the new timer_shutdown() API Date: Sat, 29 Nov 2025 01:05:38 +0900 Message-Id: <20251128160539.358938-14-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128160539.358938-1-aha310510@gmail.com> References: <20251128160539.358938-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 Mon Dec 1 22:05:06 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 6E0E133122B for ; Fri, 28 Nov 2025 16:07:03 +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=1764346024; cv=none; b=IH5TLzp6gbOMjMnWkII21VpUBDkYPCgzilS4vdYAGYzZ3On4QwsMiNYfabLsVD2+5dvSyoh07e89o/m2nt5mU63w1ERLXrJSjngmadqMYmz6FMRIZ9m2blnEMH4qczH4pdQRAufmAyKgDHxSKOICYMzsVqBTS3/BMxzkFW/O3GU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764346024; c=relaxed/simple; bh=wtM3KGXEQuicJ8O+1w9NeLqs1Q3c/AYVobYXG6O4xkU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BuRskWgVo/wLeuUeOU6zXl/Vw++A92754hH8GiDI7EckyN/UN9hLTH5eY3V4tBtAwy+6mdjBSFf+D/+n5iz/lWsV6DxewApWUfh51EdlX5irgVrEl95jNYQDChm5SXkBMYJmK7vbT2viX4TvQYnVfnnumt/7RIxmU0ylM73Iw9o= 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=IhOXafUE; 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="IhOXafUE" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-7b89c1ce9easo2437518b3a.2 for ; Fri, 28 Nov 2025 08:07:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764346022; x=1764950822; 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=IhOXafUEhg4evsLMn2hs+lf5f7rJn0H5MXvh51TQxLlZX/mxhGQw4mCtc+rlm9Kjgz y/k5zQwKyWO8Gx2kc3dLeByJpJfoPrK5FIyNHC7RPcRF0gONBUAn00Tg0P342NyG3j/5 SBNhpupqFdisc9BZ4BwPtKnDYQBhTp3+vtI68br+Z6UUPpSj1HcvZn2CdBRcZUdph8u9 0RMo5ekODzHm2FD+zhh01WVs5NnWYxGQnnjnKqaOaV3l5+iOliuAm3RBagWQ3xJRhI7E wrLqhyqWy9syPa4UkGNBj0RTn6Mb21Lw4fB5Zl4GEOEHvNL7jQm4qYzZDVPM0yNuMtTO 9AaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764346022; x=1764950822; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=avVd2rCSlmy3mzSueRF3eaj+JsVil8OR/Q+bsjGDE3A=; b=b5avW9WkbntVC/zfar/UUI5p3dwpXgRXd4EoQEdVo6ZDBrLVPFKOmfvqSLmP/adJRt 1/FJavBKHWIUZ5Q8KWlz3IWsMshAhKKKTxkGivOVKzFOLljf+n8Fbr3OVKM/+dQBBEq4 7NnwXrhXnhrNdNFZqOa3qRSpNv2bDHA1hPXgAxva3SXEO9YTyMRfHJb7mXJlC05vJfJW uclKsEwt6OYUa6QBEobWZa5Ux7yhHpWE+F9BB4VQ2YLcz+nrBa+4ps+njLIWDigPJo9J DypWwk5XkTLjmVseQFXdWou7D+mnnxoFIBwshN3gq/thl2fSMcGYKGQHxHtKfsYczKq7 SUJw== X-Forwarded-Encrypted: i=1; AJvYcCXkDHrAMy/QLH7Z0fmgr3w5AJsgfMQhjMNp4lOeJ2fA1dlxHYDocHedoAgKpfhWcLesQv4pG4Ztenf2EAc=@vger.kernel.org X-Gm-Message-State: AOJu0YyUXoo84Vqr6ZIKKRJeFaRrtUuEi2P0MRtqFj8J8/UrFjXjEXnE 0gJqKKIEBPIncWFBZr/+sl53VOs9R7BDUZBxghzQnn1TM0SX1ATTYmMc X-Gm-Gg: ASbGncurgT/9q3SPR4UHfOtwUNu1t3rPIAk3Rl9wvW7Mo4Zji/WGkWDuiyuQKa2OmbG XydlcZY1MX0/+gUNa1jbv3EqVlAyzD2ERc8K/wzZkxvTh5ZolveqV3DAkp8cKERcfGQbqRwHLEW bxs5bqx5XJOxJ/ctFF9Yehp53jT7KJ87aJRQE5YfGyiR6lY6hc50cm8RghOGrTAz844JYuJuWyp 8xcXObkOBBsizCEIkAoHNZMsxvG992Pah+fbMBXAp3QCicQEMR3iGTE8kdtvJN4KAxX+RSYnLqb +1OI2m06Jz3qRs0PCLN2NMFGJsY0CagnOEvctNPtD+lGC7SKYJjmqXz5aRJaVtsUUhkq4NgFbYQ HSLmzwLbj52Vx8lnyYZSj9EfKZZg5aVPH8+OAiGCrIUVbiDrZo/jPExumA03TZ9fmHRI3ORG0rF 2K0fWBH77l7JquZxV41IxHI4NgXOJgYBwRck+GIA== X-Google-Smtp-Source: AGHT+IFbb5wRaCswqOfBZvptqiaZuYa9cCWiPzI9C94VNg3d8rKHwc6PhwU1RUpFCGSPXAzo6Ott0w== X-Received: by 2002:a05:6a00:22cb:b0:7aa:2cc6:8c38 with SMTP id d2e1a72fcca58-7c58c2abb3dmr27067471b3a.2.1764346022026; Fri, 28 Nov 2025 08:07:02 -0800 (PST) Received: from name2965-Precision-7820-Tower.. ([121.185.186.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7d15f26f11fsm5408499b3a.50.2025.11.28.08.06.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 08:07:00 -0800 (PST) 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, aha310510@gmail.com, linux-staging@lists.linux.dev, Jacob Keller Subject: [PATCH 5.15.y 14/14] Bluetooth: hci_qca: Fix the teardown problem for real Date: Sat, 29 Nov 2025 01:05:39 +0900 Message-Id: <20251128160539.358938-15-aha310510@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251128160539.358938-1-aha310510@gmail.com> References: <20251128160539.358938-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); --