From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0072.outbound.protection.outlook.com [104.47.33.72]) by dpdk.org (Postfix) with ESMTP id 12A6B7D8F for ; Tue, 15 Aug 2017 08:08:32 +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=weDq0FDqb5Diz9mxK/CVZbAcOdzqPkp8klnStHTh6o4=; b=noL/7QADXQ/F46NF3l1MHpjUj5ELoVKB7/DR72eRMIhc7ZaLNJN5cmAyv9TCO3omuX9vfUaRnwqKSUKtzafCrGnVjwoHHuhO5c7l+oQGqbk74NNROBmkfl0TxFdm4acY+CxWIWbdqcTuvQ3u1NJ9khoM7DBIHlgA+A3xMr7kusE= 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:28 +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:42 +0530 Message-Id: <20170815060743.21076-7-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: c7d88fff-c814-4f67-bae1-08d4e3a40d4a 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:Cll2h8PGIHzCHsnSyjKrsuEN+zQhpvtcF0ffkrwyRHNdCdl7UzRm0xT/qcF1x5UvGAHOg4G6HBGAwxmy7v8OKMATA8VW33uZeXLId2xEAb/mdCXQDBbWlaMA9E2KSnpZ71yKkiNkSVsV2BUm6eb4nx2NfSfZCLzuLqZAAkJoAefYgWGOiz36rvDe8KNaXWlz1Li5OXHU6J7qmlHL5/edK/7uW7EegmWlpyS5/Nj9kcfQXiJXMM0JEuOHg0HcJpHp; 25:EPhymditciTuvRaGjXWFnRLm4/jhxbhUHSls0uitbGnUNzWBDPpWsXpJtnzS8zep9w2q7xdPATlRZUYJ3fLB5nBwOoXkuTOdZDeh5zeSRqlwghZ/Flf2W62MsTrbujJcnakJn3rAZTEsmfCtNieL9nTlE4Sgnrc3im7/XvwbHqKoJQbGoK4z78GvBXwTGgteVvHsW7mZpyw1bUBf3auldIRwBWTU+jbpwO5qBPibfZu52ydV0EuBK8pdL32iBYQ7GjtAzFiHpEH5fG94p/vwAVywqLeyP7N6uUXLexInIfFWrTuOuQR1DVi2YdHEpHcAQzpNl/ibM0qdrhpGx+0D3g==; 31:3J5nG5Fv7mmnDQx98X71jVw/9GbR2APQMWQTJAcKTywPQhw7Vb+wGpH2eEvdNyHutOa6C8Fo8YgYt3+N4xM2Q2VHr8dGT9y+rscYgiQPm3mwBEhBph414yKsmPY36zOglbW6YqPEddymwqkcp5jhUwbgrQyoJd25F+vkQPPDxQxA0SmcXuoKzS0jOg6O6Au/SDx2LqUS974JPlzv3k0hY8bZI7yl6eY3flXmCvr1ds8= X-MS-TrafficTypeDiagnostic: BN6PR07MB3089: X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3089; 20:QaMQnVeK+sfhNGOH4i4cobjsoolnjs1MX9Jd+K5gcdiXz0LMXo88QbhWIpTSMXif/BCGOc0HecGfa3ENEB1NoU0jIQ680GHzUjZNzPj4c/Z+Qgq2nEj584JoTZCobViy41UMIwED4Qa86aX3hmfzbs6NNigw4OYpKFNp/6oNgPDbpVwqMWpZgZx31pj7scEZB/SWbSiebJfHwZWJUcmLGk11xhsyAm7w0evJIt3a/e9aqhiY3LXrNWcTWBtd+YCRirNKP0Zq3RJHCMxaMFmnY/IAPqGNlNTfhRz9Jr5nXPtperXngt6Ya9+LE/cDUA/XV53YCoez+Lj21Xphnt9aELEtj0fwO9kg/+RDz2hkEt5aF6M+p62hxrmYs8Zo3K+Pv/jE4ylw7r5iZgYUx7GPUZmE8hp6trESK17sHzGyX+llYftKYhgHGCw/niQTlpnIOwPTzwMp5ATMyaE4eUe4SNag7YF+WXBbripJz6a+P2+ezBqUdhT5kuDeInQPtvdxcLR7UK36Kqf3MvS/32qYZA4wIxfl5uHt1pCC95v7RnWLxjN9YOdNpf3jCRrTMjXOtn5Izl7ji2N4lHSrSUZRzXpI1PrtaVFqtnPbJeVdOFU=; 4:Mfc4DmsuJKpdbLtmd8ISQgJCBtg9rZqPjoYnFEGjEYITDepPRCIRiS3+qjwe4UmG/sH+rLrZSDV+teuGfVv6blJga8nbIUN57uej8Opp2uc64103WUvUUGlOWuCe9hjvC/Wo7zJvGChL3FSh/+Hvsvd84d/risE0wpyBT1pDhvR5YVV1lH5zPJQqtonIMfcTuEybpdl18MORHQb2RVypmyLmQTHFrbrzlQ6A2EH6CoKkuFhNsNC5xYU3q69pKDWj X-Exchange-Antispam-Report-Test: UriScan:; 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:0+7lGXyB/8KfSYk3sqPV3HiXbATlrydsf1Ipg0J0M?= =?us-ascii?Q?N++QBhQVemtn94BOCiaZqYqd64+RJDoT6hBd+zDpCyPhLNYcIN/xfjmvBxlD?= =?us-ascii?Q?t+sl9oRYkiRoWN+WAuO3cVeEAxwdk43emN1EAUsAwAHG55Qf3HmMxh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U8p7MJVkNfA/BlSFBfbNUNHZJ6zULuFms1RVFfiWdcaXe1GRR7pkv7nES7ygrVfPuuH3QoHsELk9WdkaUB96h2No7oR+gQR9k= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2017 06:08:28.0413 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB3089 Subject: [dpdk-dev] [PATCH v4 6/7] 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: Tue, 15 Aug 2017 06:08:32 -0000 Some mempool hw like octeontx/fpa block, demands block size (/total_elem_sz) aligned object start address. Introducing an MEMPOOL_F_POOL_BLK_SZ_ALIGNED flag. If this flag is set: - Align object start address 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_SZ_ALIGNED flag is set. Signed-off-by: Santosh Shukla Signed-off-by: Jerin Jacob --- lib/librte_mempool/rte_mempool.c | 16 +++++++++++++--- lib/librte_mempool/rte_mempool.h | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 19e5e6ddf..7610f0d1f 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 const struct rte_mempool *mp) + const struct rte_mempool *mp) { size_t obj_per_page, pg_num, pg_sz; + if (mp && mp->flags & MEMPOOL_F_POOL_BLK_SZ_ALIGNED) + /* alignment need one additional object */ + elt_num += 1; + if (total_elt_sz == 0) return 0; @@ -265,13 +269,16 @@ 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 const struct rte_mempool *mp) + uint32_t pg_shift, 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 (mp && mp->flags & MEMPOOL_F_POOL_BLK_SZ_ALIGNED) + /* alignment need one additional object */ + elt_num += 1; /* if paddr is NULL, assume contiguous memory */ if (paddr == NULL) { @@ -389,7 +396,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_POOL_BLK_SZ_ALIGNED) + /* 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 a4bfdb56e..d7c2416f4 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -266,6 +266,7 @@ struct rte_mempool { #define MEMPOOL_F_POOL_CREATED 0x0010 /**< Internal: pool is created. */ #define MEMPOOL_F_NO_PHYS_CONTIG 0x0020 /**< Don't need physically contiguous objs. */ #define MEMPOOL_F_CAPA_PHYS_CONTIG 0x0040 /**< Detect physcially contiguous objs */ +#define MEMPOOL_F_POOL_BLK_SZ_ALIGNED 0x0080 /**< Align obj start address to total elem size */ /** * @internal When debug is enabled, store some statistics. -- 2.11.0