From patchwork Fri Oct 20 14:00:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 116500 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp13688edm; Fri, 20 Oct 2017 07:05:51 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RBmvljnntgSIU30xXloHST9o6FViUSAMFn1tG579X5UxgS3DGdrVkV5VAgPRhYNReHQYmx X-Received: by 10.55.125.196 with SMTP id y187mr7447035qkc.180.1508508351059; Fri, 20 Oct 2017 07:05:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508508351; cv=none; d=google.com; s=arc-20160816; b=EolAcverp/yp33uBKD3fqylcUh9N1Bo2GCNjuIOLTjDZSuSqFIRuvCofZLgiXSLNI/ pUzgk8sE3y4hMS42iaO0IK+c5nyOSEF3LxTa9xh15Prtcnm3fw+ZB+N/KxTrPd9wpTcj jHStd5gtByyx4qWqhANLpz3qNoQn6yoorahFj2JgkKo9oNYWM6CYllxCSz4tAkgYgFvz /eWnVqW+5p36ehUTRcltM4HJchiUSGo/BavjZVYaaWhk5WvT0zzVnQOtvEMqj0I0N6Kz lOHbbgjZ8p6xOf0baicoSolAiulq6XvU6Qloi35rHF0tuVNTRLCIKEPEyPYl2UELRak2 1mMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=DiiMywTk0owXMfWjiIhCaN7bcQTTI75LzX2wtMMtNk4=; b=wo05Z/U5l1CyVJOn1Gye2hUKXgY2hntcLJu69UoH9yBI/yepwlHQYEFzajjH5GIw/O Z3GFzn38dN2eT84hsEpkwqMNn+MLPoSI2uwTu6+kmrWoXWARu/x5sSXn7jwz3wCIZqhn 69eO2xupmEraSx/x6nLpdJ+GqicTmNMQZLePG0WSfRfZtzIb6jSbDqaDJM7661QhxA9w tgLzoAg1hWl+GVTRT3PMjMDPcCZw8rVhnBPWiW1zfX/AAGUYM7qXowkUzZQvTu7pSg3T D611MVEEDRnolhrGilNtijetyrkATPTHycjeDVxBjIze4ipdyBMSZZCL9AA4GU5UpjXG k60Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id x42si816409qtx.462.2017.10.20.07.05.50; Fri, 20 Oct 2017 07:05:51 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id C1F95608C4; Fri, 20 Oct 2017 14:05:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 0EDB861012; Fri, 20 Oct 2017 14:00:59 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 45A4E609AC; Fri, 20 Oct 2017 14:00:26 +0000 (UTC) Received: from forward103o.mail.yandex.net (forward103o.mail.yandex.net [37.140.190.177]) by lists.linaro.org (Postfix) with ESMTPS id 2788060C8F for ; Fri, 20 Oct 2017 14:00:19 +0000 (UTC) Received: from mxback11j.mail.yandex.net (mxback11j.mail.yandex.net [IPv6:2a02:6b8:0:1619::84]) by forward103o.mail.yandex.net (Yandex) with ESMTP id BC8365886466 for ; Fri, 20 Oct 2017 17:00:17 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback11j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Jr7uLcRgdA-0HcaeoD4; Fri, 20 Oct 2017 17:00:17 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id EU0BCjigMs-0HdG63Gv; Fri, 20 Oct 2017 17:00:17 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Fri, 20 Oct 2017 17:00:10 +0300 Message-Id: <1508508011-21260-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508508011-21260-1-git-send-email-odpbot@yandex.ru> References: <1508508011-21260-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 246 Subject: [lng-odp] [PATCH API-NEXT v1 3/4] linux-gen: shm: make odp_shm_print_all readable again X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Petri Savolainen Use ODP_PRINT instead of ODP_DBG in the print function. The idea of a print function is that it prints information when application calls it. ODP_DBG does not print anything by default. Format printted output to be a readable table of shm blocks. Signed-off-by: Petri Savolainen --- /** Email created from pull request 246 (psavol:next-shm-print) ** https://github.com/Linaro/odp/pull/246 ** Patch: https://github.com/Linaro/odp/pull/246.patch ** Base sha: e3108af2f0b58c2ceca422b418439bba5de04b11 ** Merge commit sha: d02ca128bb3e497ed54c1224b5bd9d9f707870b3 **/ platform/linux-generic/_ishm.c | 69 +++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/platform/linux-generic/_ishm.c b/platform/linux-generic/_ishm.c index 6e5bc61fe..e7a6c2357 100644 --- a/platform/linux-generic/_ishm.c +++ b/platform/linux-generic/_ishm.c @@ -1708,11 +1708,28 @@ int _odp_ishm_status(const char *title) int nb_allocated_frgments = 0; /* nb frag describing an allocated VA */ int nb_blocks = 0; int single_va_blocks = 0; + int max_name_len = 0; odp_spinlock_lock(&ishm_tbl->lock); procsync(); - ODP_DBG("ishm blocks allocated at: %s\n", title); + /* find longest block name */ + for (i = 0; i < ISHM_MAX_NB_BLOCKS; i++) { + int str_len; + + if (ishm_tbl->block[i].len <= 0) + continue; + + str_len = strlen(ishm_tbl->block[i].name); + + if (max_name_len < str_len) + max_name_len = str_len; + } + + ODP_PRINT("ishm blocks allocated at: %s\n", title); + + ODP_PRINT(" %-*s flag len user_len seq ref start fd" + " file\n", max_name_len, "name"); /* display block table: 1 line per entry +1 extra line if mapped here */ for (i = 0; i < ISHM_MAX_NB_BLOCKS; i++) { @@ -1742,41 +1759,39 @@ int _odp_ishm_status(const char *title) huge = '?'; } proc_index = procfind_block(i); - ODP_DBG("%-3d: name:%-.24s file:%-.24s" - " flags:%s,%c len:0x%-08lx" - " user_len:%-8ld seq:%-3ld refcnt:%-4d\n", - i, - ishm_tbl->block[i].name, - ishm_tbl->block[i].filename, - flags, huge, - ishm_tbl->block[i].len, - ishm_tbl->block[i].user_len, - ishm_tbl->block[i].seq, - ishm_tbl->block[i].refcnt); + ODP_PRINT("%2i %-*s %s%c 0x%-08lx %-8lu %-3lu %-3lu", + i, max_name_len, ishm_tbl->block[i].name, + flags, huge, + ishm_tbl->block[i].len, + ishm_tbl->block[i].user_len, + ishm_tbl->block[i].seq, + ishm_tbl->block[i].refcnt); if (proc_index < 0) continue; - ODP_DBG(" start:%-08lx fd:%-3d\n", - ishm_proctable->entry[proc_index].start, - ishm_proctable->entry[proc_index].fd); + ODP_PRINT("%-08lx %-3d", + ishm_proctable->entry[proc_index].start, + ishm_proctable->entry[proc_index].fd); + + ODP_PRINT("%s\n", ishm_tbl->block[i].filename); } /* display the virtual space allocations... : */ - ODP_DBG("ishm virtual space:\n"); + ODP_PRINT("\nishm virtual space:\n"); for (fragmnt = ishm_ftbl->used_fragmnts; fragmnt; fragmnt = fragmnt->next) { if (fragmnt->block_index >= 0) { nb_allocated_frgments++; - ODP_DBG(" %08p - %08p: ALLOCATED by block:%d\n", - (uintptr_t)fragmnt->start, - (uintptr_t)fragmnt->start + fragmnt->len - 1, - fragmnt->block_index); + ODP_PRINT(" %08p - %08p: ALLOCATED by block:%d\n", + (uintptr_t)fragmnt->start, + (uintptr_t)fragmnt->start + fragmnt->len - 1, + fragmnt->block_index); consecutive_unallocated = 0; } else { - ODP_DBG(" %08p - %08p: NOT ALLOCATED\n", - (uintptr_t)fragmnt->start, - (uintptr_t)fragmnt->start + fragmnt->len - 1); + ODP_PRINT(" %08p - %08p: NOT ALLOCATED\n", + (uintptr_t)fragmnt->start, + (uintptr_t)fragmnt->start + fragmnt->len - 1); if (consecutive_unallocated++) ODP_ERR("defragmentation error\n"); } @@ -1807,9 +1822,9 @@ int _odp_ishm_status(const char *title) fragmnt; fragmnt = fragmnt->next) nb_unused_frgments++; - ODP_DBG("ishm: %d fragment used. %d fragments unused. (total=%d)\n", - nb_used_frgments, nb_unused_frgments, - nb_used_frgments + nb_unused_frgments); + ODP_PRINT("ishm: %d fragment used. %d fragments unused. (total=%d)\n", + nb_used_frgments, nb_unused_frgments, + nb_used_frgments + nb_unused_frgments); if ((nb_used_frgments + nb_unused_frgments) != ISHM_NB_FRAGMNTS) ODP_ERR("lost fragments!\n"); @@ -1817,7 +1832,7 @@ int _odp_ishm_status(const char *title) if (nb_blocks < ishm_proctable->nb_entries) ODP_ERR("process known block cannot exceed main total sum!\n"); - ODP_DBG("\n"); + ODP_PRINT("\n"); odp_spinlock_unlock(&ishm_tbl->lock); return nb_blocks;