Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vmbus: replace modulus operation with subtraction

Takes less clock cycles to check for ring wrap and subtract than to
do a modulus instruction.

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>

authored by

Stephen Hemminger and committed by
Greg Kroah-Hartman
8d12f882 e4165a0f

+6 -3
+6 -3
drivers/hv/ring_buffer.c
··· 112 112 u32 next = ring_info->ring_buffer->read_index; 113 113 114 114 next += offset; 115 - next %= ring_info->ring_datasize; 115 + if (next >= ring_info->ring_datasize) 116 + next -= ring_info->ring_datasize; 116 117 117 118 return next; 118 119 } ··· 157 156 memcpy(dest, ring_buffer + start_read_offset, destlen); 158 157 159 158 start_read_offset += destlen; 160 - start_read_offset %= ring_buffer_size; 159 + if (start_read_offset >= ring_buffer_size) 160 + start_read_offset -= ring_buffer_size; 161 161 162 162 return start_read_offset; 163 163 } ··· 180 178 memcpy(ring_buffer + start_write_offset, src, srclen); 181 179 182 180 start_write_offset += srclen; 183 - start_write_offset %= ring_buffer_size; 181 + if (start_write_offset >= ring_buffer_size) 182 + start_write_offset -= ring_buffer_size; 184 183 185 184 return start_write_offset; 186 185 }