From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from emea01-am1-obe.outbound.protection.outlook.com (mail-am1on0063.outbound.protection.outlook.com [157.56.112.63]) by dpdk.org (Postfix) with ESMTP id 310EC5A96 for ; Thu, 9 Jul 2015 10:26:37 +0200 (CEST) Received: from AM2PR02MB0785.eurprd02.prod.outlook.com (10.163.146.17) by AM2PR02MB0804.eurprd02.prod.outlook.com (10.163.146.24) with Microsoft SMTP Server (TLS) id 15.1.213.14; Thu, 9 Jul 2015 08:26:36 +0000 Received: from DB5PR02CA0012.eurprd02.prod.outlook.com (10.161.237.22) by AM2PR02MB0785.eurprd02.prod.outlook.com (10.163.146.17) with Microsoft SMTP Server (TLS) id 15.1.207.19; Thu, 9 Jul 2015 08:26:35 +0000 Received: from AM1FFO11FD006.protection.gbl (2a01:111:f400:7e00::139) by DB5PR02CA0012.outlook.office365.com (2a01:111:e400:5805::22) with Microsoft SMTP Server (TLS) id 15.1.213.14 via Frontend Transport; Thu, 9 Jul 2015 08:26:35 +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 AM1FFO11FD006.mail.protection.outlook.com (10.174.64.68) with Microsoft SMTP Server (TLS) id 15.1.213.8 via Frontend Transport; Thu, 9 Jul 2015 08:26:33 +0000 Received: (from zlu@localhost) by bjgfarm-1.internal.tilera.com (8.14.4/8.14.4/Submit) id t698QSKT003931; Thu, 9 Jul 2015 16:26:28 +0800 From: Zhigang Lu To: Date: Thu, 9 Jul 2015 16:25:15 +0800 Message-ID: <1436430321-3864-7-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; AM1FFO11FD006; 1:M8iXLVQm3XAklNuzbt4OUlbufTsQKpSABroa4Ygk9zwKih+JgvEpl26W3OdrvBYOSx5OvUI0a6m3gAUgc2cphvWloT61FqzdHOZcfNiVQKUVTyH4cZqjJReOIVzNyYLj2opuxo4wE6LdBqcKigVlhZKfzvN2Z+sd67OjklbvmEy9Fzr4SeJZq/s61pfLwnavF6ejkbGHht+xYrP6iUfjkRmhHGzxCvnu4u1JeCs2JGyQ/OkTOoNgr27cgkMqNRLfVTpEpUFh/OXFDrCaoKJ/Pger7SwiehGdxcq/I45ROU/jqZk7awT+qg+vPZdIwiBe+1LBn1xWW1HOOKg+A05+Wx6CBKC8tMLhOTU0ajrDjUmuvt2CY0PBROkEd3ns82ssl66uH+e4o+CYH2bTy6FKwLWwt9DSlQVAnOtrqq8BJk0eX9LqJwaFnTNUcKtErMz0 X-Forefront-Antispam-Report: CIP:124.207.145.166; CTRY:CN; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(339900001)(199003)(189002)(86362001)(50226001)(87936001)(189998001)(47776003)(33646002)(104016003)(50986999)(76176999)(6806004)(2351001)(229853001)(5001960100002)(110136002)(107886002)(2950100001)(48376002)(92566002)(105606002)(36756003)(62966003)(50466002)(77156002)(450100001)(106466001)(5003940100001)(42186005)(19580405001)(46102003)(85426001)(19580395003)(4001430100001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM2PR02MB0785; 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; AM2PR02MB0785; 2:qcGuoGvJrN7GnrgT6zy5cb1wIcsUdNBTolUEECJpo0oJj8+G34zG/3fdq0/acDDl; 3:kwVMjBBHgYrWHzcPqg7VhTkVWzXTmXeri8CzVpnYvciP+hS1QqL2omvzqTXeoKNmIas70Mx9T4XytCcTh5soPYk20vS+YeVP562bnol6W7l6DURbxVKGAff8wn88A1gkQyjiPdFZaQJUhLsK4ILkO/mjU/2AAhOrsXw6f++eeVwR9yiumIf+DilFVX5hMIQZv3YfTc5TrcmCprRWyAkgOpFiLjmOZt5p3cuzfJIRHyAXIHX5MOwdtRKp2SH1Xwd1; 25:ePjurkGeSe3/EezkqW/2QJX5EmdMfD880o4Te2wVPik+d+dUrlIiRK9gjFGhGuH7pxERnkmjkwobB6Im8wFlhcqaKGJeb9H1xTHlNYKOMR8AUssXwZ0Xu4SVgi9wEb6tuR8jyR30Lhk8neG8B/wUpMEp8eRq911ggCfTOwiLT0Ib9H3q4gn20YS6v2BVoAE0cAQZlzfCW7ueHD0uSgtGRNgFLjErupgMNBkBFMaqupPnSnMX8HBialQb4CJfQzwdBNE+uOFR1PAvHz2xyPQhmA==; 20:4Jm49GQkPqYN7B1GSVOniInR+oizL+id8D0SKnLzc3Fig2QEyLfOpI3dSYiGhdZwc6SqoJZ5Eht9ON+Nsj2EwMBsEhTSkho7/AQeG9aG1Xw90vCbo7pFQcCchSCXB+onpiLuga61H5dVrdokxoFRtwGKT2Z6XPuJjiivzPkJozE= X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:; SRVR:AM2PR02MB0785; UriScan:; BCL:0; PCL:0; RULEID:; SRVR:AM2PR02MB0804; 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:AM2PR02MB0785; BCL:0; PCL:0; RULEID:; SRVR:AM2PR02MB0785; X-Microsoft-Exchange-Diagnostics: 1; AM2PR02MB0785; 4:X7RwZ6lhR3ot1zcjAix/vw6yL8g9HL3u+e4tXr8v/HaiAQwhnXFccsW50JMrZ3cEKisiPHoxx5iNlOnrH9yzOD70Lx2vWXf55GFI5kWU8c60P6890YY0v0YwmVcDIxy5LNcgsqljn6TYvrwZphEKo8K+BbsjmkGfrUURu0dBGm+l4VAk8UQS0IiQ3VZQ+DL85OyDkYTzLzLr1kdOm3iORZLVFFTI1Jr+exY5wVCf3Cc13wlRZ+MM6tCdG1JqsRWPMbL5tDR0qmp/SOBPFWx8gzfZY0iWTbJWaQGbQkDHnCo= X-Forefront-PRVS: 0632519F33 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM2PR02MB0785; 23:68iTKHeUVuI+X8Wwk4GF7jgEijcvqEil+RzO+slH4?= =?us-ascii?Q?GIX0JFeqbcogFlJ2i6viDx9qtH66UpvgS4YQ54K5H4WmaCPNIqpQstkwFYNb?= =?us-ascii?Q?RFF5Fdfno0mdptpdMkhmkfIFs8xLaU+BD+lsELUl5dz2FkneUtusaIxb9Dzo?= =?us-ascii?Q?zYDje/zAka+fXyPfQexuuGJHxP4fQXJi58V2vQTFUazYkaXnKVkC+fCDgjd1?= =?us-ascii?Q?y81x1bO378xC9VprdtlqFkpolojulpAbuxNDIzwbLpvByl3pmHEMTc8z1zSj?= =?us-ascii?Q?39x3JBqNonJCTGfKrwDX++yE2UF9lgwWQ0Jp2rUNrAkCNhyZQFvYlIJHDP3b?= =?us-ascii?Q?3pHmxFSMWd/9KW+Nqaygukz9zkzwFxkco2Kbs7AZXdjQ6Yp0/g9KX3odPDYb?= =?us-ascii?Q?uRn2IFIskl5YABnf7XwtSdRJXlexD+rxmJKoIaPtgm4Z1f+SCjLA0zhd7Qul?= =?us-ascii?Q?lgO03edA8SLhzGfeT311U9xric/aQjbfVQxOPXaSptsm0slnNfpaDCd/tt6u?= =?us-ascii?Q?qMq5eG+fGDPPDKWHVQSE/chPwXpn5TtyehA2x5PHwrE9lr4UIvmRXdODeZs4?= =?us-ascii?Q?z/2XAeHk8aIrpO+lwY0uisZIQZzdnz0SKXdD33fSj2mE6ZFmrqmAtnfOsTI/?= =?us-ascii?Q?xWYdkOvv9PdoOjWiC6G1QsW5K25TZ7LUplV68pbkgVkbiWw+6USdy+KTyWLE?= =?us-ascii?Q?rgWMkt8K2/oB8Z9ZP37s3yGSt+V3AuOfaV7PAoMqnd7JN76NOVfpe+IkZRs9?= =?us-ascii?Q?jCa1p8xfXc4DSJ9JuHA8hdd0JK8IFJqsJxoTYJHh1WStm5OBsYzCH45ZIUvX?= =?us-ascii?Q?aRmpxOtF4cWip+wTCbcHbbVV16j0ujW7tF1koRrBLdFyt5/Kwcu+rVZEMd3T?= =?us-ascii?Q?Peqo3XWLG8+N8i4rOgjGQpuwrzKZU85ZHcvCiVmeV2HMp0wVMEckfOk8rXeg?= =?us-ascii?Q?Majut5rLSQvhByy6kN3Mm88MWvUftXYBsBT9UNudo/x/DTGw61pZI3/eF7O8?= =?us-ascii?Q?kc=3D?= X-Microsoft-Exchange-Diagnostics: 1; AM2PR02MB0785; 5:dT9mjw915PONqaeTuBAQ7/wyU9Eg6j1qU4xm4O3GZ0boAS1atXWgpQjMa/U4UqLrOEpByX/1ctCpDX0R21Dt+uZgaSIh7muzjGbB0V0c0xKTO+aLM8PUc2EQzW8ZNxBrKMORVNk2S4xGhJHjjn8Y5A==; 24:VOAhENcm6gehZDoMT+duF8OJ/o+hjNhG+1xBgAr4FCzaPLeh361vV1hN+PLvkL1PAVdFFZgBT/Mr8nNK24AgZl+kNSWpZZkluaFXW2oNARk=; 20:bozVmSm+7dxzbNs+LxqSG2olF64KtTyDAOZGdJylysJDn1WJGdwyxbQW493Xj7FfMXJ2W0gZjB/8qyEjsRojOg== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2015 08:26:33.7828 (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: AM2PR02MB0785 X-Microsoft-Exchange-Diagnostics: 1; AM2PR02MB0804; 2:ZQthtdN3W0rtVTneWoOaf8tDhuZPtkZxcxi9RNhjdRDTGg3n4K8s0P/kxLp7mVmn; 3:1+THjRQvQ+DBJj1n8e4JBf/c8Ools7gb5xxOV9fURSNHLXtu8OGnS7dhrlotaoRe1VnSfXGiQmXUwGA+pLGLwFD2T//h7TTZ4TZ8xZiagS9L7ubJQPqmvb4qwTwH03dzKyL+vJIzV/qHDxJIig0yrx7zHh9g2DwcvpPAd9scH6nPGhQluIob2s+3GACMwJGuwF8649E1eqcPhmT3Kj7JlKfA4x6HQh0bNE9Gx3+7guWmRS2+2jbG7TeVt3jh2GuR; 25:KHn8B4LjfPnkeoOyPqSnk1swzy5lM5pvavjorOmQPTuFMLpAfcSYkfEOhGDdi2h2tZ/wzFYiRjjmnujUWBJGy54e9WGHSMJahk8o/cpDVgyoBCw3Rj+Mnixy+8h9mleGgqP6o0pKTkv3ublXttp9o9kokcWYU3L+DTBaHbT3TS0YVf+GbvL7I8DI5Y3RY6oa9QV3HsJde2MKZp5EdeGQzvZPXISe2jfNWinZD3Vl6GCKnuh1lSjppN2AbCo7gJRS/VWXUNEL1atD2O/bmknkaQ==; 23:lquwR/eflXguvHCjt7mTW8I38Q2x8yyJ/pvm4NLhDiPYiEhvKgiRuqdePTXmQLi8Ljkoq42oYCzX7+dBlPbiCLRnrGiMQan+UfeEH9kTvIBn871coUh0XPIY+35QAdGfRKM5xsIAdXKg8p6NuO4130vMyuFoc8effJhesx3OrdsICH+2pRl1X5opQHj8RfrtZGPKSqYbZasfHHpIEQY8YC0FBNEzZ2PQ412ULm6RmZSgpC6cqWJeas/jZID/NX3K X-OriginatorOrg: ezchip.com Cc: Cyril Chemparathy Subject: [dpdk-dev] [PATCH v5 06/11] memzone: allow multiple pagesizes to be requested 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:37 -0000 From: Cyril Chemparathy This patch extends the memzone allocator to remove the restriction that prevented callers from specifying multiple page sizes in the flags argument. In doing so, we also sanitize the free segment matching logic to get rid of architecture specific disjunctions (2MB vs 1GB on x86, and 16MB vs 16GB on PPC), thereby allowing for a broader range of hugepages on architectures that support it. Signed-off-by: Cyril Chemparathy Signed-off-by: Zhigang Lu --- lib/librte_eal/common/eal_common_memzone.c | 58 ++++++++++++++---------------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c index 1ea502b..76bae72 100644 --- a/lib/librte_eal/common/eal_common_memzone.c +++ b/lib/librte_eal/common/eal_common_memzone.c @@ -113,7 +113,8 @@ align_phys_boundary(const struct rte_memseg *ms, size_t len, size_t align, static const struct rte_memzone * memzone_reserve_aligned_thread_unsafe(const char *name, size_t len, - int socket_id, unsigned flags, unsigned align, unsigned bound) + int socket_id, uint64_t size_mask, unsigned align, + unsigned bound) { struct rte_mem_config *mcfg; unsigned i = 0; @@ -201,18 +202,7 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len, if ((requested_len + addr_offset) > free_memseg[i].len) continue; - /* check flags for hugepage sizes */ - if ((flags & RTE_MEMZONE_2MB) && - free_memseg[i].hugepage_sz == RTE_PGSIZE_1G) - continue; - if ((flags & RTE_MEMZONE_1GB) && - free_memseg[i].hugepage_sz == RTE_PGSIZE_2M) - continue; - if ((flags & RTE_MEMZONE_16MB) && - free_memseg[i].hugepage_sz == RTE_PGSIZE_16G) - continue; - if ((flags & RTE_MEMZONE_16GB) && - free_memseg[i].hugepage_sz == RTE_PGSIZE_16M) + if ((size_mask & free_memseg[i].hugepage_sz) == 0) continue; /* this segment is the best until now */ @@ -244,16 +234,6 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len, /* no segment found */ if (memseg_idx == -1) { - /* - * If RTE_MEMZONE_SIZE_HINT_ONLY flag is specified, - * try allocating again without the size parameter otherwise -fail. - */ - if ((flags & RTE_MEMZONE_SIZE_HINT_ONLY) && - ((flags & RTE_MEMZONE_1GB) || (flags & RTE_MEMZONE_2MB) - || (flags & RTE_MEMZONE_16MB) || (flags & RTE_MEMZONE_16GB))) - return memzone_reserve_aligned_thread_unsafe(name, - len, socket_id, 0, align, bound); - rte_errno = ENOMEM; return NULL; } @@ -302,13 +282,18 @@ rte_memzone_reserve_thread_safe(const char *name, size_t len, { struct rte_mem_config *mcfg; const struct rte_memzone *mz = NULL; - - /* both sizes cannot be explicitly called for */ - if (((flags & RTE_MEMZONE_1GB) && (flags & RTE_MEMZONE_2MB)) - || ((flags & RTE_MEMZONE_16MB) && (flags & RTE_MEMZONE_16GB))) { - rte_errno = EINVAL; - return NULL; - } + uint64_t size_mask = 0; + + if (flags & RTE_MEMZONE_2MB) + size_mask |= RTE_PGSIZE_2M; + if (flags & RTE_MEMZONE_16MB) + size_mask |= RTE_PGSIZE_16M; + if (flags & RTE_MEMZONE_1GB) + size_mask |= RTE_PGSIZE_1G; + if (flags & RTE_MEMZONE_16GB) + size_mask |= RTE_PGSIZE_16G; + if (!size_mask) + size_mask = UINT64_MAX; /* get pointer to global configuration */ mcfg = rte_eal_get_configuration()->mem_config; @@ -316,7 +301,18 @@ rte_memzone_reserve_thread_safe(const char *name, size_t len, rte_rwlock_write_lock(&mcfg->mlock); mz = memzone_reserve_aligned_thread_unsafe( - name, len, socket_id, flags, align, bound); + name, len, socket_id, size_mask, align, bound); + + /* + * If we failed to allocate the requested page size, and the + * RTE_MEMZONE_SIZE_HINT_ONLY flag is specified, try allocating + * again. + */ + if (!mz && rte_errno == ENOMEM && size_mask != UINT64_MAX && + flags & RTE_MEMZONE_SIZE_HINT_ONLY) { + mz = memzone_reserve_aligned_thread_unsafe( + name, len, socket_id, UINT64_MAX, align, bound); + } rte_rwlock_write_unlock(&mcfg->mlock); -- 2.1.2