From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0077.outbound.protection.outlook.com [104.47.34.77]) by dpdk.org (Postfix) with ESMTP id A542D7CB5 for ; Wed, 6 Sep 2017 13:29:35 +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=azwMOqreXcTDp3cdot6oD12hX5biKabWQBcQBioUdK8=; b=EqpiKVBbwktX+W7JI4Lj+V0+UKffQCIxOQkEUGV5/tZ1hP5JXQdky9ZkSS/uuWeg8q75To4Mh2lq1KIYsPHPVNPvjNafbhM0rM/Xr+fyPvUXP1uX6uxpjme8q8ozL8Ntx1eR2CsIeBtQ9EFJsfqy8dXtSR/5iF/bAbvZuLyAnhk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Santosh.Shukla@cavium.com; Received: from localhost.localdomain (14.140.2.178) by DM5PR07MB3098.namprd07.prod.outlook.com (10.172.85.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.35.12; Wed, 6 Sep 2017 11:29:31 +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: Wed, 6 Sep 2017 16:58:33 +0530 Message-Id: <20170906112834.32378-8-santosh.shukla@caviumnetworks.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170906112834.32378-1-santosh.shukla@caviumnetworks.com> References: <20170815060743.21076-1-santosh.shukla@caviumnetworks.com> <20170906112834.32378-1-santosh.shukla@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: BM1PR01CA0080.INDPRD01.PROD.OUTLOOK.COM (10.174.208.148) To DM5PR07MB3098.namprd07.prod.outlook.com (10.172.85.8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 25e5bf51-244d-41ec-14f1-08d4f51a8c8d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM5PR07MB3098; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3098; 3:5ndf89b6Jciec7Rmn+ZqJ0XxX4xdX/esiAfT2jMkELszxZUu4If3QAMy3pjuC5e+LxZL7AvokWmpRif5I18lSPecOzBIIXEpeTISqbGA7rcehpFJV+aNf7Mtc4UgZh5OqrI/bbUJzQQPSlW0q8RLqt8wWHUQRPUxJs+RZZ6R/ywgbrvT56O1F8ux7wmLb4VNTabqVGMFzUyiJMlmi535vEhcwXUjIpcl5qmmm+3AgJBU9Jzi7k4hhBBJARfxHXPk; 25:+DLJ2o5NMDur/pmyOMpBg++OohpGluNWfwdqlk+fx233hxPXJmGT5DSND6NwsW3kj3QLa6ZU0vPfqXlVMmcQd9A0rYdxZRw83UDkrmj7hkZMP9qyyqntRNhq8aJdkIIpA8p2g2CV3QakGXjgrann0+t4S2+lUPoJikXgy2DP9LPBMHKJAp5FUHgvFrl5jUAZHzXZwqSbZe1DiBXhIZeE1zqxfKYHklBfKpa0K9WHiILysws3j9baJNi3XeXrCigyNJmH+7TV/2CPLT2cTka2StiKbMAsXZ25KFlLLiJqHcMHR+IEPejo/Djo5jzRrPsiKurgVRch5oVYeFz8MSaPVw==; 31:QVytYWZmDFp9FKLxUE3nrtTsKhgaoVDAclYciqHNp9ORRXfoKbWwSPR9Hy9ShhdZzsQbTVo05mPKYadtnvsEypNyq6wP/7mDErvsxDy/3iL7clmkC8lapn41je0XAK2pfErfDcoW8uf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microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(93006095)(10201501046)(100000703101)(100105400095)(3002001)(6041248)(20161123560025)(20161123558100)(20161123564025)(20161123555025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM5PR07MB3098; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM5PR07MB3098; X-Forefront-PRVS: 0422860ED4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(189002)(199003)(53936002)(42882006)(2950100002)(6506006)(6486002)(6306002)(6512007)(50986999)(76176999)(106356001)(36756003)(189998001)(42186005)(105586002)(50466002)(8936002)(50226002)(48376002)(33646002)(8676002)(81156014)(81166006)(7736002)(101416001)(305945005)(966005)(68736007)(6116002)(3846002)(5003940100001)(1076002)(478600001)(5660300001)(72206003)(2906002)(25786009)(97736004)(4326008)(8656003)(5009440100003)(110136004)(575784001)(107886003)(66066001)(53376002)(47776003)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR07MB3098; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; DM5PR07MB3098; 23:7wYGql/yeYTuvEuivIFoXTR513bXWUoqqfm2jSe/w?= =?us-ascii?Q?1As4J9oRIAtlZj3yzBvysNGl7koNpGV8G5Kur6+EkU4nKuN0lT7bjeblTexx?= =?us-ascii?Q?ZZWAyHIdaynXrYn2WzuZwn894t/7KIoa/rI6at4Xw9IQih2V7QhWaN6DNYk6?= =?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Ts4U0wi5fmR4fWriMMQs9ZfqNfmZpuKUvXlxBz9qqz1/dRty6RurG/3uC36lYSHdUjRHXNMvUjP89QOLUHni7ez033Is= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2017 11:29:31.5374 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3098 Subject: [dpdk-dev] [PATCH v5 7/8] mempool: introduce block size align flag 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: Wed, 06 Sep 2017 11:29:36 -0000 Some mempool hw like octeontx/fpa block, demands block size (/total_elem_sz) aligned object start address. Introducing an MEMPOOL_F_BLK_ALIGNED_OBJECTS flag. If this flag is set: - Align object start address(vaddr) to a multiple of total_elt_sz. - Allocate one additional object. Additional object is needed to make sure that requested 'n' object gets correctly populated. Example: - Let's say that we get 'x' size of memory chunk from memzone. - And application has requested 'n' object from mempool. - Ideally, we start using objects at start address 0 to...(x-block_sz) for n obj. - Not necessarily first object address i.e. 0 is aligned to block_sz. - So we derive 'offset' value for block_sz alignment purpose i.e..'off'. - That 'off' makes sure that start address of object is blk_sz aligned. - Calculating 'off' may end up sacrificing first block_sz area of memzone area x. So total number of the object which can fit in the pool area is n-1, Which is incorrect behavior. Therefore we request one additional object (/block_sz area) from memzone when F_BLK_ALIGNED_OBJECTS flag is set. Signed-off-by: Santosh Shukla Signed-off-by: Jerin Jacob --- v4 --> v5: - Added vaddr in git description of patch (suggested by Olivier) - Renamed to aligned flag to MEMPOOL_F_BLK_ALIGNED_OBJECTS (suggested by Olivier) Refer [1]. [1] http://dpdk.org/dev/patchwork/patch/27600/ lib/librte_mempool/rte_mempool.c | 17 ++++++++++++++--- lib/librte_mempool/rte_mempool.h | 4 ++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 103fbd0ed..38dab1067 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -239,10 +239,14 @@ rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags, */ size_t rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz, uint32_t pg_shift, - __rte_unused unsigned int flags) + unsigned int flags) { size_t obj_per_page, pg_num, pg_sz; + if (flags & MEMPOOL_F_BLK_ALIGNED_OBJECTS) + /* alignment need one additional object */ + elt_num += 1; + if (total_elt_sz == 0) return 0; @@ -265,13 +269,17 @@ 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, __rte_unused unsigned int flags) + uint32_t pg_shift, unsigned int flags) { uint32_t elt_cnt = 0; phys_addr_t start, end; uint32_t paddr_idx; size_t pg_sz = (size_t)1 << pg_shift; + if (flags & MEMPOOL_F_BLK_ALIGNED_OBJECTS) + /* alignment need one additional object */ + elt_num += 1; + /* if paddr is NULL, assume contiguous memory */ if (paddr == NULL) { start = 0; @@ -390,7 +398,10 @@ rte_mempool_populate_phys(struct rte_mempool *mp, char *vaddr, memhdr->free_cb = free_cb; memhdr->opaque = opaque; - if (mp->flags & MEMPOOL_F_NO_CACHE_ALIGN) + if (mp->flags & MEMPOOL_F_BLK_ALIGNED_OBJECTS) + /* align object start address to a multiple of total_elt_sz */ + off = total_elt_sz - ((uintptr_t)vaddr % total_elt_sz); + else if (mp->flags & MEMPOOL_F_NO_CACHE_ALIGN) off = RTE_PTR_ALIGN_CEIL(vaddr, 8) - vaddr; else off = RTE_PTR_ALIGN_CEIL(vaddr, RTE_CACHE_LINE_SIZE) - vaddr; diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index 63688faff..110ffb601 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -271,6 +271,10 @@ struct rte_mempool { * Note: This flag should not be passed by application. */ #define MEMPOOL_F_CAPA_PHYS_CONTIG 0x0040 +/** + * Align object start address to total elem size + */ +#define MEMPOOL_F_BLK_ALIGNED_OBJECTS 0x0080 /** * @internal When debug is enabled, store some statistics. -- 2.11.0