From: Waiman Long <llong@redhat.com>
To: Xiongwei Song <sxwjean@me.com>,
peterz@infradead.org, mingo@redhat.com, will@kernel.org,
boqun.feng@gmail.com
Cc: linux-kernel@vger.kernel.org, Xiongwei Song <sxwjean@gmail.com>
Subject: Re: [RFC PATCH v1 2/3] locking/lockdep: Unify the return values of check_wait_context()
Date: Sun, 11 Jul 2021 11:19:40 -0400 [thread overview]
Message-ID: <0e48f59d-a8fd-936c-c57f-976632f9cead@redhat.com> (raw)
In-Reply-To: <20210711141430.896595-2-sxwjean@me.com>
On 7/11/21 10:14 AM, Xiongwei Song wrote:
> From: Xiongwei Song <sxwjean@gmail.com>
>
> Unity the return values of check_wait_context() as check_prev_add(),
"Unify"?
> check_irq_usage(), etc. 1 means no bug, 0 means there is a bug.
>
> The return values of print_lock_invalid_wait_context() are unnecessary,
> remove them.
>
> Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
> ---
> kernel/locking/lockdep.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index bf1c00c881e4..8b50da42f2c6 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -4635,16 +4635,16 @@ static inline short task_wait_context(struct task_struct *curr)
> return LD_WAIT_MAX;
> }
>
> -static int
> +static void
> print_lock_invalid_wait_context(struct task_struct *curr,
> struct held_lock *hlock)
> {
> short curr_inner;
>
> if (!debug_locks_off())
> - return 0;
> + return;
> if (debug_locks_silent)
> - return 0;
> + return;
>
> pr_warn("\n");
> pr_warn("=============================\n");
> @@ -4664,8 +4664,6 @@ print_lock_invalid_wait_context(struct task_struct *curr,
>
> pr_warn("stack backtrace:\n");
> dump_stack();
> -
> - return 0;
> }
>
> /*
> @@ -4691,7 +4689,7 @@ static int check_wait_context(struct task_struct *curr, struct held_lock *next)
> int depth;
>
> if (!next_inner || next->trylock)
> - return 0;
> + return 1;
>
> if (!next_outer)
> next_outer = next_inner;
> @@ -4723,10 +4721,12 @@ static int check_wait_context(struct task_struct *curr, struct held_lock *next)
> }
> }
>
> - if (next_outer > curr_inner)
> - return print_lock_invalid_wait_context(curr, next);
> + if (next_outer > curr_inner) {
> + print_lock_invalid_wait_context(curr, next);
> + return 0;
> + }
>
> - return 0;
> + return 1;
> }
>
> #else /* CONFIG_PROVE_LOCKING */
> @@ -4962,7 +4962,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
> #endif
> hlock->pin_count = pin_count;
>
> - if (check_wait_context(curr, hlock))
> + if (!check_wait_context(curr, hlock))
> return 0;
>
> /* Initialize the lock usage bit */
There is also another check_wait_context() in the "#else
CONFIG_PROVE_LOCKING" path that needs to be kept in sync. For clarity,
maybe you should state the meaning of the return value in the comment
above the function.
Cheers,
Longman
check_wait_context
next prev parent reply other threads:[~2021-07-11 15:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-11 14:14 [RFC PATCH v1 1/3] locking/lockdep: Fix false warning " Xiongwei Song
2021-07-11 14:14 ` [RFC PATCH v1 2/3] locking/lockdep: Unify the return values " Xiongwei Song
2021-07-11 15:19 ` Waiman Long [this message]
2021-07-12 7:48 ` Xiongwei Song
2021-07-23 2:57 ` [locking/lockdep] e0a77a7a5a: WARNING:bad_unlock_balance_detected kernel test robot
2021-07-11 14:14 ` [PATCH v1 3/3] locking/lockdep,doc: Correct the max number of lock classes Xiongwei Song
2021-07-11 15:22 ` Waiman Long
2021-07-12 7:49 ` Xiongwei Song
2021-07-11 16:43 ` [RFC PATCH v1 1/3] locking/lockdep: Fix false warning of check_wait_context() Waiman Long
2021-07-12 8:18 ` Xiongwei Song
2021-07-12 8:50 ` Boqun Feng
2021-07-12 9:21 ` Xiongwei Song
2021-07-12 13:04 ` Waiman Long
2021-07-12 15:03 ` Xiongwei Song
2021-07-13 2:29 ` Xiongwei Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0e48f59d-a8fd-936c-c57f-976632f9cead@redhat.com \
--to=llong@redhat.com \
--cc=boqun.feng@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=sxwjean@gmail.com \
--cc=sxwjean@me.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®