* [PATCH v2 01/31] KVM: MIPS: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
@ 2025-02-05 10:38 ` Nam Cao
2025-02-05 10:38 ` [PATCH v2 02/31] KVM: PPC: " Nam Cao
` (29 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:38 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Thomas Bogendoerfer
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
---
arch/mips/kvm/mips.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index 60b43ea85c12..cef3c423a41a 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -288,9 +288,8 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
if (err)
return err;
- hrtimer_init(&vcpu->arch.comparecount_timer, CLOCK_MONOTONIC,
- HRTIMER_MODE_REL);
- vcpu->arch.comparecount_timer.function = kvm_mips_comparecount_wakeup;
+ hrtimer_setup(&vcpu->arch.comparecount_timer, kvm_mips_comparecount_wakeup, CLOCK_MONOTONIC,
+ HRTIMER_MODE_REL);
/*
* Allocate space for host mode exception handlers that handle
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 02/31] KVM: PPC: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
2025-02-05 10:38 ` [PATCH v2 01/31] KVM: MIPS: Switch to use hrtimer_setup() Nam Cao
@ 2025-02-05 10:38 ` Nam Cao
2025-02-05 10:38 ` [PATCH v2 03/31] KVM: s390: " Nam Cao
` (28 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:38 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Michael Ellerman
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/kvm/powerpc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index ce1d91eed231..61f2b7e007fa 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -766,8 +766,8 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
{
int err;
- hrtimer_init(&vcpu->arch.dec_timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
- vcpu->arch.dec_timer.function = kvmppc_decrementer_wakeup;
+ hrtimer_setup(&vcpu->arch.dec_timer, kvmppc_decrementer_wakeup, CLOCK_REALTIME,
+ HRTIMER_MODE_ABS);
#ifdef CONFIG_KVM_EXIT_TIMING
mutex_init(&vcpu->arch.exit_timing_lock);
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 03/31] KVM: s390: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
2025-02-05 10:38 ` [PATCH v2 01/31] KVM: MIPS: Switch to use hrtimer_setup() Nam Cao
2025-02-05 10:38 ` [PATCH v2 02/31] KVM: PPC: " Nam Cao
@ 2025-02-05 10:38 ` Nam Cao
2025-02-07 10:29 ` Christian Borntraeger
2025-02-05 10:38 ` [PATCH v2 04/31] KVM: x86: " Nam Cao
` (27 subsequent siblings)
30 siblings, 1 reply; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:38 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Christian Borntraeger
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
---
arch/s390/kvm/interrupt.c | 3 +--
arch/s390/kvm/kvm-s390.c | 4 ++--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index d4f031e086fc..11a33fa21dfd 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -3171,8 +3171,7 @@ void kvm_s390_gisa_init(struct kvm *kvm)
gi->alert.mask = 0;
spin_lock_init(&gi->alert.ref_lock);
gi->expires = 50 * 1000; /* 50 usec */
- hrtimer_init(&gi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- gi->timer.function = gisa_vcpu_kicker;
+ hrtimer_setup(&gi->timer, gisa_vcpu_kicker, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
memset(gi->origin, 0, sizeof(struct kvm_s390_gisa));
gi->origin->next_alert = (u32)virt_to_phys(gi->origin);
VM_EVENT(kvm, 3, "gisa 0x%pK initialized", gi->origin);
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index d8080c27d45b..a0ef902c7a3d 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -3930,8 +3930,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
if (rc)
return rc;
}
- hrtimer_init(&vcpu->arch.ckc_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- vcpu->arch.ckc_timer.function = kvm_s390_idle_wakeup;
+ hrtimer_setup(&vcpu->arch.ckc_timer, kvm_s390_idle_wakeup, CLOCK_MONOTONIC,
+ HRTIMER_MODE_REL);
vcpu->arch.sie_block->hpid = HPID_KVM;
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH v2 03/31] KVM: s390: Switch to use hrtimer_setup()
2025-02-05 10:38 ` [PATCH v2 03/31] KVM: s390: " Nam Cao
@ 2025-02-07 10:29 ` Christian Borntraeger
0 siblings, 0 replies; 39+ messages in thread
From: Christian Borntraeger @ 2025-02-07 10:29 UTC (permalink / raw)
To: Nam Cao, Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel, linux-s390
Cc: Janosch Frank, Claudio Imbrenda
Am 05.02.25 um 11:38 schrieb Nam Cao:
> hrtimer_setup() takes the callback function pointer as argument and
> initializes the timer completely.
>
> Replace hrtimer_init() and the open coded initialization of
> hrtimer::function with the new setup mechanism.
>
> Patch was created by using Coccinelle.
>
> Signed-off-by: Nam Cao <namcao@linutronix.de>
> Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@linux.ibm.com>
> ---
> arch/s390/kvm/interrupt.c | 3 +--
> arch/s390/kvm/kvm-s390.c | 4 ++--
> 2 files changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
> index d4f031e086fc..11a33fa21dfd 100644
> --- a/arch/s390/kvm/interrupt.c
> +++ b/arch/s390/kvm/interrupt.c
> @@ -3171,8 +3171,7 @@ void kvm_s390_gisa_init(struct kvm *kvm)
> gi->alert.mask = 0;
> spin_lock_init(&gi->alert.ref_lock);
> gi->expires = 50 * 1000; /* 50 usec */
> - hrtimer_init(&gi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> - gi->timer.function = gisa_vcpu_kicker;
> + hrtimer_setup(&gi->timer, gisa_vcpu_kicker, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> memset(gi->origin, 0, sizeof(struct kvm_s390_gisa));
> gi->origin->next_alert = (u32)virt_to_phys(gi->origin);
> VM_EVENT(kvm, 3, "gisa 0x%pK initialized", gi->origin);
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index d8080c27d45b..a0ef902c7a3d 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -3930,8 +3930,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
> if (rc)
> return rc;
> }
> - hrtimer_init(&vcpu->arch.ckc_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> - vcpu->arch.ckc_timer.function = kvm_s390_idle_wakeup;
> + hrtimer_setup(&vcpu->arch.ckc_timer, kvm_s390_idle_wakeup, CLOCK_MONOTONIC,
> + HRTIMER_MODE_REL);
>
> vcpu->arch.sie_block->hpid = HPID_KVM;
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v2 04/31] KVM: x86: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (2 preceding siblings ...)
2025-02-05 10:38 ` [PATCH v2 03/31] KVM: s390: " Nam Cao
@ 2025-02-05 10:38 ` Nam Cao
2025-02-06 15:33 ` Sean Christopherson
2025-02-05 10:38 ` [PATCH v2 05/31] KVM: arm64: " Nam Cao
` (26 subsequent siblings)
30 siblings, 1 reply; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:38 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Sean Christopherson
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/hyperv.c | 3 +--
arch/x86/kvm/i8254.c | 3 +--
arch/x86/kvm/lapic.c | 5 ++---
arch/x86/kvm/vmx/nested.c | 5 ++---
arch/x86/kvm/xen.c | 4 ++--
5 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index 6a6dd5a84f22..eb9bca66bad0 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -952,8 +952,7 @@ static void stimer_init(struct kvm_vcpu_hv_stimer *stimer, int timer_index)
{
memset(stimer, 0, sizeof(*stimer));
stimer->index = timer_index;
- hrtimer_init(&stimer->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
- stimer->timer.function = stimer_timer_callback;
+ hrtimer_setup(&stimer->timer, stimer_timer_callback, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
stimer_prepare_msg(stimer);
}
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index d7ab8780ab9e..739aa6c0d0c3 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -690,8 +690,7 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags)
pit->kvm = kvm;
pit_state = &pit->pit_state;
- hrtimer_init(&pit_state->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
- pit_state->timer.function = pit_timer_fn;
+ hrtimer_setup(&pit_state->timer, pit_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
pit_state->irq_ack_notifier.gsi = 0;
pit_state->irq_ack_notifier.irq_acked = kvm_pit_ack_irq;
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index a009c94c26c2..eb56cd989574 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -2921,9 +2921,8 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu)
apic->nr_lvt_entries = kvm_apic_calc_nr_lvt_entries(vcpu);
- hrtimer_init(&apic->lapic_timer.timer, CLOCK_MONOTONIC,
- HRTIMER_MODE_ABS_HARD);
- apic->lapic_timer.timer.function = apic_timer_fn;
+ hrtimer_setup(&apic->lapic_timer.timer, apic_timer_fn, CLOCK_MONOTONIC,
+ HRTIMER_MODE_ABS_HARD);
if (lapic_timer_advance)
apic->lapic_timer.timer_advance_ns = LAPIC_TIMER_ADVANCE_NS_INIT;
diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 8a7af02d466e..ca18c3eec76d 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -5316,9 +5316,8 @@ static int enter_vmx_operation(struct kvm_vcpu *vcpu)
if (enable_shadow_vmcs && !alloc_shadow_vmcs(vcpu))
goto out_shadow_vmcs;
- hrtimer_init(&vmx->nested.preemption_timer, CLOCK_MONOTONIC,
- HRTIMER_MODE_ABS_PINNED);
- vmx->nested.preemption_timer.function = vmx_preemption_timer_fn;
+ hrtimer_setup(&vmx->nested.preemption_timer, vmx_preemption_timer_fn, CLOCK_MONOTONIC,
+ HRTIMER_MODE_ABS_PINNED);
vmx->nested.vpid02 = allocate_vpid();
diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
index a909b817b9c0..1ac738dcf7a2 100644
--- a/arch/x86/kvm/xen.c
+++ b/arch/x86/kvm/xen.c
@@ -2225,8 +2225,8 @@ void kvm_xen_init_vcpu(struct kvm_vcpu *vcpu)
vcpu->arch.xen.poll_evtchn = 0;
timer_setup(&vcpu->arch.xen.poll_timer, cancel_evtchn_poll, 0);
- hrtimer_init(&vcpu->arch.xen.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
- vcpu->arch.xen.timer.function = xen_timer_callback;
+ hrtimer_setup(&vcpu->arch.xen.timer, xen_timer_callback, CLOCK_MONOTONIC,
+ HRTIMER_MODE_ABS_HARD);
kvm_gpc_init(&vcpu->arch.xen.runstate_cache, vcpu->kvm);
kvm_gpc_init(&vcpu->arch.xen.runstate2_cache, vcpu->kvm);
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH v2 04/31] KVM: x86: Switch to use hrtimer_setup()
2025-02-05 10:38 ` [PATCH v2 04/31] KVM: x86: " Nam Cao
@ 2025-02-06 15:33 ` Sean Christopherson
0 siblings, 0 replies; 39+ messages in thread
From: Sean Christopherson @ 2025-02-06 15:33 UTC (permalink / raw)
To: Nam Cao
Cc: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
On Wed, Feb 05, 2025, Nam Cao wrote:
> hrtimer_setup() takes the callback function pointer as argument and
> initializes the timer completely.
>
> Replace hrtimer_init() and the open coded initialization of
> hrtimer::function with the new setup mechanism.
>
> Patch was created by using Coccinelle.
>
> Signed-off-by: Nam Cao <namcao@linutronix.de>
> Cc: Sean Christopherson <seanjc@google.com>
> ---
Acked-by: Sean Christopherson <seanjc@google.com>
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v2 05/31] KVM: arm64: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (3 preceding siblings ...)
2025-02-05 10:38 ` [PATCH v2 04/31] KVM: x86: " Nam Cao
@ 2025-02-05 10:38 ` Nam Cao
2025-02-05 10:38 ` [PATCH v2 06/31] LoongArch: KVM: " Nam Cao
` (25 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:38 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Marc Zyngier
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Acked-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Nam Cao <namcao@linutronix.de>
---
arch/arm64/kvm/arch_timer.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c
index d3d243366536..8b1fe7c47d65 100644
--- a/arch/arm64/kvm/arch_timer.c
+++ b/arch/arm64/kvm/arch_timer.c
@@ -1099,8 +1099,7 @@ static void timer_context_init(struct kvm_vcpu *vcpu, int timerid)
else
ctxt->offset.vm_offset = &kvm->arch.timer_data.poffset;
- hrtimer_init(&ctxt->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
- ctxt->hrtimer.function = kvm_hrtimer_expire;
+ hrtimer_setup(&ctxt->hrtimer, kvm_hrtimer_expire, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
switch (timerid) {
case TIMER_PTIMER:
@@ -1127,8 +1126,8 @@ void kvm_timer_vcpu_init(struct kvm_vcpu *vcpu)
timer_set_offset(vcpu_ptimer(vcpu), 0);
}
- hrtimer_init(&timer->bg_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
- timer->bg_timer.function = kvm_bg_timer_expire;
+ hrtimer_setup(&timer->bg_timer, kvm_bg_timer_expire, CLOCK_MONOTONIC,
+ HRTIMER_MODE_ABS_HARD);
}
void kvm_timer_init_vm(struct kvm *kvm)
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 06/31] LoongArch: KVM: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (4 preceding siblings ...)
2025-02-05 10:38 ` [PATCH v2 05/31] KVM: arm64: " Nam Cao
@ 2025-02-05 10:38 ` Nam Cao
2025-02-05 10:38 ` [PATCH v2 07/31] riscv: kvm: " Nam Cao
` (24 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:38 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Huacai Chen
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Huacai Chen <chenhuacai@kernel.org>
---
arch/loongarch/kvm/vcpu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c
index fb72095c8077..e721127c614e 100644
--- a/arch/loongarch/kvm/vcpu.c
+++ b/arch/loongarch/kvm/vcpu.c
@@ -1459,8 +1459,8 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
vcpu->arch.vpid = 0;
vcpu->arch.flush_gpa = INVALID_GPA;
- hrtimer_init(&vcpu->arch.swtimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
- vcpu->arch.swtimer.function = kvm_swtimer_wakeup;
+ hrtimer_setup(&vcpu->arch.swtimer, kvm_swtimer_wakeup, CLOCK_MONOTONIC,
+ HRTIMER_MODE_ABS_PINNED_HARD);
vcpu->arch.handle_exit = kvm_handle_exit;
vcpu->arch.guest_eentry = (unsigned long)kvm_loongarch_ops->exc_entry;
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 07/31] riscv: kvm: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (5 preceding siblings ...)
2025-02-05 10:38 ` [PATCH v2 06/31] LoongArch: KVM: " Nam Cao
@ 2025-02-05 10:38 ` Nam Cao
2025-02-05 10:38 ` [PATCH v2 08/31] ARM: imx: " Nam Cao
` (23 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:38 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Anup Patel
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Anup Patel <anup@brainfault.org>
---
arch/riscv/kvm/vcpu_timer.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/arch/riscv/kvm/vcpu_timer.c b/arch/riscv/kvm/vcpu_timer.c
index 96e7a4e463f7..ff672fa71fcc 100644
--- a/arch/riscv/kvm/vcpu_timer.c
+++ b/arch/riscv/kvm/vcpu_timer.c
@@ -248,18 +248,19 @@ int kvm_riscv_vcpu_timer_init(struct kvm_vcpu *vcpu)
if (t->init_done)
return -EINVAL;
- hrtimer_init(&t->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
t->init_done = true;
t->next_set = false;
/* Enable sstc for every vcpu if available in hardware */
if (riscv_isa_extension_available(NULL, SSTC)) {
t->sstc_enabled = true;
- t->hrt.function = kvm_riscv_vcpu_vstimer_expired;
+ hrtimer_setup(&t->hrt, kvm_riscv_vcpu_vstimer_expired, CLOCK_MONOTONIC,
+ HRTIMER_MODE_REL);
t->timer_next_event = kvm_riscv_vcpu_update_vstimecmp;
} else {
t->sstc_enabled = false;
- t->hrt.function = kvm_riscv_vcpu_hrtimer_expired;
+ hrtimer_setup(&t->hrt, kvm_riscv_vcpu_hrtimer_expired, CLOCK_MONOTONIC,
+ HRTIMER_MODE_REL);
t->timer_next_event = kvm_riscv_vcpu_update_hrtimer;
}
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 08/31] ARM: imx: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (6 preceding siblings ...)
2025-02-05 10:38 ` [PATCH v2 07/31] riscv: kvm: " Nam Cao
@ 2025-02-05 10:38 ` Nam Cao
2025-02-05 10:38 ` [PATCH v2 09/31] ARM: 8611/1: l2x0: " Nam Cao
` (22 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:38 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Sascha Hauer
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-imx/mmdc.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-imx/mmdc.c b/arch/arm/mach-imx/mmdc.c
index e898f7c2733e..94e4f4a2f73f 100644
--- a/arch/arm/mach-imx/mmdc.c
+++ b/arch/arm/mach-imx/mmdc.c
@@ -509,9 +509,8 @@ static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_b
pmu_mmdc->mmdc_ipg_clk = mmdc_ipg_clk;
pmu_mmdc->devtype_data = device_get_match_data(&pdev->dev);
- hrtimer_init(&pmu_mmdc->hrtimer, CLOCK_MONOTONIC,
- HRTIMER_MODE_REL);
- pmu_mmdc->hrtimer.function = mmdc_pmu_timer_handler;
+ hrtimer_setup(&pmu_mmdc->hrtimer, mmdc_pmu_timer_handler, CLOCK_MONOTONIC,
+ HRTIMER_MODE_REL);
cpumask_set_cpu(raw_smp_processor_id(), &pmu_mmdc->cpu);
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 09/31] ARM: 8611/1: l2x0: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (7 preceding siblings ...)
2025-02-05 10:38 ` [PATCH v2 08/31] ARM: imx: " Nam Cao
@ 2025-02-05 10:38 ` Nam Cao
2025-02-05 10:38 ` [PATCH v2 10/31] powerpc/watchdog: " Nam Cao
` (21 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:38 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Russell King
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Russell King <linux@armlinux.org.uk>
---
arch/arm/mm/cache-l2x0-pmu.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/arm/mm/cache-l2x0-pmu.c b/arch/arm/mm/cache-l2x0-pmu.c
index 993fefdc167a..93ef0502b7ff 100644
--- a/arch/arm/mm/cache-l2x0-pmu.c
+++ b/arch/arm/mm/cache-l2x0-pmu.c
@@ -539,8 +539,7 @@ static __init int l2x0_pmu_init(void)
* at higher frequencies.
*/
l2x0_pmu_poll_period = ms_to_ktime(1000);
- hrtimer_init(&l2x0_pmu_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- l2x0_pmu_hrtimer.function = l2x0_pmu_poll;
+ hrtimer_setup(&l2x0_pmu_hrtimer, l2x0_pmu_poll, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
cpumask_set_cpu(0, &pmu_cpu);
ret = cpuhp_setup_state_nocalls(CPUHP_AP_PERF_ARM_L2X0_ONLINE,
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 10/31] powerpc/watchdog: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (8 preceding siblings ...)
2025-02-05 10:38 ` [PATCH v2 09/31] ARM: 8611/1: l2x0: " Nam Cao
@ 2025-02-05 10:38 ` Nam Cao
2025-02-05 10:38 ` [PATCH v2 11/31] perf/x86: " Nam Cao
` (20 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:38 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Michael Ellerman
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/kernel/watchdog.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/watchdog.c b/arch/powerpc/kernel/watchdog.c
index 8c464a5d8246..2429cb1c7baa 100644
--- a/arch/powerpc/kernel/watchdog.c
+++ b/arch/powerpc/kernel/watchdog.c
@@ -495,8 +495,7 @@ static void start_watchdog(void *arg)
*this_cpu_ptr(&wd_timer_tb) = get_tb();
- hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- hrtimer->function = watchdog_timer_fn;
+ hrtimer_setup(hrtimer, watchdog_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
hrtimer_start(hrtimer, ms_to_ktime(wd_timer_period_ms),
HRTIMER_MODE_REL_PINNED);
}
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 11/31] perf/x86: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (9 preceding siblings ...)
2025-02-05 10:38 ` [PATCH v2 10/31] powerpc/watchdog: " Nam Cao
@ 2025-02-05 10:38 ` Nam Cao
2025-02-05 10:38 ` [PATCH v2 12/31] s390/ap_bus: " Nam Cao
` (19 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:38 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Peter Zijlstra
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
---
arch/x86/events/intel/uncore.c | 3 +--
arch/x86/events/rapl.c | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
index 60b3078b7502..a34e50fc4a8f 100644
--- a/arch/x86/events/intel/uncore.c
+++ b/arch/x86/events/intel/uncore.c
@@ -347,8 +347,7 @@ void uncore_pmu_cancel_hrtimer(struct intel_uncore_box *box)
static void uncore_pmu_init_hrtimer(struct intel_uncore_box *box)
{
- hrtimer_init(&box->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- box->hrtimer.function = uncore_pmu_hrtimer;
+ hrtimer_setup(&box->hrtimer, uncore_pmu_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
}
static struct intel_uncore_box *uncore_alloc_box(struct intel_uncore_type *type,
diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c
index d3bb3865c1b1..2b6cc2860836 100644
--- a/arch/x86/events/rapl.c
+++ b/arch/x86/events/rapl.c
@@ -274,8 +274,7 @@ static void rapl_hrtimer_init(struct rapl_pmu *rapl_pmu)
{
struct hrtimer *hr = &rapl_pmu->hrtimer;
- hrtimer_init(hr, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- hr->function = rapl_hrtimer_handle;
+ hrtimer_setup(hr, rapl_hrtimer_handle, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
}
static void __rapl_pmu_event_start(struct rapl_pmu *rapl_pmu,
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 12/31] s390/ap_bus: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (10 preceding siblings ...)
2025-02-05 10:38 ` [PATCH v2 11/31] perf/x86: " Nam Cao
@ 2025-02-05 10:38 ` Nam Cao
2025-02-05 10:38 ` [PATCH v2 13/31] sched: " Nam Cao
` (18 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:38 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Christian Borntraeger
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
---
drivers/s390/crypto/ap_bus.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index 26e1ea1940ec..62feb2c639d5 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -2326,8 +2326,7 @@ static inline int __init ap_async_init(void)
*/
if (MACHINE_IS_VM)
poll_high_timeout = 1500000;
- hrtimer_init(&ap_poll_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
- ap_poll_timer.function = ap_poll_timeout;
+ hrtimer_setup(&ap_poll_timer, ap_poll_timeout, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
queue_work(system_long_wq, &ap_scan_bus_work);
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 13/31] sched: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (11 preceding siblings ...)
2025-02-05 10:38 ` [PATCH v2 12/31] s390/ap_bus: " Nam Cao
@ 2025-02-05 10:38 ` Nam Cao
2025-02-05 10:38 ` [PATCH v2 14/31] mm/slab: " Nam Cao
` (17 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:38 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Peter Zijlstra
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
---
kernel/sched/core.c | 3 +--
kernel/sched/deadline.c | 6 ++----
kernel/sched/fair.c | 8 ++++----
kernel/sched/rt.c | 5 ++---
4 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 165c90ba64ea..357ff79cc760 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -916,8 +916,7 @@ static void hrtick_rq_init(struct rq *rq)
#ifdef CONFIG_SMP
INIT_CSD(&rq->hrtick_csd, __hrtick_start, rq);
#endif
- hrtimer_init(&rq->hrtick_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
- rq->hrtick_timer.function = hrtick;
+ hrtimer_setup(&rq->hrtick_timer, hrtick, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
}
#else /* CONFIG_SCHED_HRTICK */
static inline void hrtick_clear(struct rq *rq)
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 38e4537790af..2d0f571f95e9 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1382,8 +1382,7 @@ static void init_dl_task_timer(struct sched_dl_entity *dl_se)
{
struct hrtimer *timer = &dl_se->dl_timer;
- hrtimer_init(timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
- timer->function = dl_task_timer;
+ hrtimer_setup(timer, dl_task_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
}
/*
@@ -1839,8 +1838,7 @@ static void init_dl_inactive_task_timer(struct sched_dl_entity *dl_se)
{
struct hrtimer *timer = &dl_se->inactive_timer;
- hrtimer_init(timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
- timer->function = inactive_task_timer;
+ hrtimer_setup(timer, inactive_task_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
}
#define __node_2_dle(node) \
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 1c0ef435a7aa..88923f1873f6 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6539,14 +6539,14 @@ void init_cfs_bandwidth(struct cfs_bandwidth *cfs_b, struct cfs_bandwidth *paren
cfs_b->hierarchical_quota = parent ? parent->hierarchical_quota : RUNTIME_INF;
INIT_LIST_HEAD(&cfs_b->throttled_cfs_rq);
- hrtimer_init(&cfs_b->period_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED);
- cfs_b->period_timer.function = sched_cfs_period_timer;
+ hrtimer_setup(&cfs_b->period_timer, sched_cfs_period_timer, CLOCK_MONOTONIC,
+ HRTIMER_MODE_ABS_PINNED);
/* Add a random offset so that timers interleave */
hrtimer_set_expires(&cfs_b->period_timer,
get_random_u32_below(cfs_b->period));
- hrtimer_init(&cfs_b->slack_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- cfs_b->slack_timer.function = sched_cfs_slack_timer;
+ hrtimer_setup(&cfs_b->slack_timer, sched_cfs_slack_timer, CLOCK_MONOTONIC,
+ HRTIMER_MODE_REL);
cfs_b->slack_started = false;
}
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 4b8e33c615b1..7a9ed4d93397 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -127,9 +127,8 @@ void init_rt_bandwidth(struct rt_bandwidth *rt_b, u64 period, u64 runtime)
raw_spin_lock_init(&rt_b->rt_runtime_lock);
- hrtimer_init(&rt_b->rt_period_timer, CLOCK_MONOTONIC,
- HRTIMER_MODE_REL_HARD);
- rt_b->rt_period_timer.function = sched_rt_period_timer;
+ hrtimer_setup(&rt_b->rt_period_timer, sched_rt_period_timer, CLOCK_MONOTONIC,
+ HRTIMER_MODE_REL_HARD);
}
static inline void do_start_rt_bandwidth(struct rt_bandwidth *rt_b)
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 14/31] mm/slab: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (12 preceding siblings ...)
2025-02-05 10:38 ` [PATCH v2 13/31] sched: " Nam Cao
@ 2025-02-05 10:38 ` Nam Cao
2025-02-05 10:38 ` [PATCH v2 15/31] lib: test_objpool: " Nam Cao
` (16 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:38 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Paul E . McKenney
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Nam Cao <namcao@linutronix.de>
---
mm/slab_common.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 4030907b6b7d..59578dafbf37 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -1887,8 +1887,8 @@ run_page_cache_worker(struct kfree_rcu_cpu *krcp)
&krcp->page_cache_work,
msecs_to_jiffies(rcu_delay_page_cache_fill_msec));
} else {
- hrtimer_init(&krcp->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- krcp->hrtimer.function = schedule_page_work_fn;
+ hrtimer_setup(&krcp->hrtimer, schedule_page_work_fn, CLOCK_MONOTONIC,
+ HRTIMER_MODE_REL);
hrtimer_start(&krcp->hrtimer, 0, HRTIMER_MODE_REL);
}
}
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 15/31] lib: test_objpool: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (13 preceding siblings ...)
2025-02-05 10:38 ` [PATCH v2 14/31] mm/slab: " Nam Cao
@ 2025-02-05 10:38 ` Nam Cao
2025-02-05 10:39 ` [PATCH v2 16/31] io_uring/timeout: " Nam Cao
` (15 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:38 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Andrew Morton
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
lib/test_objpool.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/test_objpool.c b/lib/test_objpool.c
index 896c0131c9a8..8f688187fa87 100644
--- a/lib/test_objpool.c
+++ b/lib/test_objpool.c
@@ -190,8 +190,7 @@ static int ot_init_hrtimer(struct ot_item *item, unsigned long hrtimer)
return -ENOENT;
item->hrtcycle = ktime_set(0, hrtimer * 1000000UL);
- hrtimer_init(hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- hrt->function = ot_hrtimer_handler;
+ hrtimer_setup(hrt, ot_hrtimer_handler, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
return 0;
}
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 16/31] io_uring/timeout: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (14 preceding siblings ...)
2025-02-05 10:38 ` [PATCH v2 15/31] lib: test_objpool: " Nam Cao
@ 2025-02-05 10:39 ` Nam Cao
2025-02-05 10:39 ` [PATCH v2 17/31] fork: " Nam Cao
` (14 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:39 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Jens Axboe
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Jens Axboe <axboe@kernel.dk>
---
io_uring/timeout.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/io_uring/timeout.c b/io_uring/timeout.c
index 48fc8cf70784..c5fb817b1e28 100644
--- a/io_uring/timeout.c
+++ b/io_uring/timeout.c
@@ -407,8 +407,7 @@ static int io_linked_timeout_update(struct io_ring_ctx *ctx, __u64 user_data,
io = req->async_data;
if (hrtimer_try_to_cancel(&io->timer) == -1)
return -EALREADY;
- hrtimer_init(&io->timer, io_timeout_get_clock(io), mode);
- io->timer.function = io_link_timeout_fn;
+ hrtimer_setup(&io->timer, io_link_timeout_fn, io_timeout_get_clock(io), mode);
hrtimer_start(&io->timer, timespec64_to_ktime(*ts), mode);
return 0;
}
@@ -430,8 +429,7 @@ static int io_timeout_update(struct io_ring_ctx *ctx, __u64 user_data,
data->ts = *ts;
list_add_tail(&timeout->list, &ctx->timeout_list);
- hrtimer_init(&data->timer, io_timeout_get_clock(data), mode);
- data->timer.function = io_timeout_fn;
+ hrtimer_setup(&data->timer, io_timeout_fn, io_timeout_get_clock(data), mode);
hrtimer_start(&data->timer, timespec64_to_ktime(data->ts), mode);
return 0;
}
@@ -557,7 +555,6 @@ static int __io_timeout_prep(struct io_kiocb *req,
return -EINVAL;
data->mode = io_translate_timeout_mode(flags);
- hrtimer_init(&data->timer, io_timeout_get_clock(data), data->mode);
if (is_timeout_link) {
struct io_submit_link *link = &req->ctx->submit_state.link;
@@ -568,6 +565,10 @@ static int __io_timeout_prep(struct io_kiocb *req,
return -EINVAL;
timeout->head = link->last;
link->last->flags |= REQ_F_ARM_LTIMEOUT;
+ hrtimer_setup(&data->timer, io_link_timeout_fn, io_timeout_get_clock(data),
+ data->mode);
+ } else {
+ hrtimer_setup(&data->timer, io_timeout_fn, io_timeout_get_clock(data), data->mode);
}
return 0;
}
@@ -627,7 +628,6 @@ int io_timeout(struct io_kiocb *req, unsigned int issue_flags)
}
add:
list_add(&timeout->list, entry);
- data->timer.function = io_timeout_fn;
hrtimer_start(&data->timer, timespec64_to_ktime(data->ts), data->mode);
raw_spin_unlock_irq(&ctx->timeout_lock);
return IOU_ISSUE_SKIP_COMPLETE;
@@ -646,7 +646,6 @@ void io_queue_linked_timeout(struct io_kiocb *req)
if (timeout->head) {
struct io_timeout_data *data = req->async_data;
- data->timer.function = io_link_timeout_fn;
hrtimer_start(&data->timer, timespec64_to_ktime(data->ts),
data->mode);
list_add_tail(&timeout->list, &ctx->ltimeout_list);
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 17/31] fork: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (15 preceding siblings ...)
2025-02-05 10:39 ` [PATCH v2 16/31] io_uring/timeout: " Nam Cao
@ 2025-02-05 10:39 ` Nam Cao
2025-02-05 10:39 ` [PATCH v2 18/31] perf: " Nam Cao
` (13 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:39 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Oleg Nesterov
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Oleg Nesterov <oleg@redhat.com>
---
kernel/fork.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/kernel/fork.c b/kernel/fork.c
index 735405a9c5f3..e27fe5d5a15c 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1891,8 +1891,7 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
#ifdef CONFIG_POSIX_TIMERS
INIT_HLIST_HEAD(&sig->posix_timers);
INIT_HLIST_HEAD(&sig->ignored_posix_timers);
- hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- sig->real_timer.function = it_real_fn;
+ hrtimer_setup(&sig->real_timer, it_real_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
#endif
task_lock(current->group_leader);
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 18/31] perf: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (16 preceding siblings ...)
2025-02-05 10:39 ` [PATCH v2 17/31] fork: " Nam Cao
@ 2025-02-05 10:39 ` Nam Cao
2025-02-05 10:39 ` [PATCH v2 19/31] timerfd: " Nam Cao
` (12 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:39 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Peter Zijlstra
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
---
kernel/events/core.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 0f8c55990783..59059e348844 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -1147,8 +1147,8 @@ static void __perf_mux_hrtimer_init(struct perf_cpu_pmu_context *cpc, int cpu)
cpc->hrtimer_interval = ns_to_ktime(NSEC_PER_MSEC * interval);
raw_spin_lock_init(&cpc->hrtimer_lock);
- hrtimer_init(timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
- timer->function = perf_mux_hrtimer_handler;
+ hrtimer_setup(timer, perf_mux_hrtimer_handler, CLOCK_MONOTONIC,
+ HRTIMER_MODE_ABS_PINNED_HARD);
}
static int perf_mux_hrtimer_restart(struct perf_cpu_pmu_context *cpc)
@@ -11366,8 +11366,7 @@ static void perf_swevent_init_hrtimer(struct perf_event *event)
if (!is_sampling_event(event))
return;
- hrtimer_init(&hwc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
- hwc->hrtimer.function = perf_swevent_hrtimer;
+ hrtimer_setup(&hwc->hrtimer, perf_swevent_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
/*
* Since hrtimers have a fixed rate, we can do a static freq->period
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 19/31] timerfd: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (17 preceding siblings ...)
2025-02-05 10:39 ` [PATCH v2 18/31] perf: " Nam Cao
@ 2025-02-05 10:39 ` Nam Cao
2025-02-05 10:39 ` [PATCH v2 20/31] time: Switch to hrtimer_setup() Nam Cao
` (11 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:39 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Christian Brauner
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Christian Brauner <brauner@kernel.org>
---
fs/timerfd.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/timerfd.c b/fs/timerfd.c
index 9f7eb451a60f..cee007e0d978 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -205,9 +205,8 @@ static int timerfd_setup(struct timerfd_ctx *ctx, int flags,
ALARM_REALTIME : ALARM_BOOTTIME,
timerfd_alarmproc);
} else {
- hrtimer_init(&ctx->t.tmr, clockid, htmode);
+ hrtimer_setup(&ctx->t.tmr, timerfd_tmrproc, clockid, htmode);
hrtimer_set_expires(&ctx->t.tmr, texp);
- ctx->t.tmr.function = timerfd_tmrproc;
}
if (texp != 0) {
@@ -429,7 +428,7 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
ALARM_REALTIME : ALARM_BOOTTIME,
timerfd_alarmproc);
else
- hrtimer_init(&ctx->t.tmr, clockid, HRTIMER_MODE_ABS);
+ hrtimer_setup(&ctx->t.tmr, timerfd_tmrproc, clockid, HRTIMER_MODE_ABS);
ctx->moffs = ktime_mono_to_real(0);
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 20/31] time: Switch to hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (18 preceding siblings ...)
2025-02-05 10:39 ` [PATCH v2 19/31] timerfd: " Nam Cao
@ 2025-02-05 10:39 ` Nam Cao
2025-02-05 10:39 ` [PATCH v2 21/31] bpf: Switch to use hrtimer_setup() Nam Cao
` (10 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:39 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, John Stultz
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: John Stultz <jstultz@google.com>
---
kernel/time/ntp.c | 3 +--
kernel/time/posix-timers.c | 7 +++----
kernel/time/sched_clock.c | 3 +--
kernel/time/tick-broadcast-hrtimer.c | 3 +--
kernel/time/tick-sched.c | 6 ++----
5 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 163e7a2033b6..b837d3d9d325 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -678,8 +678,7 @@ void ntp_notify_cmos_timer(bool offset_set)
static void __init ntp_init_cmos_sync(void)
{
- hrtimer_init(&sync_hrtimer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
- sync_hrtimer.function = sync_timer_callback;
+ hrtimer_setup(&sync_hrtimer, sync_timer_callback, CLOCK_REALTIME, HRTIMER_MODE_ABS);
}
#else /* CONFIG_GENERIC_CMOS_UPDATE) || defined(CONFIG_RTC_SYSTOHC) */
static inline void __init ntp_init_cmos_sync(void) { }
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 1b675aee99a9..58351f537a04 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -381,7 +381,7 @@ static void posix_timer_unhash_and_free(struct k_itimer *tmr)
static int common_timer_create(struct k_itimer *new_timer)
{
- hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock, 0);
+ hrtimer_setup(&new_timer->it.real.timer, posix_timer_fn, new_timer->it_clock, 0);
return 0;
}
@@ -747,7 +747,7 @@ static void common_hrtimer_arm(struct k_itimer *timr, ktime_t expires,
/*
* Posix magic: Relative CLOCK_REALTIME timers are not affected by
* clock modifications, so they become CLOCK_MONOTONIC based under the
- * hood. See hrtimer_init(). Update timr->kclock, so the generic
+ * hood. See hrtimer_setup(). Update timr->kclock, so the generic
* functions which use timr->kclock->clock_get_*() work.
*
* Note: it_clock stays unmodified, because the next timer_set() might
@@ -756,8 +756,7 @@ static void common_hrtimer_arm(struct k_itimer *timr, ktime_t expires,
if (timr->it_clock == CLOCK_REALTIME)
timr->kclock = absolute ? &clock_realtime : &clock_monotonic;
- hrtimer_init(&timr->it.real.timer, timr->it_clock, mode);
- timr->it.real.timer.function = posix_timer_fn;
+ hrtimer_setup(&timr->it.real.timer, posix_timer_fn, timr->it_clock, mode);
if (!absolute)
expires = ktime_add_safe(expires, timer->base->get_time());
diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
index fcca4e72f1ef..cc15fe293719 100644
--- a/kernel/time/sched_clock.c
+++ b/kernel/time/sched_clock.c
@@ -263,8 +263,7 @@ void __init generic_sched_clock_init(void)
* Start the timer to keep sched_clock() properly updated and
* sets the initial epoch.
*/
- hrtimer_init(&sched_clock_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
- sched_clock_timer.function = sched_clock_poll;
+ hrtimer_setup(&sched_clock_timer, sched_clock_poll, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL_HARD);
}
diff --git a/kernel/time/tick-broadcast-hrtimer.c b/kernel/time/tick-broadcast-hrtimer.c
index e28f9210f8a1..a88b72b0f35e 100644
--- a/kernel/time/tick-broadcast-hrtimer.c
+++ b/kernel/time/tick-broadcast-hrtimer.c
@@ -100,7 +100,6 @@ static enum hrtimer_restart bc_handler(struct hrtimer *t)
void tick_setup_hrtimer_broadcast(void)
{
- hrtimer_init(&bctimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
- bctimer.function = bc_handler;
+ hrtimer_setup(&bctimer, bc_handler, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
clockevents_register_device(&ce_broadcast_hrtimer);
}
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index fa058510af9c..c527b421c865 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -1573,12 +1573,10 @@ void tick_setup_sched_timer(bool hrtimer)
struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);
/* Emulate tick processing via per-CPU hrtimers: */
- hrtimer_init(&ts->sched_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
+ hrtimer_setup(&ts->sched_timer, tick_nohz_handler, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
- if (IS_ENABLED(CONFIG_HIGH_RES_TIMERS) && hrtimer) {
+ if (IS_ENABLED(CONFIG_HIGH_RES_TIMERS) && hrtimer)
tick_sched_flag_set(ts, TS_FLAG_HIGHRES);
- ts->sched_timer.function = tick_nohz_handler;
- }
/* Get the next period (per-CPU) */
hrtimer_set_expires(&ts->sched_timer, tick_init_jiffy_update());
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 21/31] bpf: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (19 preceding siblings ...)
2025-02-05 10:39 ` [PATCH v2 20/31] time: Switch to hrtimer_setup() Nam Cao
@ 2025-02-05 10:39 ` Nam Cao
2025-02-05 10:39 ` [PATCH v2 22/31] ubifs: " Nam Cao
` (9 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:39 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Alexei Starovoitov
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Alexei Starovoitov <ast@kernel.org>
---
kernel/bpf/helpers.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index f27ce162427a..672abe111282 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -1284,8 +1284,7 @@ static int __bpf_async_init(struct bpf_async_kern *async, struct bpf_map *map, u
atomic_set(&t->cancelling, 0);
INIT_WORK(&t->cb.delete_work, bpf_timer_delete_work);
- hrtimer_init(&t->timer, clockid, HRTIMER_MODE_REL_SOFT);
- t->timer.function = bpf_timer_cb;
+ hrtimer_setup(&t->timer, bpf_timer_cb, clockid, HRTIMER_MODE_REL_SOFT);
cb->value = (void *)async - map->record->timer_off;
break;
case BPF_ASYNC_TYPE_WQ:
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 22/31] ubifs: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (20 preceding siblings ...)
2025-02-05 10:39 ` [PATCH v2 21/31] bpf: Switch to use hrtimer_setup() Nam Cao
@ 2025-02-05 10:39 ` Nam Cao
2025-02-10 19:36 ` Richard Weinberger
2025-02-05 10:39 ` [PATCH v2 23/31] watchdog: " Nam Cao
` (8 subsequent siblings)
30 siblings, 1 reply; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:39 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Richard Weinberger
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Richard Weinberger <richard@nod.at>
---
fs/ubifs/io.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
index 01d8eb170382..a79f229df475 100644
--- a/fs/ubifs/io.c
+++ b/fs/ubifs/io.c
@@ -1179,8 +1179,7 @@ int ubifs_wbuf_init(struct ubifs_info *c, struct ubifs_wbuf *wbuf)
wbuf->c = c;
wbuf->next_ino = 0;
- hrtimer_init(&wbuf->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- wbuf->timer.function = wbuf_timer_callback_nolock;
+ hrtimer_setup(&wbuf->timer, wbuf_timer_callback_nolock, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
return 0;
}
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH v2 22/31] ubifs: Switch to use hrtimer_setup()
2025-02-05 10:39 ` [PATCH v2 22/31] ubifs: " Nam Cao
@ 2025-02-10 19:36 ` Richard Weinberger
0 siblings, 0 replies; 39+ messages in thread
From: Richard Weinberger @ 2025-02-10 19:36 UTC (permalink / raw)
To: Nam Cao; +Cc: Anna-Maria Behnsen, frederic, tglx, linux-kernel
----- Ursprüngliche Mail -----
> Von: "Nam Cao" <namcao@linutronix.de>
> An: "Anna-Maria Behnsen" <anna-maria@linutronix.de>, "frederic" <frederic@kernel.org>, "tglx" <tglx@linutronix.de>,
> "linux-kernel" <linux-kernel@vger.kernel.org>
> CC: "Nam Cao" <namcao@linutronix.de>, "richard" <richard@nod.at>
> Gesendet: Mittwoch, 5. Februar 2025 11:39:06
> Betreff: [PATCH v2 22/31] ubifs: Switch to use hrtimer_setup()
> hrtimer_setup() takes the callback function pointer as argument and
> initializes the timer completely.
>
> Replace hrtimer_init() and the open coded initialization of
> hrtimer::function with the new setup mechanism.
>
> Patch was created by using Coccinelle.
>
> Signed-off-by: Nam Cao <namcao@linutronix.de>
> Cc: Richard Weinberger <richard@nod.at>
> ---
> fs/ubifs/io.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
> index 01d8eb170382..a79f229df475 100644
> --- a/fs/ubifs/io.c
> +++ b/fs/ubifs/io.c
> @@ -1179,8 +1179,7 @@ int ubifs_wbuf_init(struct ubifs_info *c, struct
> ubifs_wbuf *wbuf)
> wbuf->c = c;
> wbuf->next_ino = 0;
>
> - hrtimer_init(&wbuf->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> - wbuf->timer.function = wbuf_timer_callback_nolock;
> + hrtimer_setup(&wbuf->timer, wbuf_timer_callback_nolock, CLOCK_MONOTONIC,
> HRTIMER_MODE_REL);
> return 0;
Acked-by: Richard Weinberger <richard@nod.at>
Thanks,
//richard
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v2 23/31] watchdog: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (21 preceding siblings ...)
2025-02-05 10:39 ` [PATCH v2 22/31] ubifs: " Nam Cao
@ 2025-02-05 10:39 ` Nam Cao
2025-02-11 16:16 ` Guenter Roeck
2025-02-05 10:39 ` [PATCH v2 24/31] tracing/osnoise: " Nam Cao
` (7 subsequent siblings)
30 siblings, 1 reply; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:39 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Wim Van Sebroeck, linux-watchdog
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
Cc: linux-watchdog@vger.kernel.org
---
drivers/watchdog/softdog.c | 8 +++-----
drivers/watchdog/watchdog_dev.c | 4 ++--
drivers/watchdog/watchdog_hrtimer_pretimeout.c | 4 ++--
kernel/watchdog.c | 3 +--
4 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/drivers/watchdog/softdog.c b/drivers/watchdog/softdog.c
index 7a1096265f18..0820e35ad2e3 100644
--- a/drivers/watchdog/softdog.c
+++ b/drivers/watchdog/softdog.c
@@ -187,14 +187,12 @@ static int __init softdog_init(void)
watchdog_set_nowayout(&softdog_dev, nowayout);
watchdog_stop_on_reboot(&softdog_dev);
- hrtimer_init(&softdog_ticktock, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- softdog_ticktock.function = softdog_fire;
+ hrtimer_setup(&softdog_ticktock, softdog_fire, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
if (IS_ENABLED(CONFIG_SOFT_WATCHDOG_PRETIMEOUT)) {
softdog_info.options |= WDIOF_PRETIMEOUT;
- hrtimer_init(&softdog_preticktock, CLOCK_MONOTONIC,
- HRTIMER_MODE_REL);
- softdog_preticktock.function = softdog_pretimeout;
+ hrtimer_setup(&softdog_preticktock, softdog_pretimeout, CLOCK_MONOTONIC,
+ HRTIMER_MODE_REL);
}
if (soft_active_on_boot)
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 19698d87dc57..8369fd94fc1a 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -1051,8 +1051,8 @@ static int watchdog_cdev_register(struct watchdog_device *wdd)
}
kthread_init_work(&wd_data->work, watchdog_ping_work);
- hrtimer_init(&wd_data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
- wd_data->timer.function = watchdog_timer_expired;
+ hrtimer_setup(&wd_data->timer, watchdog_timer_expired, CLOCK_MONOTONIC,
+ HRTIMER_MODE_REL_HARD);
watchdog_hrtimer_pretimeout_init(wdd);
if (wdd->id == 0) {
diff --git a/drivers/watchdog/watchdog_hrtimer_pretimeout.c b/drivers/watchdog/watchdog_hrtimer_pretimeout.c
index 940b53718a91..fbc7eecd8b20 100644
--- a/drivers/watchdog/watchdog_hrtimer_pretimeout.c
+++ b/drivers/watchdog/watchdog_hrtimer_pretimeout.c
@@ -23,8 +23,8 @@ void watchdog_hrtimer_pretimeout_init(struct watchdog_device *wdd)
{
struct watchdog_core_data *wd_data = wdd->wd_data;
- hrtimer_init(&wd_data->pretimeout_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- wd_data->pretimeout_timer.function = watchdog_hrtimer_pretimeout;
+ hrtimer_setup(&wd_data->pretimeout_timer, watchdog_hrtimer_pretimeout, CLOCK_MONOTONIC,
+ HRTIMER_MODE_REL);
}
void watchdog_hrtimer_pretimeout_start(struct watchdog_device *wdd)
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index b2da7de39d06..6a98dbc931ac 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -797,8 +797,7 @@ static void watchdog_enable(unsigned int cpu)
* Start the timer first to prevent the hardlockup watchdog triggering
* before the timer has a chance to fire.
*/
- hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
- hrtimer->function = watchdog_timer_fn;
+ hrtimer_setup(hrtimer, watchdog_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
hrtimer_start(hrtimer, ns_to_ktime(sample_period),
HRTIMER_MODE_REL_PINNED_HARD);
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH v2 23/31] watchdog: Switch to use hrtimer_setup()
2025-02-05 10:39 ` [PATCH v2 23/31] watchdog: " Nam Cao
@ 2025-02-11 16:16 ` Guenter Roeck
2025-02-13 11:16 ` Thomas Gleixner
0 siblings, 1 reply; 39+ messages in thread
From: Guenter Roeck @ 2025-02-11 16:16 UTC (permalink / raw)
To: Nam Cao
Cc: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel, Wim Van Sebroeck, linux-watchdog
On Wed, Feb 05, 2025 at 11:39:07AM +0100, Nam Cao wrote:
> hrtimer_setup() takes the callback function pointer as argument and
> initializes the timer completely.
>
> Replace hrtimer_init() and the open coded initialization of
> hrtimer::function with the new setup mechanism.
>
> Patch was created by using Coccinelle.
>
> Signed-off-by: Nam Cao <namcao@linutronix.de>
> Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
> Cc: linux-watchdog@vger.kernel.org
> ---
Change log missing. I am also personally not a friend of changing
multiple drivers in a single patch for changes like this. That makes
it all but impossible to revert one of the driver changes if it was
wrong without reverting everything.
Guenter
> drivers/watchdog/softdog.c | 8 +++-----
> drivers/watchdog/watchdog_dev.c | 4 ++--
> drivers/watchdog/watchdog_hrtimer_pretimeout.c | 4 ++--
> kernel/watchdog.c | 3 +--
> 4 files changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/watchdog/softdog.c b/drivers/watchdog/softdog.c
> index 7a1096265f18..0820e35ad2e3 100644
> --- a/drivers/watchdog/softdog.c
> +++ b/drivers/watchdog/softdog.c
> @@ -187,14 +187,12 @@ static int __init softdog_init(void)
> watchdog_set_nowayout(&softdog_dev, nowayout);
> watchdog_stop_on_reboot(&softdog_dev);
>
> - hrtimer_init(&softdog_ticktock, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> - softdog_ticktock.function = softdog_fire;
> + hrtimer_setup(&softdog_ticktock, softdog_fire, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
>
> if (IS_ENABLED(CONFIG_SOFT_WATCHDOG_PRETIMEOUT)) {
> softdog_info.options |= WDIOF_PRETIMEOUT;
> - hrtimer_init(&softdog_preticktock, CLOCK_MONOTONIC,
> - HRTIMER_MODE_REL);
> - softdog_preticktock.function = softdog_pretimeout;
> + hrtimer_setup(&softdog_preticktock, softdog_pretimeout, CLOCK_MONOTONIC,
> + HRTIMER_MODE_REL);
> }
>
> if (soft_active_on_boot)
> diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
> index 19698d87dc57..8369fd94fc1a 100644
> --- a/drivers/watchdog/watchdog_dev.c
> +++ b/drivers/watchdog/watchdog_dev.c
> @@ -1051,8 +1051,8 @@ static int watchdog_cdev_register(struct watchdog_device *wdd)
> }
>
> kthread_init_work(&wd_data->work, watchdog_ping_work);
> - hrtimer_init(&wd_data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
> - wd_data->timer.function = watchdog_timer_expired;
> + hrtimer_setup(&wd_data->timer, watchdog_timer_expired, CLOCK_MONOTONIC,
> + HRTIMER_MODE_REL_HARD);
> watchdog_hrtimer_pretimeout_init(wdd);
>
> if (wdd->id == 0) {
> diff --git a/drivers/watchdog/watchdog_hrtimer_pretimeout.c b/drivers/watchdog/watchdog_hrtimer_pretimeout.c
> index 940b53718a91..fbc7eecd8b20 100644
> --- a/drivers/watchdog/watchdog_hrtimer_pretimeout.c
> +++ b/drivers/watchdog/watchdog_hrtimer_pretimeout.c
> @@ -23,8 +23,8 @@ void watchdog_hrtimer_pretimeout_init(struct watchdog_device *wdd)
> {
> struct watchdog_core_data *wd_data = wdd->wd_data;
>
> - hrtimer_init(&wd_data->pretimeout_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> - wd_data->pretimeout_timer.function = watchdog_hrtimer_pretimeout;
> + hrtimer_setup(&wd_data->pretimeout_timer, watchdog_hrtimer_pretimeout, CLOCK_MONOTONIC,
> + HRTIMER_MODE_REL);
> }
>
> void watchdog_hrtimer_pretimeout_start(struct watchdog_device *wdd)
> diff --git a/kernel/watchdog.c b/kernel/watchdog.c
> index b2da7de39d06..6a98dbc931ac 100644
> --- a/kernel/watchdog.c
> +++ b/kernel/watchdog.c
> @@ -797,8 +797,7 @@ static void watchdog_enable(unsigned int cpu)
> * Start the timer first to prevent the hardlockup watchdog triggering
> * before the timer has a chance to fire.
> */
> - hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
> - hrtimer->function = watchdog_timer_fn;
> + hrtimer_setup(hrtimer, watchdog_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
> hrtimer_start(hrtimer, ns_to_ktime(sample_period),
> HRTIMER_MODE_REL_PINNED_HARD);
>
> --
> 2.39.5
>
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH v2 23/31] watchdog: Switch to use hrtimer_setup()
2025-02-11 16:16 ` Guenter Roeck
@ 2025-02-13 11:16 ` Thomas Gleixner
2025-02-13 12:24 ` Guenter Roeck
0 siblings, 1 reply; 39+ messages in thread
From: Thomas Gleixner @ 2025-02-13 11:16 UTC (permalink / raw)
To: Guenter Roeck, Nam Cao
Cc: Anna-Maria Behnsen, Frederic Weisbecker, linux-kernel,
Wim Van Sebroeck, linux-watchdog
On Tue, Feb 11 2025 at 08:16, Guenter Roeck wrote:
> On Wed, Feb 05, 2025 at 11:39:07AM +0100, Nam Cao wrote:
>> hrtimer_setup() takes the callback function pointer as argument and
>> initializes the timer completely.
>>
>> Replace hrtimer_init() and the open coded initialization of
>> hrtimer::function with the new setup mechanism.
>>
>> Patch was created by using Coccinelle.
>>
>> Signed-off-by: Nam Cao <namcao@linutronix.de>
>> Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
>> Cc: linux-watchdog@vger.kernel.org
>> ---
>
> Change log missing.
I read the above as a change log, but _I_ might be missing something.
> I am also personally not a friend of changing
> multiple drivers in a single patch for changes like this. That makes
> it all but impossible to revert one of the driver changes if it was
> wrong without reverting everything.
Come on. This is a purely mechanical change which is fully equivalent,
so splitting it up further is just increasing patch count for no value.
Thanks,
tglx
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH v2 23/31] watchdog: Switch to use hrtimer_setup()
2025-02-13 11:16 ` Thomas Gleixner
@ 2025-02-13 12:24 ` Guenter Roeck
2025-02-13 13:43 ` Nam Cao
0 siblings, 1 reply; 39+ messages in thread
From: Guenter Roeck @ 2025-02-13 12:24 UTC (permalink / raw)
To: Thomas Gleixner, Nam Cao
Cc: Anna-Maria Behnsen, Frederic Weisbecker, linux-kernel,
Wim Van Sebroeck, linux-watchdog
On 2/13/25 03:16, Thomas Gleixner wrote:
> On Tue, Feb 11 2025 at 08:16, Guenter Roeck wrote:
>> On Wed, Feb 05, 2025 at 11:39:07AM +0100, Nam Cao wrote:
>>> hrtimer_setup() takes the callback function pointer as argument and
>>> initializes the timer completely.
>>>
>>> Replace hrtimer_init() and the open coded initialization of
>>> hrtimer::function with the new setup mechanism.
>>>
>>> Patch was created by using Coccinelle.
>>>
>>> Signed-off-by: Nam Cao <namcao@linutronix.de>
>>> Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
>>> Cc: linux-watchdog@vger.kernel.org
>>> ---
>>
>> Change log missing.
>
> I read the above as a change log, but _I_ might be missing something.
>
I have no idea what changed since v1 or why. If you can see that
in the patch description, good for you.
Guenter
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH v2 23/31] watchdog: Switch to use hrtimer_setup()
2025-02-13 12:24 ` Guenter Roeck
@ 2025-02-13 13:43 ` Nam Cao
0 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-13 13:43 UTC (permalink / raw)
To: Guenter Roeck
Cc: Thomas Gleixner, Anna-Maria Behnsen, Frederic Weisbecker,
linux-kernel, Wim Van Sebroeck, linux-watchdog
Hi Guenter,
On Thu, Feb 13, 2025 at 04:24:25AM -0800, Guenter Roeck wrote:
> I have no idea what changed since v1 or why. If you can see that
> in the patch description, good for you.
The change log is in the cover letter [1]. I just noticed that I forgot to Cc
the cover letter to the watchdog mailing list, sorry about that!
This v2 is sent due to conflict with 6.14-rc1. Most patches (including this
one) are the same.
Best regards,
Nam
[1] https://lore.kernel.org/lkml/cover.1738746821.git.namcao@linutronix.de/
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v2 24/31] tracing/osnoise: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (22 preceding siblings ...)
2025-02-05 10:39 ` [PATCH v2 23/31] watchdog: " Nam Cao
@ 2025-02-05 10:39 ` Nam Cao
2025-02-05 10:39 ` [PATCH v2 25/31] block, bfq: " Nam Cao
` (6 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:39 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Steven Rostedt
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Nam Cao <namcao@linutronix.de>
---
kernel/trace/trace_osnoise.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index f3a2722ee4c0..15999532956a 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -1901,8 +1901,7 @@ static int timerlat_main(void *data)
tlat->count = 0;
tlat->tracing_thread = false;
- hrtimer_init(&tlat->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
- tlat->timer.function = timerlat_irq;
+ hrtimer_setup(&tlat->timer, timerlat_irq, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
tlat->kthread = current;
osn_var->pid = current->pid;
/*
@@ -2456,8 +2455,7 @@ static int timerlat_fd_open(struct inode *inode, struct file *file)
tlat = this_cpu_tmr_var();
tlat->count = 0;
- hrtimer_init(&tlat->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
- tlat->timer.function = timerlat_irq;
+ hrtimer_setup(&tlat->timer, timerlat_irq, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
migrate_enable();
return 0;
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 25/31] block, bfq: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (23 preceding siblings ...)
2025-02-05 10:39 ` [PATCH v2 24/31] tracing/osnoise: " Nam Cao
@ 2025-02-05 10:39 ` Nam Cao
2025-02-05 10:39 ` [PATCH v2 26/31] ata: pata_octeon_cf: " Nam Cao
` (5 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:39 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Jens Axboe
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Jens Axboe <axboe@kernel.dk>
---
block/bfq-iosched.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index 167542201603..abd80dc13562 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -7315,9 +7315,8 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e)
INIT_LIST_HEAD(&bfqd->dispatch);
- hrtimer_init(&bfqd->idle_slice_timer, CLOCK_MONOTONIC,
- HRTIMER_MODE_REL);
- bfqd->idle_slice_timer.function = bfq_idle_slice_timer;
+ hrtimer_setup(&bfqd->idle_slice_timer, bfq_idle_slice_timer, CLOCK_MONOTONIC,
+ HRTIMER_MODE_REL);
bfqd->queue_weights_tree = RB_ROOT_CACHED;
#ifdef CONFIG_BFQ_GROUP_IOSCHED
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 26/31] ata: pata_octeon_cf: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (24 preceding siblings ...)
2025-02-05 10:39 ` [PATCH v2 25/31] block, bfq: " Nam Cao
@ 2025-02-05 10:39 ` Nam Cao
2025-02-05 10:39 ` [PATCH v2 27/31] blk_iocost: " Nam Cao
` (4 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:39 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Damien Le Moal
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Acked-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Nam Cao <namcao@linutronix.de>
---
drivers/ata/pata_octeon_cf.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/ata/pata_octeon_cf.c b/drivers/ata/pata_octeon_cf.c
index dce24806a052..2d32125c16fd 100644
--- a/drivers/ata/pata_octeon_cf.c
+++ b/drivers/ata/pata_octeon_cf.c
@@ -935,9 +935,8 @@ static int octeon_cf_probe(struct platform_device *pdev)
ap->mwdma_mask = enable_dma ? ATA_MWDMA4 : 0;
/* True IDE mode needs a timer to poll for not-busy. */
- hrtimer_init(&cf_port->delayed_finish, CLOCK_MONOTONIC,
- HRTIMER_MODE_REL);
- cf_port->delayed_finish.function = octeon_cf_delayed_finish;
+ hrtimer_setup(&cf_port->delayed_finish, octeon_cf_delayed_finish, CLOCK_MONOTONIC,
+ HRTIMER_MODE_REL);
} else {
/* 16 bit but not True IDE */
base = cs0 + 0x800;
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 27/31] blk_iocost: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (25 preceding siblings ...)
2025-02-05 10:39 ` [PATCH v2 26/31] ata: pata_octeon_cf: " Nam Cao
@ 2025-02-05 10:39 ` Nam Cao
2025-02-05 10:39 ` [PATCH v2 28/31] PM: runtime: " Nam Cao
` (3 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:39 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Jens Axboe
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Jens Axboe <axboe@kernel.dk>
---
block/blk-iocost.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 65a1d4427ccf..ed11438eb4be 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -3004,8 +3004,7 @@ static void ioc_pd_init(struct blkg_policy_data *pd)
iocg->hweight_inuse = WEIGHT_ONE;
init_waitqueue_head(&iocg->waitq);
- hrtimer_init(&iocg->waitq_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
- iocg->waitq_timer.function = iocg_waitq_timer_fn;
+ hrtimer_setup(&iocg->waitq_timer, iocg_waitq_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
iocg->level = blkg->blkcg->css.cgroup->level;
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 28/31] PM: runtime: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (26 preceding siblings ...)
2025-02-05 10:39 ` [PATCH v2 27/31] blk_iocost: " Nam Cao
@ 2025-02-05 10:39 ` Nam Cao
2025-02-05 10:39 ` [PATCH v2 29/31] PM / devfreq: rockchip-dfi: " Nam Cao
` (2 subsequent siblings)
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:39 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Rafael J . Wysocki
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Nam Cao <namcao@linutronix.de>
---
drivers/base/power/runtime.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 2ee45841486b..425c43b2d478 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -1764,8 +1764,8 @@ void pm_runtime_init(struct device *dev)
INIT_WORK(&dev->power.work, pm_runtime_work);
dev->power.timer_expires = 0;
- hrtimer_init(&dev->power.suspend_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
- dev->power.suspend_timer.function = pm_suspend_timer_fn;
+ hrtimer_setup(&dev->power.suspend_timer, pm_suspend_timer_fn, CLOCK_MONOTONIC,
+ HRTIMER_MODE_ABS);
init_waitqueue_head(&dev->power.wait_queue);
}
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 29/31] PM / devfreq: rockchip-dfi: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (27 preceding siblings ...)
2025-02-05 10:39 ` [PATCH v2 28/31] PM: runtime: " Nam Cao
@ 2025-02-05 10:39 ` Nam Cao
2025-02-05 10:39 ` [PATCH v2 30/31] null_blk: " Nam Cao
2025-02-05 10:39 ` [PATCH v2 31/31] hwrng: timeriomem: " Nam Cao
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:39 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Chanwoo Choi, Heiko Stuebner
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Heiko Stuebner <heiko@sntech.de>
---
drivers/devfreq/event/rockchip-dfi.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/devfreq/event/rockchip-dfi.c b/drivers/devfreq/event/rockchip-dfi.c
index e2a1e4463b6f..0470d7c175f4 100644
--- a/drivers/devfreq/event/rockchip-dfi.c
+++ b/drivers/devfreq/event/rockchip-dfi.c
@@ -642,8 +642,7 @@ static int rockchip_ddr_perf_init(struct rockchip_dfi *dfi)
if (ret)
return ret;
- hrtimer_init(&dfi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- dfi->timer.function = rockchip_dfi_timer;
+ hrtimer_setup(&dfi->timer, rockchip_dfi_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
switch (dfi->ddr_type) {
case ROCKCHIP_DDRTYPE_LPDDR2:
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 30/31] null_blk: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (28 preceding siblings ...)
2025-02-05 10:39 ` [PATCH v2 29/31] PM / devfreq: rockchip-dfi: " Nam Cao
@ 2025-02-05 10:39 ` Nam Cao
2025-02-05 10:39 ` [PATCH v2 31/31] hwrng: timeriomem: " Nam Cao
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:39 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Jens Axboe
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Jens Axboe <axboe@kernel.dk>
---
drivers/block/null_blk/main.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index d94ef37480bd..16457330c1bc 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -1426,8 +1426,7 @@ static void nullb_setup_bwtimer(struct nullb *nullb)
{
ktime_t timer_interval = ktime_set(0, TIMER_INTERVAL);
- hrtimer_init(&nullb->bw_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- nullb->bw_timer.function = nullb_bwtimer_fn;
+ hrtimer_setup(&nullb->bw_timer, nullb_bwtimer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
atomic_long_set(&nullb->cur_bytes, mb_per_tick(nullb->dev->mbps));
hrtimer_start(&nullb->bw_timer, timer_interval, HRTIMER_MODE_REL);
}
@@ -1604,8 +1603,8 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx,
might_sleep_if(hctx->flags & BLK_MQ_F_BLOCKING);
if (!is_poll && nq->dev->irqmode == NULL_IRQ_TIMER) {
- hrtimer_init(&cmd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- cmd->timer.function = null_cmd_timer_expired;
+ hrtimer_setup(&cmd->timer, null_cmd_timer_expired, CLOCK_MONOTONIC,
+ HRTIMER_MODE_REL);
}
cmd->error = BLK_STS_OK;
cmd->nq = nq;
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 31/31] hwrng: timeriomem: Switch to use hrtimer_setup()
2025-02-05 10:38 [PATCH v2 00/31] hrtimers: Consolidate hrtimer initialization - Part 2 Nam Cao
` (29 preceding siblings ...)
2025-02-05 10:39 ` [PATCH v2 30/31] null_blk: " Nam Cao
@ 2025-02-05 10:39 ` Nam Cao
30 siblings, 0 replies; 39+ messages in thread
From: Nam Cao @ 2025-02-05 10:39 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
linux-kernel
Cc: Nam Cao, Herbert Xu
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.
Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.
Patch was created by using Coccinelle.
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
---
drivers/char/hw_random/timeriomem-rng.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/char/hw_random/timeriomem-rng.c b/drivers/char/hw_random/timeriomem-rng.c
index 7174bfccc7b3..b95f6d0f17ed 100644
--- a/drivers/char/hw_random/timeriomem-rng.c
+++ b/drivers/char/hw_random/timeriomem-rng.c
@@ -152,8 +152,7 @@ static int timeriomem_rng_probe(struct platform_device *pdev)
priv->period = ns_to_ktime(period * NSEC_PER_USEC);
init_completion(&priv->completion);
- hrtimer_init(&priv->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
- priv->timer.function = timeriomem_rng_trigger;
+ hrtimer_setup(&priv->timer, timeriomem_rng_trigger, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
priv->rng_ops.name = dev_name(&pdev->dev);
priv->rng_ops.read = timeriomem_rng_read;
--
2.39.5
^ permalink raw reply related [flat|nested] 39+ messages in thread