mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kent Overstreet <kent.overstreet@linux.dev>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, mingo@redhat.com,
	stern@rowland.harvard.edu
Subject: Re: [PATCH 1/2] lockdep: lock_set_lock_cmp_fn()
Date: Mon, 20 Feb 2023 17:45:42 -0500	[thread overview]
Message-ID: <Y/P4FrCj7xzOccJ5@moria.home.lan> (raw)
In-Reply-To: <Y/ONLYqVrWPFyboF@hirez.programming.kicks-ass.net>

On Mon, Feb 20, 2023 at 04:09:33PM +0100, Peter Zijlstra wrote:
> On Fri, Feb 17, 2023 at 10:21:16PM -0500, Kent Overstreet wrote:
> 
> > @@ -2982,6 +2989,10 @@ print_deadlock_bug(struct task_struct *curr, struct held_lock *prev,
> >  	pr_warn("\nbut task is already holding lock:\n");
> >  	print_lock(prev);
> >  
> > +	if (class->cmp_fn)
> > +		pr_warn("and the lock comparison function returns %i:\n",
> > +			class->cmp_fn(prev->instance, next->instance));
> > +
> 
> Please, use {} for any actual multi-line.
> 
> But is this sufficient data to debug a splat? Given an inversion on this
> class, we'll get something like:
> 
>  A
>  A -a
>  A -b
> 
> vs
> 
>  A
>  A c
> 
> which is I suppose sufficient to say that A messed up, but not much
> more. With subclasses we would've gotten
> 
>  A/0
>  A/1
>  A/2
> 
> vs
> 
>  A/2
>  A/0
> 
> which is much simpler to work with. Can we improve on this? Give the
> cmp_fn an additinoal optional argument of a string pointer or so to fill
> out with actual details to be printed?

Yes. This is where printbufs and %pf() would've been really nice, it'll
be doable but ugly with what we have now for string output. We just need
to add another callback, either .lock_print() or .lock_to_text(), and
that can print the information about the lock that's relevant for lock
ordering.

For bcache, that'd be something like

static void btree_lock_to_text()
{
	struct btree *b = container_of()

	seq_buf_printf("l=%u %llu:%llu", b->level, KEY_INODE(), KEY_OFFSET()...)
}

  reply	other threads:[~2023-02-20 22:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-18  3:21 [PATCH 0/2] lockdep lock comparison function Kent Overstreet
2023-02-18  3:21 ` [PATCH 1/2] lockdep: lock_set_lock_cmp_fn() Kent Overstreet
2023-02-20 15:09   ` Peter Zijlstra
2023-02-20 22:45     ` Kent Overstreet [this message]
2023-02-20 23:51     ` Kent Overstreet
2023-02-23 13:01       ` Peter Zijlstra
2023-02-23 19:27         ` Kent Overstreet
2023-02-18  3:21 ` [PATCH 2/2] bcache: Convert to lock_cmp_fn Kent Overstreet

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=Y/P4FrCj7xzOccJ5@moria.home.lan \
    --to=kent.overstreet@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=stern@rowland.harvard.edu \
    /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®