From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7410C43331 for ; Thu, 2 Apr 2020 13:04:11 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 6DAEA20757 for ; Thu, 2 Apr 2020 13:04:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6DAEA20757 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DC1A62C15; Thu, 2 Apr 2020 15:04:10 +0200 (CEST) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id BCEBD2BCE for ; Thu, 2 Apr 2020 15:04:09 +0200 (CEST) From: Xueming Li To: Wenzhuo Lu , Jingjing Wu , Bernard Iremonger , Anatoly Burakov Cc: dev@dpdk.org, Asaf Penso Date: Thu, 2 Apr 2020 13:03:49 +0000 Message-Id: <1585832629-4959-1-git-send-email-xuemingl@mellanox.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] app/testpmd: add memory dump command 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" Introduce new command to dump memory statistics of each socket, summary, also show changes since last call. Usage: dump_socket Signed-off-by: Xueming Li --- app/test-pmd/cmdline.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index a037a55..27545ef 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -9566,6 +9566,55 @@ struct cmd_dump_result { #undef DUMP_SIZE } + +/* Dump the socket memory statistics on console */ +static void +dump_socket_mem(FILE *f) +{ + struct rte_malloc_socket_stats socket_stats; + unsigned int i; + int64_t total = 0; + int64_t alloc = 0; + int64_t free = 0; + unsigned int n_alloc = 0; + unsigned int n_free = 0; + static int64_t last_allocs; + static int64_t last_total; + + + for (i = 0; i < RTE_MAX_NUMA_NODES; i++) { + if (rte_malloc_get_socket_stats(i, &socket_stats) || + !socket_stats.heap_totalsz_bytes) + continue; + total += socket_stats.heap_totalsz_bytes; + alloc += socket_stats.heap_allocsz_bytes; + free += socket_stats.heap_freesz_bytes; + n_alloc += socket_stats.alloc_count; + n_free += socket_stats.free_count; + fprintf(f, + "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", + i, + socket_stats.heap_totalsz_bytes / 1.0e6, + socket_stats.heap_allocsz_bytes / 1.0e6, + (double)socket_stats.heap_allocsz_bytes * 100 / + (double)socket_stats.heap_totalsz_bytes, + socket_stats.heap_freesz_bytes / 1.0e6, + socket_stats.alloc_count, + socket_stats.free_count); + } + fprintf(f, + "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", + total / 1.0e6, alloc / 1.0e6, + (double)alloc * 100 / (double)total, free / 1.0e6, + n_alloc, n_free); + if (last_allocs) + fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n", + (total - last_total) / 1.0e6, + (alloc - last_allocs) / 1.0e6); + last_allocs = alloc; + last_total = total; +} + static void cmd_dump_parsed(void *parsed_result, __attribute__((unused)) struct cmdline *cl, __attribute__((unused)) void *data) @@ -9574,6 +9623,8 @@ static void cmd_dump_parsed(void *parsed_result, if (!strcmp(res->dump, "dump_physmem")) rte_dump_physmem_layout(stdout); + else if (!strcmp(res->dump, "dump_socket")) + dump_socket_mem(stdout); else if (!strcmp(res->dump, "dump_memzone")) rte_memzone_dump(stdout); else if (!strcmp(res->dump, "dump_struct_sizes")) @@ -9592,6 +9643,7 @@ static void cmd_dump_parsed(void *parsed_result, TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, "dump_physmem#" "dump_memzone#" + "dump_socket#" "dump_struct_sizes#" "dump_ring#" "dump_mempool#" -- 1.8.3.1