From: Matthew Wilcox <willy@infradead.org>
To: David Howells <dhowells@redhat.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
Miklos Szeredi <miklos@szeredi.hu>, Ian Kent <raven@themaw.net>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] vfs: Use the mounts_to_id array to do /proc/mounts and co.
Date: Mon, 15 Mar 2021 12:54:40 +0000 [thread overview]
Message-ID: <20210315125440.GV2577561@casper.infradead.org> (raw)
In-Reply-To: <161581007628.2850696.11692651942358302102.stgit@warthog.procyon.org.uk>
On Mon, Mar 15, 2021 at 12:07:56PM +0000, David Howells wrote:
> Use the mounts_to_id xarray added to the mount namespace to perform
You called it mounts_by_id in the last patch ...
> Since it doesn't trawl a standard list_head, but rather uses xarray, this
> could be done under the RCU read lock only. To do this, we would need to
> hide mounts that are in the process of being inserted into the tree by
> marking them in the xarray itself or using a mount flag.
> /* iterator; we want it to have access to namespace_sem, thus here... */
> static void *m_start(struct seq_file *m, loff_t *pos)
> {
> - struct proc_mounts *p = m->private;
> - struct list_head *prev;
> + struct proc_mounts *state = m->private;
> + void *entry;
>
> down_read(&namespace_sem);
> - if (!*pos) {
> - prev = &p->ns->list;
> - } else {
> - prev = &p->cursor.mnt_list;
> + state->xas = (struct xa_state) __XA_STATE(&state->ns->mounts_by_id, *pos, 0, 0);
>
> - /* Read after we'd reached the end? */
> - if (list_empty(prev))
> - return NULL;
> - }
> + entry = xas_find(&state->xas, ULONG_MAX);
I know you haven't enabled enough debugging because this will assert
that either the RCU read lock or the xa_lock is held to prevent xa_nodes
from disappearing underneath us.
Why do you want to use an xa_state for this? This is /proc, so efficiency
isn't the highest priority. I'd just use xa_find(), and then you don't
need to care about an xa_state or locking -- it handles taking the rcu
read lock for you.
> + while (entry && xas_invalid(entry))
I've never seen anybody make that mistake before. Good one. Not sure
if there's anything I can do to prevent it in future.
> + entry = xas_next_entry(&state->xas, ULONG_MAX);
next prev parent reply other threads:[~2021-03-15 12:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-15 12:07 [RFC][PATCH 0/3] vfs: Use an xarray instead of inserted bookmarks to scan mount list David Howells
2021-03-15 12:07 ` [PATCH 1/3] vfs: Use an xarray in the mount namespace to handle /proc/mounts list David Howells
2021-03-15 12:07 ` [PATCH 2/3] vfs: Use the mounts_to_id array to do /proc/mounts and co David Howells
2021-03-15 12:54 ` Matthew Wilcox [this message]
2021-03-15 12:08 ` [PATCH 3/3] vfs: Remove mount list trawling cursor stuff David Howells
2021-03-15 12:46 ` [RFC][PATCH 0/3] vfs: Use an xarray instead of inserted bookmarks to scan mount list Matthew Wilcox
2021-03-15 13:14 ` Miklos Szeredi
2021-03-15 13:17 ` Matthew Wilcox
2021-03-15 13:41 ` David Howells
2021-03-15 14:22 ` Miklos Szeredi
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=20210315125440.GV2577561@casper.infradead.org \
--to=willy@infradead.org \
--cc=dhowells@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=raven@themaw.net \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).