History

hrtimer: Use sequence counter with associated raw spinlock

A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_raw_spinlock_t data type, which allows to associate a raw spinlock with the sequence counter. This enables lockdep to verify that the raw spinlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead.

Ahmed S. Darwish committed 6 years ago

Commit af5a06b1 parent 5c73b9a2 files · +11 −4Browse files

Unified · Split

2 files
  1. include/linux/hrtimer.h +1 −1
  2. kernel/time/hrtimer.c +10 −3
include/linux/hrtimer.h+1−1
@@ -159,7 +159,7 @@ struct hrtimer_clock_base { · 158 unmodified lines
159 struct hrtimer_cpu_base *cpu_base;159 struct hrtimer_cpu_base *cpu_base;
160 unsigned int index;160 unsigned int index;
161 clockid_t clockid;161 clockid_t clockid;
162 seqcount_t seq;162 seqcount_raw_spinlock_t seq;
163 struct hrtimer *running;163 struct hrtimer *running;
164 struct timerqueue_head active;164 struct timerqueue_head active;
165 ktime_t (*get_time)(void);165 ktime_t (*get_time)(void);
kernel/time/hrtimer.c+10−3
@@ -135,7 +135,11 @@ static const int hrtimer_clock_to_base_table[MAX_CLOCKS] = { · 134 unmodified lines
135 * timer->base->cpu_base135 * timer->base->cpu_base
136 */136 */
137static struct hrtimer_cpu_base migration_cpu_base = {137static struct hrtimer_cpu_base migration_cpu_base = {
138 .clock_base = { { .cpu_base = &migration_cpu_base, }, },138 .clock_base = { {
139 .cpu_base = &migration_cpu_base,
140 .seq = SEQCNT_RAW_SPINLOCK_ZERO(migration_cpu_base.seq,
141 &migration_cpu_base.lock),
142 }, },
139};143};
140 144
141#define migration_base migration_cpu_base.clock_base[0]145#define migration_base migration_cpu_base.clock_base[0]
@@ -1998,8 +2002,11 @@ int hrtimers_prepare_cpu(unsigned int cpu) · 1856 unmodified lines
1998 int i;2002 int i;
1999 2003
2000 for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) {2004 for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) {
2001 cpu_base->clock_base[i].cpu_base = cpu_base;2005 struct hrtimer_clock_base *clock_b = &cpu_base->clock_base[i];
2002 timerqueue_init_head(&cpu_base->clock_base[i].active);2006
2007 clock_b->cpu_base = cpu_base;
2008 seqcount_raw_spinlock_init(&clock_b->seq, &cpu_base->lock);
2009 timerqueue_init_head(&clock_b->active);
2003 }2010 }
2004 2011
2005 cpu_base->cpu = cpu;2012 cpu_base->cpu = cpu;

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