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 6E70542E23 for ; Sat, 8 Jul 2023 18:24:04 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 627234111C; Sat, 8 Jul 2023 18:24:04 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 07B8E40156; Sat, 8 Jul 2023 18:24:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688833441; x=1720369441; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=A00Upl2boDg5RVHF7M6LNeaOxQgU+FZXNaZXJk1dRcE=; b=Q2ADA6La5PzO0PeDGd4CCxpU62MHy0eH+7YZzKrxsm1PtY5Zq3KTnrpU r2Sr5p59gY2iTEAukATWUG5EHesigqRqLYxQEgRLC+c0sc27PMjOeSUDk 4xb5+ANH2rQnUlmqSoaIywI9MO59QYo24X8OPDGlAtlmErl9PX8ThQA56 w98LX98snJuHx+tAnsqyF0YutRyMCg2tsFhR1aAmvj3DR4YAGjSQnG5sK J7uhHpm4wGGHEgAvc2kgnOZA15IvqskWply+0dF7X99Qn4hQJjyItXoiY GICYszP9wxdVTmJof4puLNXgRI7mCM8wM5Sxqb6BTaYzeyWUDjBQ6Kk/U A==; X-IronPort-AV: E=McAfee;i="6600,9927,10765"; a="364114736" X-IronPort-AV: E=Sophos;i="6.01,191,1684825200"; d="scan'208";a="364114736" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jul 2023 09:23:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10765"; a="790311539" X-IronPort-AV: E=Sophos;i="6.01,191,1684825200"; d="scan'208";a="790311539" Received: from txanpdk02.an.intel.com ([10.123.117.76]) by fmsmga004.fm.intel.com with ESMTP; 08 Jul 2023 09:23:59 -0700 From: Abdullah Sevincer To: dev@dpdk.org Cc: reshma.pattan@intel.com, stephen@networkplumber.org, Abdullah Sevincer , stable@dpdk.org Subject: [PATCH v1] app/procinfo: revise display eventdev xstats Date: Sat, 8 Jul 2023 11:23:56 -0500 Message-Id: <20230708162356.2961843-1-abdullah.sevincer@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 process_eventdev_xstats() function was iterating over eventdev_var[] structure even if there is no eventdev present. Revised the code to check to iterate and only look for the number of eventdevs present in the system. Also, shortened function name to eventdev_xstats(). Coverity issue: 395458 Fixes: 674bb3906931 ("app/procinfo: display eventdev xstats") Cc: stable@dpdk.org Signed-off-by: Abdullah Sevincer --- app/proc-info/main.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/app/proc-info/main.c b/app/proc-info/main.c index be63eace69..88cee0ca48 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -2045,19 +2045,16 @@ xstats_reset(uint8_t dev_id, } -static int -process_eventdev_xstats(void) +static unsigned int +eventdev_xstats(void) { - int i; - int j; - int processing_eventdev_xstats = 0; - - for (i = 0; i < RTE_EVENT_MAX_DEVS; i++) { + unsigned int count = 0; + int i, j; - if (!processing_eventdev_xstats) - processing_eventdev_xstats = 1; + for (i = 0; i < rte_event_dev_count(); i++) { if (eventdev_var[i].dump_xstats) { + ++count; int ret = rte_event_dev_dump(i, stdout); if (ret) @@ -2065,6 +2062,7 @@ process_eventdev_xstats(void) } if (eventdev_var[i].shw_device_xstats == 1) { + ++count; xstats_display(i, RTE_EVENT_DEV_XSTATS_DEVICE, 0); if (eventdev_var[i].reset_xstats == 1) @@ -2072,6 +2070,7 @@ process_eventdev_xstats(void) } if (eventdev_var[i].shw_all_ports == 1) { + ++count; for (j = 0; j < MAX_PORTS_QUEUES; j++) { xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT, j); @@ -2079,6 +2078,8 @@ process_eventdev_xstats(void) xstats_reset(i, RTE_EVENT_DEV_XSTATS_PORT, j); } } else { + if (eventdev_var[i].num_ports > 0) + ++count; for (j = 0; j < eventdev_var[i].num_ports; j++) { xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT, eventdev_var[i].ports[j]); @@ -2090,6 +2091,7 @@ process_eventdev_xstats(void) } if (eventdev_var[i].shw_all_queues == 1) { + ++count; for (j = 0; j < MAX_PORTS_QUEUES; j++) { xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE, j); @@ -2097,6 +2099,8 @@ process_eventdev_xstats(void) xstats_reset(i, RTE_EVENT_DEV_XSTATS_QUEUE, j); } } else { + if (eventdev_var[i].num_queues > 0) + ++count; for (j = 0; j < eventdev_var[i].num_queues; j++) { xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE, eventdev_var[i].queues[j]); @@ -2108,10 +2112,7 @@ process_eventdev_xstats(void) } } - if (processing_eventdev_xstats) - return 1; - - return 0; + return count; } int @@ -2164,7 +2165,7 @@ main(int argc, char **argv) return 0; } - if (process_eventdev_xstats()) + if (eventdev_xstats() > 0) return 0; nb_ports = rte_eth_dev_count_avail(); -- 2.25.1