From: Vlad Buslov <vladbu@nvidia•com>
To: Jamal Hadi Salim <jhs@mojatatu•com>
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>, <tomasz.osinski@intel•com>,
<jiri@resnulli•us>, <xiyou.wangcong@gmail•com>,
<davem@davemloft•net>, <edumazet@google•com>, <kuba@kernel•org>,
<pabeni@redhat•com>, <horms@kernel•org>, <kernel@mojatatu•com>,
<khalidm@nvidia•com>, <toke@redhat•com>, <mattyk@nvidia•com>
Subject: Re: [PATCH RFC v6 net-next 05/17] net: sched: act_api: Add support for preallocated dynamic action instances
Date: Sun, 8 Oct 2023 18:26:58 +0300 [thread overview]
Message-ID: <87il7hyvqf.fsf@nvidia.com> (raw)
In-Reply-To: <20230930143542.101000-6-jhs@mojatatu.com>
On Sat 30 Sep 2023 at 10:35, Jamal Hadi Salim <jhs@mojatatu•com> wrote:
> In P4, actions are assumed to pre exist and have an upper bound number of
> instances. Typically if you have 1M table entries you want to allocate
> enough action instances to cover the 1M entries. However, this is a big
> waste of memory if the action instances are not in use. So for our case,
> we allow the user to specify a minimal amount of actions in the template
> and then if more dynamic action instances are needed then they will be
> added on demand as in the current approach with tc filter-action
> relationship.
>
> Add the necessary code to preallocate actions instances for dynamic
> actions.
>
> We add 2 new actions flags:
> - TCA_ACT_FLAGS_PREALLOC: Indicates the action instance is a dynamic action
> and was preallocated for future use the templating phase of P4TC
> - TCA_ACT_FLAGS_UNREFERENCED: Indicates the action instance was
> preallocated and is currently not being referenced by any other object.
> Which means it won't show up in an action instance dump.
>
> Once an action instance is created we don't free it when the last table
> entry referring to it is deleted.
> Instead we add it to the pool/cache of action instances for
> that specific action i.e it counts as if it is preallocated.
> Preallocated actions can't be deleted by the tc actions runtime commands
> and a dump or a get will only show preallocated actions
> instances which are being used (TCA_ACT_FLAGS_UNREFERENCED == false).
>
> The preallocated actions will be deleted once the pipeline is deleted
> (which will purge the dynamic action kind and its instances).
>
> For example, if we were to create a dynamic action that preallocates 128
> elements and dumped:
>
> $ tc -j p4template get action/myprog/send_nh | jq .
>
> We'd see the following:
>
> [
> {
> "obj": "action template",
> "pname": "myprog",
> "pipeid": 1
> },
> {
> "templates": [
> {
> "aname": "myprog/send_nh",
> "actid": 1,
> "params": [
> {
> "name": "port",
> "type": "dev",
> "id": 1
> }
> ],
> "prealloc": 128
> }
> ]
> }
> ]
>
> If we try to dump the dynamic action instances, we won't see any:
>
> $ tc -j actions ls action myprog/send_nh | jq .
>
> []
>
> However, if we create a table entry which references this action kind:
>
> $ tc p4ctrl create myprog/table/cb/FDB \
> dstAddr d2:96:91:5d:02:86 action myprog/send_nh \
> param port type dev dummy0
>
> Dumping the action instance will now show this one instance which is
> associated with the table entry:
>
> $ tc -j actions ls action myprog/send_nh | jq .
>
> [
> {
> "total acts": 1
> },
> {
> "actions": [
> {
> "order": 0,
> "kind": "myprog/send_nh",
> "index": 1,
> "ref": 1,
> "bind": 1,
> "params": [
> {
> "name": "port",
> "type": "dev",
> "value": "dummy0",
> "id": 1
> }
> ],
> "not_in_hw": true
> }
> ]
> }
> ]
>
> Co-developed-by: Victor Nogueira <victor@mojatatu•com>
> Signed-off-by: Victor Nogueira <victor@mojatatu•com>
> Co-developed-by: Pedro Tammela <pctammela@mojatatu•com>
> Signed-off-by: Pedro Tammela <pctammela@mojatatu•com>
> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu•com>
> ---
act_api part looks good to me.
[...]
next prev parent reply other threads:[~2023-10-08 15:34 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-30 14:35 [PATCH RFC v6 net-next 00/17] Introducing P4TC Jamal Hadi Salim
2023-09-30 14:35 ` [PATCH RFC v6 net-next 01/17] net: sched: act_api: Introduce dynamic actions list Jamal Hadi Salim
2023-09-30 14:35 ` [PATCH RFC v6 net-next 02/17] net/sched: act_api: increase action kind string length Jamal Hadi Salim
2023-09-30 14:35 ` [PATCH RFC v6 net-next 03/17] net/sched: act_api: Update tc_action_ops to account for dynamic actions Jamal Hadi Salim
2023-09-30 14:35 ` [PATCH RFC v6 net-next 04/17] net/sched: act_api: add struct p4tc_action_ops as a parameter to lookup callback Jamal Hadi Salim
2023-09-30 14:35 ` [PATCH RFC v6 net-next 05/17] net: sched: act_api: Add support for preallocated dynamic action instances Jamal Hadi Salim
2023-10-08 15:26 ` Vlad Buslov [this message]
2023-09-30 14:35 ` [PATCH RFC v6 net-next 06/17] net: introduce rcu_replace_pointer_rtnl Jamal Hadi Salim
2023-09-30 14:35 ` [PATCH RFC v6 net-next 07/17] rtnl: add helper to check if group has listeners Jamal Hadi Salim
2023-09-30 14:35 ` [PATCH RFC v6 net-next 08/17] p4tc: add P4 data types Jamal Hadi Salim
2023-09-30 14:35 ` [PATCH RFC v6 net-next 09/17] p4tc: add pipeline create, get, update, delete Jamal Hadi Salim
2023-09-30 14:35 ` [PATCH RFC v6 net-next 10/17] p4tc: add header field create, get, delete, flush and dump Jamal Hadi Salim
2023-09-30 14:35 ` [PATCH RFC v6 net-next 11/17] p4tc: add action template create, update, delete, get, " Jamal Hadi Salim
2023-09-30 14:35 ` [PATCH RFC v6 net-next 12/17] p4tc: add table " Jamal Hadi Salim
2023-09-30 14:35 ` [PATCH RFC v6 net-next 13/17] p4tc: add table entry create, update, get, delete, " Jamal Hadi Salim
2023-10-08 16:26 ` Vlad Buslov
2023-10-08 16:53 ` Andrew Lunn
2023-10-09 6:29 ` Vlad Buslov
2023-10-09 14:02 ` Jamal Hadi Salim
2023-10-09 14:27 ` Vlad Buslov
2023-10-09 15:39 ` Jamal Hadi Salim
2023-09-30 14:35 ` [PATCH RFC v6 net-next 14/17] p4tc: add set of P4TC table kfuncs Jamal Hadi Salim
2023-09-30 14:35 ` [PATCH RFC v6 net-next 15/17] p4tc: add P4 classifier Jamal Hadi Salim
2023-09-30 14:35 ` [PATCH RFC v6 net-next 16/17] p4tc: Add P4 extern interface Jamal Hadi Salim
2023-09-30 14:35 ` [PATCH RFC v6 net-next 17/17] MAINTAINERS: add p4tc entry Jamal Hadi Salim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87il7hyvqf.fsf@nvidia.com \
--to=vladbu@nvidia$(echo .)com \
--cc=Mahesh.Shirshyad@amd$(echo .)com \
--cc=anjali.singhai@intel$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=deb.chatterjee@intel$(echo .)com \
--cc=edumazet@google$(echo .)com \
--cc=horms@kernel$(echo .)org \
--cc=jhs@mojatatu$(echo .)com \
--cc=jiri@resnulli$(echo .)us \
--cc=kernel@mojatatu$(echo .)com \
--cc=khalidm@nvidia$(echo .)com \
--cc=kuba@kernel$(echo .)org \
--cc=mattyk@nvidia$(echo .)com \
--cc=mleitner@redhat$(echo .)com \
--cc=namrata.limaye@intel$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=pabeni@redhat$(echo .)com \
--cc=toke@redhat$(echo .)com \
--cc=tom@sipanda$(echo .)io \
--cc=tomasz.osinski@intel$(echo .)com \
--cc=xiyou.wangcong@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox