0001-lockdep-mark-local_lock_t.patch 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. diff --git a/include/linux/local_lock_internal.h b/include/linux/local_lock_internal.h
  2. index 4a8795b..ded90b0 100644
  3. --- a/include/linux/local_lock_internal.h
  4. +++ b/include/linux/local_lock_internal.h
  5. @@ -18,6 +18,7 @@ typedef struct {
  6. .dep_map = { \
  7. .name = #lockname, \
  8. .wait_type_inner = LD_WAIT_CONFIG, \
  9. + .lock_type = LD_LOCK_PERCPU, \
  10. }
  11. #else
  12. # define LL_DEP_MAP_INIT(lockname)
  13. @@ -30,7 +31,9 @@ do { \
  14. static struct lock_class_key __key; \
  15. \
  16. debug_check_no_locks_freed((void *)lock, sizeof(*lock));\
  17. - lockdep_init_map_wait(&(lock)->dep_map, #lock, &__key, 0, LD_WAIT_CONFIG);\
  18. + lockdep_init_map_type(&(lock)->dep_map, #lock, &__key, 0, \
  19. + LD_WAIT_CONFIG, LD_WAIT_INV, \
  20. + LD_LOCK_PERCPU); \
  21. } while (0)
  22. #ifdef CONFIG_DEBUG_LOCK_ALLOC
  23. diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
  24. index f559487..20b6797 100644
  25. --- a/include/linux/lockdep.h
  26. +++ b/include/linux/lockdep.h
  27. @@ -185,12 +185,19 @@ extern void lockdep_unregister_key(struct lock_class_key *key);
  28. * to lockdep:
  29. */
  30. -extern void lockdep_init_map_waits(struct lockdep_map *lock, const char *name,
  31. - struct lock_class_key *key, int subclass, short inner, short outer);
  32. +extern void lockdep_init_map_type(struct lockdep_map *lock, const char *name,
  33. + struct lock_class_key *key, int subclass, u8 inner, u8 outer, u8 lock_type);
  34. +
  35. +static inline void
  36. +lockdep_init_map_waits(struct lockdep_map *lock, const char *name,
  37. + struct lock_class_key *key, int subclass, u8 inner, u8 outer)
  38. +{
  39. + lockdep_init_map_type(lock, name, key, subclass, inner, LD_WAIT_INV, LD_LOCK_NORMAL);
  40. +}
  41. static inline void
  42. lockdep_init_map_wait(struct lockdep_map *lock, const char *name,
  43. - struct lock_class_key *key, int subclass, short inner)
  44. + struct lock_class_key *key, int subclass, u8 inner)
  45. {
  46. lockdep_init_map_waits(lock, name, key, subclass, inner, LD_WAIT_INV);
  47. }
  48. @@ -340,6 +347,8 @@ static inline void lockdep_set_selftest_task(struct task_struct *task)
  49. # define lock_set_class(l, n, k, s, i) do { } while (0)
  50. # define lock_set_subclass(l, s, i) do { } while (0)
  51. # define lockdep_init() do { } while (0)
  52. +# define lockdep_init_map_type(lock, name, key, sub, inner, outer, type) \
  53. + do { (void)(name); (void)(key); } while (0)
  54. # define lockdep_init_map_waits(lock, name, key, sub, inner, outer) \
  55. do { (void)(name); (void)(key); } while (0)
  56. # define lockdep_init_map_wait(lock, name, key, sub, inner) \
  57. diff --git a/include/linux/lockdep_types.h b/include/linux/lockdep_types.h
  58. index 9a1fd49..2ec9ff5 100644
  59. --- a/include/linux/lockdep_types.h
  60. +++ b/include/linux/lockdep_types.h
  61. @@ -30,6 +30,12 @@ enum lockdep_wait_type {
  62. LD_WAIT_MAX, /* must be last */
  63. };
  64. +enum lockdep_lock_type {
  65. + LD_LOCK_NORMAL = 0, /* normal, catch all */
  66. + LD_LOCK_PERCPU, /* percpu */
  67. + LD_LOCK_MAX,
  68. +};
  69. +
  70. #ifdef CONFIG_LOCKDEP
  71. /*
  72. @@ -119,8 +125,10 @@ struct lock_class {
  73. int name_version;
  74. const char *name;
  75. - short wait_type_inner;
  76. - short wait_type_outer;
  77. + u8 wait_type_inner;
  78. + u8 wait_type_outer;
  79. + u8 lock_type;
  80. + /* u8 hole; */
  81. #ifdef CONFIG_LOCK_STAT
  82. unsigned long contention_point[LOCKSTAT_POINTS];
  83. @@ -169,8 +177,10 @@ struct lockdep_map {
  84. struct lock_class_key *key;
  85. struct lock_class *class_cache[NR_LOCKDEP_CACHING_CLASSES];
  86. const char *name;
  87. - short wait_type_outer; /* can be taken in this context */
  88. - short wait_type_inner; /* presents this context */
  89. + u8 wait_type_outer; /* can be taken in this context */
  90. + u8 wait_type_inner; /* presents this context */
  91. + u8 lock_type;
  92. + /* u8 hole; */
  93. #ifdef CONFIG_LOCK_STAT
  94. int cpu;
  95. unsigned long ip;
  96. diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
  97. index 8ae9d7a..5184f68 100644
  98. --- a/kernel/locking/lockdep.c
  99. +++ b/kernel/locking/lockdep.c
  100. @@ -1293,6 +1293,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
  101. class->name_version = count_matching_names(class);
  102. class->wait_type_inner = lock->wait_type_inner;
  103. class->wait_type_outer = lock->wait_type_outer;
  104. + class->lock_type = lock->lock_type;
  105. /*
  106. * We use RCU's safe list-add method to make
  107. * parallel walking of the hash-list safe:
  108. @@ -4621,9 +4622,9 @@ print_lock_invalid_wait_context(struct task_struct *curr,
  109. */
  110. static int check_wait_context(struct task_struct *curr, struct held_lock *next)
  111. {
  112. - short next_inner = hlock_class(next)->wait_type_inner;
  113. - short next_outer = hlock_class(next)->wait_type_outer;
  114. - short curr_inner;
  115. + u8 next_inner = hlock_class(next)->wait_type_inner;
  116. + u8 next_outer = hlock_class(next)->wait_type_outer;
  117. + u8 curr_inner;
  118. int depth;
  119. if (!next_inner || next->trylock)
  120. @@ -4646,7 +4647,7 @@ static int check_wait_context(struct task_struct *curr, struct held_lock *next)
  121. for (; depth < curr->lockdep_depth; depth++) {
  122. struct held_lock *prev = curr->held_locks + depth;
  123. - short prev_inner = hlock_class(prev)->wait_type_inner;
  124. + u8 prev_inner = hlock_class(prev)->wait_type_inner;
  125. if (prev_inner) {
  126. /*
  127. @@ -4695,9 +4696,9 @@ static inline int check_wait_context(struct task_struct *curr,
  128. /*
  129. * Initialize a lock instance's lock-class mapping info:
  130. */
  131. -void lockdep_init_map_waits(struct lockdep_map *lock, const char *name,
  132. +void lockdep_init_map_type(struct lockdep_map *lock, const char *name,
  133. struct lock_class_key *key, int subclass,
  134. - short inner, short outer)
  135. + u8 inner, u8 outer, u8 lock_type)
  136. {
  137. int i;
  138. @@ -4720,6 +4721,7 @@ void lockdep_init_map_waits(struct lockdep_map *lock, const char *name,
  139. lock->wait_type_outer = outer;
  140. lock->wait_type_inner = inner;
  141. + lock->lock_type = lock_type;
  142. /*
  143. * No key, no joy, we need to hash something.
  144. @@ -4754,7 +4756,7 @@ void lockdep_init_map_waits(struct lockdep_map *lock, const char *name,
  145. raw_local_irq_restore(flags);
  146. }
  147. }
  148. -EXPORT_SYMBOL_GPL(lockdep_init_map_waits);
  149. +EXPORT_SYMBOL_GPL(lockdep_init_map_type);
  150. struct lock_class_key __lockdep_no_validate__;
  151. EXPORT_SYMBOL_GPL(__lockdep_no_validate__);