]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
vmbus: eliminate duplicate cached index
authorStephen Hemminger <stephen@networkplumber.org>
Sun, 25 Jun 2017 19:30:27 +0000 (12:30 -0700)
committerThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Thu, 16 Nov 2017 13:23:07 +0000 (11:23 -0200)
BugLink: http://bugs.launchpad.net/bugs/1731926
commit 05d00bc94ac27d220d8a78e365d7fa3a26dcca17 upstream.

Don't need cached read index anymore now that packet iterator
is used. The iterator has the original read index until the
visible read_index is updated.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
drivers/hv/ring_buffer.c
include/linux/hyperv.h

index a9021f13379f05ba8f48162711f0fcd2533610c7..b0f79526b86af02292db6c16fe16b8fb050fa1d8 100644 (file)
@@ -358,9 +358,6 @@ struct vmpacket_descriptor *hv_pkt_iter_first(struct vmbus_channel *channel)
 {
        struct hv_ring_buffer_info *rbi = &channel->inbound;
 
-       /* set state for later hv_pkt_iter_close */
-       rbi->cached_read_index = rbi->ring_buffer->read_index;
-
        if (hv_pkt_iter_avail(rbi) < sizeof(struct vmpacket_descriptor))
                return NULL;
 
@@ -388,10 +385,7 @@ __hv_pkt_iter_next(struct vmbus_channel *channel,
                rbi->priv_read_index -= dsize;
 
        /* more data? */
-       if (hv_pkt_iter_avail(rbi) < sizeof(struct vmpacket_descriptor))
-               return NULL;
-       else
-               return hv_get_ring_buffer(rbi) + rbi->priv_read_index;
+       return hv_pkt_iter_first(channel);
 }
 EXPORT_SYMBOL_GPL(__hv_pkt_iter_next);
 
@@ -401,7 +395,7 @@ EXPORT_SYMBOL_GPL(__hv_pkt_iter_next);
 void hv_pkt_iter_close(struct vmbus_channel *channel)
 {
        struct hv_ring_buffer_info *rbi = &channel->inbound;
-       u32 cur_write_sz, cached_write_sz;
+       u32 orig_write_sz = hv_get_bytes_to_write(rbi);
        u32 pending_sz;
 
        /*
@@ -430,13 +424,10 @@ void hv_pkt_iter_close(struct vmbus_channel *channel)
        if (pending_sz == 0)
                return;
 
-       cur_write_sz = hv_get_bytes_to_write(rbi);
-
-       if (cur_write_sz < pending_sz)
+       if (hv_get_bytes_to_write(rbi) < pending_sz)
                return;
 
-       cached_write_sz = hv_get_cached_bytes_to_write(rbi);
-       if (cached_write_sz < pending_sz)
+       if (orig_write_sz < pending_sz)
                vmbus_setevent(channel);
 }
 EXPORT_SYMBOL_GPL(hv_pkt_iter_close);
index 8a1d29c431fa1bdabf77296139419620718a1002..3647085dab0a5cabfff8a6179bdb4313bc1e6851 100644 (file)
@@ -127,7 +127,6 @@ struct hv_ring_buffer_info {
        u32 ring_data_startoffset;
        u32 priv_write_index;
        u32 priv_read_index;
-       u32 cached_read_index;
 };
 
 /*
@@ -180,19 +179,6 @@ static inline u32 hv_get_bytes_to_write(const struct hv_ring_buffer_info *rbi)
        return write;
 }
 
-static inline u32 hv_get_cached_bytes_to_write(
-       const struct hv_ring_buffer_info *rbi)
-{
-       u32 read_loc, write_loc, dsize, write;
-
-       dsize = rbi->ring_datasize;
-       read_loc = rbi->cached_read_index;
-       write_loc = rbi->ring_buffer->write_index;
-
-       write = write_loc >= read_loc ? dsize - (write_loc - read_loc) :
-               read_loc - write_loc;
-       return write;
-}
 /*
  * VMBUS version is 32 bit entity broken up into
  * two 16 bit quantities: major_number. minor_number.