[dpdk-dev] [PATCH] malloc: fix memory element size in case of padding

Xueming(Steven) Li xuemingl at mellanox.com
Tue Nov 26 14:39:57 CET 2019



> -----Original Message-----
> From: Thomas Monjalon <thomas at monjalon.net>
> Sent: Tuesday, November 26, 2019 9:30 PM
> To: Burakov, Anatoly <anatoly.burakov at intel.com>
> Cc: Xueming(Steven) Li <xuemingl at mellanox.com>; dev at dpdk.org; Asaf
> Penso <asafp at mellanox.com>; stable at dpdk.org;
> david.marchand at redhat.com
> Subject: Re: [dpdk-dev] [PATCH] malloc: fix memory element size in case of
> padding
> 
> 26/11/2019 13:57, Burakov, Anatoly:
> > On 25-Nov-19 11:24 PM, Thomas Monjalon wrote:
> > > 21/11/2019 16:14, Burakov, Anatoly:
> > >> On 21-Nov-19 2:25 PM, Xueming Li wrote:
> > >>> This patch fixes wrong inner memory element size when joining two
> > >>> elements.
> > >>>
> > >>> Fixes: af75078fece3 ("first public release")
> > >>> Cc: stable at dpdk.org
> > >>>
> > >>> Signed-off-by: Xueming Li <xuemingl at mellanox.com>
> > >>> ---
> > >>> --- a/lib/librte_eal/common/malloc_elem.c
> > >>> +++ b/lib/librte_eal/common/malloc_elem.c
> > >>> @@ -487,6 +487,10 @@ join_elem(struct malloc_elem *elem1, struct
> malloc_elem *elem2)
> > >>>    	else
> > >>>    		elem1->heap->last = elem1;
> > >>>    	elem1->next = next;
> > >>> +	if (elem1->pad) {
> > >>> +		struct malloc_elem *inner = RTE_PTR_ADD(elem1, elem1-
> >pad);
> > >>> +		inner->size = elem1->size - elem1->pad;
> > >>> +	}
> > >>>    }
> > >>
> > >> Reviewed-by: Anatoly Burakov <anatoly.burakov at intel.com>
> > >
> > > I don't understand this patch.
> > > The variable inner is never used.
> > > What am I missing?
> > >
> >
> > For padded elements, malloc element has two headers - the "outer"
> > header with empty space after it, and the "inner" header, after which
> > the user memory actually starts. This makes it so that, when joining
> > elements, if the outer element had a pad, we also update the inner
> element size to match.
> 
> Where the variable "inner" is used in this function?
> 
Rte_realloc, inner size is used to copy data.


More information about the dev mailing list