From: Yejune Deng <yejune.deng@gmail.com>
To: davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org,
kuba@kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
yejune.deng@gmail.com
Subject: [PATCH] inetpeer: use else if instead of if to reduce judgment
Date: Fri, 26 Feb 2021 18:57:46 +0800 [thread overview]
Message-ID: <20210226105746.29240-1-yejune.deng@gmail.com> (raw)
In inet_initpeers(), if si.totalram <= (8192*1024)/PAGE_SIZE, it will
be judged three times. Use else if instead of if, it only needs to be
judged once.
Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
---
net/ipv4/inetpeer.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index ff327a62c9ce..07cd1f8204b3 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -81,12 +81,12 @@ void __init inet_initpeers(void)
* <kuznet@ms2.inr.ac.ru>. I don't have any opinion about the values
* myself. --SAW
*/
- if (si.totalram <= (32768*1024)/PAGE_SIZE)
+ if (si.totalram <= (8192 * 1024) / PAGE_SIZE)
+ inet_peer_threshold >>= 4; /* about 128KB */
+ else if (si.totalram <= (16384 * 1024) / PAGE_SIZE)
+ inet_peer_threshold >>= 2; /* about 512KB */
+ else if (si.totalram <= (32768 * 1024) / PAGE_SIZE)
inet_peer_threshold >>= 1; /* max pool size about 1MB on IA32 */
- if (si.totalram <= (16384*1024)/PAGE_SIZE)
- inet_peer_threshold >>= 1; /* about 512KB */
- if (si.totalram <= (8192*1024)/PAGE_SIZE)
- inet_peer_threshold >>= 2; /* about 128KB */
peer_cachep = kmem_cache_create("inet_peer_cache",
sizeof(struct inet_peer),
--
2.29.0
next reply other threads:[~2021-02-26 10:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-26 10:57 Yejune Deng [this message]
2021-02-26 14:38 ` [PATCH] inetpeer: use else if instead of if to reduce judgment Eric Dumazet
2021-03-01 1:43 ` Yejune Deng
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=20210226105746.29240-1-yejune.deng@gmail.com \
--to=yejune.deng@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=yoshfuji@linux-ipv6.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).