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: [PATCH] locking/lockdep: unlikely bfs error check
Date: Wed, 16 Jun 2021 10:48:56 -0400 [thread overview]
Message-ID: <a341e1f1-39a5-dca3-9454-8eabe085928b@redhat.com> (raw)
In-Reply-To: <20210616144210.278662-1-sxwjean@me.com>
On 6/16/21 10:42 AM, Xiongwei Song wrote:
> From: Xiongwei Song <sxwjean@gmail.com>
>
> The error from graph walk is small probability event, so unlikely
> bfs_error can improve performance a little bit.
>
> Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
> ---
> kernel/locking/lockdep.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 074fd6418c20..af8c9203cd3e 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -2646,7 +2646,7 @@ static int check_irq_usage(struct task_struct *curr, struct held_lock *prev,
> bfs_init_rootb(&this, prev);
>
> ret = __bfs_backwards(&this, &usage_mask, usage_accumulate, usage_skip, NULL);
> - if (bfs_error(ret)) {
> + if (unlikely(bfs_error(ret))) {
> print_bfs_bug(ret);
> return 0;
> }
> @@ -2664,7 +2664,7 @@ static int check_irq_usage(struct task_struct *curr, struct held_lock *prev,
> bfs_init_root(&that, next);
>
> ret = find_usage_forwards(&that, forward_mask, &target_entry1);
> - if (bfs_error(ret)) {
> + if (unlikely(bfs_error(ret))) {
> print_bfs_bug(ret);
> return 0;
> }
> @@ -2679,7 +2679,7 @@ static int check_irq_usage(struct task_struct *curr, struct held_lock *prev,
> backward_mask = original_mask(target_entry1->class->usage_mask);
>
> ret = find_usage_backwards(&this, backward_mask, &target_entry);
> - if (bfs_error(ret)) {
> + if (unlikely(bfs_error(ret))) {
> print_bfs_bug(ret);
> return 0;
> }
> @@ -2998,7 +2998,7 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev,
> * Is the <prev> -> <next> link redundant?
> */
> ret = check_redundant(prev, next);
> - if (bfs_error(ret))
> + if (unlikely(bfs_error(ret)))
> return 0;
> else if (ret == BFS_RMATCH)
> return 2;
> @@ -3911,7 +3911,7 @@ check_usage_forwards(struct task_struct *curr, struct held_lock *this,
>
> bfs_init_root(&root, this);
> ret = find_usage_forwards(&root, usage_mask, &target_entry);
> - if (bfs_error(ret)) {
> + if (unlikely(bfs_error(ret))) {
> print_bfs_bug(ret);
> return 0;
> }
> @@ -3946,7 +3946,7 @@ check_usage_backwards(struct task_struct *curr, struct held_lock *this,
>
> bfs_init_rootb(&root, this);
> ret = find_usage_backwards(&root, usage_mask, &target_entry);
> - if (bfs_error(ret)) {
> + if (unlikely(bfs_error(ret))) {
> print_bfs_bug(ret);
> return 0;
> }
I think it is better to put the unlikely() directly into the bfs_error()
inline function instead of sprinkling it all over the place.
Cheers,
Longman
next prev parent reply other threads:[~2021-06-16 14:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-16 14:42 Xiongwei Song
2021-06-16 14:42 ` [PATCH] locking/lockdep: print possible warning after counting deps Xiongwei Song
2021-06-17 2:22 ` Xiongwei Song
2021-06-16 14:48 ` Waiman Long [this message]
2021-06-16 14:59 ` [PATCH] locking/lockdep: unlikely bfs error check Xiongwei Song
2021-06-16 15:11 ` Waiman Long
2021-06-17 2:14 ` 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=a341e1f1-39a5-dca3-9454-8eabe085928b@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®