Skip to content

Commit

Permalink
Merge branch 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
torvalds committed Jan 16, 2014
2 parents 93a11c8 + 7a06c41 commit 9b6c4ea
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
8 changes: 4 additions & 4 deletions arch/x86/vdso/vclock_gettime.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ notrace static int __always_inline do_realtime(struct timespec *ts)

ts->tv_nsec = 0;
do {
seq = read_seqcount_begin_no_lockdep(&gtod->seq);
seq = raw_read_seqcount_begin(&gtod->seq);
mode = gtod->clock.vclock_mode;
ts->tv_sec = gtod->wall_time_sec;
ns = gtod->wall_time_snsec;
Expand All @@ -198,7 +198,7 @@ notrace static int do_monotonic(struct timespec *ts)

ts->tv_nsec = 0;
do {
seq = read_seqcount_begin_no_lockdep(&gtod->seq);
seq = raw_read_seqcount_begin(&gtod->seq);
mode = gtod->clock.vclock_mode;
ts->tv_sec = gtod->monotonic_time_sec;
ns = gtod->monotonic_time_snsec;
Expand All @@ -214,7 +214,7 @@ notrace static int do_realtime_coarse(struct timespec *ts)
{
unsigned long seq;
do {
seq = read_seqcount_begin_no_lockdep(&gtod->seq);
seq = raw_read_seqcount_begin(&gtod->seq);
ts->tv_sec = gtod->wall_time_coarse.tv_sec;
ts->tv_nsec = gtod->wall_time_coarse.tv_nsec;
} while (unlikely(read_seqcount_retry(&gtod->seq, seq)));
Expand All @@ -225,7 +225,7 @@ notrace static int do_monotonic_coarse(struct timespec *ts)
{
unsigned long seq;
do {
seq = read_seqcount_begin_no_lockdep(&gtod->seq);
seq = raw_read_seqcount_begin(&gtod->seq);
ts->tv_sec = gtod->monotonic_time_coarse.tv_sec;
ts->tv_nsec = gtod->monotonic_time_coarse.tv_nsec;
} while (unlikely(read_seqcount_retry(&gtod->seq, seq)));
Expand Down
27 changes: 19 additions & 8 deletions include/linux/seqlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ static inline unsigned __read_seqcount_begin(const seqcount_t *s)
}

/**
* read_seqcount_begin_no_lockdep - start seq-read critical section w/o lockdep
* raw_read_seqcount_begin - start seq-read critical section w/o lockdep
* @s: pointer to seqcount_t
* Returns: count to be passed to read_seqcount_retry
*
* read_seqcount_begin_no_lockdep opens a read critical section of the given
* raw_read_seqcount_begin opens a read critical section of the given
* seqcount, but without any lockdep checking. Validity of the critical
* section is tested by checking read_seqcount_retry function.
*/
static inline unsigned read_seqcount_begin_no_lockdep(const seqcount_t *s)
static inline unsigned raw_read_seqcount_begin(const seqcount_t *s)
{
unsigned ret = __read_seqcount_begin(s);
smp_rmb();
Expand All @@ -144,7 +144,7 @@ static inline unsigned read_seqcount_begin_no_lockdep(const seqcount_t *s)
static inline unsigned read_seqcount_begin(const seqcount_t *s)
{
seqcount_lockdep_reader_access(s);
return read_seqcount_begin_no_lockdep(s);
return raw_read_seqcount_begin(s);
}

/**
Expand Down Expand Up @@ -206,14 +206,26 @@ static inline int read_seqcount_retry(const seqcount_t *s, unsigned start)
}



static inline void raw_write_seqcount_begin(seqcount_t *s)
{
s->sequence++;
smp_wmb();
}

static inline void raw_write_seqcount_end(seqcount_t *s)
{
smp_wmb();
s->sequence++;
}

/*
* Sequence counter only version assumes that callers are using their
* own mutexing.
*/
static inline void write_seqcount_begin_nested(seqcount_t *s, int subclass)
{
s->sequence++;
smp_wmb();
raw_write_seqcount_begin(s);
seqcount_acquire(&s->dep_map, subclass, 0, _RET_IP_);
}

Expand All @@ -225,8 +237,7 @@ static inline void write_seqcount_begin(seqcount_t *s)
static inline void write_seqcount_end(seqcount_t *s)
{
seqcount_release(&s->dep_map, 1, _RET_IP_);
smp_wmb();
s->sequence++;
raw_write_seqcount_end(s);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions kernel/time/sched_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ unsigned long long notrace sched_clock(void)
return cd.epoch_ns;

do {
seq = read_seqcount_begin(&cd.seq);
seq = raw_read_seqcount_begin(&cd.seq);
epoch_cyc = cd.epoch_cyc;
epoch_ns = cd.epoch_ns;
} while (read_seqcount_retry(&cd.seq, seq));
Expand All @@ -99,10 +99,10 @@ static void notrace update_sched_clock(void)
cd.mult, cd.shift);

raw_local_irq_save(flags);
write_seqcount_begin(&cd.seq);
raw_write_seqcount_begin(&cd.seq);
cd.epoch_ns = ns;
cd.epoch_cyc = cyc;
write_seqcount_end(&cd.seq);
raw_write_seqcount_end(&cd.seq);
raw_local_irq_restore(flags);
}

Expand Down

0 comments on commit 9b6c4ea

Please sign in to comment.