From: Kuan-Wei Chiu <visitorckw@gmail.com>
To: toke@toke.dk
Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, jserv@ccns.ncku.edu.tw,
cake@lists.bufferbloat.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Kuan-Wei Chiu <visitorckw@gmail.com>
Subject: [PATCH net-next] net: sched: cake: Optimize number of calls to cake_heapify()
Date: Sun, 7 Apr 2024 07:55:32 +0800 [thread overview]
Message-ID: <20240406235532.613696-1-visitorckw@gmail.com> (raw)
Improve the max-heap construction process by reducing unnecessary
heapify operations. Specifically, adjust the starting condition from
n / 2 to n / 2 - 1 in the loop that iterates over all non-leaf
elements.
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
net/sched/sch_cake.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c
index edee926ccde8..2eabc4dc5b79 100644
--- a/net/sched/sch_cake.c
+++ b/net/sched/sch_cake.c
@@ -1512,7 +1512,7 @@ static unsigned int cake_drop(struct Qdisc *sch, struct sk_buff **to_free)
if (!q->overflow_timeout) {
int i;
/* Build fresh max-heap */
- for (i = CAKE_MAX_TINS * CAKE_QUEUES / 2; i >= 0; i--)
+ for (i = CAKE_MAX_TINS * CAKE_QUEUES / 2 - 1; i >= 0; i--)
cake_heapify(q, i);
}
q->overflow_timeout = 65535;
--
2.34.1
next reply other threads:[~2024-04-06 23:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-06 23:55 Kuan-Wei Chiu [this message]
2024-04-07 16:10 ` [PATCH net-next] net: sched: cake: Optimize number of calls to cake_heapify() Toke Høiland-Jørgensen
2024-04-08 11:14 ` Kuan-Wei Chiu
2024-04-08 13:00 ` Toke Høiland-Jørgensen
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=20240406235532.613696-1-visitorckw@gmail.com \
--to=visitorckw@gmail.com \
--cc=cake@lists.bufferbloat.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=jserv@ccns.ncku.edu.tw \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=toke@toke.dk \
--cc=xiyou.wangcong@gmail.com \
/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).