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 CDCCEA054F; Mon, 15 Mar 2021 16:50:41 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B55934068C; Mon, 15 Mar 2021 16:50:40 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mails.dpdk.org (Postfix) with ESMTP id 587704068B for ; Mon, 15 Mar 2021 16:50:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615823438; 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: in-reply-to:in-reply-to:references:references; bh=Lybb4uv4BP5ml5ySop7Jd/po7nZoJB40TyYjlhkQv2s=; b=PJn11d6dGiYbH3SL+VxDhkmf1wPF9jMvuDdaNkPjmqbmy3YeEv4uy7L5CtqE9p5qFAI2Hy FSlEA3QIElyngpJQkYKxKjr4ooCme+mDvhXYWAQ7+2hLW67CodesIAc0tN2SLsFetIhbmW m3ZDTf+AON8zn1ppTq2QplG3Ti1Ms7E= Received: from mail-vk1-f199.google.com (mail-vk1-f199.google.com [209.85.221.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-602-aED8mTriPCW2jV0ivYfspw-1; Mon, 15 Mar 2021 11:50:37 -0400 X-MC-Unique: aED8mTriPCW2jV0ivYfspw-1 Received: by mail-vk1-f199.google.com with SMTP id q15so9190643vkd.1 for ; Mon, 15 Mar 2021 08:50:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Lybb4uv4BP5ml5ySop7Jd/po7nZoJB40TyYjlhkQv2s=; b=kJ6Ihmlj7hlcwqZYr+zRgMcOHi84UkehACitQZjbBbipGcnORUPGAfbqvnFwDnc4Ad wfA0RL85Wh3w/bk32BhUfVgsiqWHN75AFhTHh+Zumj0sg/JRYEnGJOe0aEqgptipX8pM iVgpGsDRk/9ZZP/p7dw98ssARvwzM/rgrwoXp8kLSOnpQX0x0ygb220e15FEXJNk+mLk 2IqASBASc9yApK82aYrCLFwnnPIiGIgR3aJhIUbtqUHPE6ag+r/KIHx9IlAJniCa3Ac4 zFyVTiPmQ9Z31Q1OsNiT3bHpt7QQ67lUqAndQaxe2T1lwdEkvtMOnpAzy9x8r2tKuZKa Tlcg== X-Gm-Message-State: AOAM533/gT4ATWdER1mBeepPzQCy2KLFprfAbQ6cKn8iPqKvSGt9DZIp rc/9Ep75f5UM02tJx5C7UmclgOJYjaIXAl14nzcZguurxy1KAzGpq2a6q5FfQRdhNvsELERa6wP BTbjDF0R8jODJTxai24k= X-Received: by 2002:a05:6102:ace:: with SMTP id m14mr5647690vsh.5.1615823436664; Mon, 15 Mar 2021 08:50:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIEgApsHr4pfywsdVx553LjN9nbyRCYmRJSXtAnN2sasolvC+syJGCTGE29awPOE3F/nVjEUfDgh64ZdCDcdg= X-Received: by 2002:a05:6102:ace:: with SMTP id m14mr5647680vsh.5.1615823436426; Mon, 15 Mar 2021 08:50:36 -0700 (PDT) MIME-Version: 1.0 References: <20210315151957.360530-1-maxime.coquelin@redhat.com> <20210315151957.360530-4-maxime.coquelin@redhat.com> In-Reply-To: <20210315151957.360530-4-maxime.coquelin@redhat.com> From: David Marchand Date: Mon, 15 Mar 2021 16:50:24 +0100 Message-ID: To: Maxime Coquelin Cc: dev , "Xia, Chenbo" , Adrian Moreno Zapata , Olivier Matz , bnemeth@redhat.com Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" 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 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. > } 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(). -- David Marchand