diff mbox series

[20/23] rxrpc: use bvec_set_page to initialize a bvec

Message ID 20230130092157.1759539-21-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [01/23] block: factor out a bvec_set_page helper | expand

Commit Message

Christoph Hellwig Jan. 30, 2023, 9:21 a.m. UTC
Use the bvec_set_page helper to initialize a bvec.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 net/rxrpc/rxperf.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

David Howells Jan. 30, 2023, 10:31 a.m. UTC | #1
Christoph Hellwig <hch@lst.de> wrote:

> +		bvec_set_page(&bv, ZERO_PAGE(0), len, 0);

Maybe bvec_set_zero_page()?

David
Christoph Hellwig Jan. 30, 2023, 10:33 a.m. UTC | #2
On Mon, Jan 30, 2023 at 10:31:23AM +0000, David Howells wrote:
> Christoph Hellwig <hch@lst.de> wrote:
> 
> > +		bvec_set_page(&bv, ZERO_PAGE(0), len, 0);
> 
> Maybe bvec_set_zero_page()?

Why?
David Howells Jan. 30, 2023, 11:24 a.m. UTC | #3
Christoph Hellwig <hch@lst.de> wrote:

> On Mon, Jan 30, 2023 at 10:31:23AM +0000, David Howells wrote:
> > Christoph Hellwig <hch@lst.de> wrote:
> > 
> > > +		bvec_set_page(&bv, ZERO_PAGE(0), len, 0);
> > 
> > Maybe bvec_set_zero_page()?
> 
> Why?

Seems to be something people want to do quite a lot and don't know about.
I've seen places where someone allocates a buffer and clears it just to use as
a source of zeros.  There's at least one place in cifs, for example.  I know
about it from wrangling arch code, but most people working on Linux haven't
done that.

David
Christoph Hellwig Jan. 30, 2023, 12:18 p.m. UTC | #4
On Mon, Jan 30, 2023 at 11:24:15AM +0000, David Howells wrote:
> Seems to be something people want to do quite a lot and don't know about.

Hmm.  Right now there is one case where it would be used, and there's
about three that are and should be using bio_add_page.

> I've seen places where someone allocates a buffer and clears it just to use as
> a source of zeros.  There's at least one place in cifs, for example.  I know
> about it from wrangling arch code, but most people working on Linux haven't
> done that.

But we don't really need a helper for every possible page use for that.
People just need to learn about ZERO_PAGE.
David Howells Jan. 30, 2023, 3:58 p.m. UTC | #5
Christoph Hellwig <hch@lst.de> wrote:

> Use the bvec_set_page helper to initialize a bvec.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Acked-by: David Howells <dhowells@redhat.com>
diff mbox series

Patch

diff --git a/net/rxrpc/rxperf.c b/net/rxrpc/rxperf.c
index 16dcabb71ebe16..4a2e90015ca72c 100644
--- a/net/rxrpc/rxperf.c
+++ b/net/rxrpc/rxperf.c
@@ -493,7 +493,7 @@  static int rxperf_deliver_request(struct rxperf_call *call)
 static int rxperf_process_call(struct rxperf_call *call)
 {
 	struct msghdr msg = {};
-	struct bio_vec bv[1];
+	struct bio_vec bv;
 	struct kvec iov[1];
 	ssize_t n;
 	size_t reply_len = call->reply_len, len;
@@ -503,10 +503,8 @@  static int rxperf_process_call(struct rxperf_call *call)
 
 	while (reply_len > 0) {
 		len = min_t(size_t, reply_len, PAGE_SIZE);
-		bv[0].bv_page	= ZERO_PAGE(0);
-		bv[0].bv_offset	= 0;
-		bv[0].bv_len	= len;
-		iov_iter_bvec(&msg.msg_iter, WRITE, bv, 1, len);
+		bvec_set_page(&bv, ZERO_PAGE(0), len, 0);
+		iov_iter_bvec(&msg.msg_iter, WRITE, &bv, 1, len);
 		msg.msg_flags = MSG_MORE;
 		n = rxrpc_kernel_send_data(rxperf_socket, call->rxcall, &msg,
 					   len, rxperf_notify_end_reply_tx);