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 8EE4F459AE; Mon, 16 Sep 2024 14:38:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DE0D941104; Mon, 16 Sep 2024 14:38:02 +0200 (CEST) Received: from forward500d.mail.yandex.net (forward500d.mail.yandex.net [178.154.239.208]) by mails.dpdk.org (Postfix) with ESMTP id 012A641149 for ; Mon, 16 Sep 2024 14:38:01 +0200 (CEST) Received: from mail-nwsmtp-smtp-production-main-45.klg.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-45.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:70a1:0:640:6c31:0]) by forward500d.mail.yandex.net (Yandex) with ESMTPS id C552A60EF2; Mon, 16 Sep 2024 15:38:00 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-45.klg.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id ZbK04ZPqD8c0-vwBqlqXW; Mon, 16 Sep 2024 15:37:59 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1726490280; bh=Y8bk/d2h9Cvi9SkH+Kal5ADDpNZjk/WNl/rbNHqSm+c=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=fnamaNbTDX12pvhPd9QcT3Lts2DaIxfrA8b/Jo47KZo0m/X/vqZiYaozxZ6/va3JT qVGGa9h39jW03TvFxxrDfJy2O6xqzjH09iFxi5XB5/DGC0uy7gC7hzgZtzAL6Eg61G he18Zgt4FJFmj4wEfSo9Z5N8rNiWKKlYQaNpFhsc= Authentication-Results: mail-nwsmtp-smtp-production-main-45.klg.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Konstantin Ananyev To: dev@dpdk.org Cc: honnappa.nagarahalli@arm.com, jerinj@marvell.com, hemant.agrawal@nxp.com, bruce.richardson@intel.com, drc@linux.vnet.ibm.com, ruifeng.wang@arm.com, mb@smartsharesystems.com, Eimear Morrissey Subject: [PATCH v3 3/5] ring: make dump function more verbose Date: Mon, 16 Sep 2024 13:37:31 +0100 Message-Id: <20240916123733.994-4-konstantin.v.ananyev@yandex.ru> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240916123733.994-1-konstantin.v.ananyev@yandex.ru> References: <20240906131348.804-1-konstantin.v.ananyev@yandex.ru> <20240916123733.994-1-konstantin.v.ananyev@yandex.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Eimear Morrissey The current rte_ring_dump function uses the generic rte_ring_headtail structure to access head/tail positions. This is incorrect for the RTS case where the head is stored in a different offset in the union of structs. Switching to a separate function for each sync type allows to dump correct head/tail values and extra metadata. Signed-off-by: Eimear Morrissey --- .mailmap | 1 + app/test/test_ring_stress_impl.h | 1 + lib/ring/rte_ring.c | 87 ++++++++++++++++++++++++++++++-- lib/ring/rte_ring.h | 15 ++++++ lib/ring/version.map | 7 +++ 5 files changed, 107 insertions(+), 4 deletions(-) diff --git a/.mailmap b/.mailmap index 4a508bafad..3da86393c0 100644 --- a/.mailmap +++ b/.mailmap @@ -379,6 +379,7 @@ Eduard Serra Edward Makarov Edwin Brossette Eelco Chaudron +Eimear Morrissey Elad Nachman Elad Persiko Elena Agostini diff --git a/app/test/test_ring_stress_impl.h b/app/test/test_ring_stress_impl.h index 8b0bfb11fe..8449cb4b15 100644 --- a/app/test/test_ring_stress_impl.h +++ b/app/test/test_ring_stress_impl.h @@ -380,6 +380,7 @@ test_mt1(int (*test)(void *)) } lcore_stat_dump(stdout, UINT32_MAX, &arg[mc].stats); + rte_ring_dump(stdout, r); mt1_fini(r, data); return rc; } diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c index aebb6d6728..261f2a06db 100644 --- a/lib/ring/rte_ring.c +++ b/lib/ring/rte_ring.c @@ -364,20 +364,99 @@ rte_ring_free(struct rte_ring *r) rte_free(te); } +static const char * +ring_get_sync_type(const enum rte_ring_sync_type st) +{ + switch (st) { + case RTE_RING_SYNC_ST: + return "single thread"; + case RTE_RING_SYNC_MT: + return "multi thread"; + case RTE_RING_SYNC_MT_RTS: + return "multi thread - RTS"; + case RTE_RING_SYNC_MT_HTS: + return "multi thread - HTS"; + default: + return "unknown"; + } +} + +static void +ring_dump_ht_headtail(FILE *f, const char *prefix, + const struct rte_ring_headtail *ht) +{ + fprintf(f, "%ssync_type=%s\n", prefix, + ring_get_sync_type(ht->sync_type)); + fprintf(f, "%shead=%"PRIu32"\n", prefix, ht->head); + fprintf(f, "%stail=%"PRIu32"\n", prefix, ht->tail); +} + +static void +ring_dump_rts_headtail(FILE *f, const char *prefix, + const struct rte_ring_rts_headtail *rts) +{ + fprintf(f, "%ssync_type=%s\n", prefix, + ring_get_sync_type(rts->sync_type)); + fprintf(f, "%shead.pos=%"PRIu32"\n", prefix, rts->head.val.pos); + fprintf(f, "%shead.cnt=%"PRIu32"\n", prefix, rts->head.val.cnt); + fprintf(f, "%stail.pos=%"PRIu32"\n", prefix, rts->tail.val.pos); + fprintf(f, "%stail.cnt=%"PRIu32"\n", prefix, rts->tail.val.cnt); + fprintf(f, "%shtd_max=%"PRIu32"\n", prefix, rts->htd_max); +} + +static void +ring_dump_hts_headtail(FILE *f, const char *prefix, + const struct rte_ring_hts_headtail *hts) +{ + fprintf(f, "%ssync_type=%s\n", prefix, + ring_get_sync_type(hts->sync_type)); + fprintf(f, "%shead=%"PRIu32"\n", prefix, hts->ht.pos.head); + fprintf(f, "%stail=%"PRIu32"\n", prefix, hts->ht.pos.tail); +} + +void +rte_ring_headtail_dump(FILE *f, const char *prefix, + const struct rte_ring_headtail *r) +{ + if (f == NULL || r == NULL) + return; + + prefix = (prefix != NULL) ? prefix : ""; + + switch (r->sync_type) { + case RTE_RING_SYNC_ST: + case RTE_RING_SYNC_MT: + ring_dump_ht_headtail(f, prefix, r); + break; + case RTE_RING_SYNC_MT_RTS: + ring_dump_rts_headtail(f, prefix, + (const struct rte_ring_rts_headtail *)r); + break; + case RTE_RING_SYNC_MT_HTS: + ring_dump_hts_headtail(f, prefix, + (const struct rte_ring_hts_headtail *)r); + break; + default: + RING_LOG(ERR, "Invalid ring sync type detected"); + } +} + /* dump the status of the ring on the console */ void rte_ring_dump(FILE *f, const struct rte_ring *r) { + if (f == NULL || r == NULL) + return; + fprintf(f, "ring <%s>@%p\n", r->name, r); fprintf(f, " flags=%x\n", r->flags); fprintf(f, " size=%"PRIu32"\n", r->size); fprintf(f, " capacity=%"PRIu32"\n", r->capacity); - fprintf(f, " ct=%"PRIu32"\n", r->cons.tail); - fprintf(f, " ch=%"PRIu32"\n", r->cons.head); - fprintf(f, " pt=%"PRIu32"\n", r->prod.tail); - fprintf(f, " ph=%"PRIu32"\n", r->prod.head); fprintf(f, " used=%u\n", rte_ring_count(r)); fprintf(f, " avail=%u\n", rte_ring_free_count(r)); + + rte_ring_headtail_dump(f, " cons.", &(r->cons)); + rte_ring_headtail_dump(f, " prod.", &(r->prod)); } /* dump the status of all rings on the console */ diff --git a/lib/ring/rte_ring.h b/lib/ring/rte_ring.h index c709f30497..d6f9e85c64 100644 --- a/lib/ring/rte_ring.h +++ b/lib/ring/rte_ring.h @@ -204,6 +204,21 @@ void rte_ring_free(struct rte_ring *r); */ void rte_ring_dump(FILE *f, const struct rte_ring *r); +/** + * Dump the status of a headtail to a file. + * + * @param f + * A pointer to a file for output + * @param prefix + * A string to prefix each output line with + * @param r + * A pointer to a ring headtail structure. + */ +__rte_experimental +void +rte_ring_headtail_dump(FILE *f, const char *prefix, + const struct rte_ring_headtail *r); + /** * Enqueue several objects on the ring (multi-producers safe). * diff --git a/lib/ring/version.map b/lib/ring/version.map index 8da094a69a..61f7464f5a 100644 --- a/lib/ring/version.map +++ b/lib/ring/version.map @@ -14,3 +14,10 @@ DPDK_25 { local: *; }; + +EXPERIMENTAL { + global: + + # added in 24.11 + rte_ring_headtail_dump; +}; -- 2.35.3