From: David Howells <dhowells@redhat.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org,
linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 04/10] iov_iter: Add mapping and discard iterator types
Date: Mon, 17 Sep 2018 21:58:56 +0100 [thread overview]
Message-ID: <3533.1537217936@warthog.procyon.org.uk> (raw)
In-Reply-To: <20180914041831.GY19965@ZenIV.linux.org.uk>
Al Viro <viro@ZenIV.linux.org.uk> wrote:
> > Add two new iterator types to iov_iter:
> >
> > (1) ITER_MAPPING
> >
> > This walks through a set of pages attached to an address_space that
> > are pinned or locked, starting at a given page and offset and walking
> > for the specified amount of space. A facility to get a callback each
> > time a page is entirely processed is provided.
> >
> > This is useful for copying data from socket buffers to inodes in
> > network filesystems.
>
> Interesting... Questions:
> * what will hold those pages? IOW, where will you unlock/drop/whatnot
> those sucker?
The caller needs to have those pages pinned - say with PG_locked or
PG_writeback. Sorry - I mentioned this in the cover, but not here.
You can either undo there changes in the callback or upon completion of the
iteration.
> * "callback" sounds dangerous - it appears to imply that you won't
> copy to/from the same page twice. Not true for a lot of iov_iter users; what
> happens if you pass such a beast to them?
Similar to ITER_PIPE. There's no rewind. Once you've passed a page, it's
gone. Under what circumstances would you want to copy to/from the same page
twice?
> * why not simply "build and populate ITER_BVEC aliasing a piece of
> mapping", possibly in "grab" and "grab+lock" variants?
ITER_BVEC is inefficient. This is what the upstream now. See
afs_load_bvec().
That what the code currently uses. There's a
practical limit to the number of pages I can shovel into one in one go.
Further, every time I reach the end of a ITER_BVEC, I have to return to
process context, which then has to round up the next bundle of pages by
calling the radix tree. It seems to work out better to put the radix
iteration into the iterator if we can. The caller guarantees that the
contents of the region of interest are (a) fully populated and (b) pinned.
Yet further, with ITER_BVEC, I can't release any of the pinned pages until the
entire iteration is finished. That means if I have a 4GB BVEC, those pages
are going to be pinned a long time. With ITER_MAPPING, they're released
incrementally via the callback.
> Those ITER_MAPPING do seem to be related to ITER_BVEC, at the very least.
Only in the sense that the current position can be described by the same three
numbers: page, len, offset. I'm reusing struct bio_vec so that I can share
some of the code with ITER_BVEC.
> Note, BTW, that iov_iter_get_pages...() might mutate into something similar
> - "build and populate ITER_BVEC aliasing a piece of given iov_iter". Or,
> perhaps, a nicer-on-memory analogue of ITER_BVEC - with <offset, bytes,
> pointer to pages array> instead of <offset, bytes, page> as elements, with
> the same "populate from mapping" to get something similar to your
> functionality and "populate from iov_iter" for
> iov_iter_get_pages... replacement
The whole point is to avoid having to use ITER_BVEC. ITER_BVEC has a number
of issues that ITER_MAPPING overcomes - though ITER_MAPPING can only be used
with a mapping (or, at least, a radix tree).
There is no point to the loop shifting page runs into a page array for use
with a BVEC when the mapping carries the same information. You save memory
and processing time.
David
next prev parent reply other threads:[~2018-09-17 20:59 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-13 15:51 [PATCH 00/10] iov_iter: Add new iters and use with AFS David Howells
2018-09-13 15:51 ` [PATCH 01/10] iov_iter: Separate type from direction and use accessor functions David Howells
2018-09-13 15:51 ` [PATCH 02/10] iov_iter: Renumber the ITER_* constants in uio.h David Howells
2018-09-13 15:52 ` [PATCH 03/10] iov_iter: Make count and iov_offset loff_t not size_t David Howells
2018-09-13 15:52 ` [PATCH 04/10] iov_iter: Add mapping and discard iterator types David Howells
2018-09-14 4:18 ` Al Viro
2018-09-14 12:57 ` Trond Myklebust
2018-09-17 21:32 ` David Howells
2018-09-17 20:58 ` David Howells [this message]
2018-09-13 15:52 ` [PATCH 05/10] afs: Better tracing of protocol errors David Howells
2018-09-13 15:52 ` [PATCH 06/10] afs: Set up the iov_iter before calling afs_extract_data() David Howells
2018-09-13 15:52 ` [PATCH 07/10] afs: Use ITER_MAPPING for writing David Howells
2018-09-13 15:52 ` [PATCH 08/10] afs: Add O_DIRECT read support David Howells
2018-09-13 15:52 ` [PATCH 09/10] afs: Add a couple of tracepoints to log I/O errors David Howells
2018-09-13 15:52 ` [PATCH 10/10] afs: Don't invoke the server to read data beyond EOF David Howells
2018-09-13 16:10 ` [PATCH 00/10] iov_iter: Add new iters and use with AFS Matthew Wilcox
2018-09-13 16:18 ` David Howells
2018-09-13 16:43 ` Matthew Wilcox
2018-09-13 17:05 ` David Howells
2018-09-13 17:58 ` Al Viro
-- strict thread matches above, loose matches on Subject: below --
2018-08-06 13:16 David Howells
2018-08-06 13:17 ` [PATCH 04/10] iov_iter: Add mapping and discard iterator types David Howells
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=3533.1537217936@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=linux-afs@lists.infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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
Powered by JetHome