Skip to content

Commit ca10949

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
hrtimer: removing all ur callback modes
Impact: cleanup, move all hrtimer processing into hardirq context This is an attempt at removing some of the hrtimer complexity by reducing the number of callback modes to 1. This means that all hrtimer callback functions will be ran from HARD-irq context. I went through all the 30 odd hrtimer callback functions in the kernel and saw only one that I'm not quite sure of, which is the one in net/can/bcm.c - hence I'm CC-ing the folks responsible for that code. Furthermore, the hrtimer core now calls callbacks directly with IRQs disabled in case you try to enqueue an expired timer. If this timer is a periodic timer (which should use hrtimer_forward() to advance its time) then it might be possible to end up in an inf. recursive loop due to the fact that hrtimer_forward() doesn't round up to the next timer granularity, and therefore keeps on calling the callback - obviously this needs a fix. Aside from that, this seems to compile and actually boot on my dual core test box - although I'm sure there are some bugs in, me not hitting any makes me certain :-) Signed-off-by: Peter Zijlstra <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent ed31348 commit ca10949

File tree

9 files changed

+37
-293
lines changed

9 files changed

+37
-293
lines changed

drivers/input/touchscreen/ads7846.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ static enum hrtimer_restart ads7846_timer(struct hrtimer *handle)
697697
struct ads7846 *ts = container_of(handle, struct ads7846, timer);
698698
int status = 0;
699699

700-
spin_lock_irq(&ts->lock);
700+
spin_lock(&ts->lock);
701701

702702
if (unlikely(!get_pendown_state(ts) ||
703703
device_suspended(&ts->spi->dev))) {
@@ -728,7 +728,7 @@ static enum hrtimer_restart ads7846_timer(struct hrtimer *handle)
728728
dev_err(&ts->spi->dev, "spi_async --> %d\n", status);
729729
}
730730

731-
spin_unlock_irq(&ts->lock);
731+
spin_unlock(&ts->lock);
732732
return HRTIMER_NORESTART;
733733
}
734734

include/linux/hrtimer.h

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,6 @@ enum hrtimer_restart {
4242
HRTIMER_RESTART, /* Timer must be restarted */
4343
};
4444

45-
/*
46-
* hrtimer callback modes:
47-
*
48-
* HRTIMER_CB_SOFTIRQ: Callback must run in softirq context
49-
* HRTIMER_CB_IRQSAFE_PERCPU: Callback must run in hardirq context
50-
* Special mode for tick emulation and
51-
* scheduler timer. Such timers are per
52-
* cpu and not allowed to be migrated on
53-
* cpu unplug.
54-
* HRTIMER_CB_IRQSAFE_UNLOCKED: Callback should run in hardirq context
55-
* with timer->base lock unlocked
56-
* used for timers which call wakeup to
57-
* avoid lock order problems with rq->lock
58-
*/
59-
enum hrtimer_cb_mode {
60-
HRTIMER_CB_SOFTIRQ,
61-
HRTIMER_CB_IRQSAFE_PERCPU,
62-
HRTIMER_CB_IRQSAFE_UNLOCKED,
63-
};
64-
6545
/*
6646
* Values to track state of the timer
6747
*
@@ -70,7 +50,6 @@ enum hrtimer_cb_mode {
7050
* 0x00 inactive
7151
* 0x01 enqueued into rbtree
7252
* 0x02 callback function running
73-
* 0x04 callback pending (high resolution mode)
7453
*
7554
* Special cases:
7655
* 0x03 callback function running and enqueued
@@ -92,8 +71,7 @@ enum hrtimer_cb_mode {
9271
#define HRTIMER_STATE_INACTIVE 0x00
9372
#define HRTIMER_STATE_ENQUEUED 0x01
9473
#define HRTIMER_STATE_CALLBACK 0x02
95-
#define HRTIMER_STATE_PENDING 0x04
96-
#define HRTIMER_STATE_MIGRATE 0x08
74+
#define HRTIMER_STATE_MIGRATE 0x04
9775

9876
/**
9977
* struct hrtimer - the basic hrtimer structure
@@ -109,8 +87,6 @@ enum hrtimer_cb_mode {
10987
* @function: timer expiry callback function
11088
* @base: pointer to the timer base (per cpu and per clock)
11189
* @state: state information (See bit values above)
112-
* @cb_mode: high resolution timer feature to select the callback execution
113-
* mode
11490
* @cb_entry: list head to enqueue an expired timer into the callback list
11591
* @start_site: timer statistics field to store the site where the timer
11692
* was started
@@ -129,7 +105,6 @@ struct hrtimer {
129105
struct hrtimer_clock_base *base;
130106
unsigned long state;
131107
struct list_head cb_entry;
132-
enum hrtimer_cb_mode cb_mode;
133108
#ifdef CONFIG_TIMER_STATS
134109
int start_pid;
135110
void *start_site;
@@ -188,15 +163,11 @@ struct hrtimer_clock_base {
188163
* @check_clocks: Indictator, when set evaluate time source and clock
189164
* event devices whether high resolution mode can be
190165
* activated.
191-
* @cb_pending: Expired timers are moved from the rbtree to this
192-
* list in the timer interrupt. The list is processed
193-
* in the softirq.
194166
* @nr_events: Total number of timer interrupt events
195167
*/
196168
struct hrtimer_cpu_base {
197169
spinlock_t lock;
198170
struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES];
199-
struct list_head cb_pending;
200171
#ifdef CONFIG_HIGH_RES_TIMERS
201172
ktime_t expires_next;
202173
int hres_active;
@@ -404,8 +375,7 @@ static inline int hrtimer_active(const struct hrtimer *timer)
404375
*/
405376
static inline int hrtimer_is_queued(struct hrtimer *timer)
406377
{
407-
return timer->state &
408-
(HRTIMER_STATE_ENQUEUED | HRTIMER_STATE_PENDING);
378+
return timer->state & HRTIMER_STATE_ENQUEUED;
409379
}
410380

411381
/*

include/linux/interrupt.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,6 @@ enum
251251
BLOCK_SOFTIRQ,
252252
TASKLET_SOFTIRQ,
253253
SCHED_SOFTIRQ,
254-
#ifdef CONFIG_HIGH_RES_TIMERS
255-
HRTIMER_SOFTIRQ,
256-
#endif
257254
RCU_SOFTIRQ, /* Preferable RCU should always be the last softirq */
258255

259256
NR_SOFTIRQS

0 commit comments

Comments
 (0)