fate#314663 hyper-v memory ballooning support
[opensuse:kernel-source.git] / patches.suse / suse-hv-fate314665-0002-Drivers-hv-Add-state-to-manage-batched-reading.patch
1 Patch-mainline: submitted
2 From: <ohering@suse.de>
3 Date: Sat, 1 Dec 2012 06:46:33 -0800
4 Subject: [PATCH 02/28] Drivers: hv: Add state to manage batched reading
5
6 For the "read" side signaling optimization, the reader has to completely
7 drain the queue before exiting. Add state to manage this "batched"
8 reading.
9
10 Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
11 Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
12 ---
13  drivers/hv/channel_mgmt.c |  7 +++++++
14  include/linux/hyperv.h    | 20 ++++++++++++++++++++
15  2 files changed, 27 insertions(+)
16
17 diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
18 index 2b8b8d4..e4a128a 100644
19 --- a/drivers/hv/channel_mgmt.c
20 +++ b/drivers/hv/channel_mgmt.c
21 @@ -280,6 +280,13 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
22                 return;
23         }
24  
25 +       /*
26 +        * By default we setup state to enable batched
27 +        * reading. A specific service can choose to
28 +        * disable this prior to opening the channel.
29 +        */
30 +       newchannel->batched_reading = true;
31 +
32         memcpy(&newchannel->offermsg, offer,
33                sizeof(struct vmbus_channel_offer_channel));
34         newchannel->monitor_grp = (u8)offer->monitorid / 32;
35 diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
36 index e73b852..1ffe84d 100644
37 --- a/include/linux/hyperv.h
38 +++ b/include/linux/hyperv.h
39 @@ -882,8 +882,28 @@ struct vmbus_channel {
40  
41         void (*onchannel_callback)(void *context);
42         void *channel_callback_context;
43 +
44 +       /*
45 +        * A channel can be marked for efficient (batched)
46 +        * reading:
47 +        * If batched_reading is set to "true", we read until the
48 +        * channel is empty and hold off interrupts from the host
49 +        * during the entire read process.
50 +        * If batched_reading is set to "false", the client is not
51 +        * going to perform batched reading.
52 +        *
53 +        * By default we will enable batched reading; specific
54 +        * drivers that don't want this behavior can turn it off.
55 +        */
56 +
57 +       bool batched_reading;
58  };
59  
60 +static inline void set_channel_read_state(struct vmbus_channel *c, bool state)
61 +{
62 +       c->batched_reading = state;
63 +}
64 +
65  void vmbus_onmessage(void *context);
66  
67  int vmbus_request_offers(void);
68 -- 
69 1.8.0.1
70