diff options
author | Eric Dumazet <dada1@cosmosbay.com> | 2007-12-24 23:57:56 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:00:05 -0500 |
commit | 21371f768bf7127ee45bfaadd17899df6a439e8f (patch) | |
tree | 91b5debf1d861a40c942a33f1286b70031a94305 /include/net | |
parent | b15c4bcd15741b31019379298edfca28dc78029d (diff) |
[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>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/sock.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index e178b49eefbb..d27ba6fdd039 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -716,10 +716,11 @@ extern void __sk_stream_mem_reclaim(struct sock *sk); | |||
716 | extern int sk_stream_mem_schedule(struct sock *sk, int size, int kind); | 716 | extern int sk_stream_mem_schedule(struct sock *sk, int size, int kind); |
717 | 717 | ||
718 | #define SK_STREAM_MEM_QUANTUM ((int)PAGE_SIZE) | 718 | #define SK_STREAM_MEM_QUANTUM ((int)PAGE_SIZE) |
719 | #define SK_STREAM_MEM_QUANTUM_SHIFT ilog2(SK_STREAM_MEM_QUANTUM) | ||
719 | 720 | ||
720 | static inline int sk_stream_pages(int amt) | 721 | static inline int sk_stream_pages(int amt) |
721 | { | 722 | { |
722 | return DIV_ROUND_UP(amt, SK_STREAM_MEM_QUANTUM); | 723 | return (amt + SK_STREAM_MEM_QUANTUM - 1) >> SK_STREAM_MEM_QUANTUM_SHIFT; |
723 | } | 724 | } |
724 | 725 | ||
725 | static inline void sk_stream_mem_reclaim(struct sock *sk) | 726 | static inline void sk_stream_mem_reclaim(struct sock *sk) |