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 DC24945A85 for ; Wed, 2 Oct 2024 01:48:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CF3F1402CB; Wed, 2 Oct 2024 01:48:56 +0200 (CEST) Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by mails.dpdk.org (Postfix) with ESMTP id D02BE40267 for ; Wed, 2 Oct 2024 01:48:54 +0200 (CEST) Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e2364f45a4so67262877b3.2 for ; Tue, 01 Oct 2024 16:48:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727826534; x=1728431334; darn=dpdk.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=Tso2sYbWXeLjm6zFr6j+PuuoluzUuM8/94TUZeX8vQA=; b=NbyBoX3N5ZPPjREEBvdtRQkUI11I94di01T68wmUzpjDOyop2dizVgQcRJB8OegcA5 ZfgfgHvLhzAy6DWDdEyDHUcKlSjXXzEAXWIVJcQl4acpLl/MUSklTGr5FOm89zJPOjK5 LRb56/f7XG52a6POdfX4yI+D7gqHdJfy54gKm/mBwZb4ujtdx8s2tJY0waINiOXxEaGV vtPcl5WDlbp+kFJNhcDwbtrNrNYBILqdIxQfi3Bq688KIfkVxMCOPJJNkPjrZLdyzLvB +hz4cKoK2Q0t0Zfg8/qkoMA9hO77t81A62phQ8w7IS+MhgOb/O7+MW0j3rbDHul8Gi6m W3Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727826534; x=1728431334; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Tso2sYbWXeLjm6zFr6j+PuuoluzUuM8/94TUZeX8vQA=; b=LrH3HecWQBaOVmNvUC617OpF/3rNBya4zAtYJZ3v59jKBU/X9mdoNeLTR9il9JX7Tp 3zMgObRLIfROlf3y1G2cfU/MZf48QC+m9HtM1eCStPbeHhT3E6UrbIdxRrZVNr6CJnC5 CTVfMGh+f1GSwpmT+93amLeyVlFT9bfA38WONPDccAdgJCxoMVPyfN+jeeprTI89/F48 AWFbZjIOyJJBgF6RhbmvdPEHvJUuxZa5MSwZdGzFCLdjxpDmeKDmKL9MkLoH/zZAlw+C j9J46mDguM3d/AiyjVVHkKiVrkNFCPaZckx+mo9sz8UwMxYPySH59BMBxALkcJqe7Vl4 nEtw== X-Forwarded-Encrypted: i=1; AJvYcCUomyQym1e+x89Yb9L1NMxZMINmwFDdUoZVecAdOc9cFc+DfVmX1SlQfFswPwTKeXSjW0dHqEs=@dpdk.org X-Gm-Message-State: AOJu0YzzkwLB8EJO3HTZJEavX/9PiI/nMtnat3WSUYf9N5Wgpy51M0gR yB91gAjQ8T64p2tZezhd4hNfAvSPJPZey/qcuBavujVbd9p4OcfEa3Wf3UmagYElhBH6Xto1q0W z3AZCOq/3Hg== X-Google-Smtp-Source: AGHT+IF6dt90i7TgnhbBUekJo2wxv7o1L5r22dYVz2kWzEcwnsgUNm2jiqGz+YYW6j+GB+DjMyEAehvvWAr5CQ== X-Received: from joshwash.sea.corp.google.com ([2620:15c:11c:202:a282:7553:57e3:9bee]) (user=joshwash job=sendgmr) by 2002:a05:690c:2a47:b0:6b2:3ecc:817 with SMTP id 00721157ae682-6e2a3044f06mr116277b3.8.1727826534099; Tue, 01 Oct 2024 16:48:54 -0700 (PDT) Date: Tue, 1 Oct 2024 16:48:52 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Message-ID: <20241001234852.3312594-1-joshwash@google.com> Subject: [PATCH] net/gve: fix mbuf allocation memory leak for DQ Rx From: Joshua Washington To: Jeroen de Borst , Rushil Gupta , Joshua Washington , Junfeng Guo Cc: dev@dpdk.org, stable@dpdk.org, Ferruh Yigit , Praveen Kaligineedi Content-Type: text/plain; charset="UTF-8" X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Currently, gve_rxq_mbufs_alloc_dqo() allocates RING_SIZE buffers, but only posts RING_SIZE - 1 of them, inevitably leaking a buffer every time queues are stopped/started. This could eventually lead to running out of mbufs if an application stops/starts traffic enough. Fixes: b044845bb015 ("net/gve: support queue start/stop") Cc: stable@dpdk.org Signed-off-by: Joshua Washington Reviewed-by: Rushil Gupta Reviewed-by: Praveen Kaligineedi --- drivers/net/gve/gve_rx_dqo.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/net/gve/gve_rx_dqo.c b/drivers/net/gve/gve_rx_dqo.c index 60702d4100..e4084bc0dd 100644 --- a/drivers/net/gve/gve_rx_dqo.c +++ b/drivers/net/gve/gve_rx_dqo.c @@ -393,34 +393,36 @@ static int gve_rxq_mbufs_alloc_dqo(struct gve_rx_queue *rxq) { struct rte_mbuf *nmb; + uint16_t rx_mask; uint16_t i; int diag; - diag = rte_pktmbuf_alloc_bulk(rxq->mpool, &rxq->sw_ring[0], rxq->nb_rx_desc); + rx_mask = rxq->nb_rx_desc - 1; + diag = rte_pktmbuf_alloc_bulk(rxq->mpool, &rxq->sw_ring[0], + rx_mask); if (diag < 0) { rxq->stats.no_mbufs_bulk++; - for (i = 0; i < rxq->nb_rx_desc - 1; i++) { + for (i = 0; i < rx_mask; i++) { nmb = rte_pktmbuf_alloc(rxq->mpool); if (!nmb) break; rxq->sw_ring[i] = nmb; } if (i < rxq->nb_rx_desc - 1) { - rxq->stats.no_mbufs += rxq->nb_rx_desc - 1 - i; + rxq->stats.no_mbufs += rx_mask - i; return -ENOMEM; } } - for (i = 0; i < rxq->nb_rx_desc; i++) { - if (i == rxq->nb_rx_desc - 1) - break; + for (i = 0; i < rx_mask; i++) { nmb = rxq->sw_ring[i]; rxq->rx_ring[i].buf_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb)); rxq->rx_ring[i].buf_id = rte_cpu_to_le_16(i); } + rxq->rx_ring[rx_mask].buf_id = rte_cpu_to_le_16(rx_mask); rxq->nb_rx_hold = 0; - rxq->bufq_tail = rxq->nb_rx_desc - 1; + rxq->bufq_tail = rx_mask; rte_write32(rxq->bufq_tail, rxq->qrx_tail); -- 2.46.1.824.gd892dcdcdd-goog