From: David Miller <davem@davemloft.net>
To: dada1@cosmosbay.com
Cc: netdev@vger.kernel.org
Subject: Re: [SOCK] Avoid integer divides where not necessary in include/net/sock.h
Date: Fri, 21 Dec 2007 01:55:43 -0800 (PST) [thread overview]
Message-ID: <20071221.015543.19719154.davem@davemloft.net> (raw)
In-Reply-To: <476B5AC0.9060604@cosmosbay.com>
From: Eric Dumazet <dada1@cosmosbay.com>
Date: Fri, 21 Dec 2007 07:18:40 +0100
> Because sk_wmem_queued, sk_sndbuf are signed, a divide per two
> forces compiler to use an integer divide. We can instead use
> a right shift.
>
> SK_STREAM_MEM_QUANTUM deserves to be declared as an unsigned
> quantity, so that sk_stream_pages() and __sk_stream_mem_reclaim()
> can use right shifts instead of integer divides.
>
> Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Everything that works with SK_STREAM_MEM_QUANTUM is an int.
We do a DIV_ROUND_UP() using SK_STREAM_MEM_QUANTUM and an int.
We do sk->sk_forward_alloc modifications using multiplies on
SK_STREAM_MEM_QUANTUM and an int, sk_forward_alloc is an int
too.
Changing the type of SK_STREAM_MEM_QUANTUM does nothing more than
create an exception in the typing used in these operations for no real
gain, in fact it makes this code's correctness harder to verify.
I'm fine with the rest of your change, so please resubmit this patch
with the type change removed.
Thanks.
next prev parent reply other threads:[~2007-12-21 9:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-21 6:18 [SOCK] Avoid integer divides where not necessary in include/net/sock.h Eric Dumazet
2007-12-21 9:55 ` David Miller [this message]
2007-12-21 10:40 ` Eric Dumazet
2007-12-21 11:06 ` David Miller
2007-12-21 12:58 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071221.015543.19719154.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=dada1@cosmosbay.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).