From patchwork Mon Oct 23 10:00:17 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: 116671 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4458062qgn; Mon, 23 Oct 2017 03:05:40 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TVip5bk4AJN6phcjczBFQ6/A+jzFQInWW+m6dKKpukhiXMXnZ2mQvzg/WwScTWa3efyFpP X-Received: by 10.200.63.242 with SMTP id v47mr19659804qtk.29.1508753140807; Mon, 23 Oct 2017 03:05:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508753140; cv=none; d=google.com; s=arc-20160816; b=LKAzWG033+1ZUV45jyObcnFPEWxnyL1AgSmqlbQT+GoMcP76oc3zxywTIEUvmIDPnK 919bsqbQhVOw5DIaf062XOZEcxn/zTi1+UwBMwA8ZhVGi0tEzmb6YEHBv4VRtGVv5zzy IPqWyppIMbiNSS9wCw0q8E7N3mXjV/kzDYRz/NRelHv+yDzbHKlB7QOryNywFXOJiyg9 6ymUVJdPxtdtsHXaK8GSPakiksfIb+7GCy7R6gDV8rdszy6Ox2FNsATX4aVukjk5P0Is dPAdkZDOnzwSk0xnMXbmxy5coH9fbHzHVcaLakTz2d9ggDK5f8+5e/xjoeFszKDpw26e poxw== 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=gAR6TvuZZ+vgXIh5B35DFAHl+XP9Qjc1DtAjUqpvkn4=; b=kVqEury+7XMetPKMnSiOX/nUkY8pW4XN63dbat2zE3fctezP+xKbKqoRqIJmLIl5zO NkdemlsZsjWKFe+iGG/nSSshQQjtzVDnXt3t9O42mc3zHdQllzBtroMmHlLB1kqN6a4V noCY3LXq77qxcwbMZ/Z+yvrSpYD2ZdYmSoEN9IL1SSG+MZf8E5sccRT00gbRLRjOdkoq ERyn8fDeH5iaKyzoP1mpoW5EGTLL8w9rc2zvt2bU1/RXEIPM5sqlI6G+hfFrpT/7NOSk sR/QkMi92KgSvGjCT87pAoZSf/deHJufXrRI8VaGrk5UUimK5cZqOF12sFo9KWYEQkKx 7RXg== 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 100si345334qkx.263.2017.10.23.03.05.40; Mon, 23 Oct 2017 03:05:40 -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 5242F61CBB; Mon, 23 Oct 2017 10:05:40 +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 643F961D5D; Mon, 23 Oct 2017 10:02:57 +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 B464F61D5E; Mon, 23 Oct 2017 10:02:43 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id 7264861667 for ; Mon, 23 Oct 2017 10:00:36 +0000 (UTC) Received: from mxback9g.mail.yandex.net (mxback9g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:170]) by forward100p.mail.yandex.net (Yandex) with ESMTP id 50FFF5103866 for ; Mon, 23 Oct 2017 13:00:35 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback9g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 8DXtmsGMfd-0ZDi3fH2; Mon, 23 Oct 2017 13:00:35 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id fSL5x6gEpl-0Y8W5PpF; Mon, 23 Oct 2017 13:00:34 +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: Mon, 23 Oct 2017 13:00:17 +0300 Message-Id: <1508752817-11952-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508752817-11952-1-git-send-email-odpbot@yandex.ru> References: <1508752817-11952-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 246 Subject: [lng-odp] [PATCH API-NEXT v2 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: ec6510b33e8b96d6d6670efb9dc3c9101baed6c6 ** Merge commit sha: fe0769b6e9387bbfabf68b538ec83a685f406da0 **/ platform/linux-generic/_ishm.c | 49 +++++++++++++++++++++++++ platform/linux-generic/include/_ishm_internal.h | 1 + platform/linux-generic/odp_shared_memory.c | 5 +++ test/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/validation/api/shmem/shmem.c b/test/validation/api/shmem/shmem.c index 08587940c..d5335afa9 100644 --- a/test/validation/api/shmem/shmem.c +++ b/test/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)); }