From: Aaron Conole <aconole@redhat.com>
To: "Nicholas Piggin" <npiggin@gmail.com>
Cc: "Eelco Chaudron" <echaudro@redhat.com>, <netdev@vger.kernel.org>,
<dev@openvswitch.org>, "Ilya Maximets" <imaximet@redhat.com>,
"Flavio Leitner" <fbl@redhat.com>
Subject: Re: [ovs-dev] [RFC PATCH 4/7] net: openvswitch: ovs_vport_receive reduce stack usage
Date: Wed, 11 Oct 2023 09:34:53 -0400 [thread overview]
Message-ID: <f7ty1g9cmf6.fsf@redhat.com> (raw)
In-Reply-To: <CW04VKYCMTJE.ZX0TQ1Y6H6VB@wheely> (Nicholas Piggin's message of "Thu, 05 Oct 2023 12:01:15 +1000")
"Nicholas Piggin" <npiggin@gmail.com> writes:
> On Fri Sep 29, 2023 at 6:38 PM AEST, Eelco Chaudron wrote:
>>
>>
>> On 29 Sep 2023, at 9:00, Nicholas Piggin wrote:
>>
>> > On Fri Sep 29, 2023 at 1:26 AM AEST, Aaron Conole wrote:
>> >> Nicholas Piggin <npiggin@gmail.com> writes:
>> >>
>> >>> Dynamically allocating the sw_flow_key reduces stack usage of
>> >>> ovs_vport_receive from 544 bytes to 64 bytes at the cost of
>> >>> another GFP_ATOMIC allocation in the receive path.
>> >>>
>> >>> XXX: is this a problem with memory reserves if ovs is in a
>> >>> memory reclaim path, or since we have a skb allocated, is it
>> >>> okay to use some GFP_ATOMIC reserves?
>> >>>
>> >>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>> >>> ---
>> >>
>> >> This represents a fairly large performance hit. Just my own quick
>> >> testing on a system using two netns, iperf3, and simple forwarding rules
>> >> shows between 2.5% and 4% performance reduction on x86-64. Note that it
>> >> is a simple case, and doesn't involve a more involved scenario like
>> >> multiple bridges, tunnels, and internal ports. I suspect such cases
>> >> will see even bigger hit.
>> >>
>> >> I don't know the impact of the other changes, but just an FYI that the
>> >> performance impact of this change is extremely noticeable on x86
>> >> platform.
>> >
>> > Thanks for the numbers. This patch is probably the biggest perf cost,
>> > but unfortunately it's also about the biggest saving. I might have an
>> > idea to improve it.
>>
>> Also, were you able to figure out why we do not see this problem on
>> x86 and arm64? Is the stack usage so much larger, or is there some
>> other root cause? Is there a simple replicator, as this might help
>> you profile the differences between the architectures?
>
> I found some snippets of equivalent call chain (this is for 4.18 RHEL8
> kernels, but it's just to give a general idea of stack overhead
> differences in C code). Frame size annotated on the right hand side:
>
> [c0000007ffdba980] do_execute_actions 496
> [c0000007ffdbab70] ovs_execute_actions 128
> [c0000007ffdbabf0] ovs_dp_process_packet 208
> [c0000007ffdbacc0] clone_execute 176
> [c0000007ffdbad70] do_execute_actions 496
> [c0000007ffdbaf60] ovs_execute_actions 128
> [c0000007ffdbafe0] ovs_dp_process_packet 208
> [c0000007ffdbb0b0] ovs_vport_receive 528
> [c0000007ffdbb2c0] internal_dev_xmit
> total = 2368
> [ff49b6d4065a3628] do_execute_actions 416
> [ff49b6d4065a37c8] ovs_execute_actions 48
> [ff49b6d4065a37f8] ovs_dp_process_packet 112
> [ff49b6d4065a3868] clone_execute 64
> [ff49b6d4065a38a8] do_execute_actions 416
> [ff49b6d4065a3a48] ovs_execute_actions 48
> [ff49b6d4065a3a78] ovs_dp_process_packet 112
> [ff49b6d4065a3ae8] ovs_vport_receive 496
> [ff49b6d4065a3cd8] netdev_frame_hook
> total = 1712
>
> That's more significant than I thought, nearly 40% more stack usage for
> ppc even with 3 frames having large local variables that can't be
> avoided for either arch.
>
> So, x86_64 could be quite safe with its 16kB stack for the same
> workload, explaining why same overflow has not been seen there.
This is interesting - is it possible that we could resolve this without
needing to change the kernel - or at least without changing how OVS
works? Why are these so different? Maybe there's some bloat in some of
the ppc data structures that can be addressed? For example,
ovs_execute_actions shouldn't really be that different, but I wonder if
the way the per-cpu infra works, or the deferred action processing gets
inlined would be causing stack bloat?
> Thanks,
> Nick
next prev parent reply other threads:[~2023-10-11 13:35 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-27 0:13 [RFC PATCH 0/7] net: openvswitch: Reduce stack usage Nicholas Piggin
2023-09-27 0:13 ` [RFC PATCH 1/7] net: openvswitch: Move NSH buffer out of do_execute_actions Nicholas Piggin
2023-09-27 8:26 ` [ovs-dev] " Ilya Maximets
2023-09-27 10:03 ` Nicholas Piggin
2023-09-27 0:13 ` [RFC PATCH 2/7] net: openvswitch: Reduce execute_push_nsh stack overhead Nicholas Piggin
2023-09-27 0:13 ` [RFC PATCH 3/7] net: openvswitch: uninline action execution Nicholas Piggin
2023-09-27 0:13 ` [RFC PATCH 4/7] net: openvswitch: ovs_vport_receive reduce stack usage Nicholas Piggin
2023-09-28 15:26 ` [ovs-dev] " Aaron Conole
2023-09-29 7:00 ` Nicholas Piggin
2023-09-29 8:38 ` Eelco Chaudron
2023-10-04 7:11 ` Nicholas Piggin
2023-10-04 15:15 ` Aaron Conole
2023-10-05 2:01 ` Nicholas Piggin
2023-10-11 13:34 ` Aaron Conole [this message]
2023-10-11 23:58 ` Nicholas Piggin
2023-10-04 7:29 ` Nicholas Piggin
2023-10-04 15:16 ` Aaron Conole
2023-09-27 0:13 ` [RFC PATCH 5/7] net: openvswitch: uninline ovs_fragment to control " Nicholas Piggin
2023-09-27 0:13 ` [RFC PATCH 6/7] net: openvswitch: Reduce ovs_fragment " Nicholas Piggin
2023-09-27 0:13 ` [RFC PATCH 7/7] net: openvswitch: Reduce stack usage in ovs_dp_process_packet Nicholas Piggin
2023-09-27 8:36 ` [ovs-dev] [RFC PATCH 0/7] net: openvswitch: Reduce stack usage Ilya Maximets
2023-09-28 1:52 ` Nicholas Piggin
2023-10-02 11:54 ` Ilya Maximets
2023-10-04 9:56 ` Nicholas Piggin
2023-09-29 7:06 ` Nicholas Piggin
2023-10-02 11:56 ` Ilya Maximets
2023-10-03 13:31 ` Aaron Conole
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=f7ty1g9cmf6.fsf@redhat.com \
--to=aconole@redhat.com \
--cc=dev@openvswitch.org \
--cc=echaudro@redhat.com \
--cc=fbl@redhat.com \
--cc=imaximet@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=npiggin@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;
as well as URLs for NNTP newsgroup(s).