Skip to content

Commit fa509ff

Browse files
committed
Merge tag 'locking-urgent-2021-03-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull locking fixes from Thomas Gleixner: "A couple of locking fixes: - A fix for the static_call mechanism so it handles unaligned addresses correctly. - Make u64_stats_init() a macro so every instance gets a seperate lockdep key. - Make seqcount_latch_init() a macro as well to preserve the static variable which is used for the lockdep key" * tag 'locking-urgent-2021-03-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: seqlock,lockdep: Fix seqcount_latch_init() u64_stats,lockdep: Fix u64_stats_init() vs lockdep static_call: Fix the module key fixup
2 parents 75013c6 + 4817a52 commit fa509ff

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

include/linux/seqlock.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,7 @@ typedef struct {
664664
* seqcount_latch_init() - runtime initializer for seqcount_latch_t
665665
* @s: Pointer to the seqcount_latch_t instance
666666
*/
667-
static inline void seqcount_latch_init(seqcount_latch_t *s)
668-
{
669-
seqcount_init(&s->seqcount);
670-
}
667+
#define seqcount_latch_init(s) seqcount_init(&(s)->seqcount)
671668

672669
/**
673670
* raw_read_seqcount_latch() - pick even/odd latch data copy

include/linux/u64_stats_sync.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,13 @@ static inline void u64_stats_inc(u64_stats_t *p)
115115
}
116116
#endif
117117

118+
#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
119+
#define u64_stats_init(syncp) seqcount_init(&(syncp)->seq)
120+
#else
118121
static inline void u64_stats_init(struct u64_stats_sync *syncp)
119122
{
120-
#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
121-
seqcount_init(&syncp->seq);
122-
#endif
123123
}
124+
#endif
124125

125126
static inline void u64_stats_update_begin(struct u64_stats_sync *syncp)
126127
{

kernel/static_call.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,8 @@ static int static_call_add_module(struct module *mod)
349349
struct static_call_site *site;
350350

351351
for (site = start; site != stop; site++) {
352-
unsigned long addr = (unsigned long)static_call_key(site);
352+
unsigned long s_key = (long)site->key + (long)&site->key;
353+
unsigned long addr = s_key & ~STATIC_CALL_SITE_FLAGS;
353354
unsigned long key;
354355

355356
/*
@@ -373,8 +374,8 @@ static int static_call_add_module(struct module *mod)
373374
return -EINVAL;
374375
}
375376

376-
site->key = (key - (long)&site->key) |
377-
(site->key & STATIC_CALL_SITE_FLAGS);
377+
key |= s_key & STATIC_CALL_SITE_FLAGS;
378+
site->key = key - (long)&site->key;
378379
}
379380

380381
return __static_call_init(mod, start, stop);

0 commit comments

Comments
 (0)