From: Jiri Pirko <jiri@resnulli.us>
To: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Jakub Kicinski <kuba@kernel.org>,
davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
pabeni@redhat.com, willemb@google.com, fw@strlen.de,
saeedm@nvidia.com, leon@kernel.org, xiyou.wangcong@gmail.com,
roid@nvidia.com, ozsh@nvidia.com, paulb@nvidia.com
Subject: Re: [PATCH net-next 3/3] net: create and use NAPI version of tc_skb_ext_alloc()
Date: Wed, 15 Feb 2023 18:03:09 +0100 [thread overview]
Message-ID: <Y+0QTUQUDG7Zo1xq@nanopsycho> (raw)
In-Reply-To: <CAM0EoMnkcvHpbJY-Tqo8CngN4Y_hnYoeaYCMW+OVXcNVAbwzug@mail.gmail.com>
Wed, Feb 15, 2023 at 05:50:55PM CET, jhs@mojatatu.com wrote:
>On Tue, Feb 14, 2023 at 10:44 PM Jakub Kicinski <kuba@kernel.org> wrote:
>>
>> Try to use the cached skb_ext in the drivers.
>>
>> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
>> ---
>> CC: saeedm@nvidia.com
>> CC: leon@kernel.org
>> CC: jhs@mojatatu.com
>> CC: xiyou.wangcong@gmail.com
>> CC: jiri@resnulli.us
>> CC: roid@nvidia.com
>> CC: ozsh@nvidia.com
>> CC: paulb@nvidia.com
>> ---
>> drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c | 2 +-
>> drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 2 +-
>> include/net/pkt_cls.h | 9 +++++++++
>> 3 files changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
>> index 3b590cfe33b8..ffbed5a92eab 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
>> @@ -770,7 +770,7 @@ static bool mlx5e_restore_skb_chain(struct sk_buff *skb, u32 chain, u32 reg_c1,
>> struct mlx5_eswitch *esw;
>> u32 zone_restore_id;
>>
>> - tc_skb_ext = tc_skb_ext_alloc(skb);
>> + tc_skb_ext = tc_skb_ext_alloc_napi(skb);
>> if (!tc_skb_ext) {
>> WARN_ON(1);
>> return false;
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
>> index 2d06b4412762..3d9da4ccaf5d 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
>> @@ -5643,7 +5643,7 @@ bool mlx5e_tc_update_skb(struct mlx5_cqe64 *cqe,
>>
>> if (mapped_obj.type == MLX5_MAPPED_OBJ_CHAIN) {
>> chain = mapped_obj.chain;
>> - tc_skb_ext = tc_skb_ext_alloc(skb);
>> + tc_skb_ext = tc_skb_ext_alloc_napi(skb);
>> if (WARN_ON(!tc_skb_ext))
>> return false;
>>
>> diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
>> index ace437c6754b..82821a3f8a8b 100644
>> --- a/include/net/pkt_cls.h
>> +++ b/include/net/pkt_cls.h
>> @@ -764,6 +764,15 @@ static inline struct tc_skb_ext *tc_skb_ext_alloc(struct sk_buff *skb)
>> memset(tc_skb_ext, 0, sizeof(*tc_skb_ext));
>> return tc_skb_ext;
>> }
>> +
>> +static inline struct tc_skb_ext *tc_skb_ext_alloc_napi(struct sk_buff *skb)
>> +{
>> + struct tc_skb_ext *tc_skb_ext = napi_skb_ext_add(skb, TC_SKB_EXT);
>> +
>> + if (tc_skb_ext)
>> + memset(tc_skb_ext, 0, sizeof(*tc_skb_ext));
>> + return tc_skb_ext;
>> +}
>> #endif
>>
>
>Dumb question: Would this work with a consumer of the metadata past
>RPS stage? didnt look closely but assumed per cpu skb_ext because of
>the napi context - which will require a per cpu pointer to fetch it
>later.
>In P4TC we make heavy use of skb_ext and found it to be very pricey,
Why don't you use skb->cb internally in p4tc? Or does the skb leave p4tc
and arrive back again? When?
>so we ended making it per cpu - but that's post RPS so we are safe.
>
>cheers,
>jamal
next prev parent reply other threads:[~2023-02-15 17:03 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-15 3:43 [PATCH net-next 0/3] net: skbuff: cache one skb_ext for use by GRO Jakub Kicinski
2023-02-15 3:43 ` [PATCH net-next 1/3] net: skb: carve the allocation out of skb_ext_add() Jakub Kicinski
2023-02-15 3:43 ` [PATCH net-next 2/3] net: skbuff: cache one skb_ext for use by GRO Jakub Kicinski
2023-02-15 8:41 ` Paolo Abeni
2023-02-15 17:45 ` Jakub Kicinski
2023-02-15 18:08 ` Alexander Lobakin
2023-02-15 19:08 ` Paolo Abeni
2023-02-15 15:37 ` Edward Cree
2023-02-15 16:17 ` Alexander Lobakin
2023-02-15 17:52 ` Jakub Kicinski
2023-02-15 18:01 ` Alexander Lobakin
2023-02-15 18:20 ` Jakub Kicinski
2023-02-16 12:04 ` Alexander Lobakin
2023-02-15 3:43 ` [PATCH net-next 3/3] net: create and use NAPI version of tc_skb_ext_alloc() Jakub Kicinski
2023-02-15 16:50 ` Jamal Hadi Salim
2023-02-15 17:03 ` Jiri Pirko [this message]
2023-02-15 18:36 ` Jamal Hadi Salim
2023-02-15 17:35 ` Jakub Kicinski
2023-02-15 18:38 ` 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=Y+0QTUQUDG7Zo1xq@nanopsycho \
--to=jiri@resnulli.us \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=jhs@mojatatu.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=ozsh@nvidia.com \
--cc=pabeni@redhat.com \
--cc=paulb@nvidia.com \
--cc=roid@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=willemb@google.com \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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