From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: Pavel Reichl <preichl@redhat.com>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH v8 4/4] xfs: replace mrlock_t with rw_semaphores
Date: Tue, 6 Oct 2020 08:28:21 -0700 [thread overview]
Message-ID: <20201006152821.GW49547@magnolia> (raw)
In-Reply-To: <c2349a06-8ad3-664c-9510-40394fb08288@sandeen.net>
On Tue, Oct 06, 2020 at 09:04:18AM -0500, Eric Sandeen wrote:
>
>
> On 10/6/20 5:50 AM, Pavel Reichl wrote:
> >> Also, we're not really releasing the lock itself here, right? We're
> >> merely updating lockdep's bookkeepping so that the worker can make
> >> itself look like the lock owner (to lockdep, anyway).
> > Hmm...I'm afraid I don't follow - yes we are doing this to satisfy lockdep's bookkeeping,
> > however we actually do this by releasing the lock in one kernel thread and acquiring it in another.
>
> it's the difference between actually releasing the lock itself, and
> telling lockdep that we're releasing the "ownership" of the lock for tracking
> purposes; I agree that "rwsem_release" is a bit confusingly named.
Yes.
> >
> >> Does this exist as a helper anywhere in the kernel? I don't really like
> >> XFS poking into the rw_semaphore innards, though I concede that this
> >> lock transferring dance is probably pretty rare.
> > I'll try to look for it.
> >
>
> Other code I see just calls rwsem_release directly - ocfs2, jbd2, kernfs etc.
>
> I think a clearer comment might suffice, not sure what Darrick thinks, maybe something
> like this:
>
> + /*
> + * Let lockdep know that we won't own i_lock when we hand off
> + * to the worker thread
> + */
/*
* Update lockdep's ownership information to reflect that we
* will be transferring the ilock from this thread to the
* worker.
*/
> + rwsem_release(&cur->bc_ino.ip->i_lock.dep_map, _THIS_IP_);
> queue_work(xfs_alloc_wq, &args.work);
> +
> wait_for_completion(&done);
> + /* We own the i_lock again */
/*
* Update lockdep's lock ownership information to point to
* this thread as the lock owner now that the worker item is
* done.
*/
Perhaps?
--D
> + rwsem_acquire(&cur->bc_ino.ip->i_lock.dep_map, 0, 0, _RET_IP_);
>
> and similar comments in the worker:
>
> + /* Let lockdep know that we own the i_lock for now */
> + rwsem_acquire(&args->cur->bc_ino.ip->i_lock.dep_map, 0, 0, _RET_IP_);
> ...
>
> etc
>
> -Eric
prev parent reply other threads:[~2020-10-06 15:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-05 21:38 [PATCH v8 0/4] xfs: Remove wrappers for some semaphores Pavel Reichl
2020-10-05 21:38 ` [PATCH v8 1/4] xfs: Refactor xfs_isilocked() Pavel Reichl
2020-10-06 4:16 ` Darrick J. Wong
2020-10-05 21:38 ` [PATCH v8 2/4] xfs: clean up whitespace in xfs_isilocked() calls Pavel Reichl
2020-10-06 4:16 ` Darrick J. Wong
2020-10-05 21:38 ` [PATCH v8 3/4] xfs: xfs_isilocked() can only check a single lock type Pavel Reichl
2020-10-06 4:16 ` Darrick J. Wong
2020-10-05 21:38 ` [PATCH v8 4/4] xfs: replace mrlock_t with rw_semaphores Pavel Reichl
2020-10-06 4:14 ` Darrick J. Wong
2020-10-06 10:50 ` Pavel Reichl
2020-10-06 13:54 ` Eric Sandeen
2020-10-06 14:04 ` Eric Sandeen
2020-10-06 15:28 ` Darrick J. Wong [this message]
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=20201006152821.GW49547@magnolia \
--to=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
--cc=preichl@redhat.com \
--cc=sandeen@sandeen.net \
/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