DPDK patches and discussions
 help / color / mirror / Atom feed
From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: David Marchand <david.marchand@redhat.com>
Cc: dev <dev@dpdk.org>, "Xia, Chenbo" <chenbo.xia@intel.com>,
	Adrian Moreno Zapata <amorenoz@redhat.com>,
	Olivier Matz <olivier.matz@6wind.com>,
	bnemeth@redhat.com
Subject: Re: [dpdk-dev] [PATCH v2 3/4] net/virtio: allocate fake mbuf in Rx queue
Date: Mon, 15 Mar 2021 17:42:06 +0100	[thread overview]
Message-ID: <0239341e-3fe3-ef4f-299b-410d87b05c19@redhat.com> (raw)
In-Reply-To: <CAJFAV8yumpFR2pq8X6TD6N6Qgb4qn+3GWOMTOwOiP5_u87uDmQ@mail.gmail.com>



On 3/15/21 4:50 PM, David Marchand wrote:
> On Mon, Mar 15, 2021 at 4:20 PM Maxime Coquelin
> <maxime.coquelin@redhat.com> wrote:
>> @@ -550,10 +551,18 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)
>>                         goto free_hdr_mz;
>>                 }
>>
>> +               fake_mbuf = malloc(sizeof(*fake_mbuf));
>> +               if (!fake_mbuf) {
>> +                       PMD_INIT_LOG(ERR, "can not allocate fake mbuf");
>> +                       ret = -ENOMEM;
>> +                       goto free_sw_ring;
>> +               }
>> +
>>                 vq->sw_ring = sw_ring;
>>                 rxvq = &vq->rxq;
>>                 rxvq->port_id = dev->data->port_id;
>>                 rxvq->mz = mz;
>> +               rxvq->fake_mbuf = fake_mbuf;
> 
> IIRC, vq is allocated as dpdk memory (rte_malloc).
> Generally speaking, storing a local pointer inside such an object is
> dangerous if other processes start to look at this part.

Agree, I will change to rte_zmalloc_socket, as vq (which is was part of)
is allocated like that.


Thanks,
Maxime

> 
>>         } else if (queue_type == VTNET_TQ) {
>>                 txvq = &vq->txq;
>>                 txvq->port_id = dev->data->port_id;
>> @@ -613,6 +622,9 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx)
>>  clean_vq:
>>         hw->cvq = NULL;
>>
>> +       if (fake_mbuf)
>> +               free(fake_mbuf);
> 
> No need for if().
> 
> 


  reply	other threads:[~2021-03-15 16:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 15:19 [dpdk-dev] [PATCH v2 0/4] net/virtio: make virtqueue struct cache-friendly Maxime Coquelin
2021-03-15 15:19 ` [dpdk-dev] [PATCH v2 1/4] net/virtio: remove reference to virtqueue in vrings Maxime Coquelin
2021-03-15 15:19 ` [dpdk-dev] [PATCH v2 2/4] net/virtio: improve queue init error path Maxime Coquelin
2021-03-15 15:38   ` David Marchand
2021-03-15 15:41     ` Maxime Coquelin
2021-03-15 15:19 ` [dpdk-dev] [PATCH v2 3/4] net/virtio: allocate fake mbuf in Rx queue Maxime Coquelin
2021-03-15 15:50   ` David Marchand
2021-03-15 16:42     ` Maxime Coquelin [this message]
2021-03-15 15:19 ` [dpdk-dev] [PATCH v2 4/4] net/virtio: pack virtuqueue struct Maxime Coquelin
2021-03-15 15:51   ` David Marchand

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=0239341e-3fe3-ef4f-299b-410d87b05c19@redhat.com \
    --to=maxime.coquelin@redhat.com \
    --cc=amorenoz@redhat.com \
    --cc=bnemeth@redhat.com \
    --cc=chenbo.xia@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.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).