···895 }896}897000898static void block_vq(struct virtqueue *vq)899{900 struct itimerval itm;···942 if (!timeout && num)943 block_vq(vq);94400000945 if (timeout) {946 if (num < last_timeout_num)947 timeout_usec += 10;
···895 }896}897898+/* This is called when we no longer want to hear about Guest changes to a899+ * virtqueue. This is more efficient in high-traffic cases, but it means we900+ * have to set a timer to check if any more changes have occurred. */901static void block_vq(struct virtqueue *vq)902{903 struct itimerval itm;···939 if (!timeout && num)940 block_vq(vq);941942+ /* We never quite know how long should we wait before we check the943+ * queue again for more packets. We start at 500 microseconds, and if944+ * we get fewer packets than last time, we assume we made the timeout945+ * too small and increase it by 10 microseconds. Otherwise, we drop it946+ * by one microsecond every time. It seems to work well enough. */947 if (timeout) {948 if (num < last_timeout_num)949 timeout_usec += 10;
+8
drivers/lguest/lguest_device.c
···98 return features;99}1000000101static void lg_finalize_features(struct virtio_device *vdev)102{103 unsigned int i, bits;···112 /* Give virtio_ring a chance to accept features. */113 vring_transport_features(vdev);1140000115 memset(out_features, 0, desc->feature_len);116 bits = min_t(unsigned, desc->feature_len, sizeof(vdev->features)) * 8;117 for (i = 0; i < bits; i++) {
···98 return features;99}100101+/* The virtio core takes the features the Host offers, and copies the102+ * ones supported by the driver into the vdev->features array. Once103+ * that's all sorted out, this routine is called so we can tell the104+ * Host which features we understand and accept. */105static void lg_finalize_features(struct virtio_device *vdev)106{107 unsigned int i, bits;···108 /* Give virtio_ring a chance to accept features. */109 vring_transport_features(vdev);110111+ /* The vdev->feature array is a Linux bitmask: this isn't the112+ * same as a the simple array of bits used by lguest devices113+ * for features. So we do this slow, manual conversion which is114+ * completely general. */115 memset(out_features, 0, desc->feature_len);116 bits = min_t(unsigned, desc->feature_len, sizeof(vdev->features)) * 8;117 for (i = 0; i < bits; i++) {