Re: [PATCH V2 5/8] iov_iter: Remove memzero_page() in favor of zero_user()

2021-02-10 Thread Christoph Hellwig
On Tue, Feb 09, 2021 at 10:22:18PM -0800, ira.we...@intel.com wrote:
> From: Ira Weiny 
> 
> zero_user() is already defined with the same interface and contains the
> same code pattern as memzero_page().  Remove memzero_page() and use the
> already defined common function zero_user()

Looks good,

Reviewed-by: Christoph Hellwig 


[PATCH V2 5/8] iov_iter: Remove memzero_page() in favor of zero_user()

2021-02-09 Thread ira . weiny
From: Ira Weiny 

zero_user() is already defined with the same interface and contains the
same code pattern as memzero_page().  Remove memzero_page() and use the
already defined common function zero_user()

To: Alexander Viro 
Cc: Andrew Morton 
Cc: Christoph Hellwig 
Signed-off-by: Ira Weiny 

---
New for V2
---
 lib/iov_iter.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 9889e9903cdf..aa0d03b33a1e 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -5,6 +5,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -466,13 +467,6 @@ void iov_iter_init(struct iov_iter *i, unsigned int 
direction,
 }
 EXPORT_SYMBOL(iov_iter_init);
 
-static void memzero_page(struct page *page, size_t offset, size_t len)
-{
-   char *addr = kmap_atomic(page);
-   memset(addr + offset, 0, len);
-   kunmap_atomic(addr);
-}
-
 static inline bool allocated(struct pipe_buffer *buf)
 {
return buf->ops == &default_pipe_buf_ops;
@@ -950,7 +944,7 @@ static size_t pipe_zero(size_t bytes, struct iov_iter *i)
 
do {
size_t chunk = min_t(size_t, n, PAGE_SIZE - off);
-   memzero_page(pipe->bufs[i_head & p_mask].page, off, chunk);
+   zero_user(pipe->bufs[i_head & p_mask].page, off, chunk);
i->head = i_head;
i->iov_offset = off + chunk;
n -= chunk;
@@ -967,7 +961,7 @@ size_t iov_iter_zero(size_t bytes, struct iov_iter *i)
return pipe_zero(bytes, i);
iterate_and_advance(i, bytes, v,
clear_user(v.iov_base, v.iov_len),
-   memzero_page(v.bv_page, v.bv_offset, v.bv_len),
+   zero_user(v.bv_page, v.bv_offset, v.bv_len),
memset(v.iov_base, 0, v.iov_len)
)
 
-- 
2.28.0.rc0.12.gb6a658bd00c9