From patchwork Thu Feb 15 16:04:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= X-Patchwork-Id: 201628 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp506901dyb; Thu, 15 Feb 2024 08:14:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUgyyLEg9S1k9W0mRFr9DQ7mnNQ1nq8mu+O3tTNwPGSLnCj6phwcs5K+f25vTUShF3k6Gz2dSymJM+LIxMxxRS9VcxhSw== X-Google-Smtp-Source: AGHT+IE2CkH3GUBnGYzyaJSXCGFjRac08kWBGDd23HTY3tLozWvAv2rZnq3EkpRmOe0AV9oyL4va X-Received: by 2002:a17:90b:1281:b0:298:ad38:75c8 with SMTP id fw1-20020a17090b128100b00298ad3875c8mr1941438pjb.45.1708013653032; Thu, 15 Feb 2024 08:14:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708013653; cv=pass; d=google.com; s=arc-20160816; b=Rnd7nkyBZ8O3CmibBOwmKMXEVZmWzEZrr2kUdSCNRpFqCkMSpRDzda+L68P94WaHUf HjrZlGuxjzdTbwWeF9IFVjCvB8v9Iy6+U6Jx4hLiJY1Xl3HwDDWyE7tR6t/fxZPGPTXE T+9jVRGtY9oiJ//rpWLD9cKyn933x0AeiDWCV/a+5yY9gcbvpw5mEN9zyz7Oi+jw6iuc CDzgyd5bsjNj1yJMRdu8Zg4woEvUjuz8NjbXcLEx/ppfdljSXigK9KWIboIc7uYo/HVr PQaZZTfhxzKdZKBwDxuoNpn4/iMifpTdumjmqO9n4a9mBgdaBPQ/DdjJ8Cfnqvs2qSzC ANOw== 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=Ldu3/MWiz8i5k7YFRP8XCiyFuOJo3CjiWT3JeYNwRPA=; fh=qwn0ZN7d/LlgLhwKKJFblL2+CYxSTOyA+LLcZtnY3QM=; b=oHW4dv0gW1hXSHBz0PGklc5UesiFh7xMrATXpwnqBwTS+Oap62oW/5lNIVC+oze0T4 jdR+vdbJx8sm2TCu0fdAevO8oXEiBeC135eUblHb4YXvijDH2N1tbYZZt8bWf6YIYD44 /MEjJ3GbE8w6lzBpUoztd0jk7JDoeAiTY1Tpq15KQwK6LtY937DO6jyZSuOlHo6/Z+Kb NuTrq3mmCsgz+ZfAhwqxjcU6+KwaDvHQYlBYTu7RCV/TW2KQUXUHufeusranA5pSW35z rHaH2KTgQleNJHJSHSvbX2Kke135D4z/wc++HpLTgpR9oobFGCrIVk2AHmCIfiYdRVU6 5WvQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@fiberby.net header.s=202008 header.b=q+DVNN2Q; 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-67280-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67280-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fiberby.net Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id mu4-20020a17090b388400b00296fcd007d2si1464301pjb.29.2024.02.15.08.14.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 08:14:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67280-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@fiberby.net header.s=202008 header.b=q+DVNN2Q; 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-67280-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67280-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A4EBE282A13 for ; Thu, 15 Feb 2024 16:13:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 306C213664C; Thu, 15 Feb 2024 16:06:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="q+DVNN2Q" 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 2FFD91350F0; Thu, 15 Feb 2024 16:06:38 +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=1708013202; cv=none; b=Yt1g1QdaAdZt+tzW/qHQRnkMXVJSE81wb11aM4juZOdfLgi6BRZhiCeehIf1tlK9KqeyTLSJ8nEx8noJXLzGRz1Do6ul2DLoC2gEst/6sK5y4LcclQseJSca2XxJSnPu9j7TbIiXQhSKSuwcR40eQoYpiGIfbn6drr96adsxlmU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708013202; c=relaxed/simple; bh=akjpUr+ZYSjEQ/296swH0R+gJmt5trZjoLKfmLO+NZU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V6cmz3/Oo016awz1fZcC2MbXZFD7PGBxR27dUKPwq8IaHTXUsQgLczsY91WXgyBHcP6OSuOqWyo4eaksIo/LN5aVqsOwyhzmqMcVdRBv1qUKPpAY2EITjgmRDfHbpyOIRuZ5SEpwBauq6VGeHgG5PPRzaVBAPcDKF7ilJfcG5Ak= 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=q+DVNN2Q; 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 0E11F600D4; 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=akjpUr+ZYSjEQ/296swH0R+gJmt5trZjoLKfmLO+NZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q+DVNN2QORy7bWZJmmlebtJiMPJDFrwsJrv5EHEWHCk5oEuNzyP+UCunwTvFR9dvu dn+LZ7CSwcrQPShycKPCZ+Aqc9IRXWZaYmAjCg+Nb3X0OcUmkhfpZZBHN4/7jbxvvq w5ymk2v4y9F7HIk3xnvFAEnyb+dJWAnnvapHXPdE6BiMHtRksemd7laYjg4THKBLMo Rqogm2f+2zKhVl9QNSfHdJdZmEFPkJL+owLTCUu9yL/k3qR3jmr4fe8mmZkfLShX5J qbMvemeeVmmU79S/8Ptf1LyGOngQ3KAHnEv/NWvAmwG40/CVZFhnohOTiKDvuNTXHX HNOXDs+ShwJYA== Received: by x201s (Postfix, from userid 1000) id 42E0D202FB6; Thu, 15 Feb 2024 16:05:44 +0000 (UTC) From: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= To: Jamal Hadi Salim , Cong Wang , Jiri Pirko Cc: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= , Daniel Borkmann , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llu@fiberby.dk Subject: [PATCH net-next 1/3] net: sched: cls_api: add skip_sw counter Date: Thu, 15 Feb 2024 16:04:42 +0000 Message-ID: <20240215160458.1727237-2-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790982124374134874 X-GMAIL-MSGID: 1790982124374134874 Maintain a count of skip_sw filters. This counter is protected by the cb_lock, and is updated at the same time as offloadcnt. Signed-off-by: Asbjørn Sloth Tønnesen --- include/net/sch_generic.h | 1 + net/sched/cls_api.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 934fdb977551..46a63d1818a0 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -476,6 +476,7 @@ struct tcf_block { struct flow_block flow_block; struct list_head owner_list; bool keep_dst; + atomic_t skipswcnt; /* Number of skip_sw filters */ atomic_t offloadcnt; /* Number of oddloaded filters */ unsigned int nooffloaddevcnt; /* Number of devs unable to do offload */ unsigned int lockeddevcnt; /* Number of devs that require rtnl lock. */ diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index ca5676b2668e..397c3d29659c 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3483,6 +3483,8 @@ static void tcf_block_offload_inc(struct tcf_block *block, u32 *flags) if (*flags & TCA_CLS_FLAGS_IN_HW) return; *flags |= TCA_CLS_FLAGS_IN_HW; + if (tc_skip_sw(*flags)) + atomic_inc(&block->skipswcnt); atomic_inc(&block->offloadcnt); } @@ -3491,6 +3493,8 @@ static void tcf_block_offload_dec(struct tcf_block *block, u32 *flags) if (!(*flags & TCA_CLS_FLAGS_IN_HW)) return; *flags &= ~TCA_CLS_FLAGS_IN_HW; + if (tc_skip_sw(*flags)) + atomic_dec(&block->skipswcnt); atomic_dec(&block->offloadcnt); } From patchwork Thu Feb 15 16:04:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= X-Patchwork-Id: 201629 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp507032dyb; Thu, 15 Feb 2024 08:14:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWQ9jiHi9OmWsW8SsMxBvUSznjDyyxaBQXM64RiTrMPA25e9azDIXVbicUATc5oeUuPzwEqDlsYiUeMld1h2nJEw/x0Kw== X-Google-Smtp-Source: AGHT+IHmZaWg6ZekLJjCJVBlXsgnORow55CLb4uO8rPgFPKkiVGwBOQ/4+HtlJqXHpxfWvkMmMW3 X-Received: by 2002:a17:90a:eb0b:b0:298:a701:aacc with SMTP id j11-20020a17090aeb0b00b00298a701aaccmr1784707pjz.47.1708013664986; Thu, 15 Feb 2024 08:14:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708013664; cv=pass; d=google.com; s=arc-20160816; b=r/LNqnWSRVENDEBO9ftZGEqWEJeyYR65ER/BLUCWfs5wFWDhX/wKZ6+l8Equ7JtsRQ zu7N9m0Ax6pvoLYCauJgWsb0PhjdM0U26B+/L3xFrcVoj1pU7+1dro2JpA04PCzC12tD ABIXOTHA4pgJ1w9b/kspdltaRjdA8zUpHXV3j/O+Zo9uCCgAh6jqS5ZdkioRu/lHtaQh SvFb1GFmp55HO8VOptFANt5/9rJ6rsSFQvBqy7BWJkKFg+jRt91vUcmrqyoLm+I8hwnt h85IUeyPuXC67vJn4VjDyhwsa5nBRSQAK7LcCqVTFRatu8oclKREnCcQIvAY4ZixonOJ ZIng== 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=KeMP8SmCe5eKL109ZTAKbfiLHJ2qZ7p4SvBszrclqa4=; fh=qwn0ZN7d/LlgLhwKKJFblL2+CYxSTOyA+LLcZtnY3QM=; b=kD1XMmoqyNUV7xjZj/jSydi3HXF8xe+9peqNyjScp86pyMq9LKxQN5Ts0kvz2g4gsO Qm/Xw5EOsLQd65XhE1sNAen8r9rGtS5EWCOMUp9c3R+hib85cvNmJhawkBmtCtmzyfg2 VG4BT2F7vw7clnsmAl3BvJs0VulMzB9TX525ik3CuFzxQl27B8E7g/qb20ddgLzl7+P/ 6D2EnT4igauEI86nNbXxnzZzjAXjAcQJeOYeXagFQyuJvUPyKIhofsmaA1TTNXvks6cz 3PVjUtifuNlmC3Pl1v6D7beV6ExiPPc8rSajdRTR8TaYrLussY5UcTtjTkxcIwsMG7/V 2TAA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@fiberby.net header.s=202008 header.b=rbUByrVn; 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-67283-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67283-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fiberby.net Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id mu4-20020a17090b388400b00296fcd007d2si1464301pjb.29.2024.02.15.08.14.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 08:14:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67283-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@fiberby.net header.s=202008 header.b=rbUByrVn; 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-67283-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67283-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id DB3C72886FE for ; Thu, 15 Feb 2024 16:13:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A66F136671; Thu, 15 Feb 2024 16:06:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="rbUByrVn" 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 2FF9E1350EF; Thu, 15 Feb 2024 16:06:38 +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=gf9jPSVJv32Ub2NG/ctW5jlq4Z8isxm3PbQxbHuBpsg+6HdNmW9vvWcRJCmQ4F7pOt02Mc/G7/7qsC57fvKsw3y44s/oT7sEa4CF1XHnFAj7tPzCScjJsimwQFpfB4lUVERoloVDMtV+cwiMktaxogCzjSmaAEoUmRVfFIVlBak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708013203; c=relaxed/simple; bh=t0ya6U+qD8pjYYUmzKIRrk3nGKiLV2qy6SQI597Ey+w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pM/nrEoXRHavbbcXMozXRI3JbM5LJelHahWDJ2VkwSGWdzajC5GF0sufzKWJzHlRm50O7GqxpkJXtNlngFxVDlZ5utFn589IijLEJ4c6ilM/0cB9aF2k3wv7tYy9ySFExBnnda2SojA1zIR20LcjwZZfI+8iGN736SOyneFYEo4= 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=rbUByrVn; 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 16B146030D; 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=t0ya6U+qD8pjYYUmzKIRrk3nGKiLV2qy6SQI597Ey+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rbUByrVnqY8YTE//qqwdPG4bnQFVSAdKCo8Traw3RFyTZECAbA7ctkxh7FwUIGfH0 S7hFBo6u4joMnyTssavePgnyQ2y8JycQpdJKNLMP8jsJry3zvBZllHuiU+H+nWQJuS 7y2IxzBvn3unD2g3rLOhAGh6Lx5Smk7CluembziXNRqtdV5Xio3vv/aP3zpinqjIIk kHNziVXD5EQ7wwoC2Es3mH+olgafCJViHDUHHsOFm5dHr5gjon3P0PPSIc9opSd7ij 6V885E1IMH4lA264/ZFMkBv104wMYZNpk028gmx2rO21tI3l6HAErYWsmhM6U6WHHS vyeWpxheLC5Ag== Received: by x201s (Postfix, from userid 1000) id C8A24205B9D; Thu, 15 Feb 2024 16:05:50 +0000 (UTC) From: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= To: Jamal Hadi Salim , Cong Wang , Jiri Pirko Cc: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= , Daniel Borkmann , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llu@fiberby.dk Subject: [PATCH net-next 2/3] net: sched: cls_api: add filter counter Date: Thu, 15 Feb 2024 16:04:43 +0000 Message-ID: <20240215160458.1727237-3-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790982136666598818 X-GMAIL-MSGID: 1790982136666598818 Maintain a count of filters per block. Counter updates are protected by cb_lock, which is also used to protect the offload counters. Signed-off-by: Asbjørn Sloth Tønnesen --- include/net/sch_generic.h | 2 ++ net/sched/cls_api.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 46a63d1818a0..7af0621db226 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -427,6 +427,7 @@ struct tcf_proto { */ spinlock_t lock; bool deleting; + bool counted; refcount_t refcnt; struct rcu_head rcu; struct hlist_node destroy_ht_node; @@ -476,6 +477,7 @@ struct tcf_block { struct flow_block flow_block; struct list_head owner_list; bool keep_dst; + atomic_t filtercnt; /* Number of filters */ atomic_t skipswcnt; /* Number of skip_sw filters */ atomic_t offloadcnt; /* Number of oddloaded filters */ unsigned int nooffloaddevcnt; /* Number of devs unable to do offload */ diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 397c3d29659c..c750cb662142 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -411,11 +411,13 @@ static void tcf_proto_get(struct tcf_proto *tp) } static void tcf_chain_put(struct tcf_chain *chain); +static void tcf_block_filter_cnt_update(struct tcf_block *block, bool *counted, bool add); static void tcf_proto_destroy(struct tcf_proto *tp, bool rtnl_held, bool sig_destroy, struct netlink_ext_ack *extack) { tp->ops->destroy(tp, rtnl_held, extack); + tcf_block_filter_cnt_update(tp->chain->block, &tp->counted, false); if (sig_destroy) tcf_proto_signal_destroyed(tp->chain, tp); tcf_chain_put(tp->chain); @@ -2364,6 +2366,7 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, err = tp->ops->change(net, skb, tp, cl, t->tcm_handle, tca, &fh, flags, extack); if (err == 0) { + tcf_block_filter_cnt_update(block, &tp->counted, true); tfilter_notify(net, skb, n, tp, block, q, parent, fh, RTM_NEWTFILTER, false, rtnl_held, extack); tfilter_put(tp, fh); @@ -3478,6 +3481,23 @@ int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts) } EXPORT_SYMBOL(tcf_exts_dump_stats); +static void tcf_block_filter_cnt_update(struct tcf_block *block, bool *counted, bool add) +{ + lockdep_assert_not_held(&block->cb_lock); + + down_write(&block->cb_lock); + if (*counted != add) { + if (add) { + atomic_inc(&block->filtercnt); + *counted = true; + } else { + atomic_dec(&block->filtercnt); + *counted = false; + } + } + up_write(&block->cb_lock); +} + static void tcf_block_offload_inc(struct tcf_block *block, u32 *flags) { if (*flags & TCA_CLS_FLAGS_IN_HW) From patchwork Thu Feb 15 16:04:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= X-Patchwork-Id: 201627 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp506467dyb; Thu, 15 Feb 2024 08:13:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV75JxvnUVvOHmo6pkY3Pf96tAhqlvokw2mDjd/xxPJRDqlvhZzkPW6mIMH3yUiMFPxMtI42VjvbQpGggYDROZfMUchEg== X-Google-Smtp-Source: AGHT+IEGiuUn2IOdmINLy9hsyE5BV3BTtfK/B4MQccRHPEJsYgd0g76etEuEE3kAuRMLI+YxezUR X-Received: by 2002:a05:620a:c16:b0:787:2275:3aa1 with SMTP id l22-20020a05620a0c1600b0078722753aa1mr2280176qki.10.1708013611448; Thu, 15 Feb 2024 08:13:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708013611; cv=pass; d=google.com; s=arc-20160816; b=i6p8m2U4x6T2sg6P43F6rkv212obgzRuQDw9fXPAWxp1EH/yNcF+DLwWRXwGvvrt1X ApEzcayr5HIybsEEuxhKw3qLLi8NWADlDQ1+AsKjn0tJJvhaURrRGnyCUBzOXKwB1BTa Cc3X/7N6AXIznSxD4sI64SzT9wPgXwkrPS/XYW/2kdF33CFa930gFKrtTOVPWP3gGqBM h5lfGrkA7VAdwzwLXpvDSel3opyFlOR0YiIU6N5iU0gqgt/z7G45cR+32XTfTTgK6Iui lCGHEIK7QBCMMkD+RIcmYby5imjuE8xGUhLRdyG4SJn5V18+V92e9Xcqpq52L4lLAUbG KiCg== 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67281-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fiberby.net Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i17-20020a05620a0a1100b007873e88af2dsi64812qka.184.2024.02.15.08.13.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 08:13:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67281-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67281-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 3F6B11C22D9B for ; Thu, 15 Feb 2024 16:13:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 14DC8136667; Thu, 15 Feb 2024 16:06:46 +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_Sloth_T=C3=B8nnesen?= To: Jamal Hadi Salim , Cong Wang , Jiri Pirko Cc: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790982080252572665 X-GMAIL-MSGID: 1790982080252572665 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);