Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp622149lqe; Sat, 6 Apr 2024 16:55:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW0mfaqeP8gluNfOCDAYH2hohhIQNAyXfPFqIw6+gxPnluOkThgAvDVKQgBgAGyTo2nY7Vd76gq8m69AvhfSU+W/CmqZVy98XA1zHYINw== X-Google-Smtp-Source: AGHT+IHhSQO/k+9mJa7Jqgb6znuNZJBS57sF/6FFszJaiYgRE45dhBSwDYdwEZbettW2US8FVBKd X-Received: by 2002:a17:906:594c:b0:a46:22a3:479f with SMTP id g12-20020a170906594c00b00a4622a3479fmr4167542ejr.21.1712447751253; Sat, 06 Apr 2024 16:55:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712447751; cv=pass; d=google.com; s=arc-20160816; b=rTZ9xLRF08I8XMWFNckywgSnd+T9CWeUGhnAHjhmQmWeDCci9Wv0bdzTl2YTtcIihp 2iojuulbh/1Tt4m/EVAB6C6I1y1pH8iNZv0oy1Ekl6yur0GCOuCMj7VBypCuSjgUcyjR TSnhKhejTbRnb5jABxLiXtdOgBqkuccXgrP4p5t/6rgkewwtF4JIM60Kj5uqkJpY10WH MYv6OMN3kK6tsu/YT7cunQYKMXaN3FxEGRgWR61SwAnlAWdifDw9aCojifsC/HgQnWG6 s8tiH95LZArFJsTLnBIbS/xfblG5mf6ZXpYgNZ0l89NWlN3H8hXBQZgRjgaNsoCtYil6 qRqQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=AXM7kfM1Z58yWKWsC/e8tiwljIuUChOEbm514WnQ12k=; fh=DNBSedWgFPrksZBB/8GUC8FZiZ/b+w29Hp9cXf2lb6Q=; b=h4FuE2kWz+KjYWw8Gh8s5hn3nsnlp8IfsQb1tEPder5UIvSa02TddA06saTr+ytpcS gqpGbzNlrrtNPAQrZ7D1QzTwyiTEYzrCYqVDZ+GgQ7ilH1eP7MxfRwT/dnnGFBfgO+ms okmls2R648AjDK1KDO2O7cVNvO1fb4aKBkefvWyZ0CJiw7tQ+P8W5H0nqkAVPSIgkZrV GRvtNEZLuo5b983Pn//Yhdmq5hbgJa7aG0YZ66qb9RWKhtpjmqmPetes7EFUP4tGNMiO 7xIRQfRa1nDo+4rq+iifBjaWxrq47ouGXoZdEz1z7hc9SATKyyCqibi4Wop9RI9+bA4b ROsQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fD1DY5P0; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-134105-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134105-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s22-20020a170906455600b00a4e109afd18si2136865ejq.578.2024.04.06.16.55.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Apr 2024 16:55:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134105-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fD1DY5P0; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-134105-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134105-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E273B1F20F8C for ; Sat, 6 Apr 2024 23:55:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 286E458108; Sat, 6 Apr 2024 23:55:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fD1DY5P0" Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 024A4482C7; Sat, 6 Apr 2024 23:55:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712447741; cv=none; b=k124R2QHJIJIxKaxtv6Q6pyQA2QFjc4ATVdN+ZH7KZwwpnpsm2wXsV0xItLZ2Y+c+yEEhhc9j9M6AUswVaPJybmuA/3ZupEpbeCCcdSi3IcPDuz+ZMCFW78VBsRqQQ06GfT+UBadKt//EGdjEm3UD4Ws8C/Yv0LuEAhwv5p7Wkc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712447741; c=relaxed/simple; bh=Z0fSrQayCZEZ7BN+ls9wJNksXQi4tTCQ51JwCFxbtVI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=oRtKHB5uY1UH/i9L8sApwWT7gcr8fuhJoh905JW+F8rmtPbJcycCEvmdGkY7ibexp7KbjQxXPv+XDj+DI6IUIw3UEcRelM9FZoVD36XOBmd1RsDXBpmrqeeXlgNWNqVOJby5azoLkq0txd9n563WwRUWKNMCOtxq1c1afc6n9Fs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fD1DY5P0; arc=none smtp.client-ip=209.85.216.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2a2d37b8c4fso816995a91.1; Sat, 06 Apr 2024 16:55:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712447739; x=1713052539; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=AXM7kfM1Z58yWKWsC/e8tiwljIuUChOEbm514WnQ12k=; b=fD1DY5P096pY7+SuZlyA351kB6jXujeOuSaJ8MtVKcZPTbvKx5uQgLWRwtY+hKd1xP Ggi6AarBCrJRh7/VBXuDr3GTvvcgoKWK9048a3JZarPxMNhNHxqjH6ijzKh0MZYzOFHX 3aQcWwSLlGqsUd9NXjS4FOWEMnfAD2+uPE8+ZNKQJOnb9VA7tyn06VyIOtxZWfXpj/rN 19LO0ncZkKIJ2WjHk+le3VoHvpz0HioHT7qj5TROZKe5RXWQbsureD5fYqsfZKmYzlko O3upYT65SeRYHjz2/A2OirKBRe1ZxNachOGwCU8olJZ/bqcEreEwYpm7vgzXxoCvfhMl BaTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712447739; x=1713052539; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AXM7kfM1Z58yWKWsC/e8tiwljIuUChOEbm514WnQ12k=; b=IzZUgzrX0v77VH9t620vWPbyKi6bAiS/rjvkTuzFAlEbnSiASzk9rGQiS5bEmKJf1K hnEx0HrEFWsfME/7YEIR7wMdL6wtrpWapsqY44OziEAqupsgA+Oan31tNS1CdP2ltiNY vjeNgbHX6CgDt60FlqyuFElpKlYF4efJRYHR80+hP9oa4YEby8FpxmzuiZchSyx2riku uugeMrQPci8zAokn5ApEu4JOYX/uUQNzPrXh+z/05asIr2BlEjqC95R/FjbbLfrXZgFW OkBff98xDc9Bc2jg7ZyAHvhcH/L1mCQAbwRPJZDU3FoetVaS0fkH9HWTc+L+1pNcJPXv bcNg== X-Forwarded-Encrypted: i=1; AJvYcCXVPJpycba2P7Ofx5L/r5Tr1EdYEt+xam15mIwm7LGZKMzJyQmHPgY2Ct2IucUk2kHET1jrfNr71dmh9xZsPC6JQEb8WD4UoSx4bcws1iA018RD5adEbaal1lUwTVbxOnZ1YmqV X-Gm-Message-State: AOJu0YwPfVmaPhgw37zuN684MgyXeMSO35aBmW2nTv0L4DFv2mv+JMX1 CGWwAXeQUGptzUD0U0t5Hid+4Z/EL04ppJ+sjcniy9z3Na4sz37B X-Received: by 2002:a17:90a:8996:b0:2a2:83b0:5fad with SMTP id v22-20020a17090a899600b002a283b05fadmr4669920pjn.2.1712447739216; Sat, 06 Apr 2024 16:55:39 -0700 (PDT) Received: from visitorckw-System-Product-Name.. ([140.113.216.168]) by smtp.gmail.com with ESMTPSA id bt8-20020a17090af00800b002a2b06ce909sm5460178pjb.17.2024.04.06.16.55.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Apr 2024 16:55:38 -0700 (PDT) From: Kuan-Wei Chiu 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 Subject: [PATCH net-next] net: sched: cake: Optimize number of calls to cake_heapify() Date: Sun, 7 Apr 2024 07:55:32 +0800 Message-Id: <20240406235532.613696-1-visitorckw@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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