From: Qian Cai <quic_qiancai@quicinc.com>
To: Al Viro <viro@zeniv.linux.org.uk>,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: <linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
David Sterba <dsterba@suse.com>,
Miklos Szeredi <miklos@szeredi.hu>,
Anton Altaparmakov <anton@tuxera.com>,
David Howells <dhowells@redhat.com>,
Matthew Wilcox <willy@infradead.org>,
Pavel Begunkov <asml.silence@gmail.com>
Subject: Re: [RFC PATCH 16/37] iov_iter_gap_alignment(): get rid of iterate_all_kinds()
Date: Wed, 9 Jun 2021 09:01:36 -0400 [thread overview]
Message-ID: <fc95d524-3e61-208d-52af-8ad0048fd76e@quicinc.com> (raw)
In-Reply-To: <20210606191051.1216821-16-viro@zeniv.linux.org.uk>
On 6/6/2021 3:10 PM, Al Viro wrote:
> For one thing, it's only used for iovec (and makes sense only for those).
> For another, here we don't care about iov_offset, since the beginning of
> the first segment and the end of the last one are ignored. So it makes
> a lot more sense to just walk through the iovec array...
>
> We need to deal with the case of truncated iov_iter, but unlike the
> situation with iov_iter_alignment() we don't care where the last
> segment ends - just which segment is the last one.
>
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Al, today's linux-next started to give a boot warning. I looked at the code and noticed this series is new. Any thoughts?
[ 70.060822][ T1286] WARNING: CPU: 26 PID: 1286 at lib/iov_iter.c:1320 iov_iter_gap_alignment+0x144/0x1a8
[ 70.070323][ T1286] Modules linked in: loop cppc_cpufreq processor efivarfs ip_tables x_tables ext4 mbcache jbd2 dm_mod igb i2c_algo_bit nvme mlx5_core i2c_core nvme_core firmware_class
[ 70.086922][ T1286] CPU: 26 PID: 1286 Comm: fwupd Tainted: G W 5.13.0-rc5-next-20210609+ #19
[ 70.096668][ T1286] Hardware name: MiTAC RAPTOR EV-883832-X3-0001/RAPTOR, BIOS 1.6 06/28/2020
[ 70.105196][ T1286] pstate: 10000005 (nzcV daif -PAN -UAO -TCO BTYPE=--)
[ 70.111902][ T1286] pc : iov_iter_gap_alignment+0x144/0x1a8
[ 70.117485][ T1286] lr : blk_rq_map_user_iov+0xd00/0xff0
[ 70.122808][ T1286] sp : ffff80002360f680
[ 70.126821][ T1286] x29: ffff80002360f680 x28: 0000000000000000 x27: ffff00005dc8d620
[ 70.134670][ T1286] x26: 0000000000001000 x25: ffff80002360f980 x24: 0000000000001000
[ 70.142518][ T1286] x23: 0000000000000000 x22: 0000000000000007 x21: 1ffff000046c1f30
[ 70.150365][ T1286] x20: 0000000000000fff x19: ffff80002360f980 x18: 0000000000000000
[ 70.158214][ T1286] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000
[ 70.166067][ T1286] x14: 0000000000000045 x13: 0000000000000000 x12: 000000000000f1f1
[ 70.173915][ T1286] x11: ffff00093d700040 x10: 000000000000f2f2 x9 : 00000000f3000000
[ 70.181763][ T1286] x8 : dfff800000000000 x7 : 00000000f3f3f3f3 x6 : 00000000f2000000
[ 70.189610][ T1286] x5 : 0000000000000000 x4 : 0000000000000cc0 x3 : 1ffff000046c1f30
[ 70.197459][ T1286] x2 : 1ffff000046c1f30 x1 : 0000000000000000 x0 : 0000000000000000
[ 70.205307][ T1286] Call trace:
[ 70.208453][ T1286] iov_iter_gap_alignment+0x144/0x1a8
[ 70.213693][ T1286] blk_rq_map_user_iov+0xd00/0xff0
[ 70.218668][ T1286] blk_rq_map_user+0xf4/0x190
[ 70.223209][ T1286] nvme_submit_user_cmd.isra.0+0x150/0x4e0 [nvme_core]
[ 70.229943][ T1286] nvme_user_cmd.isra.0+0x298/0x3d0 [nvme_core]
[ 70.236063][ T1286] nvme_dev_ioctl+0x19c/0x3c8 [nvme_core]
[ 70.241661][ T1286] __arm64_sys_ioctl+0x114/0x180
[ 70.246463][ T1286] invoke_syscall.constprop.0+0xdc/0x1d8
[ 70.251959][ T1286] do_el0_svc+0x1f8/0x298
[ 70.256151][ T1286] el0_svc+0x20/0x30
[ 70.259910][ T1286] el0t_64_sync_handler+0xb0/0xb8
[ 70.264796][ T1286] el0t_64_sync+0x178/0x17c
[ 70.269161][ T1286] irq event stamp: 254526
[ 70.273348][ T1286] hardirqs last enabled at (254525): [<ffff8000102cae90>] seqcount_lockdep_reader_access.constprop.0+0x138/0x190
[ 70.285183][ T1286] hardirqs last disabled at (254526): [<ffff8000111371c0>] el1_dbg+0x28/0x80
[ 70.293805][ T1286] softirqs last enabled at (250668): [<ffff800010010a90>] _stext+0xa90/0x1114
[ 70.302597][ T1286] softirqs last disabled at (250661): [<ffff800010114f64>] irq_exit+0x53c/0x610
> ---
> lib/iov_iter.c | 25 ++++++++++++++-----------
> 1 file changed, 14 insertions(+), 11 deletions(-)
>
> diff --git a/lib/iov_iter.c b/lib/iov_iter.c
> index bb7089cd0cf7..a6947301b9a0 100644
> --- a/lib/iov_iter.c
> +++ b/lib/iov_iter.c
> @@ -1409,23 +1409,26 @@ EXPORT_SYMBOL(iov_iter_alignment);
> unsigned long iov_iter_gap_alignment(const struct iov_iter *i)
> {
> unsigned long res = 0;
> + unsigned long v = 0;
> size_t size = i->count;
> + unsigned k;
>
> - if (unlikely(iov_iter_is_pipe(i) || iov_iter_is_discard(i))) {
> + if (unlikely(iter_is_iovec(i))) {
> WARN_ON(1);
> return ~0U;
> }
>
> - iterate_all_kinds(i, size, v,
> - (res |= (!res ? 0 : (unsigned long)v.iov_base) |
> - (size != v.iov_len ? size : 0), 0),
> - (res |= (!res ? 0 : (unsigned long)v.bv_offset) |
> - (size != v.bv_len ? size : 0)),
> - (res |= (!res ? 0 : (unsigned long)v.iov_base) |
> - (size != v.iov_len ? size : 0)),
> - (res |= (!res ? 0 : (unsigned long)v.bv_offset) |
> - (size != v.bv_len ? size : 0))
> - );
> + for (k = 0; k < i->nr_segs; k++) {
> + if (i->iov[k].iov_len) {
> + unsigned long base = (unsigned long)i->iov[k].iov_base;
> + if (v) // if not the first one
> + res |= base | v; // this start | previous end
> + v = base + i->iov[k].iov_len;
> + if (size <= i->iov[k].iov_len)
> + break;
> + size -= i->iov[k].iov_len;
> + }
> + }
> return res;
> }
> EXPORT_SYMBOL(iov_iter_gap_alignment);
>
next prev parent reply other threads:[~2021-06-09 13:01 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-06 19:07 [RFC][PATCHSET] iov_iter work Al Viro
2021-06-06 19:10 ` [RFC PATCH 01/37] ntfs_copy_from_user_iter(): don't bother with copying iov_iter Al Viro
2021-06-06 19:10 ` [RFC PATCH 02/37] generic_perform_write()/iomap_write_actor(): saner logics for short copy Al Viro
2021-06-06 19:10 ` [RFC PATCH 03/37] fuse_fill_write_pages(): don't bother with iov_iter_single_seg_count() Al Viro
2021-06-06 19:10 ` [RFC PATCH 04/37] iov_iter: Remove iov_iter_for_each_range() Al Viro
2021-06-06 19:10 ` [RFC PATCH 05/37] teach copy_page_to_iter() to handle compound pages Al Viro
2021-06-06 19:10 ` [RFC PATCH 06/37] copy_page_to_iter(): fix ITER_DISCARD case Al Viro
2021-06-06 19:10 ` [RFC PATCH 07/37] [xarray] iov_iter_fault_in_readable() should do nothing in xarray case Al Viro
2021-06-06 19:10 ` [RFC PATCH 08/37] iov_iter_advance(): use consistent semantics for move past the end Al Viro
2021-06-06 19:10 ` [RFC PATCH 09/37] iov_iter: switch ..._full() variants of primitives to use of iov_iter_revert() Al Viro
2021-06-06 19:10 ` [RFC PATCH 10/37] iov_iter: reorder handling of flavours in primitives Al Viro
2021-06-06 19:10 ` [RFC PATCH 11/37] iov_iter_advance(): don't modify ->iov_offset for ITER_DISCARD Al Viro
2021-06-06 19:10 ` [RFC PATCH 12/37] iov_iter: separate direction from flavour Al Viro
2021-06-06 19:10 ` [RFC PATCH 13/37] iov_iter: optimize iov_iter_advance() for iovec and kvec Al Viro
2021-06-06 19:10 ` [RFC PATCH 14/37] sanitize iov_iter_fault_in_readable() Al Viro
2021-06-06 19:10 ` [RFC PATCH 15/37] iov_iter_alignment(): don't bother with iterate_all_kinds() Al Viro
2021-06-06 19:10 ` [RFC PATCH 16/37] iov_iter_gap_alignment(): get rid of iterate_all_kinds() Al Viro
2021-06-09 13:01 ` Qian Cai [this message]
2021-06-09 18:06 ` Al Viro
2021-06-06 19:10 ` [RFC PATCH 17/37] get rid of iterate_all_kinds() in iov_iter_get_pages()/iov_iter_get_pages_alloc() Al Viro
2021-06-06 19:10 ` [RFC PATCH 18/37] iov_iter_npages(): don't bother with iterate_all_kinds() Al Viro
2021-06-06 19:10 ` [RFC PATCH 19/37] [xarray] iov_iter_npages(): just use DIV_ROUND_UP() Al Viro
2021-06-06 19:10 ` [RFC PATCH 20/37] iov_iter: replace iov_iter_copy_from_user_atomic() with iterator-advancing variant Al Viro
2021-06-06 19:10 ` [RFC PATCH 21/37] csum_and_copy_to_iter(): massage into form closer to csum_and_copy_from_iter() Al Viro
2021-06-06 19:10 ` [RFC PATCH 22/37] iterate_and_advance(): get rid of magic in case when n is 0 Al Viro
2021-06-06 19:10 ` [RFC PATCH 23/37] iov_iter: massage iterate_iovec and iterate_kvec to logics similar to iterate_bvec Al Viro
2021-06-06 19:10 ` [RFC PATCH 24/37] iov_iter: unify iterate_iovec and iterate_kvec Al Viro
2021-06-06 19:10 ` [RFC PATCH 25/37] iterate_bvec(): expand bvec.h macro forest, massage a bit Al Viro
2021-06-06 19:10 ` [RFC PATCH 26/37] iov_iter: teach iterate_{bvec,xarray}() about possible short copies Al Viro
2021-06-06 19:10 ` [RFC PATCH 27/37] iov_iter: get rid of separate bvec and xarray callbacks Al Viro
2021-06-06 19:10 ` [RFC PATCH 28/37] iov_iter: make the amount already copied available to iterator callbacks Al Viro
2021-06-06 19:10 ` [RFC PATCH 29/37] iov_iter: make iterator callbacks use base and len instead of iovec Al Viro
2021-06-06 19:10 ` [RFC PATCH 30/37] pull handling of ->iov_offset into iterate_{iovec,bvec,xarray} Al Viro
2021-06-06 19:10 ` [RFC PATCH 31/37] iterate_xarray(): only of the first iteration we might get offset != 0 Al Viro
2021-06-06 19:10 ` [RFC PATCH 32/37] copy_page_to_iter(): don't bother with kmap_atomic() for bvec/kvec cases Al Viro
2021-06-06 19:10 ` [RFC PATCH 33/37] copy_page_from_iter(): don't need kmap_atomic() for kvec/bvec cases Al Viro
2021-06-06 19:10 ` [RFC PATCH 34/37] iov_iter: clean csum_and_copy_...() primitives up a bit Al Viro
2021-06-06 19:10 ` [RFC PATCH 35/37] pipe_zero(): we don't need no stinkin' kmap_atomic() Al Viro
2021-06-06 19:10 ` [RFC PATCH 36/37] clean up copy_mc_pipe_to_iter() Al Viro
2021-06-06 19:10 ` [RFC PATCH 37/37] csum_and_copy_to_pipe_iter(): leave handling of csum_state to caller Al Viro
2021-06-06 22:05 ` [RFC][PATCHSET] iov_iter work Linus Torvalds
2021-06-06 22:46 ` Linus Torvalds
2021-06-07 9:28 ` Christoph Hellwig
2021-06-07 14:43 ` Al Viro
2021-06-07 15:59 ` Christoph Hellwig
2021-06-07 21:07 ` Al Viro
2021-06-07 22:01 ` Linus Torvalds
2021-06-07 23:35 ` Linus Torvalds
2021-06-08 5:25 ` Christoph Hellwig
2021-06-08 11:27 ` Al Viro
2021-06-06 23:29 ` Al Viro
2021-06-07 10:38 ` Pavel Begunkov
2021-06-08 14:43 ` David Laight
2021-06-10 14:29 ` Qian Cai
2021-06-10 15:35 ` Al Viro
2021-06-10 15:48 ` Al Viro
2021-06-10 19:08 ` Qian Cai
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=fc95d524-3e61-208d-52af-8ad0048fd76e@quicinc.com \
--to=quic_qiancai@quicinc.com \
--cc=anton@tuxera.com \
--cc=asml.silence@gmail.com \
--cc=dhowells@redhat.com \
--cc=dsterba@suse.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=torvalds@linux-foundation.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).