diff options
author | Cody Schuffelen <schuffelen@google.com> | 2019-11-13 18:25:50 -0800 |
---|---|---|
committer | Cody Schuffelen <schuffelen@google.com> | 2019-11-13 18:43:09 -0800 |
commit | e4575a2d22e1a6ff335ee354bc2a081639b5e99f (patch) | |
tree | 132ead4020bf1311c9bb687e4a91ae22d5bf2b5c | |
parent | 903fbe76b8a529ed16170944178eb7e2b41e7991 (diff) |
commit e82b9b0727ff ("vhost: introduce vhost_exceeds_weight()")
Complete backport of vhost_exceeds_weight to android-4.4-p
Test: Compiles
Bug: 143972019
Change-Id: Ifafc3321332d9033be75123e761d7da7d8586e4c
Signed-off-by: Cody Schuffelen <schuffelen@google.com>
-rw-r--r-- | drivers/vhost/vsock.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c index 72e914de473e..81754c33c3a9 100644 --- a/drivers/vhost/vsock.c +++ b/drivers/vhost/vsock.c @@ -21,6 +21,14 @@ #include "vhost.h" #define VHOST_VSOCK_DEFAULT_HOST_CID 2 +/* Max number of bytes transferred before requeueing the job. + * Using this limit prevents one virtqueue from starving others. */ +#define VHOST_VSOCK_WEIGHT 0x80000 +/* Max number of packets transferred before requeueing the job. + * Using this limit prevents one virtqueue from starving others with + * small pkts. + */ +#define VHOST_VSOCK_PKT_WEIGHT 256 enum { VHOST_VSOCK_FEATURES = VHOST_FEATURES, @@ -529,7 +537,8 @@ static int vhost_vsock_dev_open(struct inode *inode, struct file *file) vsock->vqs[VSOCK_VQ_TX].handle_kick = vhost_vsock_handle_tx_kick; vsock->vqs[VSOCK_VQ_RX].handle_kick = vhost_vsock_handle_rx_kick; - vhost_dev_init(&vsock->dev, vqs, ARRAY_SIZE(vsock->vqs)); + vhost_dev_init(&vsock->dev, vqs, ARRAY_SIZE(vsock->vqs), + VHOST_VSOCK_PKT_WEIGHT, VHOST_VSOCK_WEIGHT); file->private_data = vsock; spin_lock_init(&vsock->send_pkt_list_lock); |