From: David Howells <dhowells@redhat.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: dhowells@redhat.com, Alexander Viro <viro@zeniv.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH] iov_iter: Add ITER_MAPPING
Date: Fri, 24 Jan 2020 14:58:37 +0000 [thread overview]
Message-ID: <911590.1579877917@warthog.procyon.org.uk> (raw)
In-Reply-To: <20200124112109.GK4675@bombadil.infradead.org>
Okay, so this then?
#define iterate_mapping(i, n, __v, skip, STEP) { \
struct page *page; \
size_t wanted = n, seg, offset; \
loff_t start = i->mapping_start + skip; \
pgoff_t index = start >> PAGE_SHIFT; \
\
XA_STATE(xas, &i->mapping->i_pages, index); \
\
rcu_read_lock(); \
for (page = xas_load(&xas); page; page = xas_next(&xas)) { \
if (xas_retry(&xas, page)) \
continue; \
if (WARN_ON(xa_is_value(page))) \
break; \
if (WARN_ON(PageHuge(page))) \
break; \
__v.bv_page = find_subpage(page, xas.xa_index); \
offset = (i->mapping_start + skip) & ~PAGE_MASK; \
seg = PAGE_SIZE - offset; \
__v.bv_offset = offset; \
__v.bv_len = min(n, seg); \
(void)(STEP); \
n -= __v.bv_len; \
skip += __v.bv_len; \
if (n == 0) \
break; \
} \
rcu_read_unlock(); \
n = wanted - n; \
}
> We could also have an ITER_XARRAY which you just pass &mapping->i_pages
> to. I don't think you use any other part of the mapping, so that would
> be a more generic version that is equally efficient.
I could give that a go. Out of interest, are there any other users of xarray
that might use it that don't have a mapping handy?
David
prev parent reply other threads:[~2020-01-24 14:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-22 14:57 [RFC][PATCH] iov_iter: Add ITER_MAPPING David Howells
2020-01-22 19:33 ` Matthew Wilcox
2020-01-22 21:42 ` David Howells
2020-01-23 11:04 ` David Howells
2020-01-24 11:21 ` Matthew Wilcox
2020-01-24 14:58 ` David Howells [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=911590.1579877917@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.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;
as well as URLs for NNTP newsgroup(s).