diff mbox series

[v2,3/3] linux-generic: packet: reorder reference fields for performance

Message ID 1502748005-17591-4-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [v2,1/3] linux-generic: packet: improve packet_init() performance | expand

Commit Message

Github ODP bot Aug. 14, 2017, 10 p.m. UTC
From: Bill Fischofer <bill.fischofer@linaro.org>


The ref_count and ref_hdr fields are the only fields referenced in
non-reference packet processing paths, so move them to be closer to
the current frame_len field so they are in the same cache line. This
results in significant improvement in odp_bench_packet measurements.

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

---
/** Email created from pull request 125 (Bill-Fischofer-Linaro:pktrefs-opt)
 ** https://github.com/Linaro/odp/pull/125
 ** Patch: https://github.com/Linaro/odp/pull/125.patch
 ** Base sha: 90d4ce1b3b25ca18446131906007571cc0ed0191
 ** Merge commit sha: 6d464aeb30e24833ae787e3997a411103c16c70c
 **/
 platform/linux-generic/include/odp/api/plat/packet_types.h | 4 ++--
 platform/linux-generic/include/odp_packet_internal.h       | 7 ++++---
 platform/linux-generic/odp_packet.c                        | 2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/platform/linux-generic/include/odp/api/plat/packet_types.h b/platform/linux-generic/include/odp/api/plat/packet_types.h
index 1554c3af..b7236412 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_types.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_types.h
@@ -84,14 +84,14 @@  typedef struct _odp_packet_inline_offset_t {
 	/** @internal field offset */
 	size_t tailroom;
 	/** @internal field offset */
-	size_t unshared_len;
-	/** @internal field offset */
 	size_t ref_hdr;
 	/** @internal field offset */
 	size_t ref_offset;
 	/** *internal field offset */
 	size_t ref_len;
 	/** @internal field offset */
+	size_t unshared_len;
+	/** @internal field offset */
 	size_t pool;
 	/** @internal field offset */
 	size_t input;
diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index 48c2463f..dfe131b1 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -124,7 +124,8 @@  typedef struct odp_packet_hdr_t {
 	uint32_t tailroom;
 
 	/* Fields used to support packet references */
-	uint32_t unshared_len;
+	/* Incremented on refs, decremented on frees. */
+	odp_atomic_u32_t ref_count;
 	/* Next pkt_hdr in reference chain */
 	struct odp_packet_hdr_t *ref_hdr;
 	/* Offset into next pkt_hdr that ref was created at */
@@ -133,8 +134,8 @@  typedef struct odp_packet_hdr_t {
 	 * allows original offset to be maintained when base pkt len
 	 * is changed */
 	uint32_t ref_len;
-	/* Incremented on refs, decremented on frees. */
-	odp_atomic_u32_t ref_count;
+	/* Track unshared portion of frame_len */
+	uint32_t unshared_len;
 
 	/*
 	 * Members below are not initialized by packet_init()
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index a71a5926..dd5be38a 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -33,10 +33,10 @@  const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = {
 	.frame_len      = offsetof(odp_packet_hdr_t, frame_len),
 	.headroom       = offsetof(odp_packet_hdr_t, headroom),
 	.tailroom       = offsetof(odp_packet_hdr_t, tailroom),
-	.unshared_len   = offsetof(odp_packet_hdr_t, unshared_len),
 	.ref_hdr        = offsetof(odp_packet_hdr_t, ref_hdr),
 	.ref_offset     = offsetof(odp_packet_hdr_t, ref_offset),
 	.ref_len        = offsetof(odp_packet_hdr_t, ref_len),
+	.unshared_len   = offsetof(odp_packet_hdr_t, unshared_len),
 	.pool           = offsetof(odp_packet_hdr_t, buf_hdr.pool_hdl),
 	.input          = offsetof(odp_packet_hdr_t, input),
 	.segcount       = offsetof(odp_packet_hdr_t, buf_hdr.segcount),