From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-f67.google.com (mail-vs1-f67.google.com [209.85.217.67]) by dpdk.org (Postfix) with ESMTP id 2C2DF7D52 for ; Mon, 29 Apr 2019 10:04:03 +0200 (CEST) Received: by mail-vs1-f67.google.com with SMTP id g187so5365822vsc.8 for ; Mon, 29 Apr 2019 01:04:03 -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=S3O5TJVkhGlj/d89purNwUE5yik9zQOgX6ncPq5Ka/c=; b=ASKAaotgEOLTZuSC+4Ev8pZOf6Iyq4PH85mWORwxiKMet5FFz9DgBnPruFYEtNzEhm PfeHeyiBvK9soMNyd8qy02jImw61tTxMdWyoANGw+irWlF6Zo+aGwc1UxkSYbH7E+Uor 1h5R7o7t02YF7TphD7AJe6EcCWO4GCFVqOMQaIk3jipLlcx4O74XALlgZsIjBRnnufbE a0pV7ykQgNzjRSQOlBGTQzTCC750uuQMd64I8xyWG4xMUPagyNYnxLagZdzzt0A2ACzv W/nPzcKHnxuPnT/oQfR1pwYQFr1epmddftnEr2t6G7MY5RdrGHMUB+07rr4dxShrl4IA pOsQ== X-Gm-Message-State: APjAAAXK1GG/4k1cWPGP4Lm9503XpQtD+h5zSnVifTo7YciQRb+yqRSx COEltp9nUhjkIDu+DfHMz/MHxNuX1FW9Ajw9izyu/g== X-Google-Smtp-Source: APXvYqyLTxMLenhq+2/5eSa3Vt1noqfoQT896Ht3P5kPXzTivggd3FIUamcESi199Wuwb/KuvJF5DzYopikWiwMut0M= X-Received: by 2002:a67:a446:: with SMTP id p6mr31406601vsh.198.1556525042534; Mon, 29 Apr 2019 01:04:02 -0700 (PDT) MIME-Version: 1.0 References: <1556358462-9920-1-git-send-email-wangyunjian@huawei.com> In-Reply-To: <1556358462-9920-1-git-send-email-wangyunjian@huawei.com> From: David Marchand Date: Mon, 29 Apr 2019 10:03:51 +0200 Message-ID: To: wangyunjian , Thomas Monjalon , Andrew Rybchenko , "Yigit, Ferruh" Cc: dev , xudingke@huawei.com Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH] ethdev: add size and align to compose dma zone name strings X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Apr 2019 08:04:03 -0000 On Sat, Apr 27, 2019 at 11:48 AM wangyunjian wrote: > From: Yunjian Wang > > The current dma zone name consists of the port_id, queue_id and > ring_name. If a port_id is reused, a new nic maybe use same dma > zone name. At this time, the zone size of the new driver is > differnt. When the zone is reused, it may cause illegal access > to memory. > > Signed-off-by: Yunjian Wang > --- > lib/librte_ethdev/rte_ethdev.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/lib/librte_ethdev/rte_ethdev.c > b/lib/librte_ethdev/rte_ethdev.c > index d7cfa3d..0703cda 100644 > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -3630,9 +3630,9 @@ int rte_eth_set_queue_rate_limit(uint16_t port_id, > uint16_t queue_idx, > const struct rte_memzone *mz; > int rc; > > - rc = snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s", > - dev->data->port_id, queue_id, ring_name); > - if (rc >= RTE_MEMZONE_NAMESIZE) { > + rc = snprintf(z_name, sizeof(z_name), "p%dq%d%s0x%zx_%d", > + dev->data->port_id, queue_id, ring_name, size, > align); > + if (rc >= RTE_MEMZONE_NAMESIZE || rc < 0) { > RTE_ETHDEV_LOG(ERR, "ring name too long\n"); > rte_errno = ENAMETOOLONG; > return NULL; > In such a case, we are leaving the previous memzone in place and just creating a new one. Should the driver free the previous memzone instead? I can't see this in existing drivers. Do we actually expect to reuse the existing memzones? -- David Marchand From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 8FAABA0679 for ; Mon, 29 Apr 2019 10:04:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3356F1B19A; Mon, 29 Apr 2019 10:04:04 +0200 (CEST) Received: from mail-vs1-f67.google.com (mail-vs1-f67.google.com [209.85.217.67]) by dpdk.org (Postfix) with ESMTP id 2C2DF7D52 for ; Mon, 29 Apr 2019 10:04:03 +0200 (CEST) Received: by mail-vs1-f67.google.com with SMTP id g187so5365822vsc.8 for ; Mon, 29 Apr 2019 01:04:03 -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=S3O5TJVkhGlj/d89purNwUE5yik9zQOgX6ncPq5Ka/c=; b=ASKAaotgEOLTZuSC+4Ev8pZOf6Iyq4PH85mWORwxiKMet5FFz9DgBnPruFYEtNzEhm PfeHeyiBvK9soMNyd8qy02jImw61tTxMdWyoANGw+irWlF6Zo+aGwc1UxkSYbH7E+Uor 1h5R7o7t02YF7TphD7AJe6EcCWO4GCFVqOMQaIk3jipLlcx4O74XALlgZsIjBRnnufbE a0pV7ykQgNzjRSQOlBGTQzTCC750uuQMd64I8xyWG4xMUPagyNYnxLagZdzzt0A2ACzv W/nPzcKHnxuPnT/oQfR1pwYQFr1epmddftnEr2t6G7MY5RdrGHMUB+07rr4dxShrl4IA pOsQ== X-Gm-Message-State: APjAAAXK1GG/4k1cWPGP4Lm9503XpQtD+h5zSnVifTo7YciQRb+yqRSx COEltp9nUhjkIDu+DfHMz/MHxNuX1FW9Ajw9izyu/g== X-Google-Smtp-Source: APXvYqyLTxMLenhq+2/5eSa3Vt1noqfoQT896Ht3P5kPXzTivggd3FIUamcESi199Wuwb/KuvJF5DzYopikWiwMut0M= X-Received: by 2002:a67:a446:: with SMTP id p6mr31406601vsh.198.1556525042534; Mon, 29 Apr 2019 01:04:02 -0700 (PDT) MIME-Version: 1.0 References: <1556358462-9920-1-git-send-email-wangyunjian@huawei.com> In-Reply-To: <1556358462-9920-1-git-send-email-wangyunjian@huawei.com> From: David Marchand Date: Mon, 29 Apr 2019 10:03:51 +0200 Message-ID: To: wangyunjian , Thomas Monjalon , Andrew Rybchenko , "Yigit, Ferruh" Cc: dev , xudingke@huawei.com Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH] ethdev: add size and align to compose dma zone name strings X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Message-ID: <20190429080351.G57URG-Mah76jGNLB0yzqv0j9tHgtUhWhp0U2UlHlOw@z> On Sat, Apr 27, 2019 at 11:48 AM wangyunjian wrote: > From: Yunjian Wang > > The current dma zone name consists of the port_id, queue_id and > ring_name. If a port_id is reused, a new nic maybe use same dma > zone name. At this time, the zone size of the new driver is > differnt. When the zone is reused, it may cause illegal access > to memory. > > Signed-off-by: Yunjian Wang > --- > lib/librte_ethdev/rte_ethdev.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/lib/librte_ethdev/rte_ethdev.c > b/lib/librte_ethdev/rte_ethdev.c > index d7cfa3d..0703cda 100644 > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -3630,9 +3630,9 @@ int rte_eth_set_queue_rate_limit(uint16_t port_id, > uint16_t queue_idx, > const struct rte_memzone *mz; > int rc; > > - rc = snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s", > - dev->data->port_id, queue_id, ring_name); > - if (rc >= RTE_MEMZONE_NAMESIZE) { > + rc = snprintf(z_name, sizeof(z_name), "p%dq%d%s0x%zx_%d", > + dev->data->port_id, queue_id, ring_name, size, > align); > + if (rc >= RTE_MEMZONE_NAMESIZE || rc < 0) { > RTE_ETHDEV_LOG(ERR, "ring name too long\n"); > rte_errno = ENAMETOOLONG; > return NULL; > In such a case, we are leaving the previous memzone in place and just creating a new one. Should the driver free the previous memzone instead? I can't see this in existing drivers. Do we actually expect to reuse the existing memzones? -- David Marchand