lkml.org 
[lkml]   [2019]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 22/28] locking/lockdep: Adjust new bit cases in mark_lock
On Wed, Apr 24, 2019 at 06:19:28PM +0800, Yuyang Du wrote:
> The new bit can be any possible lock usage except it is garbage, so the

s/except it/except when it/ ?

> cases in switch can be made simpler. Warn early on if wrong usage bit is
> passed without taking locks. No functional change.
>
> Signed-off-by: Yuyang Du <duyuyang@gmail.com>
> ---
> kernel/locking/lockdep.c | 21 +++++++--------------
> 1 file changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index c08ec88..291cc9c 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -3476,6 +3476,11 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
> {
> unsigned int new_mask = 1 << new_bit, ret = 1;
>
> + if (new_bit >= LOCK_USAGE_STATES) {
> + WARN_ON(1);

Does that want to be DEBUG_LOCKS_WARN_ON() ?

> + return 0;
> + }
> +
> /*
> * If already set then do not dirty the cacheline,
> * nor do any checks:
> @@ -3499,25 +3504,13 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
> return 0;
>
> switch (new_bit) {
> -#define LOCKDEP_STATE(__STATE) \
> - case LOCK_USED_IN_##__STATE: \
> - case LOCK_USED_IN_##__STATE##_READ: \
> - case LOCK_ENABLED_##__STATE: \
> - case LOCK_ENABLED_##__STATE##_READ:
> -#include "lockdep_states.h"
> -#undef LOCKDEP_STATE
> - ret = mark_lock_irq(curr, this, new_bit);
> - if (!ret)
> - return 0;
> - break;
> case LOCK_USED:
> debug_atomic_dec(nr_unused_locks);
> break;
> default:
> - if (!debug_locks_off_graph_unlock())
> + ret = mark_lock_irq(curr, this, new_bit);
> + if (!ret)
> return 0;
> - WARN_ON(1);
> - return 0;
> }
>
> graph_unlock();
> --
> 1.8.3.1
>

\
 
 \ /
  Last update: 2019-04-25 21:53    [W:0.194 / U:6.948 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site