From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: Justin Iurman <justin.iurman@uliege.be>
Cc: <netdev@vger.kernel.org>, <davem@davemloft.net>,
<dsahern@kernel.org>, <edumazet@google.com>, <kuba@kernel.org>,
<pabeni@redhat.com>, <horms@kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next 1/3] net: ipv6: ioam6_iptunnel: mitigate 2-realloc issue
Date: Tue, 29 Oct 2024 16:08:05 +0100 [thread overview]
Message-ID: <d04a5dc3-ea0c-499a-b01f-86d0f1ad0e13@intel.com> (raw)
In-Reply-To: <d3bce110-4b1b-44ed-8c1d-a9736a02f1dd@uliege.be>
From: Justin Iurman <justin.iurman@uliege.be>
Date: Fri, 25 Oct 2024 23:06:36 +0200
> On 10/25/24 17:12, Alexander Lobakin wrote:
>> From: Justin Iurman <justin.iurman@uliege.be>
>> Date: Fri, 25 Oct 2024 15:37:25 +0200
>>
>>> This patch mitigates the two-reallocations issue with ioam6_iptunnel by
>>> providing the dst_entry (in the cache) to the first call to
>>> skb_cow_head(). As a result, the very first iteration would still
>>> trigger two reallocations (i.e., empty cache), while next iterations
>>> would only trigger a single reallocation.
>>
>> [...]
>>
>>> static int ioam6_do_inline(struct net *net, struct sk_buff *skb,
>>> - struct ioam6_lwt_encap *tuninfo)
>>> + struct ioam6_lwt_encap *tuninfo,
>>> + struct dst_entry *dst)
>>> {
>>> struct ipv6hdr *oldhdr, *hdr;
>>> int hdrlen, err;
>>> hdrlen = (tuninfo->eh.hdrlen + 1) << 3;
>>> - err = skb_cow_head(skb, hdrlen + skb->mac_len);
>>> + err = skb_cow_head(skb, hdrlen + (!dst ? skb->mac_len
>>> + : LL_RESERVED_SPACE(dst->dev)));
>>
>> You use this pattern a lot throughout the series. I believe you should
>> make a static inline or a macro from it.
>>
>> static inline u32 some_name(const *dst, const *skb)
>> {
>> return dst ? LL_RESERVED_SPACE(dst->dev) : skb->mac_len;
>> }
>>
>> BTW why do you check for `!dst`, not `dst`? Does changing this affects
>> performance?
>
> Not at all, you're right... even the opposite actually. Regarding the
> static inline suggestion, it could be a good idea and may even look like
> this as an optimization:
>
> static inline u32 dev_overhead(struct dst_entry *dst, struct sk_buff *skb)
> {
> if (likely(dst))
> return LL_RESERVED_SPACE(dst->dev);
>
> return skb->mac_len;
> }
Oh, nice!
>
> The question is... where should it go then? A static inline function per
> file (i.e., ioam6_iptunnel.c, seg6_iptunnel.c, and rpl_iptunnel.c)? In
> that case, it would still be repeated 3 times. Or in a header file
> somewhere, to have it defined only once? If so, what location do you
> think would be best?
100% should be in a header file. Can't suggest any since I don't usually
work with tunnels and ain't deep into its header structure.
Thanks,
Olek
next prev parent reply other threads:[~2024-10-29 15:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-25 13:37 [PATCH net-next 0/3] Mitigate the two-reallocations issue for iptunnels Justin Iurman
2024-10-25 13:37 ` [PATCH net-next 1/3] net: ipv6: ioam6_iptunnel: mitigate 2-realloc issue Justin Iurman
2024-10-25 15:12 ` Alexander Lobakin
2024-10-25 21:06 ` Justin Iurman
2024-10-29 15:08 ` Alexander Lobakin [this message]
2024-10-25 13:37 ` [PATCH net-next 2/3] net: ipv6: seg6_iptunnel: " Justin Iurman
2024-10-26 8:38 ` kernel test robot
2024-10-26 10:00 ` kernel test robot
2024-10-25 13:37 ` [PATCH net-next 3/3] net: ipv6: rpl_iptunnel: " Justin Iurman
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=d04a5dc3-ea0c-499a-b01f-86d0f1ad0e13@intel.com \
--to=aleksander.lobakin@intel.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=justin.iurman@uliege.be \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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