From 6f1dab52fed5fe3059452d8047c96dc74a563dff Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Tue, 14 Oct 2014 18:05:01 +0300 Subject: [PATCH] virtio: reduce rx allocations when preparing buffers (part 2) Instead of producing a range of buffer chains, produce a range of buffer arrays (std::array). These do not require any allocations. --- net/virtio.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/net/virtio.cc b/net/virtio.cc index 04b97161c0..bb63658c75 100644 --- a/net/virtio.cc +++ b/net/virtio.cc @@ -490,7 +490,6 @@ virtio_net_device::rxq::prepare_buffers() { count += opportunistic; } auto make_buffer_chain = [this] { - vring::buffer_chain bc; std::unique_ptr buf(new char[4096]); vring::buffer b; b.addr = virt_to_phys(buf.get()); @@ -524,8 +523,7 @@ virtio_net_device::rxq::prepare_buffers() { }); } }); - bc.push_back(std::move(b)); - return bc; + return std::array{std::move(b)}; }; auto start = make_function_input_iterator(make_buffer_chain, 0U); auto finish = make_function_input_iterator(make_buffer_chain, count);