aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hv/ring_buffer.c
diff options
context:
space:
mode:
authorK. Y. Srinivasan <kys@microsoft.com>2016-01-28 01:29:44 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-02-08 00:34:12 -0500
commit3eba9a77d5fc2cee486a16fff435686f024f61cf (patch)
treede72dc9b5edc88f242121f589ad33d37f76f747e /drivers/hv/ring_buffer.c
parent85d9aa705184a4504d0330017e3956fcdae8a9d6 (diff)
Drivers: hv: vmbus: Eliminate the spin lock on the read path
The function hv_ringbuffer_read() is called always on a pre-assigned CPU. Each chnnel is bound to a specific CPU and this function is always called on the CPU the channel is bound. There is no need to acquire the spin lock; get rid of this overhead. Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hv/ring_buffer.c')
-rw-r--r--drivers/hv/ring_buffer.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index b53702ce692f..1145f3b8e4e0 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -388,7 +388,6 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info,
388 u32 bytes_avail_toread; 388 u32 bytes_avail_toread;
389 u32 next_read_location = 0; 389 u32 next_read_location = 0;
390 u64 prev_indices = 0; 390 u64 prev_indices = 0;
391 unsigned long flags;
392 struct vmpacket_descriptor desc; 391 struct vmpacket_descriptor desc;
393 u32 offset; 392 u32 offset;
394 u32 packetlen; 393 u32 packetlen;
@@ -397,7 +396,6 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info,
397 if (buflen <= 0) 396 if (buflen <= 0)
398 return -EINVAL; 397 return -EINVAL;
399 398
400 spin_lock_irqsave(&inring_info->ring_lock, flags);
401 399
402 *buffer_actual_len = 0; 400 *buffer_actual_len = 0;
403 *requestid = 0; 401 *requestid = 0;
@@ -412,7 +410,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info,
412 * No error is set when there is even no header, drivers are 410 * No error is set when there is even no header, drivers are
413 * supposed to analyze buffer_actual_len. 411 * supposed to analyze buffer_actual_len.
414 */ 412 */
415 goto out_unlock; 413 return ret;
416 } 414 }
417 415
418 next_read_location = hv_get_next_read_location(inring_info); 416 next_read_location = hv_get_next_read_location(inring_info);
@@ -425,15 +423,11 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info,
425 *buffer_actual_len = packetlen; 423 *buffer_actual_len = packetlen;
426 *requestid = desc.trans_id; 424 *requestid = desc.trans_id;
427 425
428 if (bytes_avail_toread < packetlen + offset) { 426 if (bytes_avail_toread < packetlen + offset)
429 ret = -EAGAIN; 427 return -EAGAIN;
430 goto out_unlock;
431 }
432 428
433 if (packetlen > buflen) { 429 if (packetlen > buflen)
434 ret = -ENOBUFS; 430 return -ENOBUFS;
435 goto out_unlock;
436 }
437 431
438 next_read_location = 432 next_read_location =
439 hv_get_next_readlocation_withoffset(inring_info, offset); 433 hv_get_next_readlocation_withoffset(inring_info, offset);
@@ -460,7 +454,5 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info,
460 454
461 *signal = hv_need_to_signal_on_read(bytes_avail_towrite, inring_info); 455 *signal = hv_need_to_signal_on_read(bytes_avail_towrite, inring_info);
462 456
463out_unlock:
464 spin_unlock_irqrestore(&inring_info->ring_lock, flags);
465 return ret; 457 return ret;
466} 458}