* [PATCH] net/pcap: fix indentation and numa node
@ 2025-04-05 15:36 Stephen Hemminger
2025-04-07 9:51 ` Bruce Richardson
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2025-04-05 15:36 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
The process private data allocation was indented incorrectly
in the source code, and had unnecessary cast. It is better
that the data be allocated on same numa node as the device
structure.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/pcap/pcap_ethdev.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c
index 728ef85d53..aefa74c7be 100644
--- a/drivers/net/pcap/pcap_ethdev.c
+++ b/drivers/net/pcap/pcap_ethdev.c
@@ -1208,10 +1208,8 @@ pmd_init_internals(struct rte_vdev_device *vdev,
PMD_LOG(INFO, "Creating pcap-backed ethdev on numa socket %d",
numa_node);
- pp = (struct pmd_process_private *)
- rte_zmalloc(NULL, sizeof(struct pmd_process_private),
- RTE_CACHE_LINE_SIZE);
-
+ pp = rte_zmalloc_socket(NULL, sizeof(struct pmd_process_private),
+ RTE_CACHE_LINE_SIZE, numa_node);
if (pp == NULL) {
PMD_LOG(ERR,
"Failed to allocate memory for process private");
@@ -1578,11 +1576,8 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
unsigned int i;
internal = eth_dev->data->dev_private;
- pp = (struct pmd_process_private *)
- rte_zmalloc(NULL,
- sizeof(struct pmd_process_private),
- RTE_CACHE_LINE_SIZE);
-
+ pp = rte_zmalloc_socket(NULL, sizeof(struct pmd_process_private),
+ RTE_CACHE_LINE_SIZE, dev->device.numa_node);
if (pp == NULL) {
PMD_LOG(ERR,
"Failed to allocate memory for process private");
--
2.47.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net/pcap: fix indentation and numa node
2025-04-05 15:36 [PATCH] net/pcap: fix indentation and numa node Stephen Hemminger
@ 2025-04-07 9:51 ` Bruce Richardson
2025-04-07 15:08 ` Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: Bruce Richardson @ 2025-04-07 9:51 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev
On Sat, Apr 05, 2025 at 08:36:23AM -0700, Stephen Hemminger wrote:
> The process private data allocation was indented incorrectly
> in the source code, and had unnecessary cast. It is better
> that the data be allocated on same numa node as the device
> structure.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> drivers/net/pcap/pcap_ethdev.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c
> index 728ef85d53..aefa74c7be 100644
> --- a/drivers/net/pcap/pcap_ethdev.c
> +++ b/drivers/net/pcap/pcap_ethdev.c
> @@ -1208,10 +1208,8 @@ pmd_init_internals(struct rte_vdev_device *vdev,
> PMD_LOG(INFO, "Creating pcap-backed ethdev on numa socket %d",
> numa_node);
>
> - pp = (struct pmd_process_private *)
> - rte_zmalloc(NULL, sizeof(struct pmd_process_private),
> - RTE_CACHE_LINE_SIZE);
> -
> + pp = rte_zmalloc_socket(NULL, sizeof(struct pmd_process_private),
> + RTE_CACHE_LINE_SIZE, numa_node);
> if (pp == NULL) {
> PMD_LOG(ERR,
> "Failed to allocate memory for process private");
My concern there is that by forcing the numa node parameter, you are going
to make it impossible to run with memory on the "wrong" numa node.
Admittedly, this is less of a problem with virtual devices like pcap, than
physical ones, but I still wonder if, on error, you should fallback to a
regular "rte_malloc" call to allow the allocation to succeed so long as
there is some hugepage memory available somewhere.
/Bruce
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net/pcap: fix indentation and numa node
2025-04-07 9:51 ` Bruce Richardson
@ 2025-04-07 15:08 ` Stephen Hemminger
0 siblings, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2025-04-07 15:08 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev
On Mon, 7 Apr 2025 10:51:37 +0100
Bruce Richardson <bruce.richardson@intel.com> wrote:
> On Sat, Apr 05, 2025 at 08:36:23AM -0700, Stephen Hemminger wrote:
> > The process private data allocation was indented incorrectly
> > in the source code, and had unnecessary cast. It is better
> > that the data be allocated on same numa node as the device
> > structure.
> >
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> > drivers/net/pcap/pcap_ethdev.c | 13 ++++---------
> > 1 file changed, 4 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c
> > index 728ef85d53..aefa74c7be 100644
> > --- a/drivers/net/pcap/pcap_ethdev.c
> > +++ b/drivers/net/pcap/pcap_ethdev.c
> > @@ -1208,10 +1208,8 @@ pmd_init_internals(struct rte_vdev_device *vdev,
> > PMD_LOG(INFO, "Creating pcap-backed ethdev on numa socket %d",
> > numa_node);
> >
> > - pp = (struct pmd_process_private *)
> > - rte_zmalloc(NULL, sizeof(struct pmd_process_private),
> > - RTE_CACHE_LINE_SIZE);
> > -
> > + pp = rte_zmalloc_socket(NULL, sizeof(struct pmd_process_private),
> > + RTE_CACHE_LINE_SIZE, numa_node);
> > if (pp == NULL) {
> > PMD_LOG(ERR,
> > "Failed to allocate memory for process private");
>
> My concern there is that by forcing the numa node parameter, you are going
> to make it impossible to run with memory on the "wrong" numa node.
> Admittedly, this is less of a problem with virtual devices like pcap, than
> physical ones, but I still wonder if, on error, you should fallback to a
> regular "rte_malloc" call to allow the allocation to succeed so long as
> there is some hugepage memory available somewhere.
>
> /Bruce
There already is a numa_node parameter on the eth dev, this was just trying
to put the private part on the same node as the existing eth dev.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-07 15:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-05 15:36 [PATCH] net/pcap: fix indentation and numa node Stephen Hemminger
2025-04-07 9:51 ` Bruce Richardson
2025-04-07 15:08 ` Stephen Hemminger
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).