Drivers: hv: Implement routines for read side signaling optimization
authorK. Y. Srinivasan <kys@microsoft.com>
Sat, 1 Dec 2012 14:46:32 +0000 (06:46 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Jan 2013 18:46:39 +0000 (10:46 -0800)
Implement functions that will support read-side signaling optimization.
By having the reader indicate the start of the "read" operation and the
"end" of the read operation we can more efficiently handle the signaling
protocol: while the read is in progress, there is no need for the "writer"
to signal the "reader" as new items are put on the read queue.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hv/hyperv_vmbus.h
drivers/hv/ring_buffer.c

index d8d1fad..3184f6f 100644 (file)
@@ -570,6 +570,10 @@ u32 hv_get_ringbuffer_interrupt_mask(struct hv_ring_buffer_info *ring_info);
 void hv_ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
                            struct hv_ring_buffer_debug_info *debug_info);
 
+void hv_begin_read(struct hv_ring_buffer_info *rbi);
+
+u32 hv_end_read(struct hv_ring_buffer_info *rbi);
+
 /*
  * Maximum channels is determined by the size of the interrupt page
  * which is PAGE_SIZE. 1/2 of PAGE_SIZE is for send endpoint interrupt
index 7233c88..0010792 100644 (file)
 
 #include "hyperv_vmbus.h"
 
+void hv_begin_read(struct hv_ring_buffer_info *rbi)
+{
+       rbi->ring_buffer->interrupt_mask = 1;
+       smp_mb();
+}
+
+u32 hv_end_read(struct hv_ring_buffer_info *rbi)
+{
+       u32 read;
+       u32 write;
+
+       rbi->ring_buffer->interrupt_mask = 0;
+       smp_mb();
+
+       /*
+        * Now check to see if the ring buffer is still empty.
+        * If it is not, we raced and we need to process new
+        * incoming messages.
+        */
+       hv_get_ringbuffer_availbytes(rbi, &read, &write);
+
+       return read;
+}
+
 
 /*
  * hv_get_next_write_location()