fate#314663 hyper-v memory ballooning support
[opensuse:kernel-source.git] / patches.suse / suse-hv-fate314665-0001-Drivers-hv-Implement-routines-for-read-side-signalin.patch
1 Patch-mainline: submitted
2 From: <ohering@suse.de>
3 Date: Sat, 1 Dec 2012 06:46:32 -0800
4 Subject: [PATCH 01/28] Drivers: hv: Implement routines for read side signaling
5  optimization
6
7 Implement functions that will support read-side signaling optimization.
8 By having the reader indicate the start of the "read" operation and the
9 "end" of the read operation we can more efficiently handle the signaling
10 protocol: while the read is in progress, there is no need for the "writer"
11 to signal the "reader" as new items are put on the read queue.
12
13 Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
14 Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
15 ---
16  drivers/hv/hyperv_vmbus.h |  4 ++++
17  drivers/hv/ring_buffer.c  | 24 ++++++++++++++++++++++++
18  2 files changed, 28 insertions(+)
19
20 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
21 index d8d1fad..3184f6f 100644
22 --- a/drivers/hv/hyperv_vmbus.h
23 +++ b/drivers/hv/hyperv_vmbus.h
24 @@ -570,6 +570,10 @@ u32 hv_get_ringbuffer_interrupt_mask(struct hv_ring_buffer_info *ring_info);
25  void hv_ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
26                             struct hv_ring_buffer_debug_info *debug_info);
27  
28 +void hv_begin_read(struct hv_ring_buffer_info *rbi);
29 +
30 +u32 hv_end_read(struct hv_ring_buffer_info *rbi);
31 +
32  /*
33   * Maximum channels is determined by the size of the interrupt page
34   * which is PAGE_SIZE. 1/2 of PAGE_SIZE is for send endpoint interrupt
35 diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
36 index 7233c88..0010792 100644
37 --- a/drivers/hv/ring_buffer.c
38 +++ b/drivers/hv/ring_buffer.c
39 @@ -29,6 +29,30 @@
40  
41  #include "hyperv_vmbus.h"
42  
43 +void hv_begin_read(struct hv_ring_buffer_info *rbi)
44 +{
45 +       rbi->ring_buffer->interrupt_mask = 1;
46 +       smp_mb();
47 +}
48 +
49 +u32 hv_end_read(struct hv_ring_buffer_info *rbi)
50 +{
51 +       u32 read;
52 +       u32 write;
53 +
54 +       rbi->ring_buffer->interrupt_mask = 0;
55 +       smp_mb();
56 +
57 +       /*
58 +        * Now check to see if the ring buffer is still empty.
59 +        * If it is not, we raced and we need to process new
60 +        * incoming messages.
61 +        */
62 +       hv_get_ringbuffer_availbytes(rbi, &read, &write);
63 +
64 +       return read;
65 +}
66 +
67  
68  /*
69   * hv_get_next_write_location()
70 -- 
71 1.8.0.1
72