Message ID | 1474044395-11627-2-git-send-email-hemant.agrawal@nxp.com (mailing list archive) |
---|---|
State | Changes Requested, archived |
Delegated to: | Thomas Monjalon |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 66C0168D9; Fri, 16 Sep 2016 13:12:42 +0200 (CEST) Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0087.outbound.protection.outlook.com [104.47.38.87]) by dpdk.org (Postfix) with ESMTP id 3DF074CE4 for <dev@dpdk.org>; Fri, 16 Sep 2016 13:12:38 +0200 (CEST) Received: from DM2PR03CA0027.namprd03.prod.outlook.com (10.141.96.26) by DM5PR03MB2442.namprd03.prod.outlook.com (10.168.233.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.629.8; Fri, 16 Sep 2016 11:12:37 +0000 Received: from BY2FFO11FD046.protection.gbl (2a01:111:f400:7c0c::129) by DM2PR03CA0027.outlook.office365.com (2a01:111:e400:2428::26) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.629.8 via Frontend Transport; Fri, 16 Sep 2016 11:12:37 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; nxp.com; dmarc=fail action=none header.from=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD046.mail.protection.outlook.com (10.1.15.170) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.619.6 via Frontend Transport; Fri, 16 Sep 2016 11:12:37 +0000 Received: from netperf1.ap.freescale.net ([10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u8GBCUTF026936; Fri, 16 Sep 2016 04:12:34 -0700 From: Hemant Agrawal <hemant.agrawal@nxp.com> To: <olivier.matz@6wind.com> CC: <dev@dpdk.org>, <jerin.jacob@caviumnetworks.com>, <david.hunt@intel.com>, Hemant Agrawal <hemant.agrawal@nxp.com> Date: Fri, 16 Sep 2016 22:16:35 +0530 Message-ID: <1474044395-11627-2-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1474044395-11627-1-git-send-email-hemant.agrawal@nxp.com> References: <1473959607-1951-1-git-send-email-hemant.agrawal@nxp.com> <1474044395-11627-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131184979572803408; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(2906002)(76176999)(4326007)(68736007)(575784001)(97736004)(8936002)(81166006)(50226002)(626004)(86362001)(5660300001)(104016004)(50466002)(586003)(7846002)(2950100001)(47776003)(229853001)(19580405001)(5003940100001)(110136003)(92566002)(19580395003)(2351001)(50986999)(48376002)(305945005)(77096005)(189998001)(8666005)(36756003)(81156014)(85426001)(33646002)(87936001)(106466001)(105606002)(356003)(8676002)(11100500001)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR03MB2442; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD046; 1:Z+/tZxcELSi052LzOP9f3m0rd19BdIVrgnFW35Z+idHxrpjZYlA9VCH6m3JDEZF8/4QtaAqzyDOTdd593H6pv5llGDg7fzkuSSz4y5UtCXWrEyA2jJQ1LfnftAKHxZMlcRhQiPomGpKDbpwtStPuhn6/mZ0um7We2gAgVHfDKJvMHyFfIuY/GhpjHk/EQHwXa2WFmeBzr2u06zXoR1zI6cG6vpPms+8tjVn/rytcfGZhe7aBMdamn5wVDVi3HSmbyAXGSD3mx7WWoLeVRxe6tuZ9RYfYqlxOYxahsiz0I7Zc6DNvCb/4zMKUUZ/y9IgbQtJgLe59CNU9n50dTyQt05cTlPZuj+AamaUdC4qXgqDaq2xML8U5sio1RqRt3LQHLKmHO4zcmW8xXw7IB22O3RJcz96a4GQzhDX5+zB4zKevU+DCCADGhGlODDDxwunCFrzFH8isEaOK1hmC0P+gultsHNNKSNBUhg6SLr03UqNeNHmIYuoIo702LnOueZ04CS7hvnc0fSyFvgXXSfupLO9n/vlPEh7T2HU0a3EytSLyLUYtkkAv6sv7gbRDEelARMPDtPkeYlcVCKVeF19Y+2CEu+QLT2uGIiH+LuCRn+YXzo/XAsftkL8FHAShJq+AfxZ2AbKVz7yMFqFPPb52cfXBnPn6tSD9feNgr1z4/zq3w2PJ2qsk8AqCerAWIbFXC0Yg1GJ0KxC+McPlstxsiPi42sEWC/+lqvp4sxF8X3b6IzalGY0JWMx71QJY7BxgH73tqllhs6PB3sbCyEzOqg== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 7c238995-c84f-416f-65f1-08d3de225dc2 X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2442; 2:7KamRGOycRTEJx0fADpQ7uowFht5XFDR6zHxyQJ/87dKSxHwn9rkYpVwzxImdVe3lsVzt0Eg4viA7po00qvLtDAv0BKH5XBFdoXcBo0YWcKdyV3ZY6f7G/bHS9G/NdrHr4gwhwsF2FceYD6V/cPYkZaEe55r3pDUiA6DutvP2lsZfj2492sO9yKMp8wyZEhd; 3:eClM9ziz640D8ZFmO8whzAVZlDYRrIK9vEVDQtu2y7pE4IWs9E6IHUtZplNVI5RrjXoxRxh7M1TqzxbAiiGsWQWCutoeOVW+gCLwHlr4WpsdnkADtM5POlXhVwSgUCm/ul0KkRjzpo6JPaVp4yhBlh+hdpZNn1PrBY5+3yhJ5k8CE1r8BZUQSVZsv+AHM0I6EWcw8ADnX+xTcoWjB1yrVtThHulKO14yBD5K83+RA2s= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM5PR03MB2442; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2442; 25:Kyjvo6vWpqNSLgP3ChnMopQBZlsFpbQB7JVZByWa7o0Hw/kBDVGcNc4R6g+cUL3rUs67ejWsgWNKxaCd9SBtV8RcSM0cXQ9a4MlStpFgU8kyQUK0th/YPsznjaZMHOdx0TF4tBqGu8qwENtC1wxWd15TVf5JzElvNEOr6Bef7UQKkPq3esiZ0D8Br2QbIDn/ete+dWox/qRuwMwNlkRkg01rCMxi4CgaxgRWZLAS4S5xxXDbWleffZlFaKVZ7uJPmP0d6FBI13lFlSBZPi2oEw48euNZn2qXr5TZ4hues9HU0o3HPw0W3Yzr2oYoGSKoHtn6WFCgqU50DWyIM93Cpk37cMkTmlfSF9DQBPaoBP4CXMxpdEW6Ryg7VqL6GJZOkRnd/CYes6M/DJbA2hbfJGNiHXAe6BUEIx8fxWY7h657W2Ic2QZEqf7LGnAu2s0HRfuncdmrqP/wJl7SBONenmR+cq1i6sL7j0isY4WVddIzq4d8imzMb/P8cxL39XvapW8LUNHwODi5WkAWERzYspw7Ywg+aNoQSCxIwaCWMG3KiXzeuM6g7v7xBbJGCvKpgDyUBkZRd3H4PyBkup1z/XZ7jFP0Acps3rOd2WLdMo9quabdDu3dBbOwp2Pj7evqR2fpb0crCnPDpA+SMscscj4e5T9nwyuf8CRhBRXUOPL4lVKlYg33VzriJ1OYknsmLbgCxRReLlF6vo88OGMMl+EFaE2UMxll5Qd3RZjgJ7E= X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2442; 31:YAeYexm9dJ8Da+fPmNwU3XY0xfeIvXxxS7/udEWXRGYG76Dg8dTCoJXwm3UT4T49yZGdLUqYnzA83g2uW+z9iXT65NDmm5lCHdxfN/SGOsEL0UIRBYI0k5gicu7wfEvuxxaeatlSOiXAQ1iuFiTanTB2x3ir2SgJkMD6gtjBlw77v6iCpbpkKLUqaR3+OhJX+1UqC2EqA415VwJJQSjCFVojLPl4YcaAkeFl2vt4+gU=; 4:Vhr7b0zTHz5P6Cog71rgUY2uZgwFvp5LAMPV15w76+HXkCnFSjqblbJgK2aiAP9aRyqTXUIFrloeM3oCz4Tqe+ST94JMY69o7OaAg1U8584PiV43XJ5sr2IV9T4DvRbFwzTPTZx/U13He0DjKmx5tngZjtYlwF3sUuigqn6Ka6AcpUVzZJXPCYL4e7jPqBTwiRZd8+vKSxz4bVQfuaI6n+ymxWfge835WJt6z4XoPuVCTTdu8hXTOA1Gyk4ECYgtpJCbvQyLV1Tm+a1EFwLNu6+jW3kDYLR0CxPTJ1QHl0AMazoCiTSCQx2V7QHiUmiPDZZrj5ltMXWpHXh4H8GeudcXkFHyVKVu87wmHy7IS2pDSJTX9Z3LnyPWyZNMl8iX2Wafy7lv3mijpfIKwUHSzLLKunaQoecoemUidMjCe8twbbEYZW9E+XCJwAwIpJ/GToGkxVIWYvuyS6km55lVCzVP/61xxT2kQQ7BGgFxvZAnCgYOEjC6m6ICp7Md6W9gOIUlXc7SaIKZrXIVFWa+u0ee/5YBDTOCEVPUYQMkNA4= X-Microsoft-Antispam-PRVS: <DM5PR03MB244295D916D165C64394C86089F30@DM5PR03MB2442.namprd03.prod.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(13017025)(8121501046)(5005006)(13015025)(13024025)(13023025)(13018025)(3002001)(10201501046)(6055026); SRVR:DM5PR03MB2442; BCL:0; PCL:0; RULEID:(400006); SRVR:DM5PR03MB2442; X-Forefront-PRVS: 0067A8BA2A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR03MB2442; 23:SFMyGevITM4ifUfHQ5plwFDhztNNE/MyfPrkMgsSW?= =?us-ascii?Q?KVpq+ex+Amx0K/Lxpi4O57gs/CeNaQr5m51MzyWN8GBHMDx4riKZfaonofcy?= =?us-ascii?Q?h9YHLVOdagTXLi+P0N+SXOzbLV9ggc8u9QLsceC/XfbAKsOczpB5P19VhQ48?= =?us-ascii?Q?WRT8efBNjKsLsKU0KiBVNkflP4odTC0m4ahx2hDxiw/Bh7jDaExQHm0pdL9B?= =?us-ascii?Q?neioBUmGo/vbVpIUHUQab2nesGKY5/WF+U96FFYqtxdYa3GywawjAZMQkaWf?= =?us-ascii?Q?O2YPdrsgu3jOyxFPWIQsF3D8pPK3+lNdkcZbvMZlzFVLD/dlxeSWohgTIgKV?= =?us-ascii?Q?BtH6XIEv723VC+ZHvOn6vcw8i7lyuxWeFvNZN2clEuFKC5Kax697a+Z++7EY?= =?us-ascii?Q?5q3ZL4XKPVxZWmiBDO/okpn+ifaa3jeyYv4bNTljKUzdVRZW1FNEP2IBn637?= =?us-ascii?Q?LtPrRe442OH0dvU2jqLujmYaFlKZuoWTFa8dYNcr3Hrcml/1pEZxTqPwv0NS?= =?us-ascii?Q?l9qaXLaesSDy6sOE6LaSDdMIv+Rl5EzyRgm9WUWQNLCNLSNFU7E84TiXJmoD?= =?us-ascii?Q?GYAg/NjL7ZteaizNAgyqwPJmoSj6q/vf//Tm5YP0KjUX17Dw3muuEmGTc2WD?= =?us-ascii?Q?wTyskN67NfGEq8cr+yMyOLJ+t8+YE/9/MaRdOWsTPKUjW8YHmr7rad2HrKIT?= =?us-ascii?Q?INpcMuXa2G5/03w1lrbT5dDSfvfPuEdaJglve5ARVvydF3xfIThUfbHrO1Gc?= =?us-ascii?Q?24O2mg9mNrURwNsAY3tEIJ+TgK2wHZaTNbKt5gE0BTm+QqD4oCRQMBZiXqfU?= =?us-ascii?Q?ZewtV0jZMYWbamFHZVZW5pK0DbssiNckKnEdOetKh6fZKy4KaZ7VPkUgy/zu?= =?us-ascii?Q?TtzvqykIOdkUXYxmWetC025+OCFN7wIOCWjEJPf5NcRkwMd24jVJwDGqktlE?= =?us-ascii?Q?9hH4ROGxwjhWXwN8kMrZ9req5H4QH+9ufgkzFIY/eO6xvLUSfWEt1NQn0QJc?= =?us-ascii?Q?24ag6sr2CxJk4LUsyCjtGN/OXCbd0iUCMAG8QkZ7zm51UZ/hAq4r4SOF65zv?= =?us-ascii?Q?nWLf5/SvsYWH7e9SnCRnPnp8hLkbSgPkZUadiINscC1qWiwJf7pBWZUgYcTK?= =?us-ascii?Q?LYh7MFycz6tpZoeonTud7mVHzp/R0LeKtEhqR40qBQTMxvsBROnzOht/vv6Y?= =?us-ascii?Q?gfQvS+uW5el8Aa+DGQv6GOLXhJv0P8qFjnc?= X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2442; 6:5VL2rZh6we4mngJlbpQSOKvCbCuO8kHhfQ3cMcJCqdu4OxVbJUyIJuoXhZMKYl0HBzoIg1CjrqPBIEJPI4HlbPOHOqFPzEqWf/E3E6D2mFzo9PKDpBt5kJMGpzFX4zuUpnkApLJzT7MBcLdHEFYyOUgHcFywEY2sNfpbkQuEaQvCtJqO186ppOlfk6BERQZhAuUDYpaYOQZr3rvHsRQdy9cUP2MilzBFBcNAwyIRuodjvO+Oo1rhFY+EPsS4GNyyUPBuYLVSqdi93v/XHye+lY1tV/IvHbfmBlgdcp87Wvk=; 5:hY3iNp5r6uyWJr6PvxDTvw/pSARcady7DOnrDeAQnkPaMNNpGldKHybV01/Rrvwj8Wp7kwJmklnX92SonY3+bBVWdxqqvvoLq/INl8SydrTdQ6bNYF796agOOnT1w+Mbte9DxR7F9JvK/B8h9lKkmgXKphPZnPWpUWyeuuIm7Ds=; 24:yLaWUvlhCeZNabRRhE6u4xWGM2Grn+L+tY4meNmYCWjM5S34U68m5NReJ4TF1KGggk8HqONdAtaJ/YYSaNZDSTm2Fjn1GYBqM8gmZ7oJm8w=; 7:ASTFNZar6HwMu6Y8XgIw4zAh+oYoFpqo5Ej6G7gPgHbjFkN+UsKnACnDWGh8GnA5TmEpSDl770rVxlPehM/9dW8Hi3SaQ2n8jhXwfWWeLHtfYX1EeeVR3pGAlNnvmR5cSeeqBlAc2yYfM+2STGCwMgWWc2jATg/kLckFc5g+/nxTPU6kOoKUx34BgGovMpt5jDqUirYVP0dGXZnk3yUda5sWTjg5moLNx0mCep0Cm1TdpBM8fJ9ZRJSXVDL81siZ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2016 11:12:37.0775 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2442 Subject: [dpdk-dev] [PATCH v3 2/2] mempool: pktmbuf pool default fallback for mempool ops error X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Hemant Agrawal
Sept. 16, 2016, 4:46 p.m. UTC
In the rte_pktmbuf_pool_create, if the default external mempool is
not available, the implementation can default to "ring_mp_mc", which
is an software implementation.
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
Changes in V3:
* adding warning message to say that falling back to default sw pool
---
lib/librte_mbuf/rte_mbuf.c | 8 ++++++++
1 file changed, 8 insertions(+)
Comments
Hi Hemant, On 09/16/2016 06:46 PM, Hemant Agrawal wrote: > In the rte_pktmbuf_pool_create, if the default external mempool is > not available, the implementation can default to "ring_mp_mc", which > is an software implementation. > > Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com> > --- > Changes in V3: > * adding warning message to say that falling back to default sw pool > --- > lib/librte_mbuf/rte_mbuf.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c > index 4846b89..8ab0eb1 100644 > --- a/lib/librte_mbuf/rte_mbuf.c > +++ b/lib/librte_mbuf/rte_mbuf.c > @@ -176,6 +176,14 @@ rte_pktmbuf_pool_create(const char *name, unsigned n, > > rte_errno = rte_mempool_set_ops_byname(mp, > RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL); > + > + /* on error, try falling back to the software based default pool */ > + if (rte_errno == -EOPNOTSUPP) { > + RTE_LOG(WARNING, MBUF, "Default HW Mempool not supported. " > + "falling back to sw mempool \"ring_mp_mc\""); > + rte_errno = rte_mempool_set_ops_byname(mp, "ring_mp_mc", NULL); > + } > + > if (rte_errno != 0) { > RTE_LOG(ERR, MBUF, "error setting mempool handler\n"); > return NULL; > Without adding a new method ".supported()", the first call to rte_mempool_populate() could return the same error ENOTSUP. In this case, it is still possible to fallback. I've just submitted an RFC, which I think is quite linked: http://dpdk.org/ml/archives/dev/2016-September/046974.html Assuming a new parameter "mempool_ops" is added to rte_pktmbuf_pool_create(), would it make sense to fallback to "ring_mp_mc"? What about just returning ENOTSUP? The application could do the job and decide which sw fallback to use. Regards, Olivier
Hi Olivier On 9/19/2016 7:27 PM, Olivier Matz wrote: > Hi Hemant, > > On 09/16/2016 06:46 PM, Hemant Agrawal wrote: >> In the rte_pktmbuf_pool_create, if the default external mempool is >> not available, the implementation can default to "ring_mp_mc", which >> is an software implementation. >> >> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com> >> --- >> Changes in V3: >> * adding warning message to say that falling back to default sw pool >> --- >> lib/librte_mbuf/rte_mbuf.c | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c >> index 4846b89..8ab0eb1 100644 >> --- a/lib/librte_mbuf/rte_mbuf.c >> +++ b/lib/librte_mbuf/rte_mbuf.c >> @@ -176,6 +176,14 @@ rte_pktmbuf_pool_create(const char *name, unsigned n, >> >> rte_errno = rte_mempool_set_ops_byname(mp, >> RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL); >> + >> + /* on error, try falling back to the software based default pool */ >> + if (rte_errno == -EOPNOTSUPP) { >> + RTE_LOG(WARNING, MBUF, "Default HW Mempool not supported. " >> + "falling back to sw mempool \"ring_mp_mc\""); >> + rte_errno = rte_mempool_set_ops_byname(mp, "ring_mp_mc", NULL); >> + } >> + >> if (rte_errno != 0) { >> RTE_LOG(ERR, MBUF, "error setting mempool handler\n"); >> return NULL; >> > > Without adding a new method ".supported()", the first call to > rte_mempool_populate() could return the same error ENOTSUP. In this > case, it is still possible to fallback. > It will be bit late. On failure, than we have to set the default ops and do a goto before rte_pktmbuf_pool_init(mp, &mbp_priv); > I've just submitted an RFC, which I think is quite linked: > http://dpdk.org/ml/archives/dev/2016-September/046974.html > Assuming a new parameter "mempool_ops" is added to > rte_pktmbuf_pool_create(), would it make sense to fallback to > "ring_mp_mc"? What about just returning ENOTSUP? The application could > do the job and decide which sw fallback to use. We ran into this issue when trying to run the standard DPDK examples (l3fwd) in VM. Do you think, is it practical to add fallback handling in each of the DPDK examples? Typically when someone is writing a application on host, he need not worry non-availability of the hw offloaded mempool. He may also want to run the same binary in virtual machine. In VM, it is not guaranteed that hw offloaded mempools will be available. w.r.t your RFC, we can do this: if the user has specified a mempool_ops in rte_pktmbuf_pool_create(), don't fallback. It will be responsibility for application to decide on calling again rte_pktmbuf_pool_create() with different mempool_ops. > > > Regards, > Olivier >
Hi Olivier, Any updates w.r.t this patch set? Regards Hemant On 9/22/2016 6:42 PM, Hemant Agrawal wrote: > Hi Olivier > > On 9/19/2016 7:27 PM, Olivier Matz wrote: >> Hi Hemant, >> >> On 09/16/2016 06:46 PM, Hemant Agrawal wrote: >>> In the rte_pktmbuf_pool_create, if the default external mempool is >>> not available, the implementation can default to "ring_mp_mc", which >>> is an software implementation. >>> >>> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com> >>> --- >>> Changes in V3: >>> * adding warning message to say that falling back to default sw pool >>> --- >>> lib/librte_mbuf/rte_mbuf.c | 8 ++++++++ >>> 1 file changed, 8 insertions(+) >>> >>> diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c >>> index 4846b89..8ab0eb1 100644 >>> --- a/lib/librte_mbuf/rte_mbuf.c >>> +++ b/lib/librte_mbuf/rte_mbuf.c >>> @@ -176,6 +176,14 @@ rte_pktmbuf_pool_create(const char *name, >>> unsigned n, >>> >>> rte_errno = rte_mempool_set_ops_byname(mp, >>> RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL); >>> + >>> + /* on error, try falling back to the software based default pool */ >>> + if (rte_errno == -EOPNOTSUPP) { >>> + RTE_LOG(WARNING, MBUF, "Default HW Mempool not supported. " >>> + "falling back to sw mempool \"ring_mp_mc\""); >>> + rte_errno = rte_mempool_set_ops_byname(mp, "ring_mp_mc", NULL); >>> + } >>> + >>> if (rte_errno != 0) { >>> RTE_LOG(ERR, MBUF, "error setting mempool handler\n"); >>> return NULL; >>> >> >> Without adding a new method ".supported()", the first call to >> rte_mempool_populate() could return the same error ENOTSUP. In this >> case, it is still possible to fallback. >> > It will be bit late. > > On failure, than we have to set the default ops and do a goto before > rte_pktmbuf_pool_init(mp, &mbp_priv); > > >> I've just submitted an RFC, which I think is quite linked: >> http://dpdk.org/ml/archives/dev/2016-September/046974.html >> Assuming a new parameter "mempool_ops" is added to >> rte_pktmbuf_pool_create(), would it make sense to fallback to >> "ring_mp_mc"? What about just returning ENOTSUP? The application could >> do the job and decide which sw fallback to use. > > We ran into this issue when trying to run the standard DPDK examples > (l3fwd) in VM. Do you think, is it practical to add fallback handling in > each of the DPDK examples? > > Typically when someone is writing a application on host, he need not > worry non-availability of the hw offloaded mempool. He may also want to > run the same binary in virtual machine. In VM, it is not guaranteed that > hw offloaded mempools will be available. > > w.r.t your RFC, we can do this: > if the user has specified a mempool_ops in rte_pktmbuf_pool_create(), > don't fallback. It will be responsibility for application to decide on > calling again rte_pktmbuf_pool_create() with different mempool_ops. > >> >> >> Regards, >> Olivier >> > > >
Hi Hemant, Sorry for the late answer. Please see some comments inline. On 10/13/2016 03:15 PM, Hemant Agrawal wrote: > Hi Olivier, > Any updates w.r.t this patch set? > > Regards > Hemant > On 9/22/2016 6:42 PM, Hemant Agrawal wrote: >> Hi Olivier >> >> On 9/19/2016 7:27 PM, Olivier Matz wrote: >>> Hi Hemant, >>> >>> On 09/16/2016 06:46 PM, Hemant Agrawal wrote: >>>> In the rte_pktmbuf_pool_create, if the default external mempool is >>>> not available, the implementation can default to "ring_mp_mc", which >>>> is an software implementation. >>>> >>>> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com> >>>> --- >>>> Changes in V3: >>>> * adding warning message to say that falling back to default sw pool >>>> --- >>>> lib/librte_mbuf/rte_mbuf.c | 8 ++++++++ >>>> 1 file changed, 8 insertions(+) >>>> >>>> diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c >>>> index 4846b89..8ab0eb1 100644 >>>> --- a/lib/librte_mbuf/rte_mbuf.c >>>> +++ b/lib/librte_mbuf/rte_mbuf.c >>>> @@ -176,6 +176,14 @@ rte_pktmbuf_pool_create(const char *name, >>>> unsigned n, >>>> >>>> rte_errno = rte_mempool_set_ops_byname(mp, >>>> RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL); >>>> + >>>> + /* on error, try falling back to the software based default >>>> pool */ >>>> + if (rte_errno == -EOPNOTSUPP) { >>>> + RTE_LOG(WARNING, MBUF, "Default HW Mempool not supported. " >>>> + "falling back to sw mempool \"ring_mp_mc\""); >>>> + rte_errno = rte_mempool_set_ops_byname(mp, "ring_mp_mc", >>>> NULL); >>>> + } >>>> + >>>> if (rte_errno != 0) { >>>> RTE_LOG(ERR, MBUF, "error setting mempool handler\n"); >>>> return NULL; >>>> >>> >>> Without adding a new method ".supported()", the first call to >>> rte_mempool_populate() could return the same error ENOTSUP. In this >>> case, it is still possible to fallback. >>> >> It will be bit late. >> >> On failure, than we have to set the default ops and do a goto before >> rte_pktmbuf_pool_init(mp, &mbp_priv); I still think we can do the job without adding the .supported() method. The following code is just an (untested) example: struct rte_mempool * rte_pktmbuf_pool_create(const char *name, unsigned n, unsigned cache_size, uint16_t priv_size, uint16_t data_room_size, int socket_id) { struct rte_mempool *mp; struct rte_pktmbuf_pool_private mbp_priv; unsigned elt_size; int ret; const char *ops[] = { RTE_MBUF_DEFAULT_MEMPOOL_OPS, "ring_mp_mc", NULL, }; const char **op; if (RTE_ALIGN(priv_size, RTE_MBUF_PRIV_ALIGN) != priv_size) { RTE_LOG(ERR, MBUF, "mbuf priv_size=%u is not aligned\n", priv_size); rte_errno = EINVAL; return NULL; } elt_size = sizeof(struct rte_mbuf) + (unsigned)priv_size + (unsigned)data_room_size; mbp_priv.mbuf_data_room_size = data_room_size; mbp_priv.mbuf_priv_size = priv_size; for (op = &ops[0]; *op != NULL; op++) { mp = rte_mempool_create_empty(name, n, elt_size, cache_size, sizeof(struct rte_pktmbuf_pool_private), socket_id, 0); if (mp == NULL) return NULL; ret = rte_mempool_set_ops_byname(mp, *op, NULL); if (ret != 0) { RTE_LOG(ERR, MBUF, "error setting mempool handler\n"); rte_mempool_free(mp); if (ret == -ENOTSUP) continue; rte_errno = -ret; return NULL; } rte_pktmbuf_pool_init(mp, &mbp_priv); ret = rte_mempool_populate_default(mp); if (ret < 0) { rte_mempool_free(mp); if (ret == -ENOTSUP) continue; rte_errno = -ret; return NULL; } } rte_mempool_obj_iter(mp, rte_pktmbuf_init, NULL); return mp; } >>> I've just submitted an RFC, which I think is quite linked: >>> http://dpdk.org/ml/archives/dev/2016-September/046974.html >>> Assuming a new parameter "mempool_ops" is added to >>> rte_pktmbuf_pool_create(), would it make sense to fallback to >>> "ring_mp_mc"? What about just returning ENOTSUP? The application could >>> do the job and decide which sw fallback to use. >> >> We ran into this issue when trying to run the standard DPDK examples >> (l3fwd) in VM. Do you think, is it practical to add fallback handling in >> each of the DPDK examples? OK. What is still unclear for me, is how the software is aware of the different hardware-assisted handlers. Moreover, we could imagine more software handlers, which could be used depending on the use case. I think this choice has to be made by the user or the application: - the application may want to use a specific (sw or hw) handler: in this case, it want to be notified if it fails, instead of having a quiet fallback to ring_mp_mc - if several handlers are available, the application may want to try them in a specific order - maybe some handlers will have some limitations with some configurations or driver? The application could decide to use a different handler according the configuration. So that's why I think this is an application decision. >> Typically when someone is writing a application on host, he need not >> worry non-availability of the hw offloaded mempool. He may also want to >> run the same binary in virtual machine. In VM, it is not guaranteed that >> hw offloaded mempools will be available. Running the same binary is of course a need. But if your VM does not provide the same virtualized hardware than the host, I think the command line option makes sense. AFAIU, on the host, you can use a hw mempool handler or a sw one, and on the guest, only a sw one. So you need an option to select the behavior you want on the host, without recompiling. I understand that modifying all the applications is not a good option either. I'm thinking a a EAL parameter that would allow to configure a library (mbuf in this case). Something like kernel boot options. Example: testpmd -l 2,4 --opt mbuf.handler="ring_mp_mc" -- [app args] I don't know if this is feasible, this has to be discussed first, but what do you think on the principle? The value could also be an ordered list if we want a fallback, and this option could be overriden by the application before creating the mbuf pool. There was some discussions about a kind of dpdk global configuration some time ago. Regards, Olivier
Hi Olivier, > -----Original Message----- > From: Olivier Matz [mailto:olivier.matz@6wind.com] > Sent: Friday, October 14, 2016 5:41 PM > > On 9/22/2016 6:42 PM, Hemant Agrawal wrote: > >> Hi Olivier > >> > >> On 9/19/2016 7:27 PM, Olivier Matz wrote: > >>> Hi Hemant, > >>> > >>> On 09/16/2016 06:46 PM, Hemant Agrawal wrote: > >>>> In the rte_pktmbuf_pool_create, if the default external mempool is > >>>> not available, the implementation can default to "ring_mp_mc", > >>>> which is an software implementation. > >>>> > >>>> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com> > >>>> --- > >>>> Changes in V3: > >>>> * adding warning message to say that falling back to default sw > >>>> pool > >>>> --- > >>>> lib/librte_mbuf/rte_mbuf.c | 8 ++++++++ > >>>> 1 file changed, 8 insertions(+) > >>>> > >>>> diff --git a/lib/librte_mbuf/rte_mbuf.c > >>>> b/lib/librte_mbuf/rte_mbuf.c index 4846b89..8ab0eb1 100644 > >>>> --- a/lib/librte_mbuf/rte_mbuf.c > >>>> +++ b/lib/librte_mbuf/rte_mbuf.c > >>>> @@ -176,6 +176,14 @@ rte_pktmbuf_pool_create(const char *name, > >>>> unsigned n, > >>>> > >>>> rte_errno = rte_mempool_set_ops_byname(mp, > >>>> RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL); > >>>> + > >>>> + /* on error, try falling back to the software based default > >>>> pool */ > >>>> + if (rte_errno == -EOPNOTSUPP) { > >>>> + RTE_LOG(WARNING, MBUF, "Default HW Mempool not supported. " > >>>> + "falling back to sw mempool \"ring_mp_mc\""); > >>>> + rte_errno = rte_mempool_set_ops_byname(mp, "ring_mp_mc", > >>>> NULL); > >>>> + } > >>>> + > >>>> if (rte_errno != 0) { > >>>> RTE_LOG(ERR, MBUF, "error setting mempool handler\n"); > >>>> return NULL; > >>>> > >>> > >>> Without adding a new method ".supported()", the first call to > >>> rte_mempool_populate() could return the same error ENOTSUP. In this > >>> case, it is still possible to fallback. > >>> > >> It will be bit late. > >> > >> On failure, than we have to set the default ops and do a goto before > >> rte_pktmbuf_pool_init(mp, &mbp_priv); > > I still think we can do the job without adding the .supported() method. > The following code is just an (untested) example: > > struct rte_mempool * > rte_pktmbuf_pool_create(const char *name, unsigned n, > unsigned cache_size, uint16_t priv_size, uint16_t data_room_size, > int socket_id) > { > struct rte_mempool *mp; > struct rte_pktmbuf_pool_private mbp_priv; > unsigned elt_size; > int ret; > const char *ops[] = { > RTE_MBUF_DEFAULT_MEMPOOL_OPS, "ring_mp_mc", NULL, > }; > const char **op; > > if (RTE_ALIGN(priv_size, RTE_MBUF_PRIV_ALIGN) != priv_size) { > RTE_LOG(ERR, MBUF, "mbuf priv_size=%u is not aligned\n", > priv_size); > rte_errno = EINVAL; > return NULL; > } > elt_size = sizeof(struct rte_mbuf) + (unsigned)priv_size + > (unsigned)data_room_size; > mbp_priv.mbuf_data_room_size = data_room_size; > mbp_priv.mbuf_priv_size = priv_size; > > for (op = &ops[0]; *op != NULL; op++) { > mp = rte_mempool_create_empty(name, n, elt_size, cache_size, > sizeof(struct rte_pktmbuf_pool_private), socket_id, 0); > if (mp == NULL) > return NULL; > > ret = rte_mempool_set_ops_byname(mp, *op, NULL); > if (ret != 0) { > RTE_LOG(ERR, MBUF, "error setting mempool handler\n"); > rte_mempool_free(mp); > if (ret == -ENOTSUP) > continue; > rte_errno = -ret; > return NULL; > } > rte_pktmbuf_pool_init(mp, &mbp_priv); > > ret = rte_mempool_populate_default(mp); > if (ret < 0) { > rte_mempool_free(mp); > if (ret == -ENOTSUP) > continue; > rte_errno = -ret; > return NULL; > } > } > > rte_mempool_obj_iter(mp, rte_pktmbuf_init, NULL); > > return mp; > } > > [Hemant] This look fine to me. Please submit a patch for the same. > >>> I've just submitted an RFC, which I think is quite linked: > >>> http://dpdk.org/ml/archives/dev/2016-September/046974.html > >>> Assuming a new parameter "mempool_ops" is added to > >>> rte_pktmbuf_pool_create(), would it make sense to fallback to > >>> "ring_mp_mc"? What about just returning ENOTSUP? The application > >>> could do the job and decide which sw fallback to use. > >> > >> We ran into this issue when trying to run the standard DPDK examples > >> (l3fwd) in VM. Do you think, is it practical to add fallback handling > >> in each of the DPDK examples? > > OK. What is still unclear for me, is how the software is aware of the different > hardware-assisted handlers. Moreover, we could imagine more software > handlers, which could be used depending on the use case. > > I think this choice has to be made by the user or the application: > > - the application may want to use a specific (sw or hw) handler: in > this case, it want to be notified if it fails, instead of having > a quiet fallback to ring_mp_mc > - if several handlers are available, the application may want to > try them in a specific order > - maybe some handlers will have some limitations with some > configurations or driver? The application could decide to use > a different handler according the configuration. > > So that's why I think this is an application decision. > [Hemant] We should simplify it: if the application has supplied the handler, it is application's responsibility to take care of failure. Only if the application want to use the default handler, the implementation can fallback. The fallback handler can again be configurable. > >> Typically when someone is writing a application on host, he need not > >> worry non-availability of the hw offloaded mempool. He may also want > >> to run the same binary in virtual machine. In VM, it is not > >> guaranteed that hw offloaded mempools will be available. > > Running the same binary is of course a need. But if your VM does not provide > the same virtualized hardware than the host, I think the command line option > makes sense. > > AFAIU, on the host, you can use a hw mempool handler or a sw one, and on the > guest, only a sw one. So you need an option to select the behavior you want on > the host, without recompiling. > > I understand that modifying all the applications is not a good option either. I'm > thinking a a EAL parameter that would allow to configure a library (mbuf in this > case). Something like kernel boot options. > Example: testpmd -l 2,4 --opt mbuf.handler="ring_mp_mc" -- [app args] > > I don't know if this is feasible, this has to be discussed first, but what do you > think on the principle? The value could also be an ordered list if we want a > fallback, and this option could be overriden by the application before creating > the mbuf pool. There was some discussions about a kind of dpdk global > configuration some time ago. > [Hemant] I agree that command line option provide a better control in this case. On the flipside, We need to be careful that we do not end up having too many command line options. > > Regards, > Olivier
Hi Hemant, Back on this topic, please see some comments below. On 11/07/2016 01:30 PM, Hemant Agrawal wrote: > Hi Olivier, > >> -----Original Message----- >> From: Olivier Matz [mailto:olivier.matz@6wind.com] >> Sent: Friday, October 14, 2016 5:41 PM >>> On 9/22/2016 6:42 PM, Hemant Agrawal wrote: >>>> Hi Olivier >>>> >>>> On 9/19/2016 7:27 PM, Olivier Matz wrote: >>>>> Hi Hemant, >>>>> >>>>> On 09/16/2016 06:46 PM, Hemant Agrawal wrote: >>>>>> In the rte_pktmbuf_pool_create, if the default external mempool is >>>>>> not available, the implementation can default to "ring_mp_mc", >>>>>> which is an software implementation. >>>>>> >>>>>> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com> >>>>>> --- >>>>>> Changes in V3: >>>>>> * adding warning message to say that falling back to default sw >>>>>> pool >>>>>> --- >>>>>> lib/librte_mbuf/rte_mbuf.c | 8 ++++++++ >>>>>> 1 file changed, 8 insertions(+) >>>>>> >>>>>> diff --git a/lib/librte_mbuf/rte_mbuf.c >>>>>> b/lib/librte_mbuf/rte_mbuf.c index 4846b89..8ab0eb1 100644 >>>>>> --- a/lib/librte_mbuf/rte_mbuf.c >>>>>> +++ b/lib/librte_mbuf/rte_mbuf.c >>>>>> @@ -176,6 +176,14 @@ rte_pktmbuf_pool_create(const char *name, >>>>>> unsigned n, >>>>>> >>>>>> rte_errno = rte_mempool_set_ops_byname(mp, >>>>>> RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL); >>>>>> + >>>>>> + /* on error, try falling back to the software based default >>>>>> pool */ >>>>>> + if (rte_errno == -EOPNOTSUPP) { >>>>>> + RTE_LOG(WARNING, MBUF, "Default HW Mempool not supported. " >>>>>> + "falling back to sw mempool \"ring_mp_mc\""); >>>>>> + rte_errno = rte_mempool_set_ops_byname(mp, "ring_mp_mc", >>>>>> NULL); >>>>>> + } >>>>>> + >>>>>> if (rte_errno != 0) { >>>>>> RTE_LOG(ERR, MBUF, "error setting mempool handler\n"); >>>>>> return NULL; >>>>>> >>>>> >>>>> Without adding a new method ".supported()", the first call to >>>>> rte_mempool_populate() could return the same error ENOTSUP. In this >>>>> case, it is still possible to fallback. >>>>> >>>> It will be bit late. >>>> >>>> On failure, than we have to set the default ops and do a goto before >>>> rte_pktmbuf_pool_init(mp, &mbp_priv); >> >> I still think we can do the job without adding the .supported() method. >> The following code is just an (untested) example: >> >> struct rte_mempool * >> rte_pktmbuf_pool_create(const char *name, unsigned n, >> unsigned cache_size, uint16_t priv_size, uint16_t data_room_size, >> int socket_id) >> { >> struct rte_mempool *mp; >> struct rte_pktmbuf_pool_private mbp_priv; >> unsigned elt_size; >> int ret; >> const char *ops[] = { >> RTE_MBUF_DEFAULT_MEMPOOL_OPS, "ring_mp_mc", NULL, >> }; >> const char **op; >> >> if (RTE_ALIGN(priv_size, RTE_MBUF_PRIV_ALIGN) != priv_size) { >> RTE_LOG(ERR, MBUF, "mbuf priv_size=%u is not aligned\n", >> priv_size); >> rte_errno = EINVAL; >> return NULL; >> } >> elt_size = sizeof(struct rte_mbuf) + (unsigned)priv_size + >> (unsigned)data_room_size; >> mbp_priv.mbuf_data_room_size = data_room_size; >> mbp_priv.mbuf_priv_size = priv_size; >> >> for (op = &ops[0]; *op != NULL; op++) { >> mp = rte_mempool_create_empty(name, n, elt_size, cache_size, >> sizeof(struct rte_pktmbuf_pool_private), socket_id, 0); >> if (mp == NULL) >> return NULL; >> >> ret = rte_mempool_set_ops_byname(mp, *op, NULL); >> if (ret != 0) { >> RTE_LOG(ERR, MBUF, "error setting mempool handler\n"); >> rte_mempool_free(mp); >> if (ret == -ENOTSUP) >> continue; >> rte_errno = -ret; >> return NULL; >> } >> rte_pktmbuf_pool_init(mp, &mbp_priv); >> >> ret = rte_mempool_populate_default(mp); >> if (ret < 0) { >> rte_mempool_free(mp); >> if (ret == -ENOTSUP) >> continue; >> rte_errno = -ret; >> return NULL; >> } >> } >> >> rte_mempool_obj_iter(mp, rte_pktmbuf_init, NULL); >> >> return mp; >> } >> >> > [Hemant] This look fine to me. Please submit a patch for the same. > >>>>> I've just submitted an RFC, which I think is quite linked: >>>>> http://dpdk.org/ml/archives/dev/2016-September/046974.html >>>>> Assuming a new parameter "mempool_ops" is added to >>>>> rte_pktmbuf_pool_create(), would it make sense to fallback to >>>>> "ring_mp_mc"? What about just returning ENOTSUP? The application >>>>> could do the job and decide which sw fallback to use. >>>> >>>> We ran into this issue when trying to run the standard DPDK examples >>>> (l3fwd) in VM. Do you think, is it practical to add fallback handling >>>> in each of the DPDK examples? >> >> OK. What is still unclear for me, is how the software is aware of the different >> hardware-assisted handlers. Moreover, we could imagine more software >> handlers, which could be used depending on the use case. >> >> I think this choice has to be made by the user or the application: >> >> - the application may want to use a specific (sw or hw) handler: in >> this case, it want to be notified if it fails, instead of having >> a quiet fallback to ring_mp_mc >> - if several handlers are available, the application may want to >> try them in a specific order >> - maybe some handlers will have some limitations with some >> configurations or driver? The application could decide to use >> a different handler according the configuration. >> >> So that's why I think this is an application decision. >> > [Hemant] We should simplify it: if the application has supplied the handler, it is application's responsibility to take care of failure. Only if the application want to use the default handler, the implementation can fallback. The fallback handler can again be configurable. Honestly, I'm not very convinced that having a quiet fallback is the proper solution: the application won't be notified that the fallback occured. I understand your patch solves your use-case, but my fear is that we just integrate this minimal patch and never do the harder work of solving all the use-cases. I think we need to give the tools to the applications to control what occurs because we also need to solve these issues: - you have a hardware handler, but you want to use the software handler - you have several software handlers, and you (as an administrator) or the application knows which one is the best to use in your case. An alternative (which I don't like either) to solve your issue without modifying the mbuf code is to have your own handler fallbacking to ring_mp_mc. >>>> Typically when someone is writing a application on host, he need not >>>> worry non-availability of the hw offloaded mempool. He may also want >>>> to run the same binary in virtual machine. In VM, it is not >>>> guaranteed that hw offloaded mempools will be available. >> >> Running the same binary is of course a need. But if your VM does not provide >> the same virtualized hardware than the host, I think the command line option >> makes sense. >> >> AFAIU, on the host, you can use a hw mempool handler or a sw one, and on the >> guest, only a sw one. So you need an option to select the behavior you want on >> the host, without recompiling. >> >> I understand that modifying all the applications is not a good option either. I'm >> thinking a a EAL parameter that would allow to configure a library (mbuf in this >> case). Something like kernel boot options. >> Example: testpmd -l 2,4 --opt mbuf.handler="ring_mp_mc" -- [app args] >> >> I don't know if this is feasible, this has to be discussed first, but what do you >> think on the principle? The value could also be an ordered list if we want a >> fallback, and this option could be overriden by the application before creating >> the mbuf pool. There was some discussions about a kind of dpdk global >> configuration some time ago. >> > [Hemant] I agree that command line option provide a better control in this case. > On the flipside, We need to be careful that we do not end up having too many command line options. Yes, we should avoid having too many command line arguments. I think we should go in the direction of having a sort of key/value database in EAL. It could be set by: - a generic command line argument - a config file (maybe later) - the application through an API Then, it would be used by: - dpdk libraries - the application (maybe) This has been discussed some times, the latest was probably: http://dpdk.org/ml/archives/dev/2016-June/040079.html I think it would be a good tool for dpdk configurability, and it would help to remove some compile-time options and maybe some eal options. Unfortunately, I don't have the time to work on this at the moment. Regards, Olivier
Hi Olivier, Apology for a delayed response. > -----Original Message----- > From: Olivier Matz [mailto:olivier.matz@6wind.com] > Sent: Tuesday, November 22, 2016 2:55 PM > To: Hemant Agrawal <hemant.agrawal@nxp.com> > Cc: dev@dpdk.org; jerin.jacob@caviumnetworks.com; david.hunt@intel.com > Subject: Re: [PATCH v3 2/2] mempool: pktmbuf pool default fallback for > mempool ops error > > Hi Hemant, > > Back on this topic, please see some comments below. > > On 11/07/2016 01:30 PM, Hemant Agrawal wrote: > > Hi Olivier, > > > >> -----Original Message----- > >> From: Olivier Matz [mailto:olivier.matz@6wind.com] > >> Sent: Friday, October 14, 2016 5:41 PM > >>> On 9/22/2016 6:42 PM, Hemant Agrawal wrote: > >>>> Hi Olivier > >>>> > >>>> On 9/19/2016 7:27 PM, Olivier Matz wrote: > >>>>> Hi Hemant, > >>>>> > >>>>> On 09/16/2016 06:46 PM, Hemant Agrawal wrote: > >>>>>> In the rte_pktmbuf_pool_create, if the default external mempool > >>>>>> is not available, the implementation can default to "ring_mp_mc", > >>>>>> which is an software implementation. > >>>>>> > >>>>>> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com> > >>>>>> --- > >>>>>> Changes in V3: > >>>>>> * adding warning message to say that falling back to default sw > >>>>>> pool > >>>>>> --- > >>>>>> lib/librte_mbuf/rte_mbuf.c | 8 ++++++++ > >>>>>> 1 file changed, 8 insertions(+) > >>>>>> > >>>>>> diff --git a/lib/librte_mbuf/rte_mbuf.c > >>>>>> b/lib/librte_mbuf/rte_mbuf.c index 4846b89..8ab0eb1 100644 > >>>>>> --- a/lib/librte_mbuf/rte_mbuf.c > >>>>>> +++ b/lib/librte_mbuf/rte_mbuf.c > >>>>>> @@ -176,6 +176,14 @@ rte_pktmbuf_pool_create(const char *name, > >>>>>> unsigned n, > >>>>>> > >>>>>> rte_errno = rte_mempool_set_ops_byname(mp, > >>>>>> RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL); > >>>>>> + > >>>>>> + /* on error, try falling back to the software based default > >>>>>> pool */ > >>>>>> + if (rte_errno == -EOPNOTSUPP) { > >>>>>> + RTE_LOG(WARNING, MBUF, "Default HW Mempool not > supported. " > >>>>>> + "falling back to sw mempool \"ring_mp_mc\""); > >>>>>> + rte_errno = rte_mempool_set_ops_byname(mp, "ring_mp_mc", > >>>>>> NULL); > >>>>>> + } > >>>>>> + > >>>>>> if (rte_errno != 0) { > >>>>>> RTE_LOG(ERR, MBUF, "error setting mempool handler\n"); > >>>>>> return NULL; > >>>>>> > >>>>> > >>>>> Without adding a new method ".supported()", the first call to > >>>>> rte_mempool_populate() could return the same error ENOTSUP. In > >>>>> this case, it is still possible to fallback. > >>>>> > >>>> It will be bit late. > >>>> > >>>> On failure, than we have to set the default ops and do a goto > >>>> before rte_pktmbuf_pool_init(mp, &mbp_priv); > >> > >> I still think we can do the job without adding the .supported() method. > >> The following code is just an (untested) example: > >> > >> struct rte_mempool * > >> rte_pktmbuf_pool_create(const char *name, unsigned n, > >> unsigned cache_size, uint16_t priv_size, uint16_t data_room_size, > >> int socket_id) > >> { > >> struct rte_mempool *mp; > >> struct rte_pktmbuf_pool_private mbp_priv; > >> unsigned elt_size; > >> int ret; > >> const char *ops[] = { > >> RTE_MBUF_DEFAULT_MEMPOOL_OPS, "ring_mp_mc", NULL, > >> }; > >> const char **op; > >> > >> if (RTE_ALIGN(priv_size, RTE_MBUF_PRIV_ALIGN) != priv_size) { > >> RTE_LOG(ERR, MBUF, "mbuf priv_size=%u is not aligned\n", > >> priv_size); > >> rte_errno = EINVAL; > >> return NULL; > >> } > >> elt_size = sizeof(struct rte_mbuf) + (unsigned)priv_size + > >> (unsigned)data_room_size; > >> mbp_priv.mbuf_data_room_size = data_room_size; > >> mbp_priv.mbuf_priv_size = priv_size; > >> > >> for (op = &ops[0]; *op != NULL; op++) { > >> mp = rte_mempool_create_empty(name, n, elt_size, cache_size, > >> sizeof(struct rte_pktmbuf_pool_private), socket_id, 0); > >> if (mp == NULL) > >> return NULL; > >> > >> ret = rte_mempool_set_ops_byname(mp, *op, NULL); > >> if (ret != 0) { > >> RTE_LOG(ERR, MBUF, "error setting mempool handler\n"); > >> rte_mempool_free(mp); > >> if (ret == -ENOTSUP) > >> continue; > >> rte_errno = -ret; > >> return NULL; > >> } > >> rte_pktmbuf_pool_init(mp, &mbp_priv); > >> > >> ret = rte_mempool_populate_default(mp); > >> if (ret < 0) { > >> rte_mempool_free(mp); > >> if (ret == -ENOTSUP) > >> continue; > >> rte_errno = -ret; > >> return NULL; > >> } > >> } > >> > >> rte_mempool_obj_iter(mp, rte_pktmbuf_init, NULL); > >> > >> return mp; > >> } > >> > >> > > [Hemant] This look fine to me. Please submit a patch for the same. > > > >>>>> I've just submitted an RFC, which I think is quite linked: > >>>>> http://dpdk.org/ml/archives/dev/2016-September/046974.html > >>>>> Assuming a new parameter "mempool_ops" is added to > >>>>> rte_pktmbuf_pool_create(), would it make sense to fallback to > >>>>> "ring_mp_mc"? What about just returning ENOTSUP? The application > >>>>> could do the job and decide which sw fallback to use. > >>>> > >>>> We ran into this issue when trying to run the standard DPDK > >>>> examples > >>>> (l3fwd) in VM. Do you think, is it practical to add fallback > >>>> handling in each of the DPDK examples? > >> > >> OK. What is still unclear for me, is how the software is aware of the > >> different hardware-assisted handlers. Moreover, we could imagine more > >> software handlers, which could be used depending on the use case. > >> > >> I think this choice has to be made by the user or the application: > >> > >> - the application may want to use a specific (sw or hw) handler: in > >> this case, it want to be notified if it fails, instead of having > >> a quiet fallback to ring_mp_mc > >> - if several handlers are available, the application may want to > >> try them in a specific order > >> - maybe some handlers will have some limitations with some > >> configurations or driver? The application could decide to use > >> a different handler according the configuration. > >> > >> So that's why I think this is an application decision. > >> > > [Hemant] We should simplify it: if the application has supplied the handler, it > is application's responsibility to take care of failure. Only if the application want > to use the default handler, the implementation can fallback. The fallback > handler can again be configurable. > > Honestly, I'm not very convinced that having a quiet fallback is the proper > solution: the application won't be notified that the fallback occured. > > I understand your patch solves your use-case, but my fear is that we just > integrate this minimal patch and never do the harder work of solving all the use- > cases. I think we need to give the tools to the applications to control what > occurs because we also need to solve these issues: > - you have a hardware handler, but you want to use the software > handler > - you have several software handlers, and you (as an administrator) or > the application knows which one is the best to use in your case. > > An alternative (which I don't like either) to solve your issue without modifying > the mbuf code is to have your own handler fallbacking to ring_mp_mc. > [Hemant] are you suggesting that we also configure a fallback handler in addition to default? I agree that we need to provide full flexibility to the applications, who are willing to implement the fallback mechanism. > > >>>> Typically when someone is writing a application on host, he need > >>>> not worry non-availability of the hw offloaded mempool. He may also > >>>> want to run the same binary in virtual machine. In VM, it is not > >>>> guaranteed that hw offloaded mempools will be available. > >> > >> Running the same binary is of course a need. But if your VM does not > >> provide the same virtualized hardware than the host, I think the > >> command line option makes sense. > >> > >> AFAIU, on the host, you can use a hw mempool handler or a sw one, and > >> on the guest, only a sw one. So you need an option to select the > >> behavior you want on the host, without recompiling. > >> > >> I understand that modifying all the applications is not a good option > >> either. I'm thinking a a EAL parameter that would allow to configure > >> a library (mbuf in this case). Something like kernel boot options. > >> Example: testpmd -l 2,4 --opt mbuf.handler="ring_mp_mc" -- [app args] > >> > >> I don't know if this is feasible, this has to be discussed first, but > >> what do you think on the principle? The value could also be an > >> ordered list if we want a fallback, and this option could be > >> overriden by the application before creating the mbuf pool. There was > >> some discussions about a kind of dpdk global configuration some time ago. > >> > > [Hemant] I agree that command line option provide a better control in this > case. > > On the flipside, We need to be careful that we do not end up having too many > command line options. > > Yes, we should avoid having too many command line arguments. > I think we should go in the direction of having a sort of key/value database in > EAL. It could be set by: > - a generic command line argument > - a config file (maybe later) > - the application through an API > > Then, it would be used by: > - dpdk libraries > - the application (maybe) > > This has been discussed some times, the latest was probably: > http://dpdk.org/ml/archives/dev/2016-June/040079.html > > I think it would be a good tool for dpdk configurability, and it would help to > remove some compile-time options and maybe some eal options. > Unfortunately, I don't have the time to work on this at the moment. > > Regards, > Olivier
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 4846b89..8ab0eb1 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -176,6 +176,14 @@ rte_pktmbuf_pool_create(const char *name, unsigned n, rte_errno = rte_mempool_set_ops_byname(mp, RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL); + + /* on error, try falling back to the software based default pool */ + if (rte_errno == -EOPNOTSUPP) { + RTE_LOG(WARNING, MBUF, "Default HW Mempool not supported. " + "falling back to sw mempool \"ring_mp_mc\""); + rte_errno = rte_mempool_set_ops_byname(mp, "ring_mp_mc", NULL); + } + if (rte_errno != 0) { RTE_LOG(ERR, MBUF, "error setting mempool handler\n"); return NULL;