Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp558398rdb; Thu, 15 Feb 2024 08:13:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWECkwiwnLMvhqS9qrrctJ++K8qaAwgR6V8yoYrxby9PLYik/yZEIg2tW5eOjQN/OoJ3frtYsRdvC2ciGEjs5Dz58pUEuBpSM5UQGSCrA== X-Google-Smtp-Source: AGHT+IGCfNQfdHT2zxB/su8tTsxOe/TD9kr+DuDRA7/LpDmsZPKH6hpFRzksOzMjBfZ5UIHQw3Yf X-Received: by 2002:a17:906:e25a:b0:a3c:b354:b947 with SMTP id gq26-20020a170906e25a00b00a3cb354b947mr1747268ejb.24.1708013603349; Thu, 15 Feb 2024 08:13:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708013603; cv=pass; d=google.com; s=arc-20160816; b=brO+4nInxatwpoPdiyy/9XAMYqc2dObgJLQfhizpwEevW4xsjmivYMVv4EbbfrtW/f oRPRXjNpk1HMnwx4yF3jG8d85DcSblvItvdL5kLW1PAb7CgpiRnbUq8Jscbt/TYsej6i JmjZSCbI6VuL4F5uwk7XIjAFe19pzWFh0bpi3wDotXDr3JMpXDgxrp3xrI8ok8/aB1rF 6wg6a7nLJ60KGV3x4qu65m6o+hQs8Rb1GO428GtMXI4IB8oqOlNJWmnrI9Xe1H/pK/4u xOr5iPqh9wN3CGdsxcVtYU6RADKrXUN61kmwLy334NRffcxK0bDvaqEfFTE5UcNp9LFB HqAg== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=iBZSk8naZMxxBLwccmRwaox0neFVJbgGQ0P1Zg0iUas=; fh=qwn0ZN7d/LlgLhwKKJFblL2+CYxSTOyA+LLcZtnY3QM=; b=o+CxO3dLy+r2ccQQi4o247BrsXHZO0NN28ojdrIOf9kdWaSicIwqYJZbQ3TFnlfgnK RZlUSfT/UXkWgBhUv+G64ayjdgv818tq5RZrGXKUOR+dFtESFUEHHb0F3P5IMNLPJ0s/ WGd7yQnW4onim5TthrIiEkJUABz+Ri0MvQKZqlni7byBFf2PnlfVNue2JTXyO5rQ4JNa 9rq7cZZ0AWPHhp9qQmkbJ3Eme+JU+ze8q8xiUsppJP7fF6OJ4ACST5o8Cg2yb70slW1y RA0tHO/7Ql0zSn9GtOt4sajheyXIhMITX0GbH7Vuok3QqawZSqhmeHwhVmW8VZOEs/rd zd6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@fiberby.net header.s=202008 header.b=n15Yix4h; arc=pass (i=1 spf=pass spfdomain=fiberby.net dkim=pass dkdomain=fiberby.net dmarc=pass fromdomain=fiberby.net); spf=pass (google.com: domain of linux-kernel+bounces-67281-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67281-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fiberby.net Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id uz11-20020a170907118b00b00a3d6aceb46dsi776644ejb.359.2024.02.15.08.13.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 08:13:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67281-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@fiberby.net header.s=202008 header.b=n15Yix4h; arc=pass (i=1 spf=pass spfdomain=fiberby.net dkim=pass dkdomain=fiberby.net dmarc=pass fromdomain=fiberby.net); spf=pass (google.com: domain of linux-kernel+bounces-67281-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67281-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fiberby.net 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 C210F1F25789 for ; Thu, 15 Feb 2024 16:12:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2FC5C135A4F; Thu, 15 Feb 2024 16:06:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="n15Yix4h" Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48CA213342A; Thu, 15 Feb 2024 16:06:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708013203; cv=none; b=Mf7cqjeqk7i5EAGsO/QXqqC1UNXMSWlYcUVpDWvWijPRumkdqutpR42c5u96wB6RZIWmLSe2MbZZsCCTLzfyeKouHCtkLfOOBfpV/FdWqZ6u3m00w2E6K8MW6LBrEqLkkgKY7CUlrg2JFvCUWlP8Al8Y2izGensHNO2r+7WE95I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708013203; c=relaxed/simple; bh=oHc3l+4peZjS6tTsw+CB3JlnCa+oPdVEiLwpuc9h+V4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VE4YaNWn46KBYsP4Vnw1vaoZrhZ38YR070v3o28bL/kaVHL/gzdKiYt74zDm5Ujt/GIBg5hZupi/vV0owPtlpvpMxdG7Ke7Heh+ca1m09Ipe+Jvij66v1X1/Qvr7k3RLt5hVjVRiiBY3m3x+wliOcHGQh8nHzZy0aqN34V0wEnY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=n15Yix4h; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 10341600D7; Thu, 15 Feb 2024 16:06:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1708013196; bh=oHc3l+4peZjS6tTsw+CB3JlnCa+oPdVEiLwpuc9h+V4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n15Yix4h0hq6UboabRZQnLStC8gIBPLyq0ecgocjRzIqbkNz4Km3tIMCyNdElXxh1 5bIP78T9SFflzyPNYBxcx3YVVASQouXni6P7U8aAA+mh1ChXJVNyKjsZqFQfWXZOIh aZcudveYRJQjDirHg5GHuglnfSo1/kP86IAAoFKrDYjzHdK8jOKCaqKk6kVdC92mvg ZeetVKQpww2FQCY3YppZ0UXmEBm1RmsqlFk3V5LXlsLsQa7hSQjRanju3TfjjWklhM A0G1j+PLcgAGpvnwIeKYWjP4cFrVLuu7tHLpy1HZMtR7Z7sFPahtYxHQzyZqMZjEEP nOYm62BHwE08g== Received: by x201s (Postfix, from userid 1000) id 5820721472C; Thu, 15 Feb 2024 16:05:55 +0000 (UTC) From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= To: Jamal Hadi Salim , Cong Wang , Jiri Pirko Cc: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= , Daniel Borkmann , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llu@fiberby.dk Subject: [PATCH net-next 3/3] net: sched: make skip_sw actually skip software Date: Thu, 15 Feb 2024 16:04:44 +0000 Message-ID: <20240215160458.1727237-4-ast@fiberby.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215160458.1727237-1-ast@fiberby.net> References: <20240215160458.1727237-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TC filters come in 3 variants: - no flag (no opinion, process wherever possible) - skip_hw (do not process filter by hardware) - skip_sw (do not process filter by software) However skip_sw is implemented so that the skip_sw flag can first be checked, after it has been matched. IMHO it's common when using skip_sw, to use it on all rules. So if all filters in a block is skip_sw filters, then we can bail early, we can thus avoid having to match the filters, just to check for the skip_sw flag. +----------------------------+--------+--------+--------+ | Test description | Pre | Post | Rel. | | | kpps | kpps | chg. | +----------------------------+--------+--------+--------+ | basic forwarding + notrack | 1264.9 | 1277.7 | 1.01x | | switch to eswitch mode | 1067.1 | 1071.0 | 1.00x | | add ingress qdisc | 1056.0 | 1059.1 | 1.00x | +----------------------------+--------+--------+--------+ | 1 non-matching rule | 927.9 | 1057.1 | 1.14x | | 10 non-matching rules | 495.8 | 1055.6 | 2.13x | | 25 non-matching rules | 280.6 | 1053.5 | 3.75x | | 50 non-matching rules | 162.0 | 1055.7 | 6.52x | | 100 non-matching rules | 87.7 | 1019.0 | 11.62x | +----------------------------+--------+--------+--------+ perf top (100 n-m skip_sw rules - pre patch): 25.57% [kernel] [k] __skb_flow_dissect 20.77% [kernel] [k] rhashtable_jhash2 14.26% [kernel] [k] fl_classify 13.28% [kernel] [k] fl_mask_lookup 6.38% [kernel] [k] memset_orig 3.22% [kernel] [k] tcf_classify perf top (100 n-m skip_sw rules - post patch): 4.28% [kernel] [k] __dev_queue_xmit 3.80% [kernel] [k] check_preemption_disabled 3.68% [kernel] [k] nft_do_chain 3.08% [kernel] [k] __netif_receive_skb_core.constprop.0 2.59% [kernel] [k] mlx5e_xmit 2.48% [kernel] [k] mlx5e_skb_from_cqe_mpwrq_nonlinear Test setup: DUT: Intel Xeon D-1518 (2.20GHz) w/ Nvidia/Mellanox ConnectX-6 Dx 2x100G Data rate measured on switch (Extreme X690), and DUT connected as a router on a stick, with pktgen and pktsink as VLANs. Pktgen was in range 12.79 - 12.95 Mpps across all tests. Signed-off-by: Asbjørn Sloth Tønnesen --- include/net/pkt_cls.h | 5 +++++ net/core/dev.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index a4ee43f493bb..a065da4df7ff 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -74,6 +74,11 @@ static inline bool tcf_block_non_null_shared(struct tcf_block *block) return block && block->index; } +static inline bool tcf_block_has_skip_sw_only(struct tcf_block *block) +{ + return block && atomic_read(&block->filtercnt) == atomic_read(&block->skipswcnt); +} + static inline struct Qdisc *tcf_block_q(struct tcf_block *block) { WARN_ON(tcf_block_shared(block)); diff --git a/net/core/dev.c b/net/core/dev.c index d8dd293a7a27..7cd014e5066e 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3910,6 +3910,9 @@ static int tc_run(struct tcx_entry *entry, struct sk_buff *skb, if (!miniq) return ret; + if (tcf_block_has_skip_sw_only(miniq->block)) + return ret; + tc_skb_cb(skb)->mru = 0; tc_skb_cb(skb)->post_ct = false; tcf_set_drop_reason(skb, *drop_reason); -- 2.43.0