From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x229.google.com (mail-wm0-x229.google.com [IPv6:2a00:1450:400c:c09::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.bufferbloat.net (Postfix) with ESMTPS id 16ABD3B2A4 for ; Wed, 22 Nov 2017 05:06:21 -0500 (EST) Received: by mail-wm0-x229.google.com with SMTP id g130so13078237wme.0 for ; Wed, 22 Nov 2017 02:06:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:subject:message-id:date:to :mime-version; bh=EDuyRuIJeE1GFx5ju/XZ67ICVz+pNfWqMq8yimP4Q1o=; b=PVP+2Qukr7Aq3gbKgIa8Waz1BZcXsP8S15hbBKdsHowo4pYoWl8h322fXb1PaXArTM m2qvh/gYxIPCpfudbYmXlOhymqXBtvdQxuKnPHgFEZp6PDv1KbsVrTN6aSaCVnu1hHFS puDaRjnpqV0AzSLyBMX6qawHC5dyBYR33W056ZuGdqaOYDPvT/E9K098fBVcStmoOHBt 4xLz3NLpBlC0KftoqZY3vi6mocsyDgysGuq0ugec488LfkHUtfd0DuIlhpBRHgS4NN8B ZDxfsEKmcHSDOlsOuIXFCdfuuty1Gf0XTcmm8P+ZG0jvB6KrSjVYx8iyXeFQCqHNS7er vswA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:subject :message-id:date:to:mime-version; bh=EDuyRuIJeE1GFx5ju/XZ67ICVz+pNfWqMq8yimP4Q1o=; b=BtsIZ4uUdSCn1/BPkSV6NWJ4c8qF3DZfyB3fGVNX2ODfx2Cj+qi4jOsOc0ptgVwN1+ ppC6vNnIMluZ0oaLsta2vrQg0ca0dYW7WLJDJ+CMZ2qhTvT7IzYaUck2wxiiCv+Bre7e 3LGzoCeyy7daFMITZLI+8FX7kD159iAQwYROyEpZondvgzfJ4A/rn8dKQ0zRK0E67rRW rtAaEZUGgix8tIVDu11JIpfl8qEw+Yt7pTnJBFzgSyNhc3AWPvwkvvCcWTR2kY06s5DZ inDM3EIybNPsEpCoiVqkUuBLeyEOkgRb/DHaT3OAUcDGq+yvk+WQe22PEizF+KcXwTFe IsNg== X-Gm-Message-State: AJaThX4TR4cM2vel+SKYx1KlJfHcsBfi+spq9iq1kT4qv3SrS9zSAt00 BlllCg4/K0bK+TxNvBHu6REwqVuj X-Google-Smtp-Source: AGs4zMYs1zs9tbsZAuT9zjFfFtiPf/6RZdHU1rQxdKGMRJzyZ+hT32rZYWNpIX7AVNeSIdWG8z9EMA== X-Received: by 10.28.210.72 with SMTP id j69mr4002125wmg.51.1511345180927; Wed, 22 Nov 2017 02:06:20 -0800 (PST) Received: from [10.72.0.130] (h-1169.lbcfree.net. [185.99.119.68]) by smtp.gmail.com with ESMTPSA id t63sm8187957wme.35.2017.11.22.02.06.19 for (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Nov 2017 02:06:20 -0800 (PST) From: Pete Heist Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Message-Id: <107CB879-B196-40F1-A7C2-08B963B7A835@gmail.com> Date: Wed, 22 Nov 2017 11:06:18 +0100 To: Cake List Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) X-Mailer: Apple Mail (2.3124) Subject: [Cake] small cake_hash optimization? X-BeenThere: cake@lists.bufferbloat.net X-Mailman-Version: 2.1.20 Precedence: list List-Id: Cake - FQ_codel the next generation List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Nov 2017 10:06:22 -0000 I=E2=80=99ve been playing around with cake=E2=80=99s hashing and = happened to notice in cake_hash that it seems like srchost_idx and = dsthost_idx could rather be calculated only if need_allocate_src or = need_allocate_dst are true, respectively, as the values are only used = inside those code blocks. I=E2=80=99ve not done any testing on what the real impact of this change = would be, or even if it breaks something. Forgive me for any waste of time if I=E2=80=99ve missed something = here... ----- sysadmin@apu2b:~/src/sch_cake$ git diff sch_cake.c diff --git a/sch_cake.c b/sch_cake.c index 97a27be..8f59917 100644 --- a/sch_cake.c +++ b/sch_cake.c @@ -747,8 +747,6 @@ cake_hash(struct cake_tin_data *q, const struct = sk_buff *skb, int flow_mode) } =20 reduced_hash =3D flow_hash % CAKE_QUEUES; - srchost_idx =3D srchost_hash % CAKE_QUEUES; - dsthost_idx =3D dsthost_hash % CAKE_QUEUES; =20 /* set-associative hashing */ /* fast path if no hash collision (direct lookup succeeds) */ @@ -809,6 +807,7 @@ found: q->tags[reduced_hash] =3D flow_hash; =20 if (need_allocate_src) { + srchost_idx =3D srchost_hash % CAKE_QUEUES; inner_hash =3D srchost_idx % CAKE_SET_WAYS; outer_hash =3D srchost_idx - inner_hash; for (i =3D 0, k =3D inner_hash; i < = CAKE_SET_WAYS; @@ -830,6 +829,7 @@ found_src: } =20 if (need_allocate_dst) { + dsthost_idx =3D dsthost_hash % CAKE_QUEUES; inner_hash =3D dsthost_idx % CAKE_SET_WAYS; outer_hash =3D dsthost_idx - inner_hash; for (i =3D 0, k =3D inner_hash; i < = CAKE_SET_WAYS; -----=