All instances of struct dp_netdev_pmd_thread are allocated by xzalloc
and therefore doesn't guarantee memory allocation aligned on
CACHE_LINE_SIZE boundary. Due to this any padding done inside
the structure with this assumption might create holes.
This commit replaces xzalloc, free with xzalloc_cacheline and
free_cacheline. With the changes the memory is 64 byte aligned.
Before: With xzalloc, all the memory is 16 byte aligned.
(gdb) p pmd
$1 = (struct dp_netdev_pmd_thread *) 0x7eff8a813010
After: With xzalloc_cacheline, all the memory is 64 byte aligned.
(gdb) p pmd
$1 = (struct dp_netdev_pmd_thread *) 0x7f39e2365040
Reported-by: Ilya Maximets <i.maximets at samsung.com>
Signed-off-by: Bhanuprakash Bodireddy <[email protected]>
---
v1 -> v2
* Allocate memory for non-pmd thread using xzalloc_cacheline().
lib/dpif-netdev.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index c7d157a..ef8ebf2 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -3732,7 +3732,7 @@ reconfigure_pmd_threads(struct dp_netdev *dp)
FOR_EACH_CORE_ON_DUMP(core, pmd_cores) {
pmd = dp_netdev_get_pmd(dp, core->core_id);
if (!pmd) {
- pmd = xzalloc(sizeof *pmd);
+ pmd = xzalloc_cacheline(sizeof *pmd);
dp_netdev_configure_pmd(pmd, dp, core->core_id, core->numa_id);
pmd->thread = ovs_thread_create("pmd", pmd_thread_main, pmd);
VLOG_INFO("PMD thread on numa_id: %d, core id: %2d created.",
@@ -4565,7 +4565,7 @@ dp_netdev_set_nonpmd(struct dp_netdev *dp)
{
struct dp_netdev_pmd_thread *non_pmd;
- non_pmd = xzalloc(sizeof *non_pmd);
+ non_pmd = xzalloc_cacheline(sizeof *non_pmd);
dp_netdev_configure_pmd(non_pmd, dp, NON_PMD_CORE_ID, OVS_NUMA_UNSPEC);
}
@@ -4665,7 +4665,7 @@ dp_netdev_destroy_pmd(struct dp_netdev_pmd_thread *pmd)
xpthread_cond_destroy(&pmd->cond);
ovs_mutex_destroy(&pmd->cond_mutex);
ovs_mutex_destroy(&pmd->port_mutex);
- free(pmd);
+ free_cacheline(pmd);
}
/* Stops the pmd thread, removes it from the 'dp->poll_threads',
--
2.4.11
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev