Skip to content

Commit 8b0e195

Browse files
committed
ktime: Cleanup ktime_set() usage
ktime_set(S,N) was required for the timespec storage type and is still useful for situations where a Seconds and Nanoseconds part of a time value needs to be converted. For anything where the Seconds argument is 0, this is pointless and can be replaced with a simple assignment. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]>
1 parent 2456e85 commit 8b0e195

File tree

56 files changed

+84
-95
lines changed

Some content is hidden

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

56 files changed

+84
-95
lines changed

arch/powerpc/kvm/book3s_hv.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,8 +1872,7 @@ static void kvmppc_set_timer(struct kvm_vcpu *vcpu)
18721872
}
18731873
dec_nsec = (vcpu->arch.dec_expires - now) * NSEC_PER_SEC
18741874
/ tb_ticks_per_sec;
1875-
hrtimer_start(&vcpu->arch.dec_timer, ktime_set(0, dec_nsec),
1876-
HRTIMER_MODE_REL);
1875+
hrtimer_start(&vcpu->arch.dec_timer, dec_nsec, HRTIMER_MODE_REL);
18771876
vcpu->arch.timer_running = 1;
18781877
}
18791878

arch/powerpc/oprofile/cell/spu_profiler.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static enum hrtimer_restart profile_spus(struct hrtimer *timer)
180180
smp_wmb(); /* insure spu event buffer updates are written */
181181
/* don't want events intermingled... */
182182

183-
kt = ktime_set(0, profiling_interval);
183+
kt = profiling_interval;
184184
if (!spu_prof_running)
185185
goto stop;
186186
hrtimer_forward(timer, timer->base->get_time(), kt);
@@ -204,7 +204,7 @@ int start_spu_profiling_cycles(unsigned int cycles_reset)
204204
ktime_t kt;
205205

206206
pr_debug("timer resolution: %lu\n", TICK_NSEC);
207-
kt = ktime_set(0, profiling_interval);
207+
kt = profiling_interval;
208208
hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
209209
hrtimer_set_expires(&timer, kt);
210210
timer.function = profile_spus;

arch/s390/kvm/interrupt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ int kvm_s390_handle_wait(struct kvm_vcpu *vcpu)
10191019
return 0;
10201020

10211021
__set_cpu_idle(vcpu);
1022-
hrtimer_start(&vcpu->arch.ckc_timer, ktime_set (0, sltime) , HRTIMER_MODE_REL);
1022+
hrtimer_start(&vcpu->arch.ckc_timer, sltime, HRTIMER_MODE_REL);
10231023
VCPU_EVENT(vcpu, 4, "enabled wait: %llu ns", sltime);
10241024
no_timer:
10251025
srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);

arch/x86/kvm/lapic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ static u32 apic_get_tmcct(struct kvm_lapic *apic)
11061106
now = ktime_get();
11071107
remaining = ktime_sub(apic->lapic_timer.target_expiration, now);
11081108
if (ktime_to_ns(remaining) < 0)
1109-
remaining = ktime_set(0, 0);
1109+
remaining = 0;
11101110

11111111
ns = mod_64(ktime_to_ns(remaining), apic->lapic_timer.period);
11121112
tmcct = div64_u64(ns,
@@ -2057,7 +2057,7 @@ void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu)
20572057
apic->lapic_timer.tscdeadline = 0;
20582058
if (apic_lvtt_oneshot(apic)) {
20592059
apic->lapic_timer.tscdeadline = 0;
2060-
apic->lapic_timer.target_expiration = ktime_set(0, 0);
2060+
apic->lapic_timer.target_expiration = 0;
20612061
}
20622062
atomic_set(&apic->lapic_timer.pending, 0);
20632063
}

block/blk-mq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2569,7 +2569,7 @@ static bool blk_mq_poll_hybrid_sleep(struct request_queue *q,
25692569
* This will be replaced with the stats tracking code, using
25702570
* 'avg_completion_time / 2' as the pre-sleep target.
25712571
*/
2572-
kt = ktime_set(0, nsecs);
2572+
kt = nsecs;
25732573

25742574
mode = HRTIMER_MODE_REL;
25752575
hrtimer_init_on_stack(&hs.timer, CLOCK_MONOTONIC, mode);

drivers/base/power/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ void device_pm_move_last(struct device *dev)
194194

195195
static ktime_t initcall_debug_start(struct device *dev)
196196
{
197-
ktime_t calltime = ktime_set(0, 0);
197+
ktime_t calltime = 0;
198198

199199
if (pm_print_times_enabled) {
200200
pr_info("calling %s+ @ %i, parent: %s\n",

drivers/base/power/wakeup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ static int print_wakeup_source_stats(struct seq_file *m,
10051005
prevent_sleep_time = ktime_add(prevent_sleep_time,
10061006
ktime_sub(now, ws->start_prevent_time));
10071007
} else {
1008-
active_time = ktime_set(0, 0);
1008+
active_time = 0;
10091009
}
10101010

10111011
seq_printf(m, "%-12s\t%lu\t\t%lu\t\t%lu\t\t%lu\t\t%lld\t\t%lld\t\t%lld\t\t%lld\t\t%lld\n",

drivers/block/null_blk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ static enum hrtimer_restart null_cmd_timer_expired(struct hrtimer *timer)
257257

258258
static void null_cmd_end_timer(struct nullb_cmd *cmd)
259259
{
260-
ktime_t kt = ktime_set(0, completion_nsec);
260+
ktime_t kt = completion_nsec;
261261

262262
hrtimer_start(&cmd->timer, kt, HRTIMER_MODE_REL);
263263
}

drivers/dma/dmatest.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,8 @@ static int dmatest_func(void *data)
429429
int dst_cnt;
430430
int i;
431431
ktime_t ktime, start, diff;
432-
ktime_t filltime = ktime_set(0, 0);
433-
ktime_t comparetime = ktime_set(0, 0);
432+
ktime_t filltime = 0;
433+
ktime_t comparetime = 0;
434434
s64 runtime = 0;
435435
unsigned long long total_len = 0;
436436
u8 align = 0;

drivers/gpu/drm/amd/amdgpu/dce_virtual.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ static enum hrtimer_restart dce_virtual_vblank_timer_handle(struct hrtimer *vbla
752752

753753
drm_handle_vblank(ddev, amdgpu_crtc->crtc_id);
754754
dce_virtual_pageflip(adev, amdgpu_crtc->crtc_id);
755-
hrtimer_start(vblank_timer, ktime_set(0, DCE_VIRTUAL_VBLANK_PERIOD),
755+
hrtimer_start(vblank_timer, DCE_VIRTUAL_VBLANK_PERIOD,
756756
HRTIMER_MODE_REL);
757757

758758
return HRTIMER_NORESTART;
@@ -772,11 +772,11 @@ static void dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device *ad
772772
hrtimer_init(&adev->mode_info.crtcs[crtc]->vblank_timer,
773773
CLOCK_MONOTONIC, HRTIMER_MODE_REL);
774774
hrtimer_set_expires(&adev->mode_info.crtcs[crtc]->vblank_timer,
775-
ktime_set(0, DCE_VIRTUAL_VBLANK_PERIOD));
775+
DCE_VIRTUAL_VBLANK_PERIOD);
776776
adev->mode_info.crtcs[crtc]->vblank_timer.function =
777777
dce_virtual_vblank_timer_handle;
778778
hrtimer_start(&adev->mode_info.crtcs[crtc]->vblank_timer,
779-
ktime_set(0, DCE_VIRTUAL_VBLANK_PERIOD), HRTIMER_MODE_REL);
779+
DCE_VIRTUAL_VBLANK_PERIOD, HRTIMER_MODE_REL);
780780
} else if (!state && adev->mode_info.crtcs[crtc]->vsync_timer_enabled) {
781781
DRM_DEBUG("Disable software vsync timer\n");
782782
hrtimer_cancel(&adev->mode_info.crtcs[crtc]->vblank_timer);

0 commit comments

Comments
 (0)