All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>
Cc: "Simon Horman" <horms@kernel.org>,
	"Jamal Hadi Salim" <jhs@mojatatu.com>,
	"Cong Wang" <xiyou.wangcong@gmail.com>,
	"Jiri Pirko" <jiri@resnulli.us>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>,
	"Kuniyuki Iwashima" <kuniyu@google.com>,
	"Willem de Bruijn" <willemb@google.com>,
	netdev@vger.kernel.org, eric.dumazet@gmail.com,
	"Eric Dumazet" <edumazet@google.com>
Subject: [PATCH v3 net-next 06/14] net_sched: cake: use qdisc_pkt_segs()
Date: Fri, 21 Nov 2025 08:32:48 +0000	[thread overview]
Message-ID: <20251121083256.674562-7-edumazet@google.com> (raw)
In-Reply-To: <20251121083256.674562-1-edumazet@google.com>

Use new qdisc_pkt_segs() to avoid a cache line miss in cake_enqueue()
for non GSO packets.

cake_overhead() does not have to recompute it.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/sched/sch_cake.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c
index a20880034aa5eacec0c25977406104448b336397..5948a149129c6de041ba949e2e2b5b6b4eb54166 100644
--- a/net/sched/sch_cake.c
+++ b/net/sched/sch_cake.c
@@ -1398,12 +1398,12 @@ static u32 cake_overhead(struct cake_sched_data *q, const struct sk_buff *skb)
 	const struct skb_shared_info *shinfo = skb_shinfo(skb);
 	unsigned int hdr_len, last_len = 0;
 	u32 off = skb_network_offset(skb);
+	u16 segs = qdisc_pkt_segs(skb);
 	u32 len = qdisc_pkt_len(skb);
-	u16 segs = 1;
 
 	q->avg_netoff = cake_ewma(q->avg_netoff, off << 16, 8);
 
-	if (!shinfo->gso_size)
+	if (segs == 1)
 		return cake_calc_overhead(q, len, off);
 
 	/* borrowed from qdisc_pkt_len_segs_init() */
@@ -1430,12 +1430,6 @@ static u32 cake_overhead(struct cake_sched_data *q, const struct sk_buff *skb)
 			hdr_len += sizeof(struct udphdr);
 	}
 
-	if (unlikely(shinfo->gso_type & SKB_GSO_DODGY))
-		segs = DIV_ROUND_UP(skb->len - hdr_len,
-				    shinfo->gso_size);
-	else
-		segs = shinfo->gso_segs;
-
 	len = shinfo->gso_size + hdr_len;
 	last_len = skb->len - shinfo->gso_size * (segs - 1);
 
@@ -1788,7 +1782,7 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Qdisc *sch,
 	if (unlikely(len > b->max_skblen))
 		b->max_skblen = len;
 
-	if (skb_is_gso(skb) && q->rate_flags & CAKE_FLAG_SPLIT_GSO) {
+	if (qdisc_pkt_segs(skb) > 1 && q->rate_flags & CAKE_FLAG_SPLIT_GSO) {
 		struct sk_buff *segs, *nskb;
 		netdev_features_t features = netif_skb_features(skb);
 		unsigned int slen = 0, numsegs = 0;
-- 
2.52.0.460.gd25c4c69ec-goog


  parent reply	other threads:[~2025-11-21  8:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-21  8:32 [PATCH v3 net-next 00/14] net_sched: speedup qdisc dequeue Eric Dumazet
2025-11-21  8:32 ` [PATCH v3 net-next 01/14] net_sched: make room for (struct qdisc_skb_cb)->pkt_segs Eric Dumazet
2025-11-21  8:32 ` [PATCH v3 net-next 02/14] net: init shinfo->gso_segs from qdisc_pkt_len_init() Eric Dumazet
2025-11-21  8:32 ` [PATCH v3 net-next 03/14] net_sched: initialize qdisc_skb_cb(skb)->pkt_segs in qdisc_pkt_len_init() Eric Dumazet
2025-11-21  8:32 ` [PATCH v3 net-next 04/14] net: use qdisc_pkt_len_segs_init() in sch_handle_ingress() Eric Dumazet
2025-11-21  8:32 ` [PATCH v3 net-next 05/14] net_sched: use qdisc_skb_cb(skb)->pkt_segs in bstats_update() Eric Dumazet
2025-11-21  8:32 ` Eric Dumazet [this message]
2025-11-21  8:32 ` [PATCH v3 net-next 07/14] net_sched: add Qdisc_read_mostly and Qdisc_write groups Eric Dumazet
2025-11-21  8:32 ` [PATCH v3 net-next 08/14] net_sched: sch_fq: move qdisc_bstats_update() to fq_dequeue_skb() Eric Dumazet
2025-11-21  8:32 ` [PATCH v3 net-next 09/14] net_sched: sch_fq: prefetch one skb ahead in dequeue() Eric Dumazet
2025-11-21  8:32 ` [PATCH v3 net-next 10/14] net: prefech skb->priority in __dev_xmit_skb() Eric Dumazet
2025-11-21  8:32 ` [PATCH v3 net-next 11/14] net: annotate a data-race " Eric Dumazet
2025-11-21  8:32 ` [PATCH v3 net-next 12/14] net_sched: add tcf_kfree_skb_list() helper Eric Dumazet
2025-11-21  8:32 ` [PATCH v3 net-next 13/14] net_sched: add qdisc_dequeue_drop() helper Eric Dumazet
2025-11-21  8:32 ` [PATCH v3 net-next 14/14] net_sched: use qdisc_dequeue_drop() in cake, codel, fq_codel Eric Dumazet
2025-11-25 15:24 ` [PATCH v3 net-next 00/14] net_sched: speedup qdisc dequeue patchwork-bot+netdevbpf

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=20251121083256.674562-7-edumazet@google.com \
    --to=edumazet@google.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=toke@redhat.com \
    --cc=willemb@google.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.