DPDK patches and discussions
 help / color / mirror / Atom feed
From: Shahaf Shuler <shahafs@mellanox.com>
To: "Burakov, Anatoly" <anatoly.burakov@intel.com>,
	"wenzhuo.lu@intel.com" <wenzhuo.lu@intel.com>,
	"jingjing.wu@intel.com" <jingjing.wu@intel.com>,
	"bernard.iremonger@intel.com" <bernard.iremonger@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	Raslan Darawsheh <rasland@mellanox.com>,
	Thomas Monjalon <thomas@monjalon.net>,
	"ferruh.yigit@intel.com" <ferruh.yigit@intel.com>
Subject: Re: [dpdk-dev] [PATCH 3/3] app/testpmd: map anonymous memory for eth devices
Date: Tue, 2 Apr 2019 07:04:51 +0000	[thread overview]
Message-ID: <AM0PR0502MB379574CA225F1DC1B1DD7723C3560@AM0PR0502MB3795.eurprd05.prod.outlook.com> (raw)
Message-ID: <20190402070451.njPnwcmA3A4uW5iRN8NzUDiF8-7LkReiotxggo38gn4@z> (raw)
In-Reply-To: <eec81d18-d339-05ce-a4ff-6d27efdf92d1@intel.com>

Monday, April 1, 2019 4:28 PM, Burakov, Anatoly:
> Subject: Re: [dpdk-dev] [PATCH 3/3] app/testpmd: map anonymous memory
> for eth devices
> 
> On 01-Apr-19 11:34 AM, Shahaf Shuler wrote:
> > Mempools can be populated with anonymous memory when using
> command
> > line parameter --mp-alloc=anon.
> >
> > Considering the mempools are going to be used by the net devices, it
> > is better to DMA map this memory.
> >
> > This patch add such mapping now that we have the APIs in place[1].
> >
> > [1] commit c33a675b6276 ("bus: introduce device level DMA memory
> > mapping")
> >
> > Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
> > ---
> >   app/test-pmd/testpmd.c | 62
> ++++++++++++++++++++++++++++++++++++++++++++-
> >   1 file changed, 61 insertions(+), 1 deletion(-)
> >
> > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> > 8c4ebc774c..6729469c6b 100644
> > --- a/app/test-pmd/testpmd.c
> > +++ b/app/test-pmd/testpmd.c
> > @@ -834,6 +834,61 @@ setup_extmem(uint32_t nb_mbufs, uint32_t
> mbuf_sz,
> > bool huge)
> >
> >   	return 0;
> >   }
> > +static void
> > +dma_unmap_cb(struct rte_mempool *mp __rte_unused, void *opaque
> __rte_unused,
> > +	     struct rte_mempool_memhdr *memhdr, unsigned mem_idx
> > +__rte_unused) {
> > +	uint16_t pid = 0;
> > +	int ret;
> > +
> > +	ret = rte_extmem_unregister(memhdr->addr, memhdr->len);
> > +	if (ret) {
> > +		TESTPMD_LOG(DEBUG,
> > +			    "unable to un-register addr 0x%p\n", memhdr-
> >addr);
> > +		return;
> > +	}
> > +	RTE_ETH_FOREACH_DEV(pid) {
> > +		struct rte_eth_dev *dev =
> > +			&rte_eth_devices[pid];
> > +
> > +		ret = rte_dev_dma_unmap(dev->device, memhdr->addr, 0,
> > +					memhdr->len);
> > +		if (ret) {
> > +			TESTPMD_LOG(DEBUG,
> > +				    "unable to DMA unmap addr 0x%p\n",
> > +				    memhdr->addr);
> > +		}
> > +	}
> 
> I would expect unmap *then* unregister.

Right, thanks. 

> 
> > +}
> > +
> > +static void
> > +dma_map_cb(struct rte_mempool *mp __rte_unused, void *opaque
> __rte_unused,
> > +	   struct rte_mempool_memhdr *memhdr, unsigned mem_idx
> __rte_unused)
> > +{
> > +	uint16_t pid = 0;
> > +	size_t page_size = sysconf(_SC_PAGESIZE);
> > +	int ret;
> > +
> > +	ret = rte_extmem_register(memhdr->addr, memhdr->len, NULL, 0,
> > +				  page_size);
> > +	if (ret) {
> > +		TESTPMD_LOG(DEBUG,
> > +			    "unable to register addr 0x%p\n", memhdr->addr);
> > +		return;
> > +	}
> > +	RTE_ETH_FOREACH_DEV(pid) {
> > +		struct rte_eth_dev *dev =
> > +			&rte_eth_devices[pid];
> > +
> > +		ret = rte_dev_dma_map(dev->device, memhdr->addr, 0,
> > +				      memhdr->len);
> > +		if (ret) {
> > +			TESTPMD_LOG(DEBUG,
> > +				    "unable to DMA map addr 0x%p\n",
> > +				    memhdr->addr);
> 
> Maybe mention the device/driver name as well? Otherwise it's hard to see
> which particular DMA map/unmap has failed, should one choose to debug-
> by-logs.

Will add. 

> 
> > +		}
> > +	}
> > +}
> >
> >   /*
> >    * Configuration initialisation done once at init time.
> > @@ -879,6 +934,7 @@ mbuf_pool_create(uint16_t mbuf_seg_size,
> unsigned nb_mbuf,
> >   			}
> >   			rte_pktmbuf_pool_init(rte_mp, NULL);
> >   			rte_mempool_obj_iter(rte_mp, rte_pktmbuf_init,
> NULL);
> > +			rte_mempool_mem_iter(rte_mp, dma_map_cb,
> NULL);
> >   			break;
> >   		}
> >   	case MP_ALLOC_XMEM:
> > @@ -2460,8 +2516,12 @@ pmd_test_exit(void)
> >   		}
> >   	}
> >   	for (i = 0 ; i < RTE_MAX_NUMA_NODES ; i++)
> > -		if (mempools[i])
> > +		if (mempools[i]) {
> > +			if (mp_alloc_type == MP_ALLOC_ANON)
> > +				rte_mempool_mem_iter(mempools[i],
> dma_unmap_cb,
> > +						     NULL);
> >   			rte_mempool_free(mempools[i]);
> > +		}
> >
> >   	printf("\nBye...\n");
> >   }
> >
> 
> 
> --
> Thanks,
> Anatoly

  parent reply	other threads:[~2019-04-02  7:04 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-01 10:34 [dpdk-dev] [PATCH 0/3] DMA map anonymous memory to " Shahaf Shuler
2019-04-01 10:34 ` Shahaf Shuler
2019-04-01 10:34 ` [dpdk-dev] [PATCH 1/3] app/testpmd: fix mempool free on exit Shahaf Shuler
2019-04-01 10:34   ` Shahaf Shuler
2019-04-01 10:34 ` [dpdk-dev] [PATCH 2/3] app/testpmd: support creation of no IOVA contig mempools Shahaf Shuler
2019-04-01 10:34   ` Shahaf Shuler
2019-04-01 13:50   ` Burakov, Anatoly
2019-04-01 13:50     ` Burakov, Anatoly
2019-04-02  7:02     ` Shahaf Shuler
2019-04-02  7:02       ` Shahaf Shuler
2019-04-02 15:15       ` Burakov, Anatoly
2019-04-02 15:15         ` Burakov, Anatoly
2019-04-03  5:47         ` Shahaf Shuler
2019-04-03  5:47           ` Shahaf Shuler
2019-04-01 10:34 ` [dpdk-dev] [PATCH 3/3] app/testpmd: map anonymous memory for eth devices Shahaf Shuler
2019-04-01 10:34   ` Shahaf Shuler
2019-04-01 13:28   ` Burakov, Anatoly
2019-04-01 13:28     ` Burakov, Anatoly
2019-04-02  7:04     ` Shahaf Shuler [this message]
2019-04-02  7:04       ` Shahaf Shuler
2019-04-04  5:14 ` [dpdk-dev] [PATCH v2 0/3] DMA map anonymous memory to " Shahaf Shuler
2019-04-04  5:14   ` Shahaf Shuler
2019-04-04  5:14   ` [dpdk-dev] [PATCH v2 1/3] app/testpmd: fix mempool free on exit Shahaf Shuler
2019-04-04  5:14     ` Shahaf Shuler
2019-04-08 13:39     ` Iremonger, Bernard
2019-04-08 13:39       ` Iremonger, Bernard
2019-04-04  5:14   ` [dpdk-dev] [PATCH v2 2/3] app/testpmd: support creation of no IOVA contig mempools Shahaf Shuler
2019-04-04  5:14     ` Shahaf Shuler
2019-04-04  9:36     ` Burakov, Anatoly
2019-04-04  9:36       ` Burakov, Anatoly
2019-04-04  5:14   ` [dpdk-dev] [PATCH v2 3/3] app/testpmd: map anonymous memory for eth devices Shahaf Shuler
2019-04-04  5:14     ` Shahaf Shuler
2019-04-04  9:38     ` Burakov, Anatoly
2019-04-04  9:38       ` Burakov, Anatoly
2019-04-04 19:34   ` [dpdk-dev] [PATCH v3 0/3] DMA map anonymous memory to " Shahaf Shuler
2019-04-04 19:34     ` Shahaf Shuler
2019-04-04 19:34     ` [dpdk-dev] [PATCH v3 1/3] app/testpmd: fix mempool free on exit Shahaf Shuler
2019-04-04 19:34       ` Shahaf Shuler
2019-04-05 14:41       ` Ferruh Yigit
2019-04-05 14:41         ` Ferruh Yigit
2019-04-04 19:34     ` [dpdk-dev] [PATCH v3 2/3] app/testpmd: support creation of no IOVA contig mempools Shahaf Shuler
2019-04-04 19:34       ` Shahaf Shuler
2019-04-04 19:35     ` [dpdk-dev] [PATCH v3 3/3] app/testpmd: map anonymous memory for eth devices Shahaf Shuler
2019-04-04 19:35       ` Shahaf Shuler
2019-04-05  0:17     ` [dpdk-dev] [PATCH v3 0/3] DMA map anonymous memory to " Ferruh Yigit
2019-04-05  0:17       ` Ferruh Yigit
2019-04-07  5:02     ` [dpdk-dev] [PATCH v4 " Shahaf Shuler
2019-04-07  5:02       ` Shahaf Shuler
2019-04-07  5:02       ` [dpdk-dev] [PATCH v4 1/3] app/testpmd: fix mempool free on exit Shahaf Shuler
2019-04-07  5:02         ` Shahaf Shuler
2019-04-08 14:14         ` Iremonger, Bernard
2019-04-08 14:14           ` Iremonger, Bernard
2019-04-07  5:02       ` [dpdk-dev] [PATCH v4 2/3] app/testpmd: support creation of no IOVA contig mempools Shahaf Shuler
2019-04-07  5:02         ` Shahaf Shuler
2019-04-07  5:02       ` [dpdk-dev] [PATCH v4 3/3] app/testpmd: map anonymous memory for eth devices Shahaf Shuler
2019-04-07  5:02         ` Shahaf Shuler
2019-04-11 14:07       ` [dpdk-dev] [PATCH v4 0/3] DMA map anonymous memory to " Ferruh Yigit
2019-04-11 14:07         ` Ferruh Yigit

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=AM0PR0502MB379574CA225F1DC1B1DD7723C3560@AM0PR0502MB3795.eurprd05.prod.outlook.com \
    --to=shahafs@mellanox.com \
    --cc=anatoly.burakov@intel.com \
    --cc=bernard.iremonger@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=jingjing.wu@intel.com \
    --cc=rasland@mellanox.com \
    --cc=thomas@monjalon.net \
    --cc=wenzhuo.lu@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).