From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 739F867C6E for ; Fri, 1 Mar 2024 07:30:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709278214; cv=none; b=ap9+B9Q/uVzheT5l0u2BWQ50QRf5erJg8e2KpJNcZlfFn+QmQDz7O5/BXV0U6XsxZ5EoxZw0hIZkdDDgRh6fJMtIFjIIhFcUpLyDIKEBvlX0G6PHSoZc+uCP7/b8hYHWELcqYJfFgUAtaJr31IR1DKjutrro/TiR/Yp6lvzZX4c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709278214; c=relaxed/simple; bh=Ikhxf0/eHLVPqABdwtE7XMNSCYVODeCQZ59FSCqtbYk=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=dhKDYD86D7DQNqgaxLxtezUce6CeHMz+X6YFfLoMurrC/AMQI6kKuwL89Dtik/sWyyumDQihsjxcuAAco92WkL2CfZObUPt6q7/4Iv2U6ZWeXhELJtz9Zaly0aH8/MAnC53re1+sYMzSF9RzD0nwKgrB+YS5X2qudQ3dYHOWJ5Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=K+TM/dHf; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="K+TM/dHf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709278211; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=sD7VxdaiJ+Kjq1G3tM2pMh8dxyqSV9/4iHg7NclTyNA=; b=K+TM/dHfOHb6OLl9F6DMAcf4CLBqGopjfh70rozoQQtheuvnnKB06mpdYn7eZ8ZL3y9JyT Waa/Q6dWKHmSEutBKZUwYE5ogM+Nyve3lXeZzbljfbhdJ9wCRTjrYNJcMurX/AL0CsyEAY s0hzRmi8ZEu24FgwGiXZsyz9ZA4rqUI= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-433-WmPMIaf5NqWiEEH57hgMDw-1; Fri, 01 Mar 2024 02:30:10 -0500 X-MC-Unique: WmPMIaf5NqWiEEH57hgMDw-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-412c8c1979dso427255e9.1 for ; Thu, 29 Feb 2024 23:30:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709278209; x=1709883009; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:from:subject:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sD7VxdaiJ+Kjq1G3tM2pMh8dxyqSV9/4iHg7NclTyNA=; b=E9cnGeqK9ynpDbcVftPXXnHIFq/+hMOKc/QVJ53IL6Bjzrg8hDQVBOIGYkDw7a0Sbi nsosKerqczEXn8PhL/Ekg1RcINuXXHu7AWrnGQAXmHfkWb/73uRI897vUQld7089M129 UITlqRpsEMosdZe3wxAaRviS56T8v80cFktvjCrXmKcyEns5gC6WEDgS/tj1q9SuI8T+ UjcwTaG3bxcAWZDjy98Bl092NVe94XwJ38wHBRCkoDnh43TSUpCejshBhv/8bi+GVw6b IB+OwfVKzP3X/CFkFBIDVInOAOnX9rYghFOUBKSDCkKEIcHEs5NXA8radGpjLcVCEo79 Pdig== X-Gm-Message-State: AOJu0YycEv5njz7LgtMMo3HBJeoXFbRW2B8VBnjVsQ0q+jAHlVwaOMfE W1Fx2bsfn3RmZqAVyXRNsfzKU84lJHR4qtQdfRh3jysQqtXxHnhJaGVAX5zEOTAznWsTnGJMxDB 6T7xHN06VLW60K6PiFzPHndDJu+7B43QzVQ41fscQ2kMmdlSqk2XlJw== X-Received: by 2002:adf:cc14:0:b0:33d:a6f2:86f5 with SMTP id x20-20020adfcc14000000b0033da6f286f5mr514796wrh.4.1709278208858; Thu, 29 Feb 2024 23:30:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqKv23HgdvLIMHjppTOCD3ItVT2gg886XxFka9OeHDNWleuznYQdnSNo+6jkCuZgVUniqhhg== X-Received: by 2002:adf:cc14:0:b0:33d:a6f2:86f5 with SMTP id x20-20020adfcc14000000b0033da6f286f5mr514775wrh.4.1709278208429; Thu, 29 Feb 2024 23:30:08 -0800 (PST) Received: from gerbillo.redhat.com (146-241-247-38.dyn.eolo.it. [146.241.247.38]) by smtp.gmail.com with ESMTPSA id g25-20020adfa499000000b0033d6c928a95sm3823448wrb.63.2024.02.29.23.30.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 23:30:07 -0800 (PST) Message-ID: <0e2f24d44a565114f06c5015680b482ecc34d0e9.camel@redhat.com> Subject: Re: [PATCH net-next v12 01/15] net: sched: act_api: Introduce P4 actions list From: Paolo Abeni To: Jamal Hadi Salim Cc: netdev@vger.kernel.org, deb.chatterjee@intel.com, anjali.singhai@intel.com, namrata.limaye@intel.com, tom@sipanda.io, mleitner@redhat.com, Mahesh.Shirshyad@amd.com, Vipin.Jain@amd.com, tomasz.osinski@intel.com, jiri@resnulli.us, xiyou.wangcong@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, vladbu@nvidia.com, horms@kernel.org, khalidm@nvidia.com, toke@redhat.com, daniel@iogearbox.net, victor@mojatatu.com, pctammela@mojatatu.com, bpf@vger.kernel.org Date: Fri, 01 Mar 2024 08:30:05 +0100 In-Reply-To: References: <20240225165447.156954-1-jhs@mojatatu.com> <20240225165447.156954-2-jhs@mojatatu.com> Autocrypt: addr=pabeni@redhat.com; prefer-encrypt=mutual; keydata=mQINBGISiDUBEAC5uMdJicjm3ZlWQJG4u2EU1EhWUSx8IZLUTmEE8zmjPJFSYDcjtfGcbzLPb63BvX7FADmTOkO7gwtDgm501XnQaZgBUnCOUT8qv5MkKsFH20h1XJyqjPeGM55YFAXc+a4WD0YyO5M0+KhDeRLoildeRna1ey944VlZ6Inf67zMYw9vfE5XozBtytFIrRyGEWkQwkjaYhr1cGM8ia24QQVQid3P7SPkR78kJmrT32sGk+TdR4YnZzBvVaojX4AroZrrAQVdOLQWR+w4w1mONfJvahNdjq73tKv51nIpu4SAC1Zmnm3x4u9r22mbMDr0uWqDqwhsvkanYmn4umDKc1ZkBnDIbbumd40x9CKgG6ogVlLYeJa9WyfVMOHDF6f0wRjFjxVoPO6p/ZDkuEa67KCpJnXNYipLJ3MYhdKWBZw0xc3LKiKc+nMfQlo76T/qHMDfRMaMhk+L8gWc3ZlRQFG0/Pd1pdQEiRuvfM5DUXDo/YOZLV0NfRFU9SmtIPhbdm9cV8Hf8mUwubihiJB/9zPvVq8xfiVbdT0sPzBtxW0fXwrbFxYAOFvT0UC2MjlIsukjmXOUJtdZqBE3v3Jf7VnjNVj9P58+MOx9iYo8jl3fNd7biyQWdPDfYk9ncK8km4skfZQIoUVqrWqGDJjHO1W9CQLAxkfOeHrmG29PK9tHIwARAQABtB9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I06aTdvvuiigBwjngo/Rk5S+iEGR5KmTqGyp27o6YxZy6D4NIc6PKUzhIUxfvuHNvfu sD2W1U7eyLdm/jCgticGDsRtweytsgCSYfbz0gdgUuL3EBYN3JLbAU+UZpy v/fyD4cHDWaizNy/KmOI6FFjvVh4LRCpGTGDVPHsQXaqvzUybaMb7HSfmBBzZqqfVbq9n5FqPjAgD2lJ0rkzb9XnVXHgr6bmMRlaTlBMAEQEAAYkCNgQYAQgAIBYhBINQI6gu+8G3S19i2ykkeY3MjxOkBQJiEog1AhsMAAoJECkkeY3MjxOkY1YQAKdGjHyIdOWSjM8DPLdGJaPgJdugHZowaoyCxffilMGXqc8axBtmYjUIoXurpl+f+a7S0tQhXjGUt09zKlNXxGcebL5TEPFqgJTHN/77ayLslMTtZVYHE2FiIxkvW48yDjZUlefmphGpfpoXe4nRBNto1mMB9Pb9vR47EjNBZCtWWbwJTIEUwHP2Z5fV9nMx9Zw2BhwrfnODnzI8xRWVqk7/5R+FJvl7s3nY4F+svKGD9QHYmxfd8Gx42PZc/qkeCjUORaOf1fsYyChTtJI4iNm6iWbD9HK5LTMzwl0n0lL7CEsBsCJ97i2swm1DQiY1ZJ95G2Nz5PjNRSiymIw9/neTvUT8VJJhzRl3Nb/EmO/qeahfiG7zTpqSn2dEl+AwbcwQrbAhTPzuHIcoLZYV0xDWzAibUnn7pSrQKja+b8kHD9WF+m7dPlRVY7soqEYXylyCOXr5516upH8vVBmqweCIxXSWqPAhQq8d3hB/Ww2A0H0PBTN1REVw8pRLNApEA7C2nX6RW0XmA53PIQvAP0EAakWsqHoKZ5WdpeOcH9iVlUQhRgemQSkhfNaP9LqR1XKujlTuUTpoyT3xwAzkmSxN1nABoutHEO/N87fpIbpbZaIdinF7b9srwUvDOKsywfs5HMiUZhLKoZzCcU/AEFjQsPTATACGsWf3JYPnWxL9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.4 (3.50.4-1.fc39) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Thu, 2024-02-29 at 13:21 -0500, Jamal Hadi Salim wrote: > On Thu, Feb 29, 2024 at 10:05=E2=80=AFAM Paolo Abeni = wrote: > >=20 > > On Sun, 2024-02-25 at 11:54 -0500, Jamal Hadi Salim wrote: > > > In P4 we require to generate new actions "on the fly" based on the > > > specified P4 action definition. P4 action kinds, like the pipeline > > > they are attached to, must be per net namespace, as opposed to native > > > action kinds which are global. For that reason, we chose to create a > > > separate structure to store P4 actions. > > >=20 > > > Co-developed-by: Victor Nogueira > > > Signed-off-by: Victor Nogueira > > > Co-developed-by: Pedro Tammela > > > Signed-off-by: Pedro Tammela > > > Signed-off-by: Jamal Hadi Salim > > > Reviewed-by: Vlad Buslov > > > Reviewed-by: Marcelo Ricardo Leitner > > > --- > > > include/net/act_api.h | 8 ++- > > > net/sched/act_api.c | 123 +++++++++++++++++++++++++++++++++++++---= -- > > > net/sched/cls_api.c | 2 +- > > > 3 files changed, 116 insertions(+), 17 deletions(-) > > >=20 > > > diff --git a/include/net/act_api.h b/include/net/act_api.h > > > index 77ee0c657..f22be14bb 100644 > > > --- a/include/net/act_api.h > > > +++ b/include/net/act_api.h > > > @@ -105,6 +105,7 @@ typedef void (*tc_action_priv_destructor)(void *p= riv); > > >=20 > > > struct tc_action_ops { > > > struct list_head head; > > > + struct list_head p4_head; > > > char kind[IFNAMSIZ]; > > > enum tca_id id; /* identifier should match kind */ > > > unsigned int net_id; > > > @@ -199,10 +200,12 @@ int tcf_idr_check_alloc(struct tc_action_net *t= n, u32 *index, > > > int tcf_idr_release(struct tc_action *a, bool bind); > > >=20 > > > int tcf_register_action(struct tc_action_ops *a, struct pernet_opera= tions *ops); > > > +int tcf_register_p4_action(struct net *net, struct tc_action_ops *ac= t); > > > int tcf_unregister_action(struct tc_action_ops *a, > > > struct pernet_operations *ops); > > > #define NET_ACT_ALIAS_PREFIX "net-act-" > > > #define MODULE_ALIAS_NET_ACT(kind) MODULE_ALIAS(NET_ACT_ALIAS_PREF= IX kind) > > > +void tcf_unregister_p4_action(struct net *net, struct tc_action_ops = *act); > > > int tcf_action_destroy(struct tc_action *actions[], int bind); > > > int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions, > > > int nr_actions, struct tcf_result *res); > > > @@ -210,8 +213,9 @@ int tcf_action_init(struct net *net, struct tcf_p= roto *tp, struct nlattr *nla, > > > struct nlattr *est, > > > struct tc_action *actions[], int init_res[], size_t= *attr_size, > > > u32 flags, u32 fl_flags, struct netlink_ext_ack *ex= tack); > > > -struct tc_action_ops *tc_action_load_ops(struct nlattr *nla, u32 fla= gs, > > > - struct netlink_ext_ack *extack= ); > > > +struct tc_action_ops * > > > +tc_action_load_ops(struct net *net, struct nlattr *nla, > > > + u32 flags, struct netlink_ext_ack *extack); > > > struct tc_action *tcf_action_init_1(struct net *net, struct tcf_prot= o *tp, > > > struct nlattr *nla, struct nlattr *= est, > > > struct tc_action_ops *a_o, int *ini= t_res, > > > diff --git a/net/sched/act_api.c b/net/sched/act_api.c > > > index 9ee622fb1..23ef394f2 100644 > > > --- a/net/sched/act_api.c > > > +++ b/net/sched/act_api.c > > > @@ -57,6 +57,40 @@ static void tcf_free_cookie_rcu(struct rcu_head *p= ) > > > kfree(cookie); > > > } > > >=20 > > > +static unsigned int p4_act_net_id; > > > + > > > +struct tcf_p4_act_net { > > > + struct list_head act_base; > > > + rwlock_t act_mod_lock; > >=20 > > Note that rwlock in networking code is discouraged, as they have to be > > unfair, see commit 0daf07e527095e64ee8927ce297ab626643e9f51. > >=20 > > In this specific case I think there should be no problems, as is > > extremely hard/impossible to have serious contention on the write > > side,. Also there is already an existing rwlock nearby, no not a > > blocker but IMHO worthy to be noted. > >=20 >=20 > Sure - we can replace it. What's the preference? Spinlock? Plain spinlock will work. Using spinlock + RCU should be quite straight forward and will provide faster lookup. Cheers, Paolo