Skip to content

Commit

Permalink
Merge tag 'locking-urgent-2021-03-14' 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 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
  • Loading branch information
torvalds committed Mar 14, 2021
2 parents 75013c6 + 4817a52 commit fa509ff
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
5 changes: 1 addition & 4 deletions include/linux/seqlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -664,10 +664,7 @@ typedef struct {
* seqcount_latch_init() - runtime initializer for seqcount_latch_t
* @s: Pointer to the seqcount_latch_t instance
*/
static inline void seqcount_latch_init(seqcount_latch_t *s)
{
seqcount_init(&s->seqcount);
}
#define seqcount_latch_init(s) seqcount_init(&(s)->seqcount)

/**
* raw_read_seqcount_latch() - pick even/odd latch data copy
Expand Down
7 changes: 4 additions & 3 deletions include/linux/u64_stats_sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,13 @@ static inline void u64_stats_inc(u64_stats_t *p)
}
#endif

#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
#define u64_stats_init(syncp) seqcount_init(&(syncp)->seq)
#else
static inline void u64_stats_init(struct u64_stats_sync *syncp)
{
#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
seqcount_init(&syncp->seq);
#endif
}
#endif

static inline void u64_stats_update_begin(struct u64_stats_sync *syncp)
{
Expand Down
7 changes: 4 additions & 3 deletions kernel/static_call.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ static int static_call_add_module(struct module *mod)
struct static_call_site *site;

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

/*
Expand All @@ -373,8 +374,8 @@ static int static_call_add_module(struct module *mod)
return -EINVAL;
}

site->key = (key - (long)&site->key) |
(site->key & STATIC_CALL_SITE_FLAGS);
key |= s_key & STATIC_CALL_SITE_FLAGS;
site->key = key - (long)&site->key;
}

return __static_call_init(mod, start, stop);
Expand Down

0 comments on commit fa509ff

Please sign in to comment.