All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Nathan Scott <nathans@sgi.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>,
	Matthew Wilcox <matthew@wil.cx>,
	linux-fsdevel@vger.kernel.org, xfs@oss.sgi.com,
	Arjan van de Ven <arjan@infradead.org>
Subject: Re: [LOCKDEP] xfs: possible recursive locking detected
Date: Tue, 4 Jul 2006 11:57:43 +0200	[thread overview]
Message-ID: <20060704095743.GA21480@elte.hu> (raw)
In-Reply-To: <20060704191100.C1497438@wobbly.melbourne.sgi.com>


* Nathan Scott <nathans@sgi.com> wrote:

> > flag-passing into an opaque function (such as xfs_ilock), just to have 
> > them untangled in xfs_ilock():
> > 
> >         if (lock_flags & XFS_IOLOCK_EXCL) {
> >                 mrupdate(&ip->i_iolock);
> >         } else if (lock_flags & XFS_IOLOCK_SHARED) {
> >                 mraccess(&ip->i_iolock);
> >         }
> >         if (lock_flags & XFS_ILOCK_EXCL) {
> >                 mrupdate(&ip->i_lock);
> >         } else if (lock_flags & XFS_ILOCK_SHARED) {
> >                 mraccess(&ip->i_lock);
> >         }
> > 
> > is pretty inefficient too - there are 85 calls to xfs_ilock(), and 
> > 74 of them have static flags.
> 
> Right... but that leaves plenty that don't, and they're not simple to 
> change.  There are generic routines that need to be called from 
> different contexts with different locking requirements (xfs_iget).

the main variation in xfs_iget() is whether we lock the inode 
read-write, read-only or not at all, correct? (XFS_ILOCK_EXCL, 
XFS_ILOCK_SHARED and 0)

That could be cleaned up the following way:

- rename the current xfs_iget() to __xfs_iget() and remove ilock locking 
  from it.

- add 3 new APIs: xfs_iget_read(), xfs_iget_write() and 
  xfs_iget_nolock():

   - xfs_iget_read() just calls __xfs_iget() and does a down_read() if 
     the inode was looked up successfully.

   - xfs_iget_write() does the same but with down_write()

   - xfs_iget_nolock() is just an alias to __xfs_iget().

 - update all 13 uses of xfs_iget() to one of the 3 API variants

 - [ there might be other details i missed, but this seems to be the 
     rough list of things to do. ]

NOTE: since the majority (9 out of 13) of xfs_iget() uses are for the 
'no lock' variant, this construction of functions, besides making the 
code more readable, _further_ reduces overhead, because there is no 
ilock-flags checking overhead in __xfs_iget() anymore.

	Ingo

  parent reply	other threads:[~2006-07-04 10:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-04  0:41 [LOCKDEP] xfs: possible recursive locking detected Alexey Dobriyan
2006-07-04  1:18 ` Matthew Wilcox
2006-07-04  1:25   ` Nathan Scott
2006-07-04  6:32     ` Ingo Molnar
2006-07-04  6:56       ` Nathan Scott
2006-07-04  8:41       ` Ingo Molnar
2006-07-04  9:11         ` Nathan Scott
2006-07-04  9:12           ` Ingo Molnar
2006-07-05  3:23             ` Nathan Scott
2006-07-05  4:44               ` Arjan van de Ven
2006-07-04  9:57           ` Ingo Molnar [this message]
2006-07-04 13:03             ` Ingo Molnar
2006-07-05  5:26               ` Nathan Scott
2006-07-05  6:46                 ` Ingo Molnar
2006-07-05  6:58                   ` Nathan Scott
2006-07-05  3:37             ` Nathan Scott
     [not found]         ` <20060704191100.C1497438__38681.8935432986$1152004607$gmane$org@wobbly.melbourne.sgi.com>
2006-07-04 12:42           ` Andi Kleen

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=20060704095743.GA21480@elte.hu \
    --to=mingo@elte.hu \
    --cc=adobriyan@gmail.com \
    --cc=arjan@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=matthew@wil.cx \
    --cc=nathans@sgi.com \
    --cc=xfs@oss.sgi.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.