Skip to content
Snippets Groups Projects
Commit cd987b50 authored by Avi Kivity's avatar Avi Kivity Committed by Pekka Enberg
Browse files

virtio-rng: drop excessive producer/consumer serialization


There is no need to hold the lock while waiting for the host to refill the
entropy buffer; drop it.

Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent b641f572
No related branches found
No related tags found
No related merge requests found
......@@ -123,25 +123,27 @@ void virtio_rng::refill()
{
auto remaining = _pool_size - _entropy.size();
vector<char> buf(remaining);
void *data = buf.data();
auto paddr = mmu::virt_to_phys(data);
u32 len;
DROP_LOCK(_mtx) {
void *data = buf.data();
auto paddr = mmu::virt_to_phys(data);
_queue->_sg_vec.clear();
_queue->_sg_vec.push_back(vring::sg_node(paddr, remaining, vring_desc::VRING_DESC_F_WRITE));
_queue->_sg_vec.clear();
_queue->_sg_vec.push_back(vring::sg_node(paddr, remaining, vring_desc::VRING_DESC_F_WRITE));
while (!_queue->add_buf(data)) {
sched::thread::wait_until([&] {
_queue->get_buf_gc();
return _queue->avail_ring_has_room(_queue->_sg_vec.size());
});
}
_queue->kick();
while (!_queue->add_buf(data)) {
sched::thread::wait_until([&] {
_queue->get_buf_gc();
return _queue->avail_ring_has_room(_queue->_sg_vec.size());
});
}
_queue->kick();
wait_for_queue(_queue, &vring::used_ring_not_empty);
wait_for_queue(_queue, &vring::used_ring_not_empty);
u32 len;
_queue->get_buf_elem(&len);
_queue->get_buf_finalize();
_queue->get_buf_elem(&len);
_queue->get_buf_finalize();
}
copy_n(buf.begin(), len, back_inserter(_entropy));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment