History

Merge branch 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull locking fixes from Ingo Molnar: "Two fixes from lockdep coverage of seqlocks, which fix deadlocks on lockdep-enabled ARM systems" * 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: sched_clock: Disable seqlock lockdep usage in sched_clock() seqlock: Use raw_ prefix instead of _no_lockdep

Linus Torvalds committed 12 years ago

Commit 9b6c4ea2 parents 93a11c8 7a06c413 files · +26 −15Browse files

Unified · Split

3 files
  1. arch/x86/vdso/vclock_gettime.c +4 −4
  2. include/linux/seqlock.h +19 −8
  3. kernel/time/sched_clock.c +3 −3
arch/x86/vdso/vclock_gettime.c+4−4
@@ -178,7 +178,7 @@ notrace static int __always_inline do_realtime(struct timespec *ts) · 177 unmodified lines
178178
179179 ts->tv_nsec = 0;
180180 do {
181− seq = read_seqcount_begin_no_lockdep(&gtod->seq);
181+ seq = raw_read_seqcount_begin(&gtod->seq);
182182 mode = gtod->clock.vclock_mode;
183183 ts->tv_sec = gtod->wall_time_sec;
184184 ns = gtod->wall_time_snsec;
@@ -198,7 +198,7 @@ notrace static int do_monotonic(struct timespec *ts) · 13 unmodified lines
198198
199199 ts->tv_nsec = 0;
200200 do {
201− seq = read_seqcount_begin_no_lockdep(&gtod->seq);
201+ seq = raw_read_seqcount_begin(&gtod->seq);
202202 mode = gtod->clock.vclock_mode;
203203 ts->tv_sec = gtod->monotonic_time_sec;
204204 ns = gtod->monotonic_time_snsec;
@@ -214,7 +214,7 @@ notrace static int do_realtime_coarse(struct timespec *ts) · 9 unmodified lines
214214 {
215215 unsigned long seq;
216216 do {
217− seq = read_seqcount_begin_no_lockdep(&gtod->seq);
217+ seq = raw_read_seqcount_begin(&gtod->seq);
218218 ts->tv_sec = gtod->wall_time_coarse.tv_sec;
219219 ts->tv_nsec = gtod->wall_time_coarse.tv_nsec;
220220 } while (unlikely(read_seqcount_retry(&gtod->seq, seq)));
@@ -225,7 +225,7 @@ notrace static int do_monotonic_coarse(struct timespec *ts) · 4 unmodified lines
225225 {
226226 unsigned long seq;
227227 do {
228− seq = read_seqcount_begin_no_lockdep(&gtod->seq);
228+ seq = raw_read_seqcount_begin(&gtod->seq);
229229 ts->tv_sec = gtod->monotonic_time_coarse.tv_sec;
230230 ts->tv_nsec = gtod->monotonic_time_coarse.tv_nsec;
231231 } while (unlikely(read_seqcount_retry(&gtod->seq, seq)));
include/linux/seqlock.h+19−8
@@ -117,15 +117,15 @@ repeat: · 116 unmodified lines
117117 }
118118
119119 /**
120− * read_seqcount_begin_no_lockdep - start seq-read critical section w/o lockdep
120+ * raw_read_seqcount_begin - start seq-read critical section w/o lockdep
121121 * @s: pointer to seqcount_t
122122 * Returns: count to be passed to read_seqcount_retry
123123 *
124− * read_seqcount_begin_no_lockdep opens a read critical section of the given
124+ * raw_read_seqcount_begin opens a read critical section of the given
125125 * seqcount, but without any lockdep checking. Validity of the critical
126126 * section is tested by checking read_seqcount_retry function.
127127 */
128−static inline unsigned read_seqcount_begin_no_lockdep(const seqcount_t *s)
128+static inline unsigned raw_read_seqcount_begin(const seqcount_t *s)
129129 {
130130 unsigned ret = __read_seqcount_begin(s);
131131 smp_rmb();
@@ -144,7 +144,7 @@ static inline unsigned read_seqcount_begin_no_lockdep(const seqcount_t *s) · 12 unmodified lines
144144 static inline unsigned read_seqcount_begin(const seqcount_t *s)
145145 {
146146 seqcount_lockdep_reader_access(s);
147− return read_seqcount_begin_no_lockdep(s);
147+ return raw_read_seqcount_begin(s);
148148 }
149149
150150 /**
@@ -206,14 +206,26 @@ static inline int read_seqcount_retry(const seqcount_t *s, unsigned start) · 55 unmodified lines
206206 }
207207
208208
209+
210+static inline void raw_write_seqcount_begin(seqcount_t *s)
211+{
212+ s->sequence++;
213+ smp_wmb();
214+}
215+
216+static inline void raw_write_seqcount_end(seqcount_t *s)
217+{
218+ smp_wmb();
219+ s->sequence++;
220+}
221+
209222 /*
210223 * Sequence counter only version assumes that callers are using their
211224 * own mutexing.
212225 */
213226 static inline void write_seqcount_begin_nested(seqcount_t *s, int subclass)
214227 {
215− s->sequence++;
216− smp_wmb();
228+ raw_write_seqcount_begin(s);
217229 seqcount_acquire(&s->dep_map, subclass, 0, _RET_IP_);
218230 }
219231
@@ -225,8 +237,7 @@ static inline void write_seqcount_begin(seqcount_t *s) · 5 unmodified lines
225237 static inline void write_seqcount_end(seqcount_t *s)
226238 {
227239 seqcount_release(&s->dep_map, 1, _RET_IP_);
228− smp_wmb();
229− s->sequence++;
240+ raw_write_seqcount_end(s);
230241 }
231242
232243 /**
kernel/time/sched_clock.c+3−3
@@ -74,7 +74,7 @@ unsigned long long notrace sched_clock(void) · 73 unmodified lines
7474 return cd.epoch_ns;
7575
7676 do {
77− seq = read_seqcount_begin(&cd.seq);
77+ seq = raw_read_seqcount_begin(&cd.seq);
7878 epoch_cyc = cd.epoch_cyc;
7979 epoch_ns = cd.epoch_ns;
8080 } while (read_seqcount_retry(&cd.seq, seq));
@@ -99,10 +99,10 @@ static void notrace update_sched_clock(void) · 18 unmodified lines
9999 cd.mult, cd.shift);
100100
101101 raw_local_irq_save(flags);
102− write_seqcount_begin(&cd.seq);
102+ raw_write_seqcount_begin(&cd.seq);
103103 cd.epoch_ns = ns;
104104 cd.epoch_cyc = cyc;
105− write_seqcount_end(&cd.seq);
105+ raw_write_seqcount_end(&cd.seq);
106106 raw_local_irq_restore(flags);
107107 }
108108