mirror of
https://github.com/genesi/linux-legacy.git
synced 2026-05-18 18:37:29 +00:00
[SOCK] Avoid divides in sk_stream_pages() and __sk_stream_mem_reclaim()
sk_forward_alloc being signed, we should take care of divides by SK_STREAM_MEM_QUANTUM we do in sk_stream_pages() and __sk_stream_mem_reclaim() This patchs introduces SK_STREAM_MEM_QUANTUM_SHIFT, defined as ilog2(SK_STREAM_MEM_QUANTUM), to be able to use right shifts instead of plain divides. This should help compiler to choose right shifts instead of expensive divides (as seen with CONFIG_CC_OPTIMIZE_FOR_SIZE=y on x86) Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
b15c4bcd15
commit
21371f768b
@@ -196,7 +196,7 @@ EXPORT_SYMBOL(sk_stream_error);
|
||||
|
||||
void __sk_stream_mem_reclaim(struct sock *sk)
|
||||
{
|
||||
atomic_sub(sk->sk_forward_alloc / SK_STREAM_MEM_QUANTUM,
|
||||
atomic_sub(sk->sk_forward_alloc >> SK_STREAM_MEM_QUANTUM_SHIFT,
|
||||
sk->sk_prot->memory_allocated);
|
||||
sk->sk_forward_alloc &= SK_STREAM_MEM_QUANTUM - 1;
|
||||
if (*sk->sk_prot->memory_pressure &&
|
||||
|
||||
Reference in New Issue
Block a user