pktgen.c (b74494872555d1f7888dfd9225700a363f4a84fc) | pktgen.c (dbc1625fc9deefb352f6ff26a575ae4b3ddef23a) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Authors: 4 * Copyright 2001, 2002 by Robert Olsson <robert.olsson@its.uu.se> 5 * Uppsala University and 6 * Swedish University of Agricultural Sciences 7 * 8 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> --- 2142 unchanged lines hidden (view full) --- 2151 2152 2153static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until) 2154{ 2155 ktime_t start_time, end_time; 2156 s64 remaining; 2157 struct hrtimer_sleeper t; 2158 | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Authors: 4 * Copyright 2001, 2002 by Robert Olsson <robert.olsson@its.uu.se> 5 * Uppsala University and 6 * Swedish University of Agricultural Sciences 7 * 8 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> --- 2142 unchanged lines hidden (view full) --- 2151 2152 2153static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until) 2154{ 2155 ktime_t start_time, end_time; 2156 s64 remaining; 2157 struct hrtimer_sleeper t; 2158 |
2159 hrtimer_init_on_stack(&t.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); | 2159 hrtimer_init_sleeper_on_stack(&t, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); |
2160 hrtimer_set_expires(&t.timer, spin_until); 2161 2162 remaining = ktime_to_ns(hrtimer_expires_remaining(&t.timer)); 2163 if (remaining <= 0) 2164 goto out; 2165 2166 start_time = ktime_get(); 2167 if (remaining < 100000) { 2168 /* for small delays (<100us), just loop until limit is reached */ 2169 do { 2170 end_time = ktime_get(); 2171 } while (ktime_compare(end_time, spin_until) < 0); 2172 } else { | 2160 hrtimer_set_expires(&t.timer, spin_until); 2161 2162 remaining = ktime_to_ns(hrtimer_expires_remaining(&t.timer)); 2163 if (remaining <= 0) 2164 goto out; 2165 2166 start_time = ktime_get(); 2167 if (remaining < 100000) { 2168 /* for small delays (<100us), just loop until limit is reached */ 2169 do { 2170 end_time = ktime_get(); 2171 } while (ktime_compare(end_time, spin_until) < 0); 2172 } else { |
2173 /* see do_nanosleep */ 2174 hrtimer_init_sleeper(&t); | |
2175 do { 2176 set_current_state(TASK_INTERRUPTIBLE); 2177 hrtimer_start_expires(&t.timer, HRTIMER_MODE_ABS); 2178 2179 if (likely(t.task)) 2180 schedule(); 2181 2182 hrtimer_cancel(&t.timer); --- 1717 unchanged lines hidden --- | 2173 do { 2174 set_current_state(TASK_INTERRUPTIBLE); 2175 hrtimer_start_expires(&t.timer, HRTIMER_MODE_ABS); 2176 2177 if (likely(t.task)) 2178 schedule(); 2179 2180 hrtimer_cancel(&t.timer); --- 1717 unchanged lines hidden --- |