diff options
-rw-r--r-- | include/net/sock.h | 3 | ||||
-rw-r--r-- | net/core/stream.c | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index e178b49eefb..d27ba6fdd03 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -716,10 +716,11 @@ extern void __sk_stream_mem_reclaim(struct sock *sk); extern int sk_stream_mem_schedule(struct sock *sk, int size, int kind); #define SK_STREAM_MEM_QUANTUM ((int)PAGE_SIZE) +#define SK_STREAM_MEM_QUANTUM_SHIFT ilog2(SK_STREAM_MEM_QUANTUM) static inline int sk_stream_pages(int amt) { - return DIV_ROUND_UP(amt, SK_STREAM_MEM_QUANTUM); + return (amt + SK_STREAM_MEM_QUANTUM - 1) >> SK_STREAM_MEM_QUANTUM_SHIFT; } static inline void sk_stream_mem_reclaim(struct sock *sk) diff --git a/net/core/stream.c b/net/core/stream.c index 5586879bb9b..bf188ffdbdb 100644 --- a/net/core/stream.c +++ b/net/core/stream.c @@ -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 && |