From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 959F8A054F; Mon, 15 Mar 2021 17:42:19 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0E3BA2426CB; Mon, 15 Mar 2021 17:42:19 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id E15184068C for ; Mon, 15 Mar 2021 17:42:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615826536; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jnvKD8JHzfn7hVbuRTMq4BD3a9WA7QJIW2YIL2jY1tI=; b=dE4EZ8rRLO7AwIiGXNjFCntut2wrknasbvQnIPixMY2LmRKIhVo8GoOvuUjCAnoXVVqAZf 4hnVc9eJ0vRbjNKbIeYRWtYDMtQpAWelnGGJd2MqoTQ60uFcPTvNRhj+ZB9ajdHV5A1Vh+ SSLO3gZXEC/6SukO0YAZjJgtGdeIZoY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-123-D683_VexNxyGx_3EBpXmuQ-1; Mon, 15 Mar 2021 12:42:14 -0400 X-MC-Unique: D683_VexNxyGx_3EBpXmuQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 87F92101F002; Mon, 15 Mar 2021 16:42:13 +0000 (UTC) Received: from [10.36.110.10] (unknown [10.36.110.10]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1FFE4620DE; Mon, 15 Mar 2021 16:42:07 +0000 (UTC) To: David Marchand Cc: dev , "Xia, Chenbo" , Adrian Moreno Zapata , Olivier Matz , bnemeth@redhat.com References: <20210315151957.360530-1-maxime.coquelin@redhat.com> <20210315151957.360530-4-maxime.coquelin@redhat.com> From: Maxime Coquelin Message-ID: <0239341e-3fe3-ef4f-299b-410d87b05c19@redhat.com> Date: Mon, 15 Mar 2021 17:42:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2 3/4] net/virtio: allocate fake mbuf in Rx queue X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 3/15/21 4:50 PM, David Marchand wrote: > On Mon, Mar 15, 2021 at 4:20 PM Maxime Coquelin > 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(). > >