From: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
To: fengchengwen <fengchengwen@huawei.com>,
Jerin Jacob <jerinj@marvell.com>,
Kevin Laatz <kevin.laatz@intel.com>,
Bruce Richardson <bruce.richardson@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: RE: [EXT] Re: [PATCH] dmadev: standardize alignment and allocation
Date: Sat, 10 Feb 2024 06:20:43 +0000 [thread overview]
Message-ID: <PH0PR18MB408639A3CF161F79A8952256DE4A2@PH0PR18MB4086.namprd18.prod.outlook.com> (raw)
In-Reply-To: <97c4bca5-39f6-c66b-bb51-675c3695b3d1@huawei.com>
> Hi Pavan,
>
> Alloc fp_objects from rte_memory is a good idea, but this may cause
> the rte_memory memory leak, especially in multi-process scenario.
>
> Currently, there is no mechanism for releasing such a rte_memory which
> don't belong to any driver.
>
Yeah, secondary process will leak rte_zmalloc allocations if not freed.
The only option currently is to use mmap and allocate non-shared memory
on secondary, which is not ideal.
> So I suggest: maybe we could add rte_mem_align API which alloc from libc
> and use in this cases.
>
Yeah, maybe in future we could add something like rte_zmalloc_private which
would create new mappings on secondary process. But that is out of scope for
this patch.
I will send a v2 dropping the malloc changes and keeping the cache alignment changes.
> BTW: the rte_dma_devices is only used in control-path, so it don't need
> use rte_memory API, but I think it could use the new rte_mem_align API.
>
> Thanks
>
Thanks,
Pavan.
> On 2024/2/2 17:06, pbhagavatula@marvell.com wrote:
> > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> >
> > Align fp_objects based on cacheline size, allocate
> > devices and fp_objects memory on hugepages.
> >
> > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > ---
> > lib/dmadev/rte_dmadev.c | 6 ++----
> > lib/dmadev/rte_dmadev_core.h | 2 +-
> > 2 files changed, 3 insertions(+), 5 deletions(-)
> >
> > diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
> > index 67434c805f43..1fe1434019f0 100644
> > --- a/lib/dmadev/rte_dmadev.c
> > +++ b/lib/dmadev/rte_dmadev.c
> > @@ -143,10 +143,9 @@ dma_fp_data_prepare(void)
> > */
> > size = dma_devices_max * sizeof(struct rte_dma_fp_object) +
> > RTE_CACHE_LINE_SIZE;
> > - ptr = malloc(size);
> > + ptr = rte_zmalloc("", size, RTE_CACHE_LINE_SIZE);
> > if (ptr == NULL)
> > return -ENOMEM;
> > - memset(ptr, 0, size);
> >
> > rte_dma_fp_objs = RTE_PTR_ALIGN(ptr, RTE_CACHE_LINE_SIZE);
> > for (i = 0; i < dma_devices_max; i++)
> > @@ -164,10 +163,9 @@ dma_dev_data_prepare(void)
> > return 0;
> >
> > size = dma_devices_max * sizeof(struct rte_dma_dev);
> > - rte_dma_devices = malloc(size);
> > + rte_dma_devices = rte_zmalloc("", size, RTE_CACHE_LINE_SIZE);
> > if (rte_dma_devices == NULL)
> > return -ENOMEM;
> > - memset(rte_dma_devices, 0, size);
> >
> > return 0;
> > }
> > diff --git a/lib/dmadev/rte_dmadev_core.h
> b/lib/dmadev/rte_dmadev_core.h
> > index 064785686f7f..e8239c2d22b6 100644
> > --- a/lib/dmadev/rte_dmadev_core.h
> > +++ b/lib/dmadev/rte_dmadev_core.h
> > @@ -73,7 +73,7 @@ struct rte_dma_fp_object {
> > rte_dma_completed_t completed;
> > rte_dma_completed_status_t completed_status;
> > rte_dma_burst_capacity_t burst_capacity;
> > -} __rte_aligned(128);
> > +} __rte_cache_aligned;
> >
> > extern struct rte_dma_fp_object *rte_dma_fp_objs;
> >
> >
next prev parent reply other threads:[~2024-02-10 6:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-02 9:06 pbhagavatula
2024-02-04 1:38 ` fengchengwen
2024-02-10 6:20 ` Pavan Nikhilesh Bhagavatula [this message]
2024-02-10 6:27 ` [PATCH v2] dmadev: standardize alignment pbhagavatula
2024-02-10 11:34 ` fengchengwen
2024-02-19 1:32 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=PH0PR18MB408639A3CF161F79A8952256DE4A2@PH0PR18MB4086.namprd18.prod.outlook.com \
--to=pbhagavatula@marvell.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
--cc=jerinj@marvell.com \
--cc=kevin.laatz@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).