udp: align udp_encap_t_ to 2 cachelines 25/27525/3
authorVadym Martsynovskyy <vmartsyn@fb.com>
Fri, 12 Jun 2020 16:50:50 +0000 (09:50 -0700)
committerDamjan Marion <dmarion@me.com>
Sat, 27 Jun 2020 10:27:55 +0000 (10:27 +0000)
Based on the comments in the struct, udp_encap_t_ is meant to span 2
cachelines. Due to the 64 bit alignment of dpo_id_t, the struct spanned
3 cachelines. This caused fetching ue_ip_proto to trigger an additional
cache miss. This patch rearranges the ordering of the struct fields
so that udp_encap_t_ only spans 2 cachelines as intended.

before:
(gdb) print (int)&((struct udp_encap_t_*)0)->cacheline1
$8 = 128

after:
(gdb) print (int)&((struct udp_encap_t_*)0)->cacheline1
$1 = 64

Type: fix
Signed-off-by: Vadym Martsynovskyy <vmartsyn@fb.com>
Change-Id: I066c08654d4a8ef3e2d3954e957d4c5d382b209f

src/vnet/udp/udp_encap.h

index 888efa8..9d82e59 100644 (file)
@@ -68,14 +68,14 @@ typedef struct udp_encap_t_
   } __attribute__ ((packed)) ue_hdrs;
 
   /**
-   * Flags controlling fixup behaviour
+   * The DPO used to forward to the next node in the VLIB graph
    */
-  udp_encap_fixup_flags_t ue_flags;
+  dpo_id_t ue_dpo;
 
   /**
-   * The DPO used to forward to the next node in the VLIB graph
+   * Flags controlling fixup behaviour
    */
-  dpo_id_t ue_dpo;
+  udp_encap_fixup_flags_t ue_flags;
 
   /**
    * the protocol of the IP header imposed