From patchwork Fri Oct 20 14:00:11 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: 116498 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp10251edm; Fri, 20 Oct 2017 07:03:20 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RR1a7JEee8FpdNjjmdZK7vJeKwGfXp4MXsM6n0fHQ6+8sEJJH+fmPH6N4laevp/isaeEIa X-Received: by 10.37.194.130 with SMTP id s124mr3319278ybf.271.1508508200076; Fri, 20 Oct 2017 07:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508508200; cv=none; d=google.com; s=arc-20160816; b=CYkg0S9BlX4SMXOdOl0UqBDlyeTxyfK3Dtfj90XKdXrzV1ApUdoqHzrVflh1bSQOJs 33L+aS1oSL0YT725+SZ4WfGrJAGpZG90LBAJY4Cl0qRQ/uMhPdptzO5dem5WhPi9/Gwv RqS2gtNPF7uq8x+gW0Rgr22zYogZFq4RwqvCKxgCjyLXmjo+puFjLx1RQvepLsU7rSuf AaL+/crsRsxzUwjA84H/QKhK+l3FhKXFeAKLS/H0GLXVuYE1Wbwkd8xtcULSwslHcJle 9/nlZq6LdXn6TwneAZi3j4JJNjM5X8Qhf5jXe9pm2ZuY2h1j1LwlCn0uTqdjRucZW4dV fOBw== 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=Dtb5uIe+coLPNK8Yes3jf9GqKv3migtaUqPxwGH/ORw=; b=YpuLvdyrnftQncJNjLliq1zgkz9GHyg73ie666CiaMqUHAA9jKnuhG1wqhj6O+/vkk acXtE/tTWTXG+UktrX2vcsRhNDfXB/7CeR/ZIMkbSY6o12EJC2dP8H1qGHWvVk1NBNUU ChjRh0YB7hPHRnMNMQFNzoWFPebz+9w2QiznNyFjQc9LF8GD1gYm8WEbD8/d/F8X8tem SfpGRLtotX/nI/XFhZCD1jMjCdVGWQ/HakR3q6T4Ls1wcCIk8umU2sluS0U8Pe7jkiyU HHtEp/7v4dp3T+nJlvkzjGlv7qJY9JWXfosG/fRRHkzFmq3oU76XZjcY7DeP3ffPwHsh l8GQ== 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 n17si792976qki.236.2017.10.20.07.03.18; Fri, 20 Oct 2017 07:03:20 -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 129A160CF7; Fri, 20 Oct 2017 14:03:18 +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 E309960FFA; Fri, 20 Oct 2017 14:00:45 +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 B1C2760D36; Fri, 20 Oct 2017 14:00:23 +0000 (UTC) Received: from forward101p.mail.yandex.net (forward101p.mail.yandex.net [77.88.28.101]) by lists.linaro.org (Postfix) with ESMTPS id ACC316013A for ; Fri, 20 Oct 2017 14:00:19 +0000 (UTC) Received: from mxback12g.mail.yandex.net (mxback12g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:91]) by forward101p.mail.yandex.net (Yandex) with ESMTP id 3C8876A84485 for ; Fri, 20 Oct 2017 17:00:18 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback12g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id lH0nCV7tXt-0IDCLEBv; Fri, 20 Oct 2017 17:00:18 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id EU0BCjigMs-0Hdm3GvM; 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:11 +0300 Message-Id: <1508508011-21260-5-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 4/4] linux-gen: shm: implement odp_shm_print 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 Implement the new block level debug print function. 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 | 49 +++++++++++++++++++++++++ platform/linux-generic/include/_ishm_internal.h | 1 + platform/linux-generic/odp_shared_memory.c | 5 +++ test/common_plat/validation/api/shmem/shmem.c | 2 + 4 files changed, 57 insertions(+) diff --git a/platform/linux-generic/_ishm.c b/platform/linux-generic/_ishm.c index e7a6c2357..238efb81a 100644 --- a/platform/linux-generic/_ishm.c +++ b/platform/linux-generic/_ishm.c @@ -1837,3 +1837,52 @@ int _odp_ishm_status(const char *title) odp_spinlock_unlock(&ishm_tbl->lock); return nb_blocks; } + +void _odp_ishm_print(int block_index) +{ + ishm_block_t *block; + const char *str; + + odp_spinlock_lock(&ishm_tbl->lock); + + if ((block_index < 0) || + (block_index >= ISHM_MAX_NB_BLOCKS) || + (ishm_tbl->block[block_index].len == 0)) { + odp_spinlock_unlock(&ishm_tbl->lock); + ODP_ERR("Request for info on an invalid block\n"); + return; + } + + block = &ishm_tbl->block[block_index]; + + ODP_PRINT("\nSHM block info\n--------------\n"); + ODP_PRINT(" name: %s\n", block->name); + ODP_PRINT(" file: %s\n", block->filename); + ODP_PRINT(" expt: %s\n", block->exptname); + ODP_PRINT(" user_flags: 0x%x\n", block->user_flags); + ODP_PRINT(" flags: 0x%x\n", block->flags); + ODP_PRINT(" user_len: %lu\n", block->user_len); + ODP_PRINT(" start: %p\n", block->start); + ODP_PRINT(" len: %lu\n", block->len); + + switch (block->huge) { + case HUGE: + str = "huge"; + break; + case NORMAL: + str = "normal"; + break; + case EXTERNAL: + str = "external"; + break; + default: + str = "??"; + } + + ODP_PRINT(" page type: %s\n", str); + ODP_PRINT(" seq: %lu\n", block->seq); + ODP_PRINT(" refcnt: %lu\n", block->refcnt); + ODP_PRINT("\n"); + + odp_spinlock_unlock(&ishm_tbl->lock); +} diff --git a/platform/linux-generic/include/_ishm_internal.h b/platform/linux-generic/include/_ishm_internal.h index 005d6b551..34068bc0c 100644 --- a/platform/linux-generic/include/_ishm_internal.h +++ b/platform/linux-generic/include/_ishm_internal.h @@ -45,6 +45,7 @@ void *_odp_ishm_address(int block_index); int _odp_ishm_info(int block_index, _odp_ishm_info_t *info); int _odp_ishm_status(const char *title); int _odp_ishm_cleanup_files(const char *dirpath); +void _odp_ishm_print(int block_index); #ifdef __cplusplus } diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c index ccd25c8c8..aabecd9b0 100644 --- a/platform/linux-generic/odp_shared_memory.c +++ b/platform/linux-generic/odp_shared_memory.c @@ -116,6 +116,11 @@ void odp_shm_print_all(void) _odp_ishm_status("Memory allocation status:"); } +void odp_shm_print(odp_shm_t shm) +{ + _odp_ishm_print(from_handle(shm)); +} + uint64_t odp_shm_to_u64(odp_shm_t hdl) { return _odp_pri(hdl); diff --git a/test/common_plat/validation/api/shmem/shmem.c b/test/common_plat/validation/api/shmem/shmem.c index 08587940c..d5335afa9 100644 --- a/test/common_plat/validation/api/shmem/shmem.c +++ b/test/common_plat/validation/api/shmem/shmem.c @@ -152,6 +152,8 @@ void shmem_test_basic(void) odp_cunit_thread_create(run_test_basic_thread, &thrdarg); CU_ASSERT(odp_cunit_thread_exit(&thrdarg) >= 0); + odp_shm_print(shm); + CU_ASSERT(0 == odp_shm_free(shm)); }