Skip to content

Commit

Permalink
dpif-netdev: Fix misaligned access.
Browse files Browse the repository at this point in the history
Remove the forced cache-line size alignment markers from
struct dp_netdev_pmd_thread and struct dp_netdev as discussed
at [0].  They don't seem to add any benefit and cause 64 byte
alignment requirements.

UB Sanitizer report:
  lib/dpif-netdev.c:6758:13:
        runtime error: member access within misaligned address 0x7f7f24d25010
        for type 'struct dp_netdev_pmd_thread', which requires 64 byte alignment
  0x7f7f24d25010: note: pointer points here
   00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 ...
                ^
     #0 0x5fbfde in dp_netdev_configure_pmd lib/dpif-netdev.c:6758
     openvswitch#1 0x5fbde9 in dp_netdev_set_nonpmd lib/dpif-netdev.c:6715
     openvswitch#2 0x5d6fdd in create_dp_netdev lib/dpif-netdev.c:1769
     openvswitch#3 0x5d72d0 in dpif_netdev_open lib/dpif-netdev.c:1807
     #4 0x61c83f in do_open lib/dpif.c:347
     [...]
  lib/dpif-netdev.c:1724:6:
        runtime error: member access within misaligned address 0x000002005eb0
        for type 'struct dp_netdev', which requires 64 byte alignment
  0x000002005eb0: note: pointer points here
   00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 ...
                ^
      #0 0x5d6660 in create_dp_netdev lib/dpif-netdev.c:1724
      openvswitch#1 0x5d72d0 in dpif_netdev_open lib/dpif-netdev.c:1807
      openvswitch#2 0x61c846 in do_open lib/dpif.c:347
      openvswitch#3 0x61ca9c in dpif_create lib/dpif.c:402
      #4 0x61cac9 in dpif_create_and_open lib/dpif.c:415
      #5 0x48f235 in open_dpif_backer ofproto/ofproto-dpif.c:776
      [...]

[0] https://mail.openvswitch.org/pipermail/ovs-dev/2021-December/390256.html

Suggested-by: Ilya Maximets <[email protected]>
Signed-off-by: Dumitru Ceara <[email protected]>
Acked-by: Paolo Valerio <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
dceara authored and igsilya committed Feb 14, 2022
1 parent 8ed26a8 commit 5a9bb85
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/dpif-netdev-private-thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct dp_netdev_pmd_thread {
* instance for cpu core NON_PMD_CORE_ID can be accessed by multiple
* threads, and thusly need to be protected by 'non_pmd_mutex'. Every
* other instance will only be accessed by its own pmd thread. */
OVS_ALIGNED_VAR(CACHE_LINE_SIZE) struct dfc_cache flow_cache;
struct dfc_cache flow_cache;

/* Flow-Table and classifiers
*
Expand Down
2 changes: 1 addition & 1 deletion lib/dpif-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ struct dp_netdev {
struct cmap meters OVS_GUARDED;

/* Probability of EMC insertions is a factor of 'emc_insert_min'.*/
OVS_ALIGNED_VAR(CACHE_LINE_SIZE) atomic_uint32_t emc_insert_min;
atomic_uint32_t emc_insert_min;
/* Enable collection of PMD performance metrics. */
atomic_bool pmd_perf_metrics;
/* Enable the SMC cache from ovsdb config */
Expand Down

0 comments on commit 5a9bb85

Please sign in to comment.