Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp779844rdb; Thu, 15 Feb 2024 15:41:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWpr6ZX8OM8F9PdWrqZVWNZFMSq41Tc6GYo+su4/9lOttJLuuDB8o3WcJwCxAyiszl1oAZd6IhTQvg92U/J3EsSVCYqgYn8/DBQtP7TlA== X-Google-Smtp-Source: AGHT+IGSGMsn3xnR9zcSueCyXDb5dfQobAJuytC7VvfrygmDw0fuNPMZwJP6N8l4b41mbXK81eHY X-Received: by 2002:a05:6a21:150b:b0:1a0:5fab:9b01 with SMTP id nq11-20020a056a21150b00b001a05fab9b01mr4052164pzb.10.1708040489031; Thu, 15 Feb 2024 15:41:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708040489; cv=pass; d=google.com; s=arc-20160816; b=Fa35Ih8MjqOcN4aNXgBjOJr0paaP7K5s3HTKp0aRavTp+mzLTPh8IW02IoTzIdfHVN z7Uzbz/Li66q7Mt6Xm+cY/8eIUpnbT7acs4iIIr2aIn2oB8VaLB+R7M3uqUOiwOAxvn0 nGjRG9kftRXvvsYqANZnRIvDiRZ8ptlGGCrAYioi69rzNngY19KArimZOWWVKF9PNY3/ x8xgf8Af9ovUi1c9TZ0HiIJomU6aVcl6C6LKzApU0zcB3AwZKpxvQlBUWIGohbsIMOjz TTMIaxtiXZEOO/07KTOAKEa+mqpOeQBkEOeY9LBWUCEom8n8S1TxcBKI6+yvsMqiXnAi 35Dg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=n/9s/uBw5gPYioJxYGVG2/9ZiUh6Gf7AdsNMDAFrZUU=; fh=ArP01Sr/LzHPsZTBgyqXJCxdzwcg69CkPhZwXatVFgw=; b=wpUGqd2OLJMWDyHigWhbu6rFXFd1NMA43uDllc/ruvchwUkjJHMXK/PazlaLnoLqjl +bMI31L706ngUlUkIyFaRVe8uNIPLmNAo9wPI5Ur1JaRQbcp1TJAFonCVItiMYHfoybF wuRxMG2/Tk4m743UzNPKNni3y92ejOPjEZild8N0RfNJakLxwUn8QMbioqhWJi/Opf3i 7/wLBnO0uTS5kapg3oQZhgQmAbDx85mgxsAFJjk/gsdgh04+Ok03MN1QbiYKmx2EiEAI j9sfqKyfE5z8jxLP02HXtlSZB/AFV9iMhlDrqZ9s5dlhi20L93ew8z96CDvWv2j8K8/i 9/OQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@fiberby.net header.s=202008 header.b="eO8kA/v4"; 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-67841-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67841-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fiberby.net Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l184-20020a6391c1000000b005dc883a6ba5si1858601pge.500.2024.02.15.15.41.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 15:41:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67841-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@fiberby.net header.s=202008 header.b="eO8kA/v4"; 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-67841-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67841-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id BD00AB23451 for ; Thu, 15 Feb 2024 23:39:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 28CF5145FF2; Thu, 15 Feb 2024 23:39:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="eO8kA/v4" 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 E718053362; Thu, 15 Feb 2024 23:39:21 +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=1708040365; cv=none; b=ZQi61fatgJkAgiRJXIFfeb/0qb2rA5/lfVRFKDDu8Iam3HV4WQjkiENGTho+NilHR8ZO3z2hnhb81t3XYnC1fJkp0Pgd+jUGu09olyuwSZrDajxbOFyd4vAOPvl++nXWxlE8gqoTX0KULbmIpu9/0gZThN5lObDpYJaSvmzCsAk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708040365; c=relaxed/simple; bh=eQxomNVfWWrzdgxqJHK578iWgPvpAddY5NiTfq6HaqM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=uwg1fLUCfkF21V6vK2bvNuVqVP/UKUdhN0pgvYT+iYaVWWUv/9XERee5TYFP0b9jjyNtZOjm1QBqVREXZCTmSxEDz1cfKD9dCakConn5TXWkJMAI+51l7eMVIdaj8hz58j0FDWHphz504dKV/enJcyajKASCctcPWYBFYyX9xTA= 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=eO8kA/v4; 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 C431F600D7; Thu, 15 Feb 2024 23:39:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1708040360; bh=eQxomNVfWWrzdgxqJHK578iWgPvpAddY5NiTfq6HaqM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=eO8kA/v4+8nXr5onGAkqPI/kSCzCCvfHJDF2KhF0KWzQxwho/45G0JBuXIYcR9n5Z gV+DArGInYiw2AIha3jrBhaQA+2UmlEK8pZFcxiju3+5FxbyxeVP/Lx7zhtSj2XePM i93PU6Ii50ZU/33LEslZhmHUEyTPhcBO63zzAaxb+61HtMHvq9JyYNnXCHyD/IJHNH jRDr8+2ic+44USbaAqmXxPFKa55eXielNhn4Oirt16g6weyoC7qBwGCF+bxSfQEidr LzNielHJqRAKgJqg8uOri/f3QKf/G15ou3IrNU0d9lYBtm3QbIu8NAuFRa0vrFnEaF 0WBGzaPbX4mOw== Received: from [127.0.0.1] (localhost [127.0.0.1]) by x201s (Postfix) with ESMTP id 978AC200338; Thu, 15 Feb 2024 23:34:02 +0000 (UTC) Message-ID: Date: Thu, 15 Feb 2024 23:34:02 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next 1/3] net: sched: cls_api: add skip_sw counter Content-Language: en-US To: Jamal Hadi Salim Cc: Cong Wang , Jiri Pirko , Daniel Borkmann , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llu@fiberby.dk, Vlad Buslov , Marcelo Ricardo Leitner References: <20240215160458.1727237-1-ast@fiberby.net> <20240215160458.1727237-2-ast@fiberby.net> From: =?UTF-8?Q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Jamal, Thank you for the review. On 2/15/24 17:39, Jamal Hadi Salim wrote: > +Cc Vlad and Marcelo.. > > On Thu, Feb 15, 2024 at 11:06 AM Asbjørn Sloth Tønnesen wrote: >> >> 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 */ > > For your use case is skipswcnt ever going to be any different than offloadcnt? No, we only use skip_sw filters, since we only use TC as a control path to install skip_sw rules into hardware. AFAICT offloadcnt is the sum of skip_sw filters, and filters with no flags which have implicitly been offloaded. The reason that I didn't just use offloadcnt, is that I'm not sure if it is acceptable to treat implicitly offloaded rules without skip_sw, as if they were explicitly skip_sw. It sounds reasonable, given that the filters without skip_* flags shouldn't really care. I tried to only trigger the TC bypass, in the cases that I was absolutely sure would be safe as a first step. > > cheers, > jamal > >> 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); >> } >> >> -- >> 2.43.0 >> -- Best regards Asbjørn Sloth Tønnesen Network Engineer Fiberby - AS42541