From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from emea01-db3-obe.outbound.protection.outlook.com (mail-db3on0073.outbound.protection.outlook.com [157.55.234.73]) by dpdk.org (Postfix) with ESMTP id 18122C344 for ; Thu, 9 Jul 2015 10:26:46 +0200 (CEST) Received: from DB3PR02CA0024.eurprd02.prod.outlook.com (10.242.134.34) by HE1PR02MB0809.eurprd02.prod.outlook.com (10.161.118.149) with Microsoft SMTP Server (TLS) id 15.1.207.19; Thu, 9 Jul 2015 08:26:44 +0000 Received: from DB3FFO11FD054.protection.gbl (2a01:111:f400:7e04::175) by DB3PR02CA0024.outlook.office365.com (2a01:111:e400:9814::34) with Microsoft SMTP Server (TLS) id 15.1.213.14 via Frontend Transport; Thu, 9 Jul 2015 08:26:44 +0000 Authentication-Results: spf=fail (sender IP is 124.207.145.166) smtp.mailfrom=ezchip.com; ezchip.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of ezchip.com does not designate 124.207.145.166 as permitted sender) receiver=protection.outlook.com; client-ip=124.207.145.166; helo=bjgfarm-1.internal.tilera.com; Received: from bjgfarm-1.internal.tilera.com (124.207.145.166) by DB3FFO11FD054.mail.protection.outlook.com (10.47.217.126) with Microsoft SMTP Server (TLS) id 15.1.213.8 via Frontend Transport; Thu, 9 Jul 2015 08:26:42 +0000 Received: (from zlu@localhost) by bjgfarm-1.internal.tilera.com (8.14.4/8.14.4/Submit) id t698Qbe7003932; Thu, 9 Jul 2015 16:26:37 +0800 From: Zhigang Lu To: Date: Thu, 9 Jul 2015 16:25:16 +0800 Message-ID: <1436430321-3864-8-git-send-email-zlu@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1436430321-3864-1-git-send-email-zlu@ezchip.com> References: <1436430321-3864-1-git-send-email-zlu@ezchip.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD054; 1:pgu93CsoGXoW6i3Y2FNebkLictffm+5RAy8/dNvvMSqSgUFR8vyUmJOs9lz4MRfJqfoztYMe4ddaX1SGWwnUJkB8AsFLcJElA+lACSEdMjY9486SwRHgO5Mf69GiXy0fkJez5kfLMQGyBCiECbjt4t34cTCjlcOEN25aLpaTRqzrcfQx/CBN0r3Q1fW4ZwyBjiJk8NkQKW40NuMV9HwtjZQqiNcGWPgnavqgAPAhFIyYrbYCOzgxbnjka1T2zA4hYG7dpj95Gxs0OngWD1Myh4REU16zTxqC3Vcnj1K3+5Xp4ybTlXLFoshOOe4yyrwn+TboEWCmHkt3BMo5+0yxtZTzaM11fEqUabS/evIC3IJR4+SCwyBWAadRjyWZarv0v6c2HcyWV5Cqgdyxus+fkesXYWhiisng7tkD3sjF7NK9G+qKlaAbHDXP00hHwLnZ X-Forefront-Antispam-Report: CIP:124.207.145.166; CTRY:CN; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(339900001)(199003)(189002)(229853001)(85426001)(107886002)(50466002)(33646002)(77156002)(87936001)(2351001)(62966003)(5001960100002)(2950100001)(47776003)(50986999)(76176999)(106466001)(50226001)(86362001)(450100001)(36756003)(6806004)(42186005)(19580395003)(104016003)(110136002)(105606002)(5001920100001)(5003940100001)(19580405001)(46102003)(189998001)(48376002)(92566002)(4001430100001); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR02MB0809; H:bjgfarm-1.internal.tilera.com; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1; HE1PR02MB0809; 2:tmyccovj90lwhHecpjOPzleIDlDI5ZYCee+yizZD9N2tZvg3gL0u253SLkYRO/0n; 3:4Pc7Opw3F0/h5RtntszwArlt+XVhaOAYbA8WxVYb5XNnMcbX6W5PwsDP1BSZZvaX8vAe1KqAl6jmB+4ATmYFU4mNaPNBQy6bPvLqMzAcRcbfU0TFyGCe8kKckQfZGU2+REdXb4MyVuDZcMgf5ppamDr4gGxkfZNtWKBGvz+FjTiQ3yLt65CQD4rIS36rOEChUGzXa3IKKc/cBVdM4rnoufcrt1LUk8vOKifu8frHT7FoYLr9iZeZHnanJkNEow76; 25:kwvxoYIJkOk84lbtRpJ87RFD3/eFblYbgHb1j7sYcoruCt9GSLMiLpxeDdWlct0giy957aT+kC46qO1hUpCLqo9VngYI1rHDEQdj6KSyTCRrNqYACkYfOE+IjZpQD9jz5JJz9jpDX0hHzqOkeAN5qYTIHZ7M0ywGxPtyCPcuqNxbiEIKU35Gcl0e6/YI5zDNqsOmdHpNE7IoXAruqaJ6fA0a2zAK/Jb+v2vwFf+DKbeRYvs5EHcDM2T6utd5XqBsjS58dhTKoMn719d8HGwRhA==; 20:vKK/lLQ0Fgg1p/+69xNuHO/oO+WHH5ltGtgbQ1K8Bd9reTx83F0VfkVqXkPe6beAmYL9QRaSOcykC9xNFQM3Fv9uc2O+D2X15JCgvRCOAtV6tK1HK68F8kpQ+n2dHihUrKoqsbXhVnUpiRj5Vmucnc56fi8TkWYbrG4tanCQuiU= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HE1PR02MB0809; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:HE1PR02MB0809; BCL:0; PCL:0; RULEID:; SRVR:HE1PR02MB0809; X-Microsoft-Exchange-Diagnostics: 1; HE1PR02MB0809; 4:D7TD5Zn2AmD0sofurLUCBFqnDDRp/01fYSvtgHHG8w52aV8SUwQ7NWvfUNSpW2cnBUvEptzDqxH/TzPFzZvxzsHKnlV77e7HSPTBsYR4zzgkMPMOGRorCRuAjr9Z4+sWQe+DE1uy0FLEMgfbTX4whRCmiXvhvDOLlB9c6y+x6uLhdJYjkQ11W/GTYBWe6KjPJxkyAIzomBw46SYpIX0WuJZ3kYCriaqVhIviDYB5h4+p/8vAwC9BEajDwyTvJ/9cn+F6ztfd5Q4YtBpVvGQ+BBo2OZCu9GfK+h65HjaDunA= X-Forefront-PRVS: 0632519F33 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR02MB0809; 23:Biq0UgTeE0TaddDdkDQf/fM8U9rMBg4PVKJV8OOe8?= =?us-ascii?Q?P0rw5yWtoLEHq/+hlJr+DCMUsh3IMmlTAaMKIrKY9IrXVEcL3GSY4fyoAEdK?= =?us-ascii?Q?LVbrSUqC9iC9xNtfivnzm/s9auf8/tMMQhVqwjl/TPzNJEygMOfXGiQWLqho?= =?us-ascii?Q?B1qoQKKgggP4hfbRqcQ7FgAxbLR/nr/hBh1iUvV+/vjlKbKyHekC0s6h0L8v?= =?us-ascii?Q?70uQ7Uca8de3hUPS1lIhjAHfjgt8Ar2HAe45DMXGe0uECqNVj5VODwVucPLf?= =?us-ascii?Q?Kos5gEAzun+25A4j19U+c4kEv1YUa17WZRbgAhPEiGrKR+soUiWNyAu702qJ?= =?us-ascii?Q?FK0gMFR0A75jF4jAeIS50XkBNJxwZydCBlMx1iAgfn5wCFxaq/5R3jp77ydD?= =?us-ascii?Q?kxoqPC2qGEKYXGVyjWvPaZfbFHHxiJpNCso7F+xDiEdT+bGTjJqwQhRUZE6S?= =?us-ascii?Q?EX2XQd0PoSi7JxiXl0++cslF1PqMuwMDWxcZC//jaUnUiJbIh2KqF6hZZDUN?= =?us-ascii?Q?eNJGWq09RSgL7Xr9/r/XxsJGo6WlPnDZXiV5NmYGL5R9zFhiEgehkcdDtwYo?= =?us-ascii?Q?iuq57H2YL57dcsNgZNcV+LtGqgbto5vqqqWCfRYJWS4MgJqrFXOY6P1ykdOt?= =?us-ascii?Q?NRJLfhdYil6kF79MCwH2we8qW7NTz1nK3WLT5pAHoXX2hZVMuqUlBwkaq688?= =?us-ascii?Q?Ov30bjvytdUDKY24yXAHRkHmDQvIhqgL6MRmhCMtl8tmFhfjrELbAov7X7BH?= =?us-ascii?Q?kvExXW4BRfZuwDWElj8aRV5x1gwoNB/gFGaiVC7xbn3q1icO0eKiZOS2ZVRp?= =?us-ascii?Q?XJFvyy3etRu2F9zSlO+AtXoPE4RrnAuXMtRMt+Qt6+qdugnKGTyrzKOUnsSc?= =?us-ascii?Q?nktfzr+Dvk1m69u13CYabFU883szgsHBxJNiJtESqjNfjawwJZxGLyzO9Mzk?= =?us-ascii?Q?QGsaKSj+k40tAwYBQQLOsH1R1mtc9FRhAyHyN5ORxJGWrCn2z6Kk7G1UxzgV?= =?us-ascii?Q?+7+lj4YFyS0wRK54bCU2tnm?= X-Microsoft-Exchange-Diagnostics: 1; HE1PR02MB0809; 5:IDdTTwQ6XzrM2LuLxP1edxd9vMVo92UI9KMKw5C1i+qO31O5zLOTo6s0Qxd8krPtt39o3sUzWPB2EiS8uC5WCHsuD/liT5E2T/6tk+rv3vi6QD+D3lOMEunRuHzlO5CcUG255gzZ6B2Hr5PZ6zZa5A==; 24:NDKpXAajxZxKj5Mq6k4tN1Cyh/nQiZmRXZIKa9jVMJWlM3TLxoXLylpCCwB0G1NVMjaSmPOssOehQzhLK0/qFJun6jGgntMtWwvpamOvDRs=; 20:EqMDDnJbfurAvI3vAj5p18mp7dEP6L9/iXePRCtznnr2E8IDdgy76zwOW0B7RsygslP8AXzGdzWuDE3xnZ/kkQ== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2015 08:26:42.6964 (UTC) X-MS-Exchange-CrossTenant-Id: 0fc16e0a-3cd3-4092-8b2f-0a42cff122c3 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=0fc16e0a-3cd3-4092-8b2f-0a42cff122c3; Ip=[124.207.145.166]; Helo=[bjgfarm-1.internal.tilera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR02MB0809 Cc: Cyril Chemparathy Subject: [dpdk-dev] [PATCH v5 07/11] mempool: allow config override on element alignment X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jul 2015 08:26:46 -0000 From: Cyril Chemparathy On TILE-Gx and TILE-Mx platforms, the buffers fed into the hardware buffer manager require a 128-byte alignment. With this change, we allow configuration based override of the element alignment, and default to RTE_CACHE_LINE_SIZE if left unspecified. Signed-off-by: Cyril Chemparathy Signed-off-by: Zhigang Lu Acked-by: Bruce Richardson --- lib/librte_mempool/rte_mempool.c | 16 +++++++++------- lib/librte_mempool/rte_mempool.h | 6 ++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 02699a1..8e185c5 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -120,10 +120,10 @@ static unsigned optimize_object_size(unsigned obj_size) nrank = 1; /* process new object size */ - new_obj_size = (obj_size + RTE_CACHE_LINE_MASK) / RTE_CACHE_LINE_SIZE; + new_obj_size = (obj_size + RTE_MEMPOOL_ALIGN_MASK) / RTE_MEMPOOL_ALIGN; while (get_gcd(new_obj_size, nrank * nchan) != 1) new_obj_size++; - return new_obj_size * RTE_CACHE_LINE_SIZE; + return new_obj_size * RTE_MEMPOOL_ALIGN; } static void @@ -267,7 +267,7 @@ rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags, #endif if ((flags & MEMPOOL_F_NO_CACHE_ALIGN) == 0) sz->header_size = RTE_ALIGN_CEIL(sz->header_size, - RTE_CACHE_LINE_SIZE); + RTE_MEMPOOL_ALIGN); /* trailer contains the cookie in debug mode */ sz->trailer_size = 0; @@ -281,9 +281,9 @@ rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags, if ((flags & MEMPOOL_F_NO_CACHE_ALIGN) == 0) { sz->total_size = sz->header_size + sz->elt_size + sz->trailer_size; - sz->trailer_size += ((RTE_CACHE_LINE_SIZE - - (sz->total_size & RTE_CACHE_LINE_MASK)) & - RTE_CACHE_LINE_MASK); + sz->trailer_size += ((RTE_MEMPOOL_ALIGN - + (sz->total_size & RTE_MEMPOOL_ALIGN_MASK)) & + RTE_MEMPOOL_ALIGN_MASK); } /* @@ -498,7 +498,7 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size, * cache-aligned */ private_data_size = (private_data_size + - RTE_CACHE_LINE_MASK) & (~RTE_CACHE_LINE_MASK); + RTE_MEMPOOL_ALIGN_MASK) & (~RTE_MEMPOOL_ALIGN_MASK); if (! rte_eal_has_hugepages()) { /* @@ -525,6 +525,7 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size, * enough to hold mempool header and metadata plus mempool objects. */ mempool_size = MEMPOOL_HEADER_SIZE(mp, pg_num) + private_data_size; + mempool_size = RTE_ALIGN_CEIL(mempool_size, RTE_MEMPOOL_ALIGN); if (vaddr == NULL) mempool_size += (size_t)objsz.total_size * n; @@ -580,6 +581,7 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size, /* calculate address of the first element for continuous mempool. */ obj = (char *)mp + MEMPOOL_HEADER_SIZE(mp, pg_num) + private_data_size; + obj = RTE_PTR_ALIGN_CEIL(obj, RTE_MEMPOOL_ALIGN); /* populate address translation fields. */ mp->pg_num = pg_num; diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index 6d4ce9a..ee67ce7 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -142,6 +142,12 @@ struct rte_mempool_objsz { /** Mempool over one chunk of physically continuous memory */ #define MEMPOOL_PG_NUM_DEFAULT 1 +#ifndef RTE_MEMPOOL_ALIGN +#define RTE_MEMPOOL_ALIGN RTE_CACHE_LINE_SIZE +#endif + +#define RTE_MEMPOOL_ALIGN_MASK (RTE_MEMPOOL_ALIGN - 1) + /** * Mempool object header structure * -- 2.1.2