From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0063.outbound.protection.outlook.com [104.47.33.63]) by dpdk.org (Postfix) with ESMTP id 5C2787D2A for ; Tue, 15 Aug 2017 08:08:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=TL9ntvCIAcuy4T52VqKZm9CmTblwo2tIQlRsuGoRDqI=; b=Rr5kjFFxmDyAUI4xJBJSBFfCxvvwgLWxzE+VmGeJ4wC99B6yx65eSFDjHIY5JfkT82TIiK9LW2pRFXWbLvfhAZIrpXsvoeQq+LNYGKnyt+yZoCIP/KL+1zXoPwJ3eaDplQ0Z5EYNtNcKmgMRIJkTmLCqEZIL8kqyq5LCWlaR504= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Santosh.Shukla@cavium.com; Received: from localhost.localdomain (14.140.2.178) by BN6PR07MB3089.namprd07.prod.outlook.com (10.172.105.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1341.17; Tue, 15 Aug 2017 06:08:16 +0000 From: Santosh Shukla To: olivier.matz@6wind.com, dev@dpdk.org Cc: thomas@monjalon.net, jerin.jacob@caviumnetworks.com, hemant.agrawal@nxp.com, Santosh Shukla Date: Tue, 15 Aug 2017 11:37:38 +0530 Message-Id: <20170815060743.21076-3-santosh.shukla@caviumnetworks.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170815060743.21076-1-santosh.shukla@caviumnetworks.com> References: <20170720134759.4680-1-santosh.shukla@caviumnetworks.com> <20170815060743.21076-1-santosh.shukla@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: BMXPR01CA0022.INDPRD01.PROD.OUTLOOK.COM (10.174.214.160) To BN6PR07MB3089.namprd07.prod.outlook.com (10.172.105.7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c11a8a2a-7476-4349-21d4-08d4e3a40639 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:BN6PR07MB3089; X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3089; 3:AtV9uwwWXhiseHAzXrWrh92CQt8acvrEBgvRqCIXF+T92mWwF6GugGODjeczJsHhWIECSQsaV287RO4/LA5YUVuwQltHxchbU2vFI+mRUrdlkua3NO4/5Ejn6m4/wVX/oNNg1DCoOgLr2b8pR1ELoJLm+2K9J0iIXehypml+IT77Kjs/PTjmrXEv7sRN8ojY67ik9lqtB3qWsfyPv52yzIg0Ax3+6/osHSlbXzdvT69nudlFKFkJq1ACDo4w0UCn; 25:pqtJ39pN7EeshxXJt6cqKRGSFUlf0JsT2gvlN1qkb5MjB8mhJWoZFDc2u4qXWQ3G2VEVliNcJ6dVsYH3N9rXMbYENAQ0GrgVXzubgx74hHjs7NdGoWRThgfrV7A+9Pv6jT6APqnWyr0byfG2AvPGK/rewxcsTX4/irRZGyhi9lRA8SfTIPNVit6DrEyWXZ59pDGIzMA09eL2ymXt3RFFHKYa5G/F2JVWbzui6AhkaO3F7g5dbaYTUXkO1m2JHuR9hpJDtbgwhu4slmwXGvdR6N6oLneyA09HY3vOqIObLoJlywwNBr2KXOdFeiJ+FOzXZa0CEA3izcMHU/2V4iRJqA==; 31:fbcFtyd5cxkmEyXTAmkcJHpuEP8mn9NRyclLd3rtTgECYA9p7Rv3X2YQxdYpHF9ZxV0jWtcoxA63FVcoMrCkDkW15kUxUfWoD2GTUTuZt4bg+V+MpFq8OE+2XhJLff4T6teczfL5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o6E= X-Exchange-Antispam-Report-Test: UriScan:(131327999870524); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(100000703101)(100105400095)(93006095)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123560025)(20161123562025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR07MB3089; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR07MB3089; X-Forefront-PRVS: 04004D94E2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(6069001)(199003)(189002)(6512007)(106356001)(72206003)(6486002)(42882006)(6506006)(66066001)(2950100002)(47776003)(6666003)(48376002)(4326008)(36756003)(50466002)(575784001)(68736007)(478600001)(25786009)(2906002)(105586002)(97736004)(5660300001)(7736002)(305945005)(50226002)(8656003)(189998001)(53936002)(8676002)(5003940100001)(7350300001)(42186005)(33646002)(5009440100003)(76176999)(6116002)(3846002)(107886003)(81156014)(81166006)(110136004)(101416001)(50986999)(1076002)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR07MB3089; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR07MB3089; 23:qmEI1rrtcoZPN/fS0CDT7MEa0sV49pgxOXSqKoGl4?= =?us-ascii?Q?2hwiJxWzOFnMDUogSOxzMTL34CsvKZcDpHLTXKrkB+ggS8CpOn0EcGojtdNa?= =?us-ascii?Q?/uFNPZDLzo+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cj1/2aGSNbRF1+DAPn6Z/vllVCsqRKvnv6e/hJIDXkKWb6Eg1FWOvaomCisQCTyPKw0uSwY/ErvCb+006aYPMpR123rIeQooKzFuRZo45LSgQWd3Nm9c7c5dzEZ52/rXS+bnaZX2KQ675zRTZCsTTlJdLEzJk+HcXJpM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2017 06:08:16.1975 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB3089 Subject: [dpdk-dev] [PATCH v4 2/7] mempool: add mempool arg in xmem size and usage 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: , X-List-Received-Date: Tue, 15 Aug 2017 06:08:20 -0000 xmem_size and xmem_usage need to know the status of mp->flag. Following patch will make use of that. Signed-off-by: Santosh Shukla --- drivers/net/xenvirt/rte_mempool_gntalloc.c | 5 +++-- lib/librte_mempool/rte_mempool.c | 10 ++++++---- lib/librte_mempool/rte_mempool.h | 8 ++++++-- test/test/test_mempool.c | 4 ++-- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/net/xenvirt/rte_mempool_gntalloc.c b/drivers/net/xenvirt/rte_mempool_gntalloc.c index 73e82f808..ee0bda459 100644 --- a/drivers/net/xenvirt/rte_mempool_gntalloc.c +++ b/drivers/net/xenvirt/rte_mempool_gntalloc.c @@ -114,7 +114,7 @@ _create_mempool(const char *name, unsigned elt_num, unsigned elt_size, pg_shift = rte_bsf32(pg_sz); rte_mempool_calc_obj_size(elt_size, flags, &objsz); - sz = rte_mempool_xmem_size(elt_num, objsz.total_size, pg_shift); + sz = rte_mempool_xmem_size(elt_num, objsz.total_size, pg_shift, NULL); pg_num = sz >> pg_shift; pa_arr = calloc(pg_num, sizeof(pa_arr[0])); @@ -162,7 +162,8 @@ _create_mempool(const char *name, unsigned elt_num, unsigned elt_size, * Check that allocated size is big enough to hold elt_num * objects and a calcualte how many bytes are actually required. */ - usz = rte_mempool_xmem_usage(va, elt_num, objsz.total_size, pa_arr, pg_num, pg_shift); + usz = rte_mempool_xmem_usage(va, elt_num, objsz.total_size, pa_arr, + pg_num, pg_shift, NULL); if (usz < 0) { mp = NULL; i = pg_num; diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 237665c65..f95c01c00 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -238,7 +238,8 @@ rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags, * Calculate maximum amount of memory required to store given number of objects. */ size_t -rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz, uint32_t pg_shift) +rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz, uint32_t pg_shift, + __rte_unused const struct rte_mempool *mp) { size_t obj_per_page, pg_num, pg_sz; @@ -264,13 +265,14 @@ rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz, uint32_t pg_shift) ssize_t rte_mempool_xmem_usage(__rte_unused void *vaddr, uint32_t elt_num, size_t total_elt_sz, const phys_addr_t paddr[], uint32_t pg_num, - uint32_t pg_shift) + uint32_t pg_shift, __rte_unused const struct rte_mempool *mp) { uint32_t elt_cnt = 0; phys_addr_t start, end; uint32_t paddr_idx; size_t pg_sz = (size_t)1 << pg_shift; + /* if paddr is NULL, assume contiguous memory */ if (paddr == NULL) { start = 0; @@ -543,7 +545,7 @@ rte_mempool_populate_default(struct rte_mempool *mp) total_elt_sz = mp->header_size + mp->elt_size + mp->trailer_size; for (mz_id = 0, n = mp->size; n > 0; mz_id++, n -= ret) { - size = rte_mempool_xmem_size(n, total_elt_sz, pg_shift); + size = rte_mempool_xmem_size(n, total_elt_sz, pg_shift, mp); ret = snprintf(mz_name, sizeof(mz_name), RTE_MEMPOOL_MZ_FORMAT "_%d", mp->name, mz_id); @@ -600,7 +602,7 @@ get_anon_size(const struct rte_mempool *mp) pg_sz = getpagesize(); pg_shift = rte_bsf32(pg_sz); total_elt_sz = mp->header_size + mp->elt_size + mp->trailer_size; - size = rte_mempool_xmem_size(mp->size, total_elt_sz, pg_shift); + size = rte_mempool_xmem_size(mp->size, total_elt_sz, pg_shift, mp); return size; } diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index bd7be2319..74e91d34f 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -1476,11 +1476,13 @@ uint32_t rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags, * by rte_mempool_calc_obj_size(). * @param pg_shift * LOG2 of the physical pages size. If set to 0, ignore page boundaries. + * @param mp + * A pointer to the mempool structure. * @return * Required memory size aligned at page boundary. */ size_t rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz, - uint32_t pg_shift); + uint32_t pg_shift, const struct rte_mempool *mp); /** * Get the size of memory required to store mempool elements. @@ -1503,6 +1505,8 @@ size_t rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz, * Number of elements in the paddr array. * @param pg_shift * LOG2 of the physical pages size. + * @param mp + * A pointer to the mempool structure. * @return * On success, the number of bytes needed to store given number of * objects, aligned to the given page size. If the provided memory @@ -1511,7 +1515,7 @@ size_t rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz, */ ssize_t rte_mempool_xmem_usage(void *vaddr, uint32_t elt_num, size_t total_elt_sz, const phys_addr_t paddr[], uint32_t pg_num, - uint32_t pg_shift); + uint32_t pg_shift, const struct rte_mempool *mp); /** * Walk list of all memory pools diff --git a/test/test/test_mempool.c b/test/test/test_mempool.c index 47dc3ac5f..1eb81081c 100644 --- a/test/test/test_mempool.c +++ b/test/test/test_mempool.c @@ -485,10 +485,10 @@ test_mempool_xmem_misc(void) elt_num = MAX_KEEP; total_size = rte_mempool_calc_obj_size(MEMPOOL_ELT_SIZE, 0, NULL); - sz = rte_mempool_xmem_size(elt_num, total_size, MEMPOOL_PG_SHIFT_MAX); + sz = rte_mempool_xmem_size(elt_num, total_size, MEMPOOL_PG_SHIFT_MAX, NULL); usz = rte_mempool_xmem_usage(NULL, elt_num, total_size, 0, 1, - MEMPOOL_PG_SHIFT_MAX); + MEMPOOL_PG_SHIFT_MAX, NULL); if (sz != (size_t)usz) { printf("failure @ %s: rte_mempool_xmem_usage(%u, %u) " -- 2.11.0