<div dir="rtl"><div dir="rtl"><div dir="rtl"><div dir="ltr">Calling it from net_dev_init doesn&#39;t look clean.</div><div dir="ltr">If you will see who is calling &#39;dev_add_offload&#39; you will find out that there are couple of modules that doing that except of the 8021q. so either all modules should add offload from net_dev_init or stay with the current model where each module adds its offload.</div><div dir="ltr"><br></div><div dir="ltr">When adding a vlan interface using &#39;ip link add&#39;, the module 8021q is loaded. What is the flow that causing ip link to load this module?</div><div dir="ltr">Why can&#39;t we do the same thing when a vlan interface is created from ovs?</div><div dir="ltr"><br></div><div dir="ltr">Jiri,</div><div dir="ltr">Any other idea how we can solve this issue?</div><div dir="ltr"><br></div><div dir="ltr">Michael </div><div dir="ltr"><br></div></div></div></div><br><div class="gmail_quote"><div dir="rtl">‫בתאריך יום א׳, 28 באוק׳ 2018 ב-18:54 מאת ‪Jiri Pirko‬‏ &lt;‪<a href="mailto:jiri@resnulli.us">jiri@resnulli.us</a>‬‏&gt;:‬<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Sun, Oct 28, 2018 at 03:03:42PM CET, <a href="mailto:michaelsh86@gmail.com" target="_blank">michaelsh86@gmail.com</a> wrote:<br>
&gt;Jiri,<br>
&gt;I am not sure it would be simple to move the add_offload to vlan_Core.c as<br>
&gt;the add_offload should happen once.<br>
<br>
Just call it from net_dev_init()<br>
<br>
&gt;in vlan.c it&#39;s done as part of module init but in vlan_core.c we are not<br>
&gt;initializing any model and making some logic for doing that once looks<br>
&gt;awkward to me.<br>
&gt;Why can&#39;t we just load the module (8021q) once  a vlan interface is added<br>
&gt;via OVS?<br>
<br>
I have no clue how exactly would you like to do it...<br>
<br>
<br>
&gt;<br>
&gt;<br>
&gt;‫בתאריך יום ה׳, 25 באוק׳ 2018 ב-15:15 מאת ‪Jiri Pirko‬‏ &lt;‪<a href="mailto:jiri@resnulli.us" target="_blank">jiri@resnulli.us</a><br>
&gt;‬‏&gt;:‬<br>
&gt;<br>
&gt;&gt; Thu, Oct 25, 2018 at 01:34:04PM CEST, <a href="mailto:michaelsh86@gmail.com" target="_blank">michaelsh86@gmail.com</a> wrote:<br>
&gt;&gt; &gt;I&#39;v used ftrace to see which paths we take in the kernel.<br>
&gt;&gt; &gt;I remind you that the packet (in my scenario) looks like the following:<br>
&gt;&gt; &gt;ETH | IP | UDP | VXLAN | L2 | VLAN | IP | TCP | payload<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;When 8021q is not loaded:<br>
&gt;&gt; &gt;dev_gro_receive &lt;-napi_gro_receive<br>
&gt;&gt; &gt;inet_gro_receive &lt;-dev_gro_receive<br>
&gt;&gt; &gt;udp4_gro_receive &lt;-inet_gro_receive<br>
&gt;&gt; &gt;udp_gro_receive &lt;-udp4_gro_receive<br>
&gt;&gt; &gt;udp4_lib_lookup_skb &lt;-udp_gro_receive<br>
&gt;&gt; &gt;__udp4_lib_lookup &lt;-udp4_lib_lookup_skb<br>
&gt;&gt; &gt;compute_score &lt;-__udp4_lib_lookup<br>
&gt;&gt; &gt;vxlan_gro_receive &lt;-udp_gro_receive<br>
&gt;&gt; &gt;__pskb_pull_tail &lt;-vxlan_gro_receive<br>
&gt;&gt; &gt;skb_copy_bits &lt;-__pskb_pull_tail<br>
&gt;&gt; &gt;eth_gro_receive &lt;-vxlan_gro_receive<br>
&gt;&gt; &gt;__pskb_pull_tail &lt;-eth_gro_receive<br>
&gt;&gt; &gt;skb_copy_bits &lt;-__pskb_pull_tail<br>
&gt;&gt; &gt;gro_find_receive_by_type &lt;-eth_gro_receive<br>
&gt;&gt; &gt;netif_receive_skb_internal &lt;-napi_gro_receive<br>
&gt;&gt; &gt;ktime_get_real &lt;-netif_receive_skb_internal<br>
&gt;&gt; &gt;getnstimeofday64 &lt;-ktime_get_real<br>
&gt;&gt; &gt;__getnstimeofday64 &lt;-getnstimeofday64<br>
&gt;&gt; &gt;skb_defer_rx_timestamp &lt;-netif_receive_skb_internal<br>
&gt;&gt; &gt;classify &lt;-skb_defer_rx_timestamp<br>
&gt;&gt; &gt;__netif_receive_skb &lt;-netif_receive_skb_internal<br>
&gt;&gt; &gt;__netif_receive_skb_core &lt;-__netif_receive_skb<br>
&gt;&gt; &gt;ip_rcv &lt;-__netif_receive_skb_core<br>
&gt;&gt; &gt;nf_hook_slow &lt;-ip_rcv<br>
&gt;&gt; &gt;nf_iterate &lt;-nf_hook_slow<br>
&gt;&gt; &gt;ipv4_conntrack_defrag &lt;-nf_iterate<br>
&gt;&gt; &gt;ipv4_conntrack_in &lt;-nf_iterate<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;When 8021q was loaded manually:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;inet_gro_receive &lt;-dev_gro_receive<br>
&gt;&gt; &gt;classify &lt;-skb_clone_tx_timestamp<br>
&gt;&gt; &gt;udp4_gro_receive &lt;-inet_gro_receive<br>
&gt;&gt; &gt;_raw_spin_lock &lt;-sch_direct_xmit<br>
&gt;&gt; &gt;udp_gro_receive &lt;-udp4_gro_receive<br>
&gt;&gt; &gt;udp4_lib_lookup_skb &lt;-udp_gro_receive<br>
&gt;&gt; &gt;local_bh_enable &lt;-__dev_queue_xmit<br>
&gt;&gt; &gt;__udp4_lib_lookup &lt;-udp4_lib_lookup_skb<br>
&gt;&gt; &gt;__local_bh_enable_ip &lt;-local_bh_enable<br>
&gt;&gt; &gt;compute_score &lt;-__udp4_lib_lookup<br>
&gt;&gt; &gt;local_bh_enable &lt;-ip_finish_output<br>
&gt;&gt; &gt;vxlan_gro_receive &lt;-udp_gro_receive<br>
&gt;&gt; &gt;__local_bh_enable_ip &lt;-local_bh_enable<br>
&gt;&gt; &gt;__pskb_pull_tail &lt;-vxlan_gro_receive<br>
&gt;&gt; &gt;skb_copy_bits &lt;-__pskb_pull_tail<br>
&gt;&gt; &gt;local_bh_enable &lt;-__dev_queue_xmit<br>
&gt;&gt; &gt;eth_gro_receive &lt;-vxlan_gro_receive<br>
&gt;&gt; &gt;__local_bh_enable_ip &lt;-local_bh_enable<br>
&gt;&gt; &gt;__pskb_pull_tail &lt;-eth_gro_receive<br>
&gt;&gt; &gt;skb_copy_bits &lt;-__pskb_pull_tail<br>
&gt;&gt; &gt;gro_find_receive_by_type &lt;-eth_gro_receive<br>
&gt;&gt; &gt;local_bh_enable &lt;-__dev_queue_xmit<br>
&gt;&gt; &gt;__local_bh_enable_ip &lt;-local_bh_enable<br>
&gt;&gt; &gt;vlan_gro_receive &lt;-eth_gro_receive<br>
&gt;&gt; &gt;__pskb_pull_tail &lt;-vlan_gro_receive<br>
&gt;&gt; &gt;local_bh_enable &lt;-ip_finish_output<br>
&gt;&gt; &gt;skb_copy_bits &lt;-__pskb_pull_tail<br>
&gt;&gt; &gt;__local_bh_enable_ip &lt;-local_bh_enable<br>
&gt;&gt; &gt;gro_find_receive_by_type &lt;-vlan_gro_receive<br>
&gt;&gt; &gt;inet_gro_receive &lt;-vlan_gro_receive<br>
&gt;&gt; &gt;kfree_skb_partial &lt;-tcp_rcv_established<br>
&gt;&gt; &gt;__pskb_pull_tail &lt;-inet_gro_receive<br>
&gt;&gt; &gt;skb_release_all &lt;-kfree_skb_partial<br>
&gt;&gt; &gt;skb_copy_bits &lt;-__pskb_pull_tail<br>
&gt;&gt; &gt;skb_release_head_state &lt;-skb_release_all<br>
&gt;&gt; &gt;skb_release_data &lt;-skb_release_all<br>
&gt;&gt; &gt;tcp4_gro_receive &lt;-inet_gro_receive<br>
&gt;&gt; &gt;tcp_gro_receive &lt;-tcp4_gro_receive<br>
&gt;&gt; &gt;put_page &lt;-skb_release_data<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;You can see that eth_gro_receive calls vlan_gro_recieve when 8021q module<br>
&gt;&gt; &gt;is loaded and then performs ding gro_receive for the next layers as well<br>
&gt;&gt; &gt;(inet, tcp), whereas on default scenario where 8021q is not loaded the<br>
&gt;&gt; vlan<br>
&gt;&gt; &gt;device ndo cannot be used.<br>
&gt;&gt;<br>
&gt;&gt; Ah, got it.<br>
&gt;&gt;<br>
&gt;&gt; What happens is that during the module load, vlan_proto_init() registers<br>
&gt;&gt; vlan_packet_offloads:<br>
&gt;&gt;<br>
&gt;&gt;         for (i = 0; i &lt; ARRAY_SIZE(vlan_packet_offloads); i++)<br>
&gt;&gt;                 dev_add_offload(&amp;vlan_packet_offloads[i]);<br>
&gt;&gt;<br>
&gt;&gt; I think that it would make sense to move this and the related code<br>
&gt;&gt; to net/8021q/vlan_core.c<br>
&gt;&gt; Then the offloads will be there regardless if the vlan module is loaded<br>
&gt;&gt; or not.<br>
&gt;&gt;<br>
&gt;&gt; Please feel free to spin-up a patch, will be more than happy to review<br>
&gt;&gt; it. Thanks!<br>
&gt;&gt;<br>
&gt;&gt; Jiri<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;‫בתאריך יום ה׳, 25 באוק׳ 2018 ב-9:40 מאת ‪Jiri Pirko‬‏ &lt;‪<a href="mailto:jiri@resnulli.us" target="_blank">jiri@resnulli.us</a><br>
&gt;&gt; &gt;‬‏&gt;:‬<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; Wed, Oct 24, 2018 at 10:12:54PM CEST, <a href="mailto:michaelsh86@gmail.com" target="_blank">michaelsh86@gmail.com</a> wrote:<br>
&gt;&gt; &gt;&gt; &gt;Hi,<br>
&gt;&gt; &gt;&gt; &gt;I noticed that there is a performance issue when running traffic on a<br>
&gt;&gt; vlan<br>
&gt;&gt; &gt;&gt; &gt;interface that was created by OVS.<br>
&gt;&gt; &gt;&gt; &gt;If we create a bridge with a vlan interface, the 8021q module is not<br>
&gt;&gt; &gt;&gt; loaded.<br>
&gt;&gt; &gt;&gt; &gt;Then when packets with a 8021q tag arrives, the linux stack can&#39;t use<br>
&gt;&gt; the<br>
&gt;&gt; &gt;&gt; &gt;vlan ndos (such as gro_recieve) since there is no such vlan device.<br>
&gt;&gt; &gt;&gt; &gt;If I perform the same test after loading the 8021q module, I get 2x-5x<br>
&gt;&gt; &gt;&gt; &gt;better performance.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Could you please describe why exacly do you think you see this increase?<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;I personally test that using tunnels (vxlan) but I think the issue<br>
&gt;&gt; exists<br>
&gt;&gt; &gt;&gt; &gt;even without the tunnel.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;*Creating a bridge and vlan interface:*<br>
&gt;&gt; &gt;&gt; &gt;ovs-vsctl --no-wait add-br br_0<br>
&gt;&gt; &gt;&gt; &gt;ip link set br_0 up<br>
&gt;&gt; &gt;&gt; &gt;ovs-vsctl --no-wait add-port br_0 ens5f0<br>
&gt;&gt; &gt;&gt; &gt;ovs-vsctl --no-wait add-port br_0 vlan10 tag=10 -- set interface vlan10<br>
&gt;&gt; &gt;&gt; &gt;type=internal<br>
&gt;&gt; &gt;&gt; &gt;ip link set vlan10 up<br>
&gt;&gt; &gt;&gt; &gt;ip addr add &lt;ip&gt; dev vlan10<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;run traffic (netperf on the vlan10 interface) and see the result.<br>
&gt;&gt; &gt;&gt; &gt;Then do &#39;modprobe 8021q&#39; and perform the same test -&gt; you will see much<br>
&gt;&gt; &gt;&gt; &gt;better numbers.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;I am suggesting to load 80021q module once vlan interface is added<br>
&gt;&gt; through<br>
&gt;&gt; &gt;&gt; &gt;ovs.<br>
&gt;&gt; &gt;&gt; &gt;similarly as a vlan interface would be created using &#39;ip link&#39;.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;Michael<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt;<br>
</blockquote></div>