From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from emea01-am1-obe.outbound.protection.outlook.com (mail-am1on0097.outbound.protection.outlook.com [157.56.112.97]) by dpdk.org (Postfix) with ESMTP id 0DB715A74 for ; Thu, 9 Jul 2015 07:00:54 +0200 (CEST) Received: from DB5PR02MB0808.eurprd02.prod.outlook.com (10.161.243.154) by DB5PR02MB0760.eurprd02.prod.outlook.com (10.161.243.143) with Microsoft SMTP Server (TLS) id 15.1.213.14; Thu, 9 Jul 2015 05:00:53 +0000 Received: from DB5PR02CA0027.eurprd02.prod.outlook.com (10.161.237.37) by DB5PR02MB0808.eurprd02.prod.outlook.com (10.161.243.154) with Microsoft SMTP Server (TLS) id 15.1.207.19; Thu, 9 Jul 2015 05:00:52 +0000 Received: from DB3FFO11FD023.protection.gbl (2a01:111:f400:7e04::187) by DB5PR02CA0027.outlook.office365.com (2a01:111:e400:5805::37) with Microsoft SMTP Server (TLS) id 15.1.213.14 via Frontend Transport; Thu, 9 Jul 2015 05:00:51 +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 DB3FFO11FD023.mail.protection.outlook.com (10.47.217.54) with Microsoft SMTP Server (TLS) id 15.1.213.8 via Frontend Transport; Thu, 9 Jul 2015 05:00:50 +0000 Received: (from zlu@localhost) by bjgfarm-1.internal.tilera.com (8.14.4/8.14.4/Submit) id t6950kka018574; Thu, 9 Jul 2015 13:00:46 +0800 From: Zhigang Lu To: Date: Thu, 9 Jul 2015 12:58:53 +0800 Message-ID: <1436417938-18496-8-git-send-email-zlu@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1436417938-18496-1-git-send-email-zlu@ezchip.com> References: <1436417938-18496-1-git-send-email-zlu@ezchip.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD023; 1:NbS4hQSwR03sss1O92h/d4G0rAdjRJed7K42rZUxdokeuLm/KDzZ/hwO7UPRvxOoU6Q/GQ19vQQi2LnKHtSc9Dm5vrE/1XT0PzslYXF3W7dNVZ65YRXNX3SLN1FkCHO0Pv1DoyTK0oyFC78/hN9ecsLk95ga0sHQQxOmivv764BZy47KGqv13hMYfzwxPey6MT8Q/CgZsq6Hzkooq8+APpAEw4jhw/zfqu4ahcMu08ii/wKAb86sj/bYtvC//vKyh6FiqyU0rJAR35zG9jUZwQHaX9+V6SDeSBWhBPEYIjhAMeBVjT+vUnRqkE3H2LhpA45B40rLGsNgWNsD8jOnT147itBxhYY4o4dj0MBwVS2bFW/g5/ZY7CDM3rGyeazdeRgxPdt9h33uESRTAvInIPVLPceCEJ5IKzmt7pEvrXZGUWqio2uxhZz7SV+vsKzv X-Forefront-Antispam-Report: CIP:124.207.145.166; CTRY:CN; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(339900001)(199003)(189002)(5001960100002)(36756003)(50986999)(87936001)(110136002)(105606002)(450100001)(33646002)(189998001)(107886002)(104016003)(86362001)(77156002)(62966003)(50466002)(50226001)(42186005)(6806004)(5001920100001)(47776003)(48376002)(92566002)(2950100001)(46102003)(19580395003)(85426001)(5003940100001)(76176999)(229853001)(106466001)(19580405001)(2351001)(4001430100001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR02MB0808; 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; DB5PR02MB0808; 2:yUsYWjmDX6cDdcMzpdm/Hycyz97iaStYWl6v8P7jCGHhv02iijzbvYEGnbvZ6hUc; 3:JvX1GepX/h9ZZp/Yze18N0zpL7+AgbtiBRe60++1bKb1KYVdt7AhwrFIHiwUL7tAP78iLT44xhIWlkI7Q/XSYfeWvKfqeILa4LOntfJdJ/9DAl7ofq8xh7IdNC8Y2dK40d4v18VQqdhkyl9rM2J8Oh0mr1jmgeEZhy9YC/WwRS65OnYNhT4T/6WUgAvPZONSGOd41IySJeXDykESdqf4aba9EG79GQDGQFM13v6FIdxRG+WaIP8nonXQrimMHn9S; 25:niUgLMEAjhoQKQaUNAn95wlfSXSpDeOXADHBJo/hhgQpG9Yekqh3fd38r7Ogzc4bmrY319/mYWW5FD11SPD1gRySCLtBbeJ/rsYU0YJq8Wh2RLq5RVcxfDw0/q4XAagGMZOV8mnLfII8aNMGyubbXz+CE7BB3T1s1P3Y/oBmlj3rES2mTMyeve+FUkfyieddEb+Ry86sCq3sG1splbjWsN9s/f5Wx62jZWo6pnedtMT1kZX652oNYrI/bqOAdCuQ9nluT6nGem0HFA22lk7HMw==; 20:A0LrvWNJimGjYZlbVBv0x6hesp0RvGdzzQc/hZlGGlDAGmIfDfEv1m8Z1EwA2yLHIvycH71pOHYM/sf2fCbUlQyC6hlGzz+0INIwwElrGdLuoLYSU98ju+3ncilDNkUJVy85pmRIcm++xHDPcU0YhVASh1HpRiiwPnjvz+DwYjk= X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:; SRVR:DB5PR02MB0808; UriScan:; BCL:0; PCL:0; RULEID:; SRVR:DB5PR02MB0760; 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:DB5PR02MB0808; BCL:0; PCL:0; RULEID:; SRVR:DB5PR02MB0808; X-Microsoft-Exchange-Diagnostics: 1; DB5PR02MB0808; 4:6cFJiSV7UymA3XRKUWYZcT3HeHMrvkJG9DzR+dr4DlSOKmkDCr4l7mmlVU9ZBjGaxTOclQPtRtImFVcxZswc0LwJd3u0UJQaYOWVtzQhZ0CUy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5M0aMvZhTMoGRX9NbOebKC0+AUr6JiIbuNNA4s0dYeswtWic0R?= =?us-ascii?Q?YRIGWpyetCPXisaA+msjWQSDf/NuF7LzW2zX/WN1ewSMf7YtBX/+vWO4+0Ij?= =?us-ascii?Q?7yVltNDZiNMDIFKVlbxRdv2eYwzT+akNShf3oEyA3gwDEJl45N64deMNpX5p?= =?us-ascii?Q?z8MDU5QWWcldq2cF+x87tH2+dT4ArdKZpDIsufsypSvNnDVKTEgDVarXGxWN?= =?us-ascii?Q?B7Thn7zHMEPmz9heP7wouBQg+DmS11S8TmxBjxHE4SW0d4K5nnrBjw29+eMB?= =?us-ascii?Q?ZO8LTqTQ9uJpTVK529oCn3rxEevmAb0o5NzKQThQjWejF2KGgl9bEz0ZKOdd?= =?us-ascii?Q?tFtG+Bf8qLincJfy08rzIZJ?= X-Microsoft-Exchange-Diagnostics: 1; DB5PR02MB0808; 5:6D119iab8nFMlf/aKX2nqVFUQHpRFtOv7ezO7E2qD46CpCjnLNzpNuP6aaWADLvY3kAogz1Fi8a4jTk2vN8BduuS9Hd1V19b7h9BulItchvbzsAQQDJDreuMqCu2ZaS1XhBUBCQ7fnkrbtN2D5+GtQ==; 24:1kMrFlEi3x9weuSFlagqm7O1ezA4t868mZ70K2TK/2hQ/40KGoVi0LR+dbQQNWmReHyDzzmQdFjvc/A47x5Pc+QP56ilZoMoLVk8iTJ1PHI=; 20:tjYpo3LCmA9abWdIXLr9gxdWRwfPNk2CgY2+BDj9Nbgls+irFXeXNm5m9ZgSznUsTLrA4UQt4dMLxSI2KEAzCg== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2015 05:00:50.4622 (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: DB5PR02MB0808 X-Microsoft-Exchange-Diagnostics: 1; DB5PR02MB0760; 2:PyBLeQSPMiD8PmL4OySsf+X4gTZUFuUVJt8IaXZo0YGmc2UoRx27Qx1+89paiENz; 3:+MwitSCGcGyeqHI3VgZKxJFIFjIq7R9wxZO5qrWoEd/LBGuDFZJqIgiytyLfZ7Oi0hbhNSLYDPCCI8BYcvj42eb04jneQWqCYn+BPf7v7MAh/TTsjEYtkWOgNBREbofiVgzyS0znvKVH17NLgbmRVs9/FDKqcYLHSMd/xdL/wG1akYR1RMq8fJsTwAE69uHEiMo4UUAikdsa0XwfSkQ1XEscEmZv2kuAtFdXf/kFxHYtUOJNlSaMEF6BbCgQsFRX; 25:ZtNFX1KVzp8j+froflSibTICQQrgxsJ33M2tmTeBgjcZiNlOvrDKE+eIaWz42mBHCK8ODFO8y8BtDQM4xK5VnZ7v40hXqKoLFSsdo79xd+H9+FnHLQOwSnkhgO9Ox8hJE6Z74twGEO7JCrX9nAnP2wULt8Os/mUvsLVz5A3ybVhZ3dtOgZUnt/eKv2AL/lgyi9S0Rx1BsUL2TCVVdACjR6PaxXZ2Ef5Zwwd45B7RXxyhpQ8C/jhjAutmi59Qz3yhscX41v0RCzuO2h8Ip5gmzw==; 23:8STmnWUTkI6+8H+VOH08h3V8BBT9Q4JGlBl9w7UqLE6zYXuyksiU6W1oMG9bReGIhRSuXDOI9YHZQld6aEbzhTdrSSyjaSFQeM72FdIwpCR1RfthITIK5mYq1V+Tv7CKWY6OBrGple0X0q/yQ1dZkuiaKvf9TscnKYkBMd4JJ4kozBbv5GRwapOt116zjwRgDiVnRVNOXxTY6Tnui/8vHwS8Zp6HtzCUQfgHNhPB7nj7eUaZ0DBl+Q3ImphKmoZw X-OriginatorOrg: ezchip.com Cc: Cyril Chemparathy Subject: [dpdk-dev] [PATCH v4 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 05:00:54 -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: 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