[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200122193306.GB4675@bombadil.infradead.org>
Date: Wed, 22 Jan 2020 11:33:06 -0800
From: Matthew Wilcox <willy@...radead.org>
To: David Howells <dhowells@...hat.com>
Cc: Alexander Viro <viro@...iv.linux.org.uk>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [RFC][PATCH] iov_iter: Add ITER_MAPPING
On Wed, Jan 22, 2020 at 02:57:55PM +0000, David Howells wrote:
> An alternative could be to have an "ITER_ARRAY" that just has the page
> pointers and not the offset/length info. This decreases the redundancy and
> increases the max payload-per-array-page to 2M.
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.
> + rcu_read_lock(); \
> + for (page = xas_load(&xas); page; page = xas_next(&xas)) { \
> + if (xas_retry(&xas, page)) \
> + continue; \
> + if (xa_is_value(page)) \
> + break; \
Do you also want to check for !page? That would be a bug in the caller.
> + if (PageCompound(page)) \
> + break; \
It's perfectly legal to have compound pages in the page cache. Call
find_subpage(page, xas.xa_index) unconditionally.
> + if (page_to_pgoff(page) != xas.xa_index) \
> + break; \
... and you can ditch this if the pages are pinned as find_subpage()
will bug in this case.
> + __v.bv_page = page; \
> + 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; \
Do we want STEP to be called with PAGE_SIZE chunks, or if they have a
THP, can we have it called with larger than a PAGE_SIZE chunk?
> +#define iterate_all_kinds(i, n, v, I, B, K, M) { \
> if (likely(n)) { \
> size_t skip = i->iov_offset; \
> if (unlikely(i->type & ITER_BVEC)) { \
> @@ -86,6 +119,9 @@
> struct kvec v; \
> iterate_kvec(i, n, v, kvec, skip, (K)) \
> } else if (unlikely(i->type & ITER_DISCARD)) { \
> + } else if (unlikely(i->type & ITER_MAPPING)) { \
> + struct bio_vec v; \
> + iterate_mapping(i, n, v, skip, (M)); \
bio_vec?
> -#define iterate_and_advance(i, n, v, I, B, K) { \
> +#define iterate_and_advance(i, n, v, I, B, K, M) { \
> if (unlikely(i->count < n)) \
> n = i->count; \
> if (i->count) { \
> @@ -119,6 +155,9 @@
> i->kvec = kvec; \
> } else if (unlikely(i->type & ITER_DISCARD)) { \
> skip += n; \
> + } else if (unlikely(i->type & ITER_MAPPING)) { \
> + struct bio_vec v; \
> + iterate_mapping(i, n, v, skip, (M)) \
again?
Powered by blists - more mailing lists