* [PATCH] power: use hugepage memory for queue list entry structure
@ 2024-12-19 7:53 Huisong Li
2025-02-20 9:01 ` lihuisong (C)
0 siblings, 1 reply; 8+ messages in thread
From: Huisong Li @ 2024-12-19 7:53 UTC (permalink / raw)
To: dev
Cc: thomas, david.hunt, anatoly.burakov, sivaprasad.tummala,
liuyonglong, lihuisong
The queue_list_entry structure data is used in rx_callback of io path
when enable PMD Power Management. However its memory is currently from
normal heap memory. For better performance, use hugepage memory to
replace it.
Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
lib/power/rte_power_pmd_mgmt.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c
index a2fff3b765..c7bf57a910 100644
--- a/lib/power/rte_power_pmd_mgmt.c
+++ b/lib/power/rte_power_pmd_mgmt.c
@@ -97,7 +97,7 @@ queue_list_find(const struct pmd_core_cfg *cfg, const union queue *q)
}
static int
-queue_list_add(struct pmd_core_cfg *cfg, const union queue *q)
+queue_list_add(struct pmd_core_cfg *cfg, const union queue *q, unsigned int lcore_id)
{
struct queue_list_entry *qle;
@@ -105,10 +105,10 @@ queue_list_add(struct pmd_core_cfg *cfg, const union queue *q)
if (queue_list_find(cfg, q) != NULL)
return -EEXIST;
- qle = malloc(sizeof(*qle));
+ qle = rte_zmalloc_socket(NULL, sizeof(*qle), RTE_CACHE_LINE_SIZE,
+ rte_lcore_to_socket_id(lcore_id));
if (qle == NULL)
return -ENOMEM;
- memset(qle, 0, sizeof(*qle));
queue_copy(&qle->queue, q);
TAILQ_INSERT_TAIL(&cfg->head, qle, next);
@@ -570,7 +570,7 @@ rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id, uint16_t port_id,
goto end;
}
/* add this queue to the list */
- ret = queue_list_add(lcore_cfg, &qdata);
+ ret = queue_list_add(lcore_cfg, &qdata, lcore_id);
if (ret < 0) {
POWER_LOG(DEBUG, "Failed to add queue to list: %s",
strerror(-ret));
@@ -664,7 +664,7 @@ rte_power_ethdev_pmgmt_queue_disable(unsigned int lcore_id,
* callbacks can be freed. we're intentionally casting away const-ness.
*/
rte_free((void *)(uintptr_t)queue_cfg->cb);
- free(queue_cfg);
+ rte_free(queue_cfg);
return 0;
}
--
2.22.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] power: use hugepage memory for queue list entry structure
2024-12-19 7:53 [PATCH] power: use hugepage memory for queue list entry structure Huisong Li
@ 2025-02-20 9:01 ` lihuisong (C)
2025-02-20 9:41 ` Konstantin Ananyev
2025-02-20 16:11 ` Stephen Hemminger
0 siblings, 2 replies; 8+ messages in thread
From: lihuisong (C) @ 2025-02-20 9:01 UTC (permalink / raw)
To: dev
Cc: thomas, david.hunt, anatoly.burakov, sivaprasad.tummala,
liuyonglong, Stephen Hemminger
Hi all,
Kindly ping for review.
在 2024/12/19 15:53, Huisong Li 写道:
> The queue_list_entry structure data is used in rx_callback of io path
> when enable PMD Power Management. However its memory is currently from
> normal heap memory. For better performance, use hugepage memory to
> replace it.
>
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> ---
> lib/power/rte_power_pmd_mgmt.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c
> index a2fff3b765..c7bf57a910 100644
> --- a/lib/power/rte_power_pmd_mgmt.c
> +++ b/lib/power/rte_power_pmd_mgmt.c
> @@ -97,7 +97,7 @@ queue_list_find(const struct pmd_core_cfg *cfg, const union queue *q)
> }
>
> static int
> -queue_list_add(struct pmd_core_cfg *cfg, const union queue *q)
> +queue_list_add(struct pmd_core_cfg *cfg, const union queue *q, unsigned int lcore_id)
> {
> struct queue_list_entry *qle;
>
> @@ -105,10 +105,10 @@ queue_list_add(struct pmd_core_cfg *cfg, const union queue *q)
> if (queue_list_find(cfg, q) != NULL)
> return -EEXIST;
>
> - qle = malloc(sizeof(*qle));
> + qle = rte_zmalloc_socket(NULL, sizeof(*qle), RTE_CACHE_LINE_SIZE,
> + rte_lcore_to_socket_id(lcore_id));
> if (qle == NULL)
> return -ENOMEM;
> - memset(qle, 0, sizeof(*qle));
>
> queue_copy(&qle->queue, q);
> TAILQ_INSERT_TAIL(&cfg->head, qle, next);
> @@ -570,7 +570,7 @@ rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id, uint16_t port_id,
> goto end;
> }
> /* add this queue to the list */
> - ret = queue_list_add(lcore_cfg, &qdata);
> + ret = queue_list_add(lcore_cfg, &qdata, lcore_id);
> if (ret < 0) {
> POWER_LOG(DEBUG, "Failed to add queue to list: %s",
> strerror(-ret));
> @@ -664,7 +664,7 @@ rte_power_ethdev_pmgmt_queue_disable(unsigned int lcore_id,
> * callbacks can be freed. we're intentionally casting away const-ness.
> */
> rte_free((void *)(uintptr_t)queue_cfg->cb);
> - free(queue_cfg);
> + rte_free(queue_cfg);
>
> return 0;
> }
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH] power: use hugepage memory for queue list entry structure
2025-02-20 9:01 ` lihuisong (C)
@ 2025-02-20 9:41 ` Konstantin Ananyev
2025-02-20 16:11 ` Stephen Hemminger
1 sibling, 0 replies; 8+ messages in thread
From: Konstantin Ananyev @ 2025-02-20 9:41 UTC (permalink / raw)
To: lihuisong (C), dev
Cc: thomas, david.hunt, anatoly.burakov, sivaprasad.tummala,
liuyonglong, Stephen Hemminger
Hi
>
> Hi all,
>
> Kindly ping for review.
>
>
> 在 2024/12/19 15:53, Huisong Li 写道:
> > The queue_list_entry structure data is used in rx_callback of io path
> > when enable PMD Power Management. However its memory is currently from
> > normal heap memory. For better performance, use hugepage memory to
> > replace it.
Make sense to me.
Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
I suppose it would also help if you can provide some numbers:
i.e.: how much exactly it is 'better'?
Did you see any changes in throughput/latency numbers, etc.
> > Signed-off-by: Huisong Li <lihuisong@huawei.com>
> > ---
> > lib/power/rte_power_pmd_mgmt.c | 10 +++++-----
> > 1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c
> > index a2fff3b765..c7bf57a910 100644
> > --- a/lib/power/rte_power_pmd_mgmt.c
> > +++ b/lib/power/rte_power_pmd_mgmt.c
> > @@ -97,7 +97,7 @@ queue_list_find(const struct pmd_core_cfg *cfg, const union queue *q)
> > }
> >
> > static int
> > -queue_list_add(struct pmd_core_cfg *cfg, const union queue *q)
> > +queue_list_add(struct pmd_core_cfg *cfg, const union queue *q, unsigned int lcore_id)
> > {
> > struct queue_list_entry *qle;
> >
> > @@ -105,10 +105,10 @@ queue_list_add(struct pmd_core_cfg *cfg, const union queue *q)
> > if (queue_list_find(cfg, q) != NULL)
> > return -EEXIST;
> >
> > - qle = malloc(sizeof(*qle));
> > + qle = rte_zmalloc_socket(NULL, sizeof(*qle), RTE_CACHE_LINE_SIZE,
> > + rte_lcore_to_socket_id(lcore_id));
> > if (qle == NULL)
> > return -ENOMEM;
> > - memset(qle, 0, sizeof(*qle));
> >
> > queue_copy(&qle->queue, q);
> > TAILQ_INSERT_TAIL(&cfg->head, qle, next);
> > @@ -570,7 +570,7 @@ rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id, uint16_t port_id,
> > goto end;
> > }
> > /* add this queue to the list */
> > - ret = queue_list_add(lcore_cfg, &qdata);
> > + ret = queue_list_add(lcore_cfg, &qdata, lcore_id);
> > if (ret < 0) {
> > POWER_LOG(DEBUG, "Failed to add queue to list: %s",
> > strerror(-ret));
> > @@ -664,7 +664,7 @@ rte_power_ethdev_pmgmt_queue_disable(unsigned int lcore_id,
> > * callbacks can be freed. we're intentionally casting away const-ness.
> > */
> > rte_free((void *)(uintptr_t)queue_cfg->cb);
> > - free(queue_cfg);
> > + rte_free(queue_cfg);
> >
> > return 0;
> > }
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] power: use hugepage memory for queue list entry structure
2025-02-20 9:01 ` lihuisong (C)
2025-02-20 9:41 ` Konstantin Ananyev
@ 2025-02-20 16:11 ` Stephen Hemminger
2025-02-20 16:39 ` Konstantin Ananyev
1 sibling, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2025-02-20 16:11 UTC (permalink / raw)
To: lihuisong (C)
Cc: dev, thomas, david.hunt, anatoly.burakov, sivaprasad.tummala,
liuyonglong
On Thu, 20 Feb 2025 17:01:53 +0800
"lihuisong (C)" <lihuisong@huawei.com> wrote:
> > The queue_list_entry structure data is used in rx_callback of io path
> > when enable PMD Power Management. However its memory is currently from
> > normal heap memory. For better performance, use hugepage memory to
> > replace it.
> >
> > Signed-off-by: Huisong Li <lihuisong@huawei.com>
How is that in a hot path where this could matter?
The safety rails in rte_malloc() are much less than regular malloc().
I prefer some degree of safety from checkers and malloc library internals.
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH] power: use hugepage memory for queue list entry structure
2025-02-20 16:11 ` Stephen Hemminger
@ 2025-02-20 16:39 ` Konstantin Ananyev
2025-02-20 16:45 ` Stephen Hemminger
0 siblings, 1 reply; 8+ messages in thread
From: Konstantin Ananyev @ 2025-02-20 16:39 UTC (permalink / raw)
To: Stephen Hemminger, lihuisong (C)
Cc: dev, thomas, david.hunt, anatoly.burakov, sivaprasad.tummala,
liuyonglong
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Thursday, February 20, 2025 4:12 PM
> To: lihuisong (C) <lihuisong@huawei.com>
> Cc: dev@dpdk.org; thomas@monjalon.net; david.hunt@intel.com; anatoly.burakov@intel.com; sivaprasad.tummala@amd.com;
> liuyonglong <liuyonglong@huawei.com>
> Subject: Re: [PATCH] power: use hugepage memory for queue list entry structure
>
> On Thu, 20 Feb 2025 17:01:53 +0800
> "lihuisong (C)" <lihuisong@huawei.com> wrote:
>
> > > The queue_list_entry structure data is used in rx_callback of io path
> > > when enable PMD Power Management. However its memory is currently from
> > > normal heap memory. For better performance, use hugepage memory to
> > > replace it.
> > >
> > > Signed-off-by: Huisong Li <lihuisong@huawei.com>
>
> How is that in a hot path where this could matter?
AFAIU - it is used in RX/TX callbacks that power library installs,
so I presume will get hit on every eth_rx_burst/tx_burst calls.
> The safety rails in rte_malloc() are much less than regular malloc().
> I prefer some degree of safety from checkers and malloc library internals.
Didn't get your point - what's suddenly wrong with rte_malloc()?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] power: use hugepage memory for queue list entry structure
2025-02-20 16:39 ` Konstantin Ananyev
@ 2025-02-20 16:45 ` Stephen Hemminger
2025-02-20 16:58 ` Konstantin Ananyev
2025-02-21 11:21 ` Burakov, Anatoly
0 siblings, 2 replies; 8+ messages in thread
From: Stephen Hemminger @ 2025-02-20 16:45 UTC (permalink / raw)
To: Konstantin Ananyev
Cc: lihuisong (C),
dev, thomas, david.hunt, anatoly.burakov, sivaprasad.tummala,
liuyonglong
On Thu, 20 Feb 2025 16:39:52 +0000
Konstantin Ananyev <konstantin.ananyev@huawei.com> wrote:
> > -----Original Message-----
> > From: Stephen Hemminger <stephen@networkplumber.org>
> > Sent: Thursday, February 20, 2025 4:12 PM
> > To: lihuisong (C) <lihuisong@huawei.com>
> > Cc: dev@dpdk.org; thomas@monjalon.net; david.hunt@intel.com; anatoly.burakov@intel.com; sivaprasad.tummala@amd.com;
> > liuyonglong <liuyonglong@huawei.com>
> > Subject: Re: [PATCH] power: use hugepage memory for queue list entry structure
> >
> > On Thu, 20 Feb 2025 17:01:53 +0800
> > "lihuisong (C)" <lihuisong@huawei.com> wrote:
> >
> > > > The queue_list_entry structure data is used in rx_callback of io path
> > > > when enable PMD Power Management. However its memory is currently from
> > > > normal heap memory. For better performance, use hugepage memory to
> > > > replace it.
> > > >
> > > > Signed-off-by: Huisong Li <lihuisong@huawei.com>
> >
> > How is that in a hot path where this could matter?
>
> AFAIU - it is used in RX/TX callbacks that power library installs,
> so I presume will get hit on every eth_rx_burst/tx_burst calls.
>
> > The safety rails in rte_malloc() are much less than regular malloc().
> > I prefer some degree of safety from checkers and malloc library internals.
>
> Didn't get your point - what's suddenly wrong with rte_malloc()?
Coverity and Gcc analyzer treat malloc as special case.
With attributes rte_malloc gets similar treatment but not quite as much.
Also internally, malloc and free have more heap pool sanity checks.
In name of performance, those don't exist in rte_malloc().
Lastly hugepages are limited resource, so they should only be used when needed.
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH] power: use hugepage memory for queue list entry structure
2025-02-20 16:45 ` Stephen Hemminger
@ 2025-02-20 16:58 ` Konstantin Ananyev
2025-02-21 11:21 ` Burakov, Anatoly
1 sibling, 0 replies; 8+ messages in thread
From: Konstantin Ananyev @ 2025-02-20 16:58 UTC (permalink / raw)
To: Stephen Hemminger
Cc: lihuisong (C),
dev, thomas, david.hunt, anatoly.burakov, sivaprasad.tummala,
liuyonglong
> > > -----Original Message-----
> > > From: Stephen Hemminger <stephen@networkplumber.org>
> > > Sent: Thursday, February 20, 2025 4:12 PM
> > > To: lihuisong (C) <lihuisong@huawei.com>
> > > Cc: dev@dpdk.org; thomas@monjalon.net; david.hunt@intel.com; anatoly.burakov@intel.com; sivaprasad.tummala@amd.com;
> > > liuyonglong <liuyonglong@huawei.com>
> > > Subject: Re: [PATCH] power: use hugepage memory for queue list entry structure
> > >
> > > On Thu, 20 Feb 2025 17:01:53 +0800
> > > "lihuisong (C)" <lihuisong@huawei.com> wrote:
> > >
> > > > > The queue_list_entry structure data is used in rx_callback of io path
> > > > > when enable PMD Power Management. However its memory is currently from
> > > > > normal heap memory. For better performance, use hugepage memory to
> > > > > replace it.
> > > > >
> > > > > Signed-off-by: Huisong Li <lihuisong@huawei.com>
> > >
> > > How is that in a hot path where this could matter?
> >
> > AFAIU - it is used in RX/TX callbacks that power library installs,
> > so I presume will get hit on every eth_rx_burst/tx_burst calls.
> >
> > > The safety rails in rte_malloc() are much less than regular malloc().
> > > I prefer some degree of safety from checkers and malloc library internals.
> >
> > Didn't get your point - what's suddenly wrong with rte_malloc()?
>
> Coverity and Gcc analyzer treat malloc as special case.
> With attributes rte_malloc gets similar treatment but not quite as much.
> Also internally, malloc and free have more heap pool sanity checks.
> In name of performance, those don't exist in rte_malloc().
> Lastly hugepages are limited resource, so they should only be used when needed.
Ok, I understand all that, but what you suggest then - not use rte_malloc() anywhere
In DPDK code, even when it is a hot-path?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] power: use hugepage memory for queue list entry structure
2025-02-20 16:45 ` Stephen Hemminger
2025-02-20 16:58 ` Konstantin Ananyev
@ 2025-02-21 11:21 ` Burakov, Anatoly
1 sibling, 0 replies; 8+ messages in thread
From: Burakov, Anatoly @ 2025-02-21 11:21 UTC (permalink / raw)
To: Stephen Hemminger, Konstantin Ananyev
Cc: lihuisong (C), dev, thomas, david.hunt, sivaprasad.tummala, liuyonglong
On 20/02/2025 17:45, Stephen Hemminger wrote:
> On Thu, 20 Feb 2025 16:39:52 +0000
> Konstantin Ananyev <konstantin.ananyev@huawei.com> wrote:
>
>>> -----Original Message-----
>>> From: Stephen Hemminger <stephen@networkplumber.org>
>>> Sent: Thursday, February 20, 2025 4:12 PM
>>> To: lihuisong (C) <lihuisong@huawei.com>
>>> Cc: dev@dpdk.org; thomas@monjalon.net; david.hunt@intel.com; anatoly.burakov@intel.com; sivaprasad.tummala@amd.com;
>>> liuyonglong <liuyonglong@huawei.com>
>>> Subject: Re: [PATCH] power: use hugepage memory for queue list entry structure
>>>
>>> On Thu, 20 Feb 2025 17:01:53 +0800
>>> "lihuisong (C)" <lihuisong@huawei.com> wrote:
>>>
>>>>> The queue_list_entry structure data is used in rx_callback of io path
>>>>> when enable PMD Power Management. However its memory is currently from
>>>>> normal heap memory. For better performance, use hugepage memory to
>>>>> replace it.
>>>>>
>>>>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>>>
>>> How is that in a hot path where this could matter?
>>
>> AFAIU - it is used in RX/TX callbacks that power library installs,
>> so I presume will get hit on every eth_rx_burst/tx_burst calls.
>>
>>> The safety rails in rte_malloc() are much less than regular malloc().
>>> I prefer some degree of safety from checkers and malloc library internals.
>>
>> Didn't get your point - what's suddenly wrong with rte_malloc()?
>
> Coverity and Gcc analyzer treat malloc as special case.
> With attributes rte_malloc gets similar treatment but not quite as much.
> Also internally, malloc and free have more heap pool sanity checks.
> In name of performance, those don't exist in rte_malloc().
> Lastly hugepages are limited resource, so they should only be used when needed.
The last thing I would associate with rte_malloc is performance. I'm not
sure I follow - which "sanity checks" were omitted from rte_malloc "in
the name of performance" that are present in regular malloc?
--
Thanks,
Anatoly
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-02-21 11:22 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-19 7:53 [PATCH] power: use hugepage memory for queue list entry structure Huisong Li
2025-02-20 9:01 ` lihuisong (C)
2025-02-20 9:41 ` Konstantin Ananyev
2025-02-20 16:11 ` Stephen Hemminger
2025-02-20 16:39 ` Konstantin Ananyev
2025-02-20 16:45 ` Stephen Hemminger
2025-02-20 16:58 ` Konstantin Ananyev
2025-02-21 11:21 ` Burakov, Anatoly
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).