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 CA01542A4F; Wed, 3 May 2023 14:12:55 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 51CB94114B; Wed, 3 May 2023 14:12:55 +0200 (CEST) Received: from mail-vk1-f171.google.com (mail-vk1-f171.google.com [209.85.221.171]) by mails.dpdk.org (Postfix) with ESMTP id A305A41144 for ; Wed, 3 May 2023 14:12:53 +0200 (CEST) Received: by mail-vk1-f171.google.com with SMTP id 71dfb90a1353d-44fc1a7d5d0so23150e0c.2 for ; Wed, 03 May 2023 05:12:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683115973; x=1685707973; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Hi0ilP8CHI0CGcDdP7xjH+eBF6KJnaY1aIjE+BZncVw=; b=bEBxj7Q8aUO0O6azD/rbhqMbpC/UgLBWlB6b22I88+c/XGcJErsvxBFJg74Grp6RWS i+jYT4ehsgu2d0ZY02kxeSUbqK+ON2EIbeq4Tf9hV/wNz4wRkrrXas4wAIQca97JOAiW jXG+d4cSXWO1IU/RI19MkIpHXyhMF/CiB678RoMYyUB1GtBV0QQinXxXTFWnaV45ggOv ySEpBv34RDK6i8k8VQc40r2CqmkQdcIz+qFInQbBhB8LT2GPXyR0niczvHQJOv0M9Whn KGvpXHSl/+IHDxUiQkiKTJppqs+hEAO20HagMFQc/BCFl69RamYMUkonswjnePi1DM7M 9sgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683115973; x=1685707973; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Hi0ilP8CHI0CGcDdP7xjH+eBF6KJnaY1aIjE+BZncVw=; b=f2PBBLxuPtq53E4E5VTPS1hNEM0PJ+xoChoER0cRFOhJubZoo+24H9XrR5tzoscBpO ZpqpWlR7UIzp78ed4Ta5C/ml+CciQ+HXsmn84mgIAJET1i9rabhDA54N/EAvQApfF6MV 6kSn+3S2h5mocvIsy5hSgHinko9Rehk6q7V0dI2RnyYbcCe7yzCLXRrvqT7gJo2u5O7b AosBjRPYsgh2O/VV0yKdnDgrcN+tTpbzEMYDa+HyQfYCyVHOoTqj5UPZKkAVzOS/NKac 2nc2Ee9YKOFkSVv79CL21E1WiQd6tBNz4LDTNHpkjgm39/RWJ/lRfL6v03sS9Rq+ZFXO BNwQ== X-Gm-Message-State: AC+VfDxizfzWIxN54uIWFh03UP0fUFuVEl4f7KMjKIR+7o4Sr3AtN8rB luzLYZzk1NQ8w6NS7bkDRVLePJTAxbFMpLvA7ro= X-Google-Smtp-Source: ACHHUZ5g4Bm+tObJs5/ha2E7+QKpUerWRVCUMzeY9l3Z/vGfh4/ujbabzzXbU54mTMFQ5crEEz/c1ajOkiC2NwfjzaQ= X-Received: by 2002:a67:b643:0:b0:42f:fae5:3b98 with SMTP id e3-20020a67b643000000b0042ffae53b98mr1256415vsm.14.1683115972679; Wed, 03 May 2023 05:12:52 -0700 (PDT) MIME-Version: 1.0 References: <20230411072146.1124802-1-asekhar@marvell.com> In-Reply-To: <20230411072146.1124802-1-asekhar@marvell.com> From: Jerin Jacob Date: Wed, 3 May 2023 17:42:26 +0530 Message-ID: Subject: Re: [PATCH] mempool/cnxk: avoid indefinite wait when counting batch alloc pointers To: Ashwin Sekhar T K Cc: dev@dpdk.org, Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao , Pavan Nikhilesh , jerinj@marvell.com, psatheesh@marvell.com, anoobj@marvell.com, gakhil@marvell.com, hkalra@marvell.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Tue, Apr 11, 2023 at 12:52=E2=80=AFPM Ashwin Sekhar T K wrote: > > Avoid waiting indefinitely when counting batch alloc pointers by adding a > wait timeout. > > Signed-off-by: Ashwin Sekhar T K Updated the git commit as follows and applied to dpdk-next-net-mrvl/for-next-net. Thanks mempool/cnxk: avoid hang when counting batch allocs Avoid waiting indefinitely when counting batch alloc pointers by adding= a wait timeout. Fixes: 8f2cd7946083 ("mempool/cnxk: add cn10k get count") Cc: stable@dpdk.org Signed-off-by: Ashwin Sekhar T K > --- > drivers/common/cnxk/roc_npa.h | 15 +++++++++------ > drivers/mempool/cnxk/cn10k_mempool_ops.c | 3 ++- > 2 files changed, 11 insertions(+), 7 deletions(-) > > diff --git a/drivers/common/cnxk/roc_npa.h b/drivers/common/cnxk/roc_npa.= h > index dd588b0322..1ef3ecc08a 100644 > --- a/drivers/common/cnxk/roc_npa.h > +++ b/drivers/common/cnxk/roc_npa.h > @@ -241,19 +241,23 @@ roc_npa_aura_batch_alloc_issue(uint64_t aura_handle= , uint64_t *buf, > } > > static inline void > -roc_npa_batch_alloc_wait(uint64_t *cache_line) > +roc_npa_batch_alloc_wait(uint64_t *cache_line, unsigned int wait_us) > { > + const uint64_t ticks =3D (uint64_t)wait_us * plt_tsc_hz() / (uint= 64_t)1E6; > + const uint64_t start =3D plt_tsc_cycles(); > + > /* Batch alloc status code is updated in bits [5:6] of the first = word > * of the 128 byte cache line. > */ > while (((__atomic_load_n(cache_line, __ATOMIC_RELAXED) >> 5) & 0x= 3) =3D=3D > ALLOC_CCODE_INVAL) > - ; > + if (wait_us && (plt_tsc_cycles() - start) >=3D ticks) > + break; > } > > static inline unsigned int > roc_npa_aura_batch_alloc_count(uint64_t *aligned_buf, unsigned int num, > - unsigned int do_wait) > + unsigned int wait_us) > { > unsigned int count, i; > > @@ -267,8 +271,7 @@ roc_npa_aura_batch_alloc_count(uint64_t *aligned_buf,= unsigned int num, > > status =3D (struct npa_batch_alloc_status_s *)&aligned_bu= f[i]; > > - if (do_wait) > - roc_npa_batch_alloc_wait(&aligned_buf[i]); > + roc_npa_batch_alloc_wait(&aligned_buf[i], wait_us); > > count +=3D status->count; > } > @@ -293,7 +296,7 @@ roc_npa_aura_batch_alloc_extract(uint64_t *buf, uint6= 4_t *aligned_buf, > > status =3D (struct npa_batch_alloc_status_s *)&aligned_bu= f[i]; > > - roc_npa_batch_alloc_wait(&aligned_buf[i]); > + roc_npa_batch_alloc_wait(&aligned_buf[i], 0); > > line_count =3D status->count; > > diff --git a/drivers/mempool/cnxk/cn10k_mempool_ops.c b/drivers/mempool/c= nxk/cn10k_mempool_ops.c > index ba826f0f01..ff0015d8de 100644 > --- a/drivers/mempool/cnxk/cn10k_mempool_ops.c > +++ b/drivers/mempool/cnxk/cn10k_mempool_ops.c > @@ -9,6 +9,7 @@ > > #define BATCH_ALLOC_SZ ROC_CN10K_NPA_BATCH_ALLOC_MAX_PTRS > #define BATCH_OP_DATA_TABLE_MZ_NAME "batch_op_data_table_mz" > +#define BATCH_ALLOC_WAIT_US 5 > > enum batch_op_status { > BATCH_ALLOC_OP_NOT_ISSUED =3D 0, > @@ -178,7 +179,7 @@ cn10k_mempool_get_count(const struct rte_mempool *mp) > > if (mem->status =3D=3D BATCH_ALLOC_OP_ISSUED) > count +=3D roc_npa_aura_batch_alloc_count( > - mem->objs, BATCH_ALLOC_SZ, 1); > + mem->objs, BATCH_ALLOC_SZ, BATCH_ALLOC_WA= IT_US); > > if (mem->status =3D=3D BATCH_ALLOC_OP_DONE) > count +=3D mem->sz; > -- > 2.25.1 >