From: Nam Cao <namcao@linutronix.de>
To: Anna-Maria Behnsen <anna-maria@linutronix.de>,
Frederic Weisbecker <frederic@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Andreas Hindborg <a.hindborg@kernel.org>,
Alice Ryhl <aliceryhl@google.com>,
Miguel Ojeda <ojeda@kernel.org>, Kees Cook <kees@kernel.org>,
linux-kernel@vger.kernel.org
Cc: Nam Cao <namcao@linutronix.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jens Axboe <axboe@kernel.dk>, Kalle Valo <kvalo@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>
Subject: [PATCH 00/12] hrtimers: Switch to new hrtimer interface functions (5/5)
Date: Mon, 28 Oct 2024 08:35:44 +0100 [thread overview]
Message-ID: <cover.1729865740.git.namcao@linutronix.de> (raw)
This is the fifth part of a 5-part series (split for convenience). All 5
parts are:
Part 1: https://lore.kernel.org/lkml/cover.1729864615.git.namcao@linutronix.de
Part 2: https://lore.kernel.org/lkml/cover.1729864823.git.namcao@linutronix.de
Part 3: https://lore.kernel.org/lkml/cover.1729865232.git.namcao@linutronix.de
Part 4: https://lore.kernel.org/lkml/cover.1729865485.git.namcao@linutronix.de
Part 5: https://lore.kernel.org/lkml/cover.1729865740.git.namcao@linutronix.de
To use hrtimer, hrtimer_init() (or one of its variant) must be called, and
also the timer's callfack function must be setup separately.
That can cause misuse of hrtimer. For example, because:
- The callback function is not setup
- The callback function is setup while it is not safe to do so
To prevent misuse of hrtimer, this series:
- Introduce new functions hrtimer_setup*(). These new functions are
similar to hrtimer_init*(), except that they also sanity-check and
initialize the callback function.
- Introduce hrtimer_update_function() which checks that it is safe to
change the callback function. The 'function' field of hrtimer is then
made private.
- Convert all users to use the new functions.
- Some minor cleanups on the way.
Most conversion patches were created using Coccinelle with the sematic
patch below; except for tricky cases that Coccinelle cannot handle, or for
some cases where a Coccinelle's bug regarding 100 column limit is
triggered. Any patches not mentioning Coccinelle were done manually.
virtual patch
@@ expression timer, clock, mode, func; @@
- hrtimer_init(timer, clock, mode);
...
- timer->function = func;
+ hrtimer_setup(timer, func, clock, mode);
@@ expression timer, clock, mode, func; @@
- hrtimer_init(&timer, clock, mode);
...
- timer.function = func;
+ hrtimer_setup(&timer, func, clock, mode);
@@ expression timer, clock, mode, func; @@
- hrtimer_init_on_stack(&timer, clock, mode);
...
- timer.function = func;
+ hrtimer_setup_on_stack(&timer, func, clock, mode);
@@ expression timer, clock, mode; @@
- hrtimer_init_sleeper_on_stack(timer, clock, mode);
+ hrtimer_setup_sleeper_on_stack(timer, clock, mode);
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Kalle Valo <kvalo@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Nam Cao (12):
hrtimers: Delete hrtimer_init()
hrtimers: Switch to use __htimer_setup()
hrtimers: Merge __hrtimer_init() into __hrtimer_setup()
serial: xilinx_uartps: Use helper function hrtimer_update_function()
io_uring: Use helper function hrtimer_update_function()
wifi: rt2x00: Switch to use hrtimer_update_function()
hrtimers: Make callback function pointer private
hrtimers: Remove unnecessary NULL check in hrtimer_start_range_ns()
hrtimers: Rename __hrtimer_init_sleeper() to __hrtimer_setup_sleeper()
hrtimers: Rename debug_init() to debug_setup()
hrtimers: Rename debug_init_on_stack() to debug_setup_on_stack()
tracing/timers: Rename hrtimer_init event to hrtimer_setup
Documentation/trace/ftrace.rst | 4 +-
.../net/wireless/ralink/rt2x00/rt2800mmio.c | 2 +-
.../net/wireless/ralink/rt2x00/rt2800usb.c | 2 +-
drivers/tty/serial/xilinx_uartps.c | 4 +-
include/linux/hrtimer.h | 4 +-
include/linux/hrtimer_types.h | 4 +-
include/trace/events/timer.h | 8 +--
io_uring/io_uring.c | 2 +-
kernel/time/hrtimer.c | 69 +++++--------------
kernel/time/timer_list.c | 2 +-
tools/perf/tests/shell/trace_btf_enum.sh | 2 +-
11 files changed, 35 insertions(+), 68 deletions(-)
--
2.39.5
next reply other threads:[~2024-10-28 7:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 7:35 Nam Cao [this message]
2024-10-28 7:35 ` [PATCH 01/12] hrtimers: Delete hrtimer_init() Nam Cao
2024-10-28 7:35 ` [PATCH 02/12] hrtimers: Switch to use __htimer_setup() Nam Cao
2024-10-28 7:35 ` [PATCH 03/12] hrtimers: Merge __hrtimer_init() into __hrtimer_setup() Nam Cao
2024-10-28 7:35 ` [PATCH 04/12] serial: xilinx_uartps: Use helper function hrtimer_update_function() Nam Cao
2024-10-28 7:35 ` [PATCH 05/12] io_uring: " Nam Cao
2024-10-28 7:35 ` [PATCH 06/12] wifi: rt2x00: Switch to use hrtimer_update_function() Nam Cao
2024-10-28 7:35 ` [PATCH 07/12] hrtimers: Make callback function pointer private Nam Cao
2024-10-28 7:35 ` [PATCH 08/12] hrtimers: Remove unnecessary NULL check in hrtimer_start_range_ns() Nam Cao
2024-10-28 7:35 ` [PATCH 09/12] hrtimers: Rename __hrtimer_init_sleeper() to __hrtimer_setup_sleeper() Nam Cao
2024-10-28 7:35 ` [PATCH 10/12] hrtimers: Rename debug_init() to debug_setup() Nam Cao
2024-10-28 7:35 ` [PATCH 11/12] hrtimers: Rename debug_init_on_stack() to debug_setup_on_stack() Nam Cao
2024-10-28 7:35 ` [PATCH 12/12] tracing/timers: Rename hrtimer_init event to hrtimer_setup Nam Cao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1729865740.git.namcao@linutronix.de \
--to=namcao@linutronix.de \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=anna-maria@linutronix.de \
--cc=axboe@kernel.dk \
--cc=frederic@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=kees@kernel.org \
--cc=kvalo@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox