reorder: improve buffer structure layout

Message ID 20230414084344.271602-1-vfialko@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series reorder: improve buffer structure layout |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Volodymyr Fialko April 14, 2023, 8:43 a.m. UTC
  Rearrange the reorder buffer structure to prevent padding to extra one
cache line.

Current layout:
struct rte_reorder_buffer {
        char name[RTE_REORDER_NAMESIZE];
        uint32_t min_seqn;
        unsigned int memsize;
// -> padding to cache align (cir_buffer is also cache aligned)
        struct cir_buffer ready_buf;
        struct cir_buffer order_buf;
        int is_initialized;
// -> padding to cache align, eat whole line
};

New layout:
struct rte_reorder_buffer {
        char name[RTE_REORDER_NAMESIZE];
        uint32_t min_seqn;
        unsigned int memsize;
        int is_initialized;
// -> padding to cache align (cir_buffer is also cache aligned)
        struct cir_buffer ready_buf;
        struct cir_buffer order_buf;
// -> no padding
};

Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
---
 lib/reorder/rte_reorder.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Bruce Richardson April 14, 2023, 9:26 a.m. UTC | #1
On Fri, Apr 14, 2023 at 10:43:43AM +0200, Volodymyr Fialko wrote:
> Rearrange the reorder buffer structure to prevent padding to extra one
> cache line.
> 
> Current layout:
> struct rte_reorder_buffer {
>         char name[RTE_REORDER_NAMESIZE];
>         uint32_t min_seqn;
>         unsigned int memsize;
> // -> padding to cache align (cir_buffer is also cache aligned)
>         struct cir_buffer ready_buf;
>         struct cir_buffer order_buf;
>         int is_initialized;
> // -> padding to cache align, eat whole line
> };
> 
> New layout:
> struct rte_reorder_buffer {
>         char name[RTE_REORDER_NAMESIZE];
>         uint32_t min_seqn;
>         unsigned int memsize;
>         int is_initialized;
> // -> padding to cache align (cir_buffer is also cache aligned)
>         struct cir_buffer ready_buf;
>         struct cir_buffer order_buf;
> // -> no padding
> };
> 
> Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> ---

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

>  lib/reorder/rte_reorder.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c
> index f55f383700..7418202b04 100644
> --- a/lib/reorder/rte_reorder.c
> +++ b/lib/reorder/rte_reorder.c
> @@ -46,9 +46,10 @@ struct rte_reorder_buffer {
>  	char name[RTE_REORDER_NAMESIZE];
>  	uint32_t min_seqn;  /**< Lowest seq. number that can be in the buffer */
>  	unsigned int memsize; /**< memory area size of reorder buffer */
> +	int is_initialized; /**< flag indicates that buffer was initialized */
> +

Since we are moving it, it might be an opportunity to change it from "int"
to "bool".

>  	struct cir_buffer ready_buf; /**< temp buffer for dequeued entries */
>  	struct cir_buffer order_buf; /**< buffer used to reorder entries */
> -	int is_initialized;
>  } __rte_cache_aligned;
>  
>  static void
> -- 
> 2.34.1
>
  
Stephen Hemminger April 14, 2023, 2:52 p.m. UTC | #2
On Fri, 14 Apr 2023 10:43:43 +0200
Volodymyr Fialko <vfialko@marvell.com> wrote:

> diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c
> index f55f383700..7418202b04 100644
> --- a/lib/reorder/rte_reorder.c
> +++ b/lib/reorder/rte_reorder.c
> @@ -46,9 +46,10 @@ struct rte_reorder_buffer {
>  	char name[RTE_REORDER_NAMESIZE];
>  	uint32_t min_seqn;  /**< Lowest seq. number that can be in the buffer */
>  	unsigned int memsize; /**< memory area size of reorder buffer */
> +	int is_initialized; /**< flag indicates that buffer was initialized */
> +
>  	struct cir_buffer ready_buf; /**< temp buffer for dequeued entries */
>  	struct cir_buffer order_buf; /**< buffer used to reorder entries */
> -	int is_initialized;
>  } __rte_cache_aligned;
>  
>  static void

Since this is ABI change it will have to wait for 23.11 release
  
Bruce Richardson April 14, 2023, 2:54 p.m. UTC | #3
On Fri, Apr 14, 2023 at 07:52:30AM -0700, Stephen Hemminger wrote:
> On Fri, 14 Apr 2023 10:43:43 +0200
> Volodymyr Fialko <vfialko@marvell.com> wrote:
> 
> > diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c
> > index f55f383700..7418202b04 100644
> > --- a/lib/reorder/rte_reorder.c
> > +++ b/lib/reorder/rte_reorder.c
> > @@ -46,9 +46,10 @@ struct rte_reorder_buffer {
> >  	char name[RTE_REORDER_NAMESIZE];
> >  	uint32_t min_seqn;  /**< Lowest seq. number that can be in the buffer */
> >  	unsigned int memsize; /**< memory area size of reorder buffer */
> > +	int is_initialized; /**< flag indicates that buffer was initialized */
> > +
> >  	struct cir_buffer ready_buf; /**< temp buffer for dequeued entries */
> >  	struct cir_buffer order_buf; /**< buffer used to reorder entries */
> > -	int is_initialized;
> >  } __rte_cache_aligned;
> >  
> >  static void
> 
> Since this is ABI change it will have to wait for 23.11 release

It shouldn't be an ABI change. This struct is defined in a C file, rather
than a header, so is not exposed to end applications.

/Bruce
  
Stephen Hemminger April 14, 2023, 3:30 p.m. UTC | #4
On Fri, 14 Apr 2023 15:54:13 +0100
Bruce Richardson <bruce.richardson@intel.com> wrote:

> On Fri, Apr 14, 2023 at 07:52:30AM -0700, Stephen Hemminger wrote:
> > On Fri, 14 Apr 2023 10:43:43 +0200
> > Volodymyr Fialko <vfialko@marvell.com> wrote:
> >   
> > > diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c
> > > index f55f383700..7418202b04 100644
> > > --- a/lib/reorder/rte_reorder.c
> > > +++ b/lib/reorder/rte_reorder.c
> > > @@ -46,9 +46,10 @@ struct rte_reorder_buffer {
> > >  	char name[RTE_REORDER_NAMESIZE];
> > >  	uint32_t min_seqn;  /**< Lowest seq. number that can be in the buffer */
> > >  	unsigned int memsize; /**< memory area size of reorder buffer */
> > > +	int is_initialized; /**< flag indicates that buffer was initialized */
> > > +
> > >  	struct cir_buffer ready_buf; /**< temp buffer for dequeued entries */
> > >  	struct cir_buffer order_buf; /**< buffer used to reorder entries */
> > > -	int is_initialized;
> > >  } __rte_cache_aligned;
> > >  
> > >  static void  
> > 
> > Since this is ABI change it will have to wait for 23.11 release  
> 
> It shouldn't be an ABI change. This struct is defined in a C file, rather
> than a header, so is not exposed to end applications.
> 
> /Bruce

Sorry, Bruce is right. 
You might want to use uint8_t or bool for a simple flag.
  
Tyler Retzlaff April 14, 2023, 5:07 p.m. UTC | #5
On Fri, Apr 14, 2023 at 10:26:26AM +0100, Bruce Richardson wrote:
> On Fri, Apr 14, 2023 at 10:43:43AM +0200, Volodymyr Fialko wrote:
> > Rearrange the reorder buffer structure to prevent padding to extra one
> > cache line.
> > 
> > Current layout:
> > struct rte_reorder_buffer {
> >         char name[RTE_REORDER_NAMESIZE];
> >         uint32_t min_seqn;
> >         unsigned int memsize;
> > // -> padding to cache align (cir_buffer is also cache aligned)
> >         struct cir_buffer ready_buf;
> >         struct cir_buffer order_buf;
> >         int is_initialized;
> > // -> padding to cache align, eat whole line
> > };
> > 
> > New layout:
> > struct rte_reorder_buffer {
> >         char name[RTE_REORDER_NAMESIZE];
> >         uint32_t min_seqn;
> >         unsigned int memsize;
> >         int is_initialized;
> > // -> padding to cache align (cir_buffer is also cache aligned)
> >         struct cir_buffer ready_buf;
> >         struct cir_buffer order_buf;
> > // -> no padding
> > };
> > 
> > Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> > ---
> 
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> >  lib/reorder/rte_reorder.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c
> > index f55f383700..7418202b04 100644
> > --- a/lib/reorder/rte_reorder.c
> > +++ b/lib/reorder/rte_reorder.c
> > @@ -46,9 +46,10 @@ struct rte_reorder_buffer {
> >  	char name[RTE_REORDER_NAMESIZE];
> >  	uint32_t min_seqn;  /**< Lowest seq. number that can be in the buffer */
> >  	unsigned int memsize; /**< memory area size of reorder buffer */
> > +	int is_initialized; /**< flag indicates that buffer was initialized */
> > +
> 
> Since we are moving it, it might be an opportunity to change it from "int"
> to "bool".

+1

> 
> >  	struct cir_buffer ready_buf; /**< temp buffer for dequeued entries */
> >  	struct cir_buffer order_buf; /**< buffer used to reorder entries */
> > -	int is_initialized;
> >  } __rte_cache_aligned;
> >  
> >  static void
> > -- 
> > 2.34.1
> >
  

Patch

diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c
index f55f383700..7418202b04 100644
--- a/lib/reorder/rte_reorder.c
+++ b/lib/reorder/rte_reorder.c
@@ -46,9 +46,10 @@  struct rte_reorder_buffer {
 	char name[RTE_REORDER_NAMESIZE];
 	uint32_t min_seqn;  /**< Lowest seq. number that can be in the buffer */
 	unsigned int memsize; /**< memory area size of reorder buffer */
+	int is_initialized; /**< flag indicates that buffer was initialized */
+
 	struct cir_buffer ready_buf; /**< temp buffer for dequeued entries */
 	struct cir_buffer order_buf; /**< buffer used to reorder entries */
-	int is_initialized;
 } __rte_cache_aligned;
 
 static void