Skip to content

Commit a50b4fe

Browse files
committed
Merge tag 'timers-cleanups-2025-03-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer cleanups from Thomas Gleixner: "A treewide hrtimer timer cleanup hrtimers are initialized with hrtimer_init() and a subsequent store to the callback pointer. This turned out to be suboptimal for the upcoming Rust integration and is obviously a silly implementation to begin with. This cleanup replaces the hrtimer_init(T); T->function = cb; sequence with hrtimer_setup(T, cb); The conversion was done with Coccinelle and a few manual fixups. Once the conversion has completely landed in mainline, hrtimer_init() will be removed and the hrtimer::function becomes a private member" * tag 'timers-cleanups-2025-03-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (100 commits) wifi: rt2x00: Switch to use hrtimer_update_function() io_uring: Use helper function hrtimer_update_function() serial: xilinx_uartps: Use helper function hrtimer_update_function() ASoC: fsl: imx-pcm-fiq: Switch to use hrtimer_setup() RDMA: Switch to use hrtimer_setup() virtio: mem: Switch to use hrtimer_setup() drm/vmwgfx: Switch to use hrtimer_setup() drm/xe/oa: Switch to use hrtimer_setup() drm/vkms: Switch to use hrtimer_setup() drm/msm: Switch to use hrtimer_setup() drm/i915/request: Switch to use hrtimer_setup() drm/i915/uncore: Switch to use hrtimer_setup() drm/i915/pmu: Switch to use hrtimer_setup() drm/i915/perf: Switch to use hrtimer_setup() drm/i915/gvt: Switch to use hrtimer_setup() drm/i915/huc: Switch to use hrtimer_setup() drm/amdgpu: Switch to use hrtimer_setup() stm class: heartbeat: Switch to use hrtimer_setup() i2c: Switch to use hrtimer_setup() iio: Switch to use hrtimer_setup() ...
2 parents d5048d1 + 86a578e commit a50b4fe

File tree

141 files changed

+281
-404
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+281
-404
lines changed

arch/arm/mach-imx/mmdc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,8 @@ static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_b
509509
pmu_mmdc->mmdc_ipg_clk = mmdc_ipg_clk;
510510
pmu_mmdc->devtype_data = device_get_match_data(&pdev->dev);
511511

512-
hrtimer_init(&pmu_mmdc->hrtimer, CLOCK_MONOTONIC,
513-
HRTIMER_MODE_REL);
514-
pmu_mmdc->hrtimer.function = mmdc_pmu_timer_handler;
512+
hrtimer_setup(&pmu_mmdc->hrtimer, mmdc_pmu_timer_handler, CLOCK_MONOTONIC,
513+
HRTIMER_MODE_REL);
515514

516515
cpumask_set_cpu(raw_smp_processor_id(), &pmu_mmdc->cpu);
517516

arch/arm/mm/cache-l2x0-pmu.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,7 @@ static __init int l2x0_pmu_init(void)
539539
* at higher frequencies.
540540
*/
541541
l2x0_pmu_poll_period = ms_to_ktime(1000);
542-
hrtimer_init(&l2x0_pmu_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
543-
l2x0_pmu_hrtimer.function = l2x0_pmu_poll;
542+
hrtimer_setup(&l2x0_pmu_hrtimer, l2x0_pmu_poll, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
544543

545544
cpumask_set_cpu(0, &pmu_cpu);
546545
ret = cpuhp_setup_state_nocalls(CPUHP_AP_PERF_ARM_L2X0_ONLINE,

arch/arm64/kvm/arch_timer.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,8 +1070,7 @@ static void timer_context_init(struct kvm_vcpu *vcpu, int timerid)
10701070
else
10711071
ctxt->offset.vm_offset = &kvm->arch.timer_data.poffset;
10721072

1073-
hrtimer_init(&ctxt->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
1074-
ctxt->hrtimer.function = kvm_hrtimer_expire;
1073+
hrtimer_setup(&ctxt->hrtimer, kvm_hrtimer_expire, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
10751074

10761075
switch (timerid) {
10771076
case TIMER_PTIMER:
@@ -1098,8 +1097,8 @@ void kvm_timer_vcpu_init(struct kvm_vcpu *vcpu)
10981097
timer_set_offset(vcpu_ptimer(vcpu), 0);
10991098
}
11001099

1101-
hrtimer_init(&timer->bg_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
1102-
timer->bg_timer.function = kvm_bg_timer_expire;
1100+
hrtimer_setup(&timer->bg_timer, kvm_bg_timer_expire, CLOCK_MONOTONIC,
1101+
HRTIMER_MODE_ABS_HARD);
11031102
}
11041103

11051104
void kvm_timer_init_vm(struct kvm *kvm)

arch/loongarch/kvm/vcpu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,8 +1459,8 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
14591459
vcpu->arch.vpid = 0;
14601460
vcpu->arch.flush_gpa = INVALID_GPA;
14611461

1462-
hrtimer_init(&vcpu->arch.swtimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
1463-
vcpu->arch.swtimer.function = kvm_swtimer_wakeup;
1462+
hrtimer_setup(&vcpu->arch.swtimer, kvm_swtimer_wakeup, CLOCK_MONOTONIC,
1463+
HRTIMER_MODE_ABS_PINNED_HARD);
14641464

14651465
vcpu->arch.handle_exit = kvm_handle_exit;
14661466
vcpu->arch.guest_eentry = (unsigned long)kvm_loongarch_ops->exc_entry;

arch/mips/kvm/mips.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,8 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
288288
if (err)
289289
return err;
290290

291-
hrtimer_init(&vcpu->arch.comparecount_timer, CLOCK_MONOTONIC,
292-
HRTIMER_MODE_REL);
293-
vcpu->arch.comparecount_timer.function = kvm_mips_comparecount_wakeup;
291+
hrtimer_setup(&vcpu->arch.comparecount_timer, kvm_mips_comparecount_wakeup, CLOCK_MONOTONIC,
292+
HRTIMER_MODE_REL);
294293

295294
/*
296295
* Allocate space for host mode exception handlers that handle

arch/powerpc/kernel/watchdog.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,7 @@ static void start_watchdog(void *arg)
495495

496496
*this_cpu_ptr(&wd_timer_tb) = get_tb();
497497

498-
hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
499-
hrtimer->function = watchdog_timer_fn;
498+
hrtimer_setup(hrtimer, watchdog_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
500499
hrtimer_start(hrtimer, ms_to_ktime(wd_timer_period_ms),
501500
HRTIMER_MODE_REL_PINNED);
502501
}

arch/powerpc/kvm/powerpc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,8 +766,8 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
766766
{
767767
int err;
768768

769-
hrtimer_init(&vcpu->arch.dec_timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
770-
vcpu->arch.dec_timer.function = kvmppc_decrementer_wakeup;
769+
hrtimer_setup(&vcpu->arch.dec_timer, kvmppc_decrementer_wakeup, CLOCK_REALTIME,
770+
HRTIMER_MODE_ABS);
771771

772772
#ifdef CONFIG_KVM_EXIT_TIMING
773773
mutex_init(&vcpu->arch.exit_timing_lock);

arch/riscv/kvm/vcpu_timer.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,18 +248,19 @@ int kvm_riscv_vcpu_timer_init(struct kvm_vcpu *vcpu)
248248
if (t->init_done)
249249
return -EINVAL;
250250

251-
hrtimer_init(&t->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
252251
t->init_done = true;
253252
t->next_set = false;
254253

255254
/* Enable sstc for every vcpu if available in hardware */
256255
if (riscv_isa_extension_available(NULL, SSTC)) {
257256
t->sstc_enabled = true;
258-
t->hrt.function = kvm_riscv_vcpu_vstimer_expired;
257+
hrtimer_setup(&t->hrt, kvm_riscv_vcpu_vstimer_expired, CLOCK_MONOTONIC,
258+
HRTIMER_MODE_REL);
259259
t->timer_next_event = kvm_riscv_vcpu_update_vstimecmp;
260260
} else {
261261
t->sstc_enabled = false;
262-
t->hrt.function = kvm_riscv_vcpu_hrtimer_expired;
262+
hrtimer_setup(&t->hrt, kvm_riscv_vcpu_hrtimer_expired, CLOCK_MONOTONIC,
263+
HRTIMER_MODE_REL);
263264
t->timer_next_event = kvm_riscv_vcpu_update_hrtimer;
264265
}
265266

arch/s390/kvm/interrupt.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3174,8 +3174,7 @@ void kvm_s390_gisa_init(struct kvm *kvm)
31743174
gi->alert.mask = 0;
31753175
spin_lock_init(&gi->alert.ref_lock);
31763176
gi->expires = 50 * 1000; /* 50 usec */
3177-
hrtimer_init(&gi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
3178-
gi->timer.function = gisa_vcpu_kicker;
3177+
hrtimer_setup(&gi->timer, gisa_vcpu_kicker, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
31793178
memset(gi->origin, 0, sizeof(struct kvm_s390_gisa));
31803179
gi->origin->next_alert = (u32)virt_to_phys(gi->origin);
31813180
VM_EVENT(kvm, 3, "gisa 0x%pK initialized", gi->origin);

arch/s390/kvm/kvm-s390.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3943,8 +3943,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
39433943
if (rc)
39443944
return rc;
39453945
}
3946-
hrtimer_init(&vcpu->arch.ckc_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
3947-
vcpu->arch.ckc_timer.function = kvm_s390_idle_wakeup;
3946+
hrtimer_setup(&vcpu->arch.ckc_timer, kvm_s390_idle_wakeup, CLOCK_MONOTONIC,
3947+
HRTIMER_MODE_REL);
39483948

39493949
vcpu->arch.sie_block->hpid = HPID_KVM;
39503950

0 commit comments

Comments
 (0)