[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Zy0fg6E7Fbmi6lsP@casper.infradead.org>
Date: Thu, 7 Nov 2024 20:13:55 +0000
From: Matthew Wilcox <willy@...radead.org>
To: Michal Wajdeczko <michal.wajdeczko@...el.com>
Cc: intel-xe@...ts.freedesktop.org,
Alexander Viro <viro@...iv.linux.org.uk>,
Andrew Morton <akpm@...ux-foundation.org>,
Rodrigo Vivi <rodrigo.vivi@...el.com>,
Matthew Brost <matthew.brost@...el.com>,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH 1/4] iov_iter: Provide copy_iomem_to|from_iter()
On Thu, Nov 07, 2024 at 05:34:45PM +0100, Michal Wajdeczko wrote:
> +size_t copy_iomem_to_iter(const void __iomem *from, size_t offset,
> + size_t bytes, struct iov_iter *i)
> +{
> + unsigned char buf[SMP_CACHE_BYTES];
> + size_t progress = 0, copied, len;
> +
> + from += offset;
> + while (bytes) {
> + len = min(bytes, sizeof(buf));
> + memcpy_fromio(buf, from + progress, len);
> + copied = _copy_to_iter(buf, len, i);
> + if (!copied)
> + break;
> + bytes -= copied;
> + progress += copied;
> + }
This seems like a rather sad implementation. Why not:
if (WARN_ON_ONCE(i->data_source))
return 0;
if (user_backed_iter(i))
might_fault();
return iterate_and_advance(i, bytes, (void *)addr,
copy_iomem_to_iter, memcpy_iomem_to_iter);
along with
size_t memcpy_iomem_to_iter()
{
memcpy_fromio(iter_to, from + progress, len);
return 0;
}`
Powered by blists - more mailing lists