Skip to content

hrtimers: Switch to new hrtimer interface functions (1/5)

Nam Cao intel-gfx kvm linux-wireless lkml 1 version NAK

Status from this message: NAK.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest21 patches 15 repliesNAK

Patches in v1

#Subject and filesSizeRepliesApplied
1/21hrtimers: Add missing hrtimer_init event trace pointsinclude/linux/hrtimer.h kernel/time/hrtimer.c+45 -380 replies
2/21hrtimers: Remove unused hrtimer_init_sleeper()include/linux/hrtimer.h kernel/time/hrtimer.c+1 -180 replies
3/21drm/i915/request: Remove unnecessary abuse of hrtimer::functiondrivers/gpu/drm/i915/i915_request.c+9 -80 replies
4/21KVM: x86/xen: Initialize hrtimer in kvm_xen_init_vcpu()arch/x86/kvm/xen.c+1 -33 replies
5/21can: bcm: Don't initialized an unused hrtimernet/can/bcm.c+8 -115 replies
6/21wifi: rt2x00: Remove redundant hrtimer_init()drivers/net/wireless/ralink/rt2x00/rt2x00usb.c+0 -21 reply
7/21io_uring: Remove redundant hrtimer's callback function setupio_uring/timeout.c+0 -10 replies
8/21hrtimers: Introduce hrtimer_setup() to replace hrtimer_init()include/linux/hrtimer.h kernel/time/hrtimer.c+40 -00 replies
9/21hrtimers: Introduce hrtimer_setup_on_stack()include/linux/hrtimer.h kernel/time/hrtimer.c+22 -00 replies
10/21hrtimers: Introduce hrtimer_setup_sleeper_on_stack()include/linux/hrtimer.h kernel/time/hrtimer.c+16 -00 replies
11/21hrtimers: Introduce hrtimer_update_function()include/linux/hrtimer.h+22 -00 replies
12/21fs/aio: Switch to use hrtimer_setup_sleeper_on_stack()fs/aio.c+1 -10 replies
13/21futex: Switch to use hrtimer_setup_sleeper_on_stack()kernel/futex/core.c+3 -30 replies
14/21net: pktgen: Switch to use hrtimer_setup_sleeper_on_stack()net/core/pktgen.c+1 -10 replies
15/21timers: Switch to use hrtimer_setup_sleeper_on_stack()kernel/time/hrtimer.c kernel/time/sleep_timeout.c+3 -40 replies
16/21wait: Switch to use hrtimer_setup_sleeper_on_stack()include/linux/wait.h+2 -20 replies
17/21hrtimers: Delete hrtimer_init_sleeper_on_stack()include/linux/hrtimer.h kernel/time/hrtimer.c+0 -170 replies
18/21sched/idle: Switch to use hrtimer_setup_on_stack()kernel/sched/idle.c+2 -24 replies
19/21io_uring: Switch to use hrtimer_setup_on_stack()io_uring/io_uring.c+4 -30 replies
20/21alarmtimer: Switch to use hrtimer_setup() and hrtimer_setup_on_stack()kernel/time/alarmtimer.c+4 -50 replies
21/21hrtimers: Delete hrtimer_init_on_stack()include/linux/hrtimer.h kernel/time/hrtimer.c+0 -190 replies

Reviews trailers per patch

2 of 21 patches have a Reviewed-by or Acked-by.

PatchSean ChristophersonKalle Valo
1/21
2/21
3/21
4/21A-b
5/21
6/21A-b
7/21
8/21
9/21
10/21
11/21
12/21
13/21
14/21
15/21
16/21
17/21
18/21
19/21
20/21
21/21

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 00/21] hrtimers: Switch to new hrtimer interface functions (1/5)

This is the first part of a 5-part series (split for convenience). All 5 parts are:

Part 1: https://lore.kernel.org/lkml/[email protected]
Part 2: https://lore.kernel.org/lkml/[email protected]
Part 3: https://lore.kernel.org/lkml/[email protected]
Part 4: https://lore.kernel.org/lkml/[email protected]
Part 5: https://lore.kernel.org/lkml/[email protected]

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);

Cc Jani Nikula <[email protected]>
Cc Sean Christopherson <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Oliver Hartkopp <[email protected]>
Cc Kalle Valo <[email protected]>
Cc Jens Axboe <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc John Stultz <[email protected]>

Nam Cao (21):
hrtimers: Add missing hrtimer_init event trace points
hrtimers: Remove unused hrtimer_init_sleeper() drm/i915/request: Remove unnecessary abuse of hrtimer::function
KVM: x86/xen: Initialize hrtimer in kvm_xen_init_vcpu()
can: bcm: Don't initialized an unused hrtimer
wifi: rt2x00: Remove redundant hrtimer_init()
io_uring: Remove redundant hrtimer's callback function setup
hrtimers: Introduce hrtimer_setup() to replace hrtimer_init()
hrtimers: Introduce hrtimer_setup_on_stack()
hrtimers: Introduce hrtimer_setup_sleeper_on_stack()
hrtimers: Introduce hrtimer_update_function()
fs/aio: Switch to use hrtimer_setup_sleeper_on_stack()
futex: Switch to use hrtimer_setup_sleeper_on_stack()
net: pktgen: Switch to use hrtimer_setup_sleeper_on_stack()
timers: Switch to use hrtimer_setup_sleeper_on_stack()
wait: Switch to use hrtimer_setup_sleeper_on_stack()
hrtimers: Delete hrtimer_init_sleeper_on_stack() sched/idle: Switch to use hrtimer_setup_on_stack()
io_uring: Switch to use hrtimer_setup_on_stack()
alarmtimer: Switch to use hrtimer_setup() and hrtimer_setup_on_stack()
hrtimers: Delete hrtimer_init_on_stack()

 arch/x86/kvm/xen.c                            |   4 +-
 drivers/gpu/drm/i915/i915_request.c           |  17 +--
 .../net/wireless/ralink/rt2x00/rt2x00usb.c    |   2 -
 fs/aio.c                                      |   2 +-
 include/linux/hrtimer.h                       |  51 ++++----
 include/linux/wait.h                          |   4 +-
 io_uring/io_uring.c                           |   7 +-
 io_uring/timeout.c                            |   1 -
 kernel/futex/core.c                           |   6 +-
 kernel/sched/idle.c                           |   4 +-
 kernel/time/alarmtimer.c                      |   9 +-
 kernel/time/hrtimer.c                         | 110 +++++++++++++-----
 kernel/time/sleep_timeout.c                   |   2 +-
 net/can/bcm.c                                 |  19 ++-
 net/core/pktgen.c                             |   2 +-
 15 files changed, 143 insertions(+), 97 deletions(-)
Signature · 1 line
2.39.5