History

timers: Rename del_timer_sync() to timer_delete_sync()

The timer related functions do not have a strict timer_ prefixed namespace which is really annoying. Rename del_timer_sync() to timer_delete_sync() and provide del_timer_sync() as a wrapper. Document that del_timer_sync() is not for new code.

Thomas Gleixner committed 3 years ago

Commit 9b13df31 parent 168f6b62 files · +23 −10Browse files

Unified · Split

2 files
  1. include/linux/timer.h +14 −1
  2. kernel/time/timer.c +9 −9
include/linux/timer.h+14−1
@@ -183,7 +183,20 @@ extern int timer_reduce(struct timer_list *timer, unsigned long expires); · 182 unmodified lines
183extern void add_timer(struct timer_list *timer);183extern void add_timer(struct timer_list *timer);
184 184
185extern int try_to_del_timer_sync(struct timer_list *timer);185extern int try_to_del_timer_sync(struct timer_list *timer);
186extern int del_timer_sync(struct timer_list *timer);186extern int timer_delete_sync(struct timer_list *timer);
187
188/**
189 * del_timer_sync - Delete a pending timer and wait for a running callback
190 * @timer: The timer to be deleted
191 *
192 * See timer_delete_sync() for detailed explanation.
193 *
194 * Do not use in new code. Use timer_delete_sync() instead.
195 */
196static inline int del_timer_sync(struct timer_list *timer)
197{
198 return timer_delete_sync(timer);
199}
187 200
188extern void init_timers(void);201extern void init_timers(void);
189struct hrtimer;202struct hrtimer;
kernel/time/timer.c+9−9
@@ -1083,7 +1083,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires, unsigned int option · 1082 unmodified lines
1083 /*1083 /*
1084 * We are trying to schedule the timer on the new base.1084 * We are trying to schedule the timer on the new base.
1085 * However we can't change timer's base while it is running,1085 * However we can't change timer's base while it is running,
1086 * otherwise del_timer_sync() can't detect that the timer's1086 * otherwise timer_delete_sync() can't detect that the timer's
1087 * handler yet has not finished. This also guarantees that the1087 * handler yet has not finished. This also guarantees that the
1088 * timer is serialized wrt itself.1088 * timer is serialized wrt itself.
1089 */1089 */
@@ -1261,7 +1261,7 @@ EXPORT_SYMBOL_GPL(add_timer_on); · 171 unmodified lines
1261 * @timer: The timer to be deactivated1261 * @timer: The timer to be deactivated
1262 *1262 *
1263 * The function only deactivates a pending timer, but contrary to1263 * The function only deactivates a pending timer, but contrary to
1264 * del_timer_sync() it does not take into account whether the timer's1264 * timer_delete_sync() it does not take into account whether the timer's
1265 * callback function is concurrently executed on a different CPU or not.1265 * callback function is concurrently executed on a different CPU or not.
1266 * It neither prevents rearming of the timer. If @timer can be rearmed1266 * It neither prevents rearming of the timer. If @timer can be rearmed
1267 * concurrently then the return value of this function is meaningless.1267 * concurrently then the return value of this function is meaningless.
@@ -1397,7 +1397,7 @@ static inline void del_timer_wait_running(struct timer_list *timer) { } · 129 unmodified lines
1397#endif1397#endif
1398 1398
1399/**1399/**
1400 * del_timer_sync - Deactivate a timer and wait for the handler to finish.1400 * timer_delete_sync - Deactivate a timer and wait for the handler to finish.
1401 * @timer: The timer to be deactivated1401 * @timer: The timer to be deactivated
1402 *1402 *
1403 * Synchronization rules: Callers must prevent restarting of the timer,1403 * Synchronization rules: Callers must prevent restarting of the timer,
@@ -1419,10 +1419,10 @@ static inline void del_timer_wait_running(struct timer_list *timer) { } · 15 unmodified lines
1419 * spin_lock_irq(somelock);1419 * spin_lock_irq(somelock);
1420 * <IRQ>1420 * <IRQ>
1421 * spin_lock(somelock);1421 * spin_lock(somelock);
1422 * del_timer_sync(mytimer);1422 * timer_delete_sync(mytimer);
1423 * while (base->running_timer == mytimer);1423 * while (base->running_timer == mytimer);
1424 *1424 *
1425 * Now del_timer_sync() will never return and never release somelock.1425 * Now timer_delete_sync() will never return and never release somelock.
1426 * The interrupt on the other CPU is waiting to grab somelock but it has1426 * The interrupt on the other CPU is waiting to grab somelock but it has
1427 * interrupted the softirq that CPU0 is waiting to finish.1427 * interrupted the softirq that CPU0 is waiting to finish.
1428 *1428 *
@@ -1435,7 +1435,7 @@ static inline void del_timer_wait_running(struct timer_list *timer) { } · 6 unmodified lines
1435 * * %0 - The timer was not pending1435 * * %0 - The timer was not pending
1436 * * %1 - The timer was pending and deactivated1436 * * %1 - The timer was pending and deactivated
1437 */1437 */
1438int del_timer_sync(struct timer_list *timer)1438int timer_delete_sync(struct timer_list *timer)
1439{1439{
1440 int ret;1440 int ret;
1441 1441
@@ -1475,7 +1475,7 @@ int del_timer_sync(struct timer_list *timer) · 33 unmodified lines
1475 1475
1476 return ret;1476 return ret;
1477}1477}
1478EXPORT_SYMBOL(del_timer_sync);1478EXPORT_SYMBOL(timer_delete_sync);
1479 1479
1480static void call_timer_fn(struct timer_list *timer,1480static void call_timer_fn(struct timer_list *timer,
1481 void (*fn)(struct timer_list *),1481 void (*fn)(struct timer_list *),
@@ -1497,8 +1497,8 @@ static void call_timer_fn(struct timer_list *timer, · 15 unmodified lines
1497#endif1497#endif
1498 /*1498 /*
1499 * Couple the lock chain with the lock chain at1499 * Couple the lock chain with the lock chain at
1500 * del_timer_sync() by acquiring the lock_map around the fn()1500 * timer_delete_sync() by acquiring the lock_map around the fn()
1501 * call here and in del_timer_sync().1501 * call here and in timer_delete_sync().
1502 */1502 */
1503 lock_map_acquire(&lockdep_map);1503 lock_map_acquire(&lockdep_map);
1504 1504

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t