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 79B2DA00C3; Thu, 16 Jun 2022 16:40:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 538E0410D1; Thu, 16 Jun 2022 16:40:22 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id C4E1D40141 for ; Thu, 16 Jun 2022 16:40:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655390421; 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=1qP8U4GSBcYBq6EDP/CL/AMqI7MWWr6Zj9NLU34P/X4=; b=LNiCYAhmAj+0llX/KjtLqqFZsyybmnSj2K7LSBwEzuqNVHlxY87qbafxblxIYzVkMtwpSC m1abqepvgbWYIi/35mlTvxebUbAsKg0fhi5AOybM6jRQr0CHODHGaR8eu2tmQiJ66rS9u1 UaqC6PUF4urtFzp4MXm9Y/SO9sixDXU= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-319-SD589KwoOZOogvvoXMgQzw-1; Thu, 16 Jun 2022 10:40:20 -0400 X-MC-Unique: SD589KwoOZOogvvoXMgQzw-1 Received: by mail-lf1-f72.google.com with SMTP id k17-20020a05651210d100b004794def3bd3so890232lfg.2 for ; Thu, 16 Jun 2022 07:40:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1qP8U4GSBcYBq6EDP/CL/AMqI7MWWr6Zj9NLU34P/X4=; b=jLR5o+MCnjNpe1ZT1P8lTVmJK4uenVgDdmJBxXAYnJtMimHl2YI5LYFH8MLAey1l/c q+bnPuJicAzAQeCi10HLBISk4dfMA9dLSx4O0gEGBs+Av6NhB23eaBekT3ewDKa3tAv1 9Aed1DaEE1xktR0mbbNLWqUZEBRBobyGcxlN8xRaSBrxUCHAba9nicDF6rdxQmlJH6tc zn+Uwlw0uQFiiQHoMK9TxtjiQ4ZDnGCQ588o61oIAZ00aeOBwtiKTd1XGYZVvWK4IKgn RVqlFDO7MzZulTgZr3YmV212C858Tkow68LWX1xBB31t6Q/7CTg8E/0wPQD6EmEzT63Z F1qQ== X-Gm-Message-State: AJIora88yIW9gzqLozXrR6EcjZV4ZBEiQOQkOXKaoU3g7PbyOwY7QUc4 N06kQjucH2AWy58HfN9pf+oepQ+4CS3P1LP1vmUY0q0XjbIeaDiPdMObv08kpo6oefy5TWCX+L8 D7k4ujpePaXZsGSDlOEc= X-Received: by 2002:a05:6512:3f87:b0:47e:f67a:da1e with SMTP id x7-20020a0565123f8700b0047ef67ada1emr2971798lfa.499.1655390418656; Thu, 16 Jun 2022 07:40:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tIPxbZer3zqzEzrmXNP9UAS0vfDNU3CM94mqNK9HSZ5iAT8CuqL8brv45kSn0OpxdutFKvE+kjTiifV+ZizU8= X-Received: by 2002:a05:6512:3f87:b0:47e:f67a:da1e with SMTP id x7-20020a0565123f8700b0047ef67ada1emr2971788lfa.499.1655390418412; Thu, 16 Jun 2022 07:40:18 -0700 (PDT) MIME-Version: 1.0 References: <20220407152546.38167-1-xuan.ding@intel.com> <20220516111041.63914-1-xuan.ding@intel.com> <20220516111041.63914-5-xuan.ding@intel.com> In-Reply-To: From: David Marchand Date: Thu, 16 Jun 2022 16:40:07 +0200 Message-ID: Subject: Re: [PATCH v8 4/5] vhost: support async dequeue for split ring To: Xuan Ding Cc: Maxime Coquelin , "Xia, Chenbo" , dev , Jiayu Hu , Cheng Jiang , Sunil Pai G , liangma@liangbit.com, Yuan Wang , "Mcnamara, John" 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" 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 On Thu, Jun 16, 2022 at 4:38 PM David Marchand wrote: > > On Mon, May 16, 2022 at 1:16 PM wrote: > > +static __rte_always_inline uint16_t > > +virtio_dev_tx_async_split(struct virtio_net *dev, struct vhost_virtqueue *vq, > > + struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count, > > + int16_t dma_id, uint16_t vchan_id, bool legacy_ol_flags) > > +{ > > + static bool allocerr_warned; > > + bool dropped = false; > > + uint16_t free_entries; > > + uint16_t pkt_idx, slot_idx = 0; > > + uint16_t nr_done_pkts = 0; > > + uint16_t pkt_err = 0; > > + uint16_t n_xfer; > > + struct vhost_async *async = vq->async; > > + struct async_inflight_info *pkts_info = async->pkts_info; > > + struct rte_mbuf *pkts_prealloc[MAX_PKT_BURST]; > > Why do we need this array? > Plus, see blow. > > > + uint16_t pkts_size = count; > > + > > + /** > > + * The ordering between avail index and > > + * desc reads needs to be enforced. > > + */ > > + free_entries = __atomic_load_n(&vq->avail->idx, __ATOMIC_ACQUIRE) - > > + vq->last_avail_idx; > > + if (free_entries == 0) > > + goto out; > > + > > + rte_prefetch0(&vq->avail->ring[vq->last_avail_idx & (vq->size - 1)]); > > + > > + async_iter_reset(async); > > + > > + count = RTE_MIN(count, MAX_PKT_BURST); ^^^ Ok, my point about the overflow does not stand. Just the pkts_prealloc array is probably useless. > > + count = RTE_MIN(count, free_entries); > > + VHOST_LOG_DATA(DEBUG, "(%s) about to dequeue %u buffers\n", > > + dev->ifname, count); > > + > > + if (rte_pktmbuf_alloc_bulk(mbuf_pool, pkts_prealloc, count)) > > 'count' is provided by the user of the vhost async dequeue public API. > There is no check that it is not bigger than MAX_PKT_BURST. > > Calling rte_pktmbuf_alloc_bulk on a fixed-size array pkts_prealloc, > allocated on the stack, it may cause a stack overflow. The rest still stands for me. vvv > > > > This code is mostly copy/pasted from the "sync" code. > I see a fix on the stats has been sent. > I point here another bug. > There are probably more... > > > I don't like how async code has been added in the vhost library by Intel. > > Maxime did a cleanup on the enqueue patch > https://patchwork.dpdk.org/project/dpdk/list/?series=20020&state=%2A&archive=both. > I see that the recent dequeue path additions have the same method of > copying/pasting code and adding some branches in a non systematic way. > Please clean this code and stop copy/pasting without a valid reason. > -- David Marchand