From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from emea01-db3-obe.outbound.protection.outlook.com (mail-db3on0081.outbound.protection.outlook.com [157.55.234.81]) by dpdk.org (Postfix) with ESMTP id 77FAA5A6C for ; Thu, 9 Jul 2015 07:00:45 +0200 (CEST) Received: from DB5PR02CA0040.eurprd02.prod.outlook.com (10.161.237.50) by HE1PR02MB0809.eurprd02.prod.outlook.com (10.161.118.149) with Microsoft SMTP Server (TLS) id 15.1.207.19; Thu, 9 Jul 2015 05:00:44 +0000 Received: from DB3FFO11FD020.protection.gbl (2a01:111:f400:7e04::143) by DB5PR02CA0040.outlook.office365.com (2a01:111:e400:5805::50) with Microsoft SMTP Server (TLS) id 15.1.213.14 via Frontend Transport; Thu, 9 Jul 2015 05:00:43 +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 DB3FFO11FD020.mail.protection.outlook.com (10.47.217.51) with Microsoft SMTP Server (TLS) id 15.1.213.8 via Frontend Transport; Thu, 9 Jul 2015 05:00:41 +0000 Received: (from zlu@localhost) by bjgfarm-1.internal.tilera.com (8.14.4/8.14.4/Submit) id t6950Yjd018572; Thu, 9 Jul 2015 13:00:34 +0800 From: Zhigang Lu To: Date: Thu, 9 Jul 2015 12:58:52 +0800 Message-ID: <1436417938-18496-7-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; DB3FFO11FD020; 1:j3oOr1vugqzZFSQjeK9RshFLViqGAtcAS6UOr/TiLOif7YRKMTi4EZTOBtiR+zOUp94pJwQXHPHhP0S4xZGDcn/02BFRcoZ5LotMw+GPLEdbDM2FKV7VMLy1IwDwC92H7kLywB6QYCGrOBeR8jNGnkLgHh30UBYvltRxKa5vjLOgEU7qEV/kn7xLs3mBnXFMjRPeEVHpEj6V5baa5893ezxgCzn/WA3TowvI2FJLPsDBdksgFnk+WJjluYQWtlHTKgZau2XjLhcT2Vwe8+gh8IYdAuZiyZl20j5lqW2q8BeayV6SNVa1BiZsdrpbADTvVTcpCucL6lPGNw2hfDApjHMQTZETCzY7JzElKXi2PmfR8fsdU5SQVJqLCdBhvI673FqHfrtN3t5Fz1N0m0B8OWJRsMfzO/VV2C6tvzu4rB8ouQfSDdizIiEJPj8vlETI 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)(47776003)(2351001)(5001960100002)(62966003)(2950100001)(76176999)(50986999)(50226001)(86362001)(106466001)(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:I2DvNrb8XVX9R+tuzltowIFF2vJOzyfRX3vYS8agvPw+/VXDP4ylXubXSz1A55Zq; 3:SOq0K/F+MI2rq1EoFK8Oqi1Wla6ItIqVCgTm6+hxY0mrnv8Xc989tFdZzQdjZjGk456HC2ytUtZGxnynRSU0WKuHUuICcbm3QR5KhorWas3iI4ul6x8LlHTNKBVhQgKqGbUW+Wi05r8EnZr2c7zKKeydbW1rTZ3mLyAaqteheHQvHnYGi6OCpHeSLKme5CyZNbqGS4D5CTUM2kXPPGjOEuvE2lAeOugdFpoicVctBxHNej4QTwboqxRhVvZ7qAZ6; 25:Uf9F8tDPqFuwLtBRr2PZFYpejxOwHcMHf5KLJJS2jC+OHde+0QqG9QeQyZyaXPmnE+P0tMF+XmhdGUUxmEjIlVDgOXLb8JDZkiKOpu2FVC/IqDlitEmOxT7GcG9Gw7aFeUM0rMCWdmTVTgRPk5IxC8aJo5f+DqckuPgI4VHUT8ryE/7d5k7EN1nFtJ+DgA7ibm2UVisZKTxD4suypr79G4/98VPALTqQWau1lZtDb4N90TXA/r4/jKfDi2Tf+A5PqiE4WeDHwpRnfovFFs0Nhw==; 20:Re/dhRjxmMBnnZBWdVCIF/7ophmsticMnjihocoi7AunGNHqTr1st9ziCPCM+j4AdMHDxHYyDXQ7NuOOC4dL3DDSXZ1B2IBDWh0fHOAJAbl6pDT1qHbSvSSNySL6HuxMgA60kRuNfpdsliuUkubGPvAsFhBoNF+8bWrTtDwAKxc= 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:KGSMhRDsE7wrZehX4RT6ahtCXZX8r+iaPWu0OktKPMrLfCUvFmqxC662TT/6l+k6qVBNHqVPHCfiO9lEZ9cpFppfVVOuIA5lGdD+0MygXr7GiTNTUdNR6s2BVnMvxgbwFm/rpvSxVY3Pa5D0CuVcsVIUdyu8GoFY02NiuwgQmeb1YTgwY2GOwlhiCJzsY0C/vkmLcF8EaDnuY8/k7gCdaYFnwXVumDptJjTJj7+xxqQbmS9PJ4K8qTqXT99WvP/tBFuwHlQiASCcM22Eb5uuuCMJZilnN8MTJy16iiDDXzs= X-Forefront-PRVS: 0632519F33 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR02MB0809; 23:WkrigDRQJXTD4LxZOHe0l/hTjHLkjurEPCiwZq5B1?= =?us-ascii?Q?VEJv8iWY1h4zyNYIDozfs0kCxvabNKqj9eYUYyvstDL1ZM5V7G4WWpg7rS8X?= =?us-ascii?Q?64NocBblxeebbw/rxNJ78CPgoly5tiiy/lk3g6SEIVH92txU1dX2jDarZXUE?= =?us-ascii?Q?Vz10owUGkBbvPtrZdHXvm040iypdgziQe59lNVBkXj7lybqNDxJmurJl7OxC?= =?us-ascii?Q?vUEQMLR9gGuOQXRR50TqIg9aKFYHuB33MLFJoo69yhLr4TXz+Te5JG6saMi4?= =?us-ascii?Q?1E+tN1EoqqCXGYyU6yG393pdxpu3WdJqW8UmH+1siqPaOsTv4KD55pSC9l1/?= =?us-ascii?Q?Gb6rEe8UciFK3CESSTsel9kwFQDIr0e4Se1hfmIhTlMNH1fjfWFqHknrTNnm?= =?us-ascii?Q?CmC2ujsDG6jonAH6Y/Qh2pZr++31AJo7sxh9epuMs1w/vW7OP/SCWzXFVfHN?= =?us-ascii?Q?F96oN70vsjjoaOC4DPPofDp7wqf1OSUTEFQz09k7No6AgI3TcvciHIKccoaH?= =?us-ascii?Q?99p3F/DK2AV3nYRkLBZGcdsVAaOaryPy5gPclr+5nTRYRqRrHLuMVl54TAUS?= =?us-ascii?Q?103G0GjwW8Qfiv3lpdJ0YFN9FR4u+pJXhkR304d+k1EpdMefldi1W7yIFiXI?= =?us-ascii?Q?33i7NTnOhYmI0GZGXYOFIWYkLBrlI7IvLfQOKAtlR71ohzA8npS8pIdX9k+G?= =?us-ascii?Q?3pJ+hqgMqlsNfycVPKabU+YhGTTPXmWEDsgbKDx+cXdtsMlnCRLmiN38h1vU?= =?us-ascii?Q?n9Qf5ztEDaaVN270pUKvXRz+GXiSKCXP53hXpGDOQrFO22LvqbyHX4g0ZWbR?= =?us-ascii?Q?9vosvQANPRa1nNrWU/lMq7I828bpDEmTMv4fnjXnjodcT8RlznYSj0O01Ydw?= =?us-ascii?Q?lF0l0B2S7ul3dEET3nCwa7BvByuu24rFZKG6Kdaqps3DrUOc53qOyT9Y24W1?= =?us-ascii?Q?udwaL5QzHaOijetuVghAzzTylklLzEI5j/QQDlIpSjvGwup8sUjtYlTm+7vP?= =?us-ascii?Q?hPaWvGb6w2oDsZ+gDf5vJ9J?= X-Microsoft-Exchange-Diagnostics: 1; HE1PR02MB0809; 5:t/6x4DFrGiaL2d2lpXAFEJz/qywTqE5q2FaPbC4Tx47c+nbXzZBhxZUDLzT1NHngJvGxh/HcAgTy18qUxdSOrXS0S9cGUNV9oLum2C1dwVU5O2sZl7IyyY1NFPun9MGvdTVhZGTYVLSbthsOhItnOw==; 24:vyAW59V6k4C3CB6AY5NdLrd2876xPfSAs8BtFQTAa8ThU1uqG8lng8HGxY64v3/sJ0vk6Vjicp0x+Iz9A6Dt2AD7wXNIeLvNmam+i75HGzQ=; 20:eOTl9qozssd5K7GVbQNA6kMUOzTHghjwkQXd/8OXk0x2El7lnEImuKDMbz2TwY4wDqt4JUVafrIC6qxkeZSpyQ== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2015 05:00:41.5338 (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 v4 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 05:00:45 -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: 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