Message ID | 1462190377-26865-1-git-send-email-jerin.jacob@caviumnetworks.com (mailing list archive) |
---|---|
State | Superseded, 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 DB6EE4CE6; Mon, 2 May 2016 14:00:15 +0200 (CEST) Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0067.outbound.protection.outlook.com [157.56.111.67]) by dpdk.org (Postfix) with ESMTP id 8766537A8 for <dev@dpdk.org>; Mon, 2 May 2016 14:00:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-caviumnetworks-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=DTQUeMDGYu9Trp/fuQ5vWSjSKKf7TNGzfrToJ6+ktcw=; b=jfrKeXddJ3ibq8MdxmaJT4ex82NVQlhSFObrQrWWG+gdAQmBPTnmPlsQ/6itjRd6Yd3xooH/boNJefs6ajU8yTM+7JSmeExbpvUDfyjfaSD0IMOIRqfVBtN7hvd28qo9ftw3JRx93CzQB4v7NULFDLoG93tAX6PILaZxUCl4y2k= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=caviumnetworks.com; Received: from localhost.caveonetworks.com (122.166.152.97) by BY1PR0701MB1723.namprd07.prod.outlook.com (10.162.111.142) with Microsoft SMTP Server (TLS) id 15.1.477.8; Mon, 2 May 2016 12:00:11 +0000 From: Jerin Jacob <jerin.jacob@caviumnetworks.com> To: <dev@dpdk.org> CC: <pablo.de.lara.guarch@intel.com>, Jerin Jacob <jerin.jacob@caviumnetworks.com> Date: Mon, 2 May 2016 17:29:37 +0530 Message-ID: <1462190377-26865-1-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.1.0 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [122.166.152.97] X-ClientProxiedBy: PN1PR01CA0042.INDPRD01.PROD.OUTLOOK.COM (10.164.136.142) To BY1PR0701MB1723.namprd07.prod.outlook.com (10.162.111.142) X-MS-Office365-Filtering-Correlation-Id: d74b3726-47d7-4b54-14ec-08d37281513d X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 2:iXrViA6WiGsf6r0ZSEoi18oTUWGyE0VPD4pw55YE+DlUIBcCdhdH2einAi1JDdQ1mZmrGf8hyoysDA4KP2k6eTXwV5ltoTbxn9CJZxOb+MOALHPTBtIR7kFPJ1TGYkrSj8rhjgQIQG5M5VoOq3uWI6UN51KNk1FCWL/2Cv38EU2XNsNezcIT/5foF1iTNfCi; 3:4CJg3FzXaahNCGmu40qfgJInMiLqDoGK0oNUeP/VDJ+zXr6dZNuNipVlcliPHgNYG082C/khGO6VFwrycbfoLfJj0kdVf/Ey5SGarn0nw5jR1lBbV+E4mIlKMpKbka6d; 25:GmQONbHhWB/k8zLUDjZaboytAMduqLH4vytGa3wQpSNELS11YxjHZTxrKfvKW84t/7t7G/9b1aXV6widKN/dJuaN5rEPTarsFMFj3nqFTwClJ+5+BJzo5cpTwWaeIypiiI6EE+WdY5bhrspgmPd+bWYbX/caVR3dYYNYh1iNNJ2SFFLh/Ie9n31dCI4UpXhCAJgKryn1ZKD6RCgruL4FqljGvZZ0rFVwf8UO0JUwtx6cCgZuoNhjd10/ZwEWljNI96EJksJa0901JzNOx9VbuHp07v5ELeKnHmBvOmOlbRzrcShEHqdRfxkgsJKxL+ehY0OrLvSrUb97FxfUBNa6oA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1723; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 20:lnhtG/9kObtV7ASnLX9bP52gkrSpFdnFYnpHG2zwmsEpHsCD1AOFq5d/B/MGQmtuFHF4tAao+fPVDQ6LeLqyb//sho//ecqEepboP5mko65GIEjMlzCYjxZGeUpiYIHPZf++rT5ylYUohz5LZ1SPlYoHkg/vKpBSpHqvwot/Tx/CxhhwF41fXuQeVw5Wqj6QWMQT9S6hLJpWxk787P11b34nShE9Lhf5T6IYya7iejiCGBTKrjaP4BQXvJ3YmvuWcM1VyZXpHzklhI0znY1mVQQwBcZTyjFflhZXEIu6zJbbF06Fz6SX5B1YVzGPInb5FOGCYLTxBBp28f1EfsvIIFJFZJDtj3QLDLP3Tjr6ElpmtJiype6AGZS9ojThvYcWTsEn+CuKTK/B1Xeoo3armzMQbUXDNnPluqLUnQAlKi7Dcvbkgd7b64v6JMrvQdBIvCaqQBO4WRwPH2LyHTjshlT+RM41YcsN+/uP59aHiIS0z9ViymmJlwtg2iurF/XVf08OaVcyjdMs/YDg8hq0JueecFxmbwLkrGUIZCV7AtdnXmJW66CMa/iH8kbnq6WdiDk44iDBLiu5JsdBKvZHJu9mdMeP+2q6+PefNSv3AXA= X-Microsoft-Antispam-PRVS: <BY1PR0701MB1723495332414BFADA6E3CBE8C790@BY1PR0701MB1723.namprd07.prod.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(9101521093)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:BY1PR0701MB1723; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0701MB1723; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 4:EgBqQeAY1k4CV51PFjpKHmOHaatPRdYVEIJ5Rk7DNLfK3CUThsejaFIkuG7ggbx17/Ous62IhL72UTHUbM60AIHwMBSEcyEKsF941JuZh6vAc6NTPJMU5LpJ/Wp3aWxx+smkXtPuP+CluW7UczDI7kaBcIu8qR+E7K1+1JJKMMzGqJlvwmwTFoOnFd7XikAUbhUGlpfhWNEyB8mkU9kkLzYtS+fcrxDtNiXVC4dRojRnxbCc57cj/X1iaK/tTcDinZxA7OYCxKqfG/fMWWXXfibHPeDWKQgIDdjV2HbJEEkVYaLVgtgf+uBTRGfsiI79wdYGLmErp/otJ5X/NE8s22wz3ClzjjRv9hDgQ/Lh+mkjoCm8VOYOMuwX499fF782zO2/kq5+QuQUGmbOnHPJqg== X-Forefront-PRVS: 0930AAFAD9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(107886002)(19580405001)(66066001)(586003)(5008740100001)(48376002)(6116002)(3846002)(47776003)(86362001)(19580395003)(77096005)(110136002)(5003940100001)(4001430100002)(50466002)(1096002)(189998001)(81166005)(2351001)(229853001)(50226002)(42186005)(76506005)(53416004)(36756003)(2906002)(33646002)(92566002)(5004730100002)(50986999)(4326007); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0701MB1723; H:localhost.caveonetworks.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR0701MB1723; 23:93C34ni19GjVmMORI8PCi32rtB9X0WPV9475PDi?= =?us-ascii?Q?eGSx24nLoR5ebZ+ioNuaU/8EtmLWeoSCP0Ta0uO33xEcj0/2NUwxk2oCzEp7?= =?us-ascii?Q?y2FdWD7f6A3HTtAPxHsV3CICeypnZd+BsfETzAnkpb42RMQovFECa/M24svZ?= =?us-ascii?Q?Q5kxmO6pTZdpD2d0E7wQY0+t4S0tOYAinQyKNbVckZnhJSQAm9eWzjl3oDvt?= =?us-ascii?Q?ZDwF57AWxSqZv80p28cwOJdJMnu+ug8D4BfIL5x8kYrgAYfyUrsSnZ2/VKgn?= =?us-ascii?Q?tBaIWY9VmfaGJ0GRFByu6MMgZcdQCeBO+dJ6IG9MUzSWFo4Y9BE/ILLXmOkr?= =?us-ascii?Q?1sO9h9f/fNsT85UtaAAcR5kiY9tZ3EHp0N+i6rX5teY70VkfAWiHCwEc/R3W?= =?us-ascii?Q?zDLv0dOrdR0IchvNV38PHpzD6uKS7OH8F0A0qT+Yp0vDbo0HHySX3NMn6Eqk?= =?us-ascii?Q?Atgf7qb9ZKFTdg/1yLwn4DMM8MGOtlF3yAVHY4orHcArO5+eGASf+xKXsRgp?= =?us-ascii?Q?JdEkL61Bco0UgmFAYMfBU0/f4jJMprXvJhCBOe+z5zqZDT/kddSmydtlVaLh?= =?us-ascii?Q?CtMegTK17JfJukIgm+MSg7toDA9Zhfxxwf8cDVYkmSfYga2bbF+PrzNQ/JvY?= =?us-ascii?Q?isdWLLiL1SQZAcw5EjqX3NIrNtYSJZUX+BTtdCywp9IL0dtWIKZxxl7QRzDg?= =?us-ascii?Q?+mVq4lUVz0nAX9FSHeoCUls9BKBE2/nmiPHLqaiAxBGhEvmoFZWW5nL3J7+G?= =?us-ascii?Q?mezXYzr1SbiJBxwUtIjqHiormGZHlPmEsTr/sxR4YSu2ZhiZjk71tejq3Psq?= =?us-ascii?Q?ZlAzdO9yS9tW6tx3ObuccafuSMHfhG9CeoYhncTw55WTvhRPL1QATsfJWmEc?= =?us-ascii?Q?ocy/KE8VbYJfGPw6MuRJzCvwJb2HyABRk63Ah57oebDEgeasaPNwk8vSK8y4?= =?us-ascii?Q?C9NPr7hi4HWsMjenFUQSo5Q17SVNKyk5wI36+sqtrOA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 5:TrPHYkh82IzuBoNfw3b9y4ztQFNcJY1QB1v02SVxd0jhLC6MtrNiuYqXbNdkJTlHJh8AFSCkqsaUe7/lNzfF5PM9z/t85pvLzvRUFetV9J2aM0xfhR+QLetu8zSdgbraog2kED/CtEWU+/JhqYAadQ==; 24:bRiAlSSj3CmH0ObCX4aKnj65G4YeIRRjs4J0lMQzhCp2nwykMsbd3SQR6LpzcI83o7NpmvwFWb/2TOr3119uqUQULLwY5ex9AKIaxYA3/N8=; 7:WNuh5LXtd9E9/ZOXhECPh0WjWVshDKtSJU1VGN0F14CxldrIFHni5Y9XhpLlB15/iL5Fu6CPra5LWkiVaasv3AQf+4DQ/w9Ym6dQ98qYTSh1tKeB+1BhI+v0TmRmcCAImf2TK5B7DermrtC4hi5/0cUhnQvM4rjsPnH3WsTDct3cVa4GLswJlPo+Tz91RnLa SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 May 2016 12:00:11.2426 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1723 Subject: [dpdk-dev] [PATCH] app/testpmd: add packet data prefetch in macswap loop 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
Jerin Jacob
May 2, 2016, 11:59 a.m. UTC
prefetch the next packet data address in advance in macswap loop
for performance improvement.
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
app/test-pmd/macswap.c | 3 +++
1 file changed, 3 insertions(+)
Comments
Hi Jerin, > -----Original Message----- > From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com] > Sent: Monday, May 02, 2016 1:00 PM > To: dev@dpdk.org > Cc: De Lara Guarch, Pablo; Jerin Jacob > Subject: [dpdk-dev] [PATCH] app/testpmd: add packet data prefetch in > macswap loop > > prefetch the next packet data address in advance in macswap loop > for performance improvement. > > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> > --- > app/test-pmd/macswap.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c > index 154889d..c10f4b5 100644 > --- a/app/test-pmd/macswap.c > +++ b/app/test-pmd/macswap.c > @@ -113,6 +113,9 @@ pkt_burst_mac_swap(struct fwd_stream *fs) > if (txp->tx_ol_flags & TESTPMD_TX_OFFLOAD_INSERT_QINQ) > ol_flags |= PKT_TX_QINQ_PKT; > for (i = 0; i < nb_rx; i++) { > + if (likely(i < nb_rx - 1)) > + rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[i + 1], > + void *)); > mb = pkts_burst[i]; > eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *); > > -- > 2.1.0 This looks good. Could you also add it in the other forwarding modes (the ones that make changes in the packets)? Thanks, Pablo
On Mon, May 02, 2016 at 05:29:37PM +0530, Jerin Jacob wrote: > prefetch the next packet data address in advance in macswap loop > for performance improvement. > > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> > --- > app/test-pmd/macswap.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c > index 154889d..c10f4b5 100644 > --- a/app/test-pmd/macswap.c > +++ b/app/test-pmd/macswap.c > @@ -113,6 +113,9 @@ pkt_burst_mac_swap(struct fwd_stream *fs) > if (txp->tx_ol_flags & TESTPMD_TX_OFFLOAD_INSERT_QINQ) > ol_flags |= PKT_TX_QINQ_PKT; > for (i = 0; i < nb_rx; i++) { > + if (likely(i < nb_rx - 1)) > + rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[i + 1], > + void *)); At least on IA platforms, there is no issue with prefetching beyond the end of the array, since it's only a hint to the cpu. If this is true for other platforms, then I suggest we just drop the conditional and just always prefetch. /Bruce > mb = pkts_burst[i]; > eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *); > > -- > 2.1.0 >
> -----Original Message----- > From: Richardson, Bruce > Sent: Tuesday, May 03, 2016 10:45 AM > To: Jerin Jacob > Cc: dev@dpdk.org; De Lara Guarch, Pablo > Subject: Re: [dpdk-dev] [PATCH] app/testpmd: add packet data prefetch in > macswap loop > > On Mon, May 02, 2016 at 05:29:37PM +0530, Jerin Jacob wrote: > > prefetch the next packet data address in advance in macswap loop > > for performance improvement. > > > > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> > > --- > > app/test-pmd/macswap.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c > > index 154889d..c10f4b5 100644 > > --- a/app/test-pmd/macswap.c > > +++ b/app/test-pmd/macswap.c > > @@ -113,6 +113,9 @@ pkt_burst_mac_swap(struct fwd_stream *fs) > > if (txp->tx_ol_flags & TESTPMD_TX_OFFLOAD_INSERT_QINQ) > > ol_flags |= PKT_TX_QINQ_PKT; > > for (i = 0; i < nb_rx; i++) { > > + if (likely(i < nb_rx - 1)) > > + rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[i + 1], > > + void *)); > > At least on IA platforms, there is no issue with prefetching beyond the end of > the array, since it's only a hint to the cpu. If this is true for other platforms, > then I suggest we just drop the conditional and just always prefetch. That's what I thought when I saw this patch, but the problem is that the prefetch is not for pkts_burst, but for rte_pktmbuf_mtod(pkts_burst...), so there must be a limit in nb_rx - 2, or there will be a seg fault. Pablo > > /Bruce > > > mb = pkts_burst[i]; > > eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *); > > > > -- > > 2.1.0 > >
On 05/03/2016 11:45 AM, Bruce Richardson wrote: > On Mon, May 02, 2016 at 05:29:37PM +0530, Jerin Jacob wrote: >> prefetch the next packet data address in advance in macswap loop >> for performance improvement. >> >> ... >> for (i = 0; i < nb_rx; i++) { >> + if (likely(i < nb_rx - 1)) >> + rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[i + 1], >> + void *)); > > At least on IA platforms, there is no issue with prefetching beyond the end of > the array, since it's only a hint to the cpu. If this is true for other platforms, > then I suggest we just drop the conditional and just always prefetch. This is an interesting point. Bruce, are you suggesting that prefetching at an invalid [virtual] address won't trigger a CPU exception? Ivan > > /Bruce > >> mb = pkts_burst[i]; >> eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
On Tue, May 03, 2016 at 10:48:34AM +0100, De Lara Guarch, Pablo wrote: > > > > -----Original Message----- > > From: Richardson, Bruce > > Sent: Tuesday, May 03, 2016 10:45 AM > > To: Jerin Jacob > > Cc: dev@dpdk.org; De Lara Guarch, Pablo > > Subject: Re: [dpdk-dev] [PATCH] app/testpmd: add packet data prefetch in > > macswap loop > > > > On Mon, May 02, 2016 at 05:29:37PM +0530, Jerin Jacob wrote: > > > prefetch the next packet data address in advance in macswap loop > > > for performance improvement. > > > > > > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> > > > --- > > > app/test-pmd/macswap.c | 3 +++ > > > 1 file changed, 3 insertions(+) > > > > > > diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c > > > index 154889d..c10f4b5 100644 > > > --- a/app/test-pmd/macswap.c > > > +++ b/app/test-pmd/macswap.c > > > @@ -113,6 +113,9 @@ pkt_burst_mac_swap(struct fwd_stream *fs) > > > if (txp->tx_ol_flags & TESTPMD_TX_OFFLOAD_INSERT_QINQ) > > > ol_flags |= PKT_TX_QINQ_PKT; > > > for (i = 0; i < nb_rx; i++) { > > > + if (likely(i < nb_rx - 1)) > > > + rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[i + 1], > > > + void *)); > > > > At least on IA platforms, there is no issue with prefetching beyond the end of > > the array, since it's only a hint to the cpu. If this is true for other platforms, > > then I suggest we just drop the conditional and just always prefetch. > > That's what I thought when I saw this patch, but the problem is that the prefetch is not for pkts_burst, > but for rte_pktmbuf_mtod(pkts_burst...), so there must be a limit in nb_rx - 2, or there will be a seg fault. > > Pablo Good point, Pablo, I missed that subtlety here. /Bruce > > > > /Bruce > > > > > mb = pkts_burst[i]; > > > eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *); > > > > > > -- > > > 2.1.0 > > >
On Tue, May 03, 2016 at 11:50:31AM +0200, Ivan Boule wrote: > On 05/03/2016 11:45 AM, Bruce Richardson wrote: > >On Mon, May 02, 2016 at 05:29:37PM +0530, Jerin Jacob wrote: > >>prefetch the next packet data address in advance in macswap loop > >>for performance improvement. > >> > >>... > >> for (i = 0; i < nb_rx; i++) { > >>+ if (likely(i < nb_rx - 1)) > >>+ rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[i + 1], > >>+ void *)); > > > >At least on IA platforms, there is no issue with prefetching beyond the end of > >the array, since it's only a hint to the cpu. If this is true for other platforms, > >then I suggest we just drop the conditional and just always prefetch. > > This is an interesting point. > Bruce, are you suggesting that prefetching at an invalid [virtual] address > won't trigger a CPU exception? > Yep. For example, adding "rte_prefetch0(NULL)" at the start of main in testpmd causes no ill effects when running the app. /Bruce
On Mon, May 02, 2016 at 05:48:02PM +0000, De Lara Guarch, Pablo wrote: > Hi Jerin, > > > -----Original Message----- > > From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com] > > Sent: Monday, May 02, 2016 1:00 PM > > To: dev@dpdk.org > > Cc: De Lara Guarch, Pablo; Jerin Jacob > > Subject: [dpdk-dev] [PATCH] app/testpmd: add packet data prefetch in > > macswap loop > > > > prefetch the next packet data address in advance in macswap loop > > for performance improvement. > > > > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> > > --- > > app/test-pmd/macswap.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c > > index 154889d..c10f4b5 100644 > > --- a/app/test-pmd/macswap.c > > +++ b/app/test-pmd/macswap.c > > @@ -113,6 +113,9 @@ pkt_burst_mac_swap(struct fwd_stream *fs) > > if (txp->tx_ol_flags & TESTPMD_TX_OFFLOAD_INSERT_QINQ) > > ol_flags |= PKT_TX_QINQ_PKT; > > for (i = 0; i < nb_rx; i++) { > > + if (likely(i < nb_rx - 1)) > > + rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[i + 1], > > + void *)); > > mb = pkts_burst[i]; > > eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *); > > > > -- > > 2.1.0 > > This looks good. Could you also add it in the other forwarding modes (the ones that make changes in the packets)? OK Pablo. I will add the similar logic in the following forwarding modes in testpmd. macswap macfwd macfwd-retry csumonly icmpecho /Jerin > > Thanks, > Pablo
> -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bruce Richardson > Sent: Tuesday, May 03, 2016 11:20 AM > To: Ivan Boule > Cc: Jerin Jacob; dev@dpdk.org; De Lara Guarch, Pablo > Subject: Re: [dpdk-dev] [PATCH] app/testpmd: add packet data prefetch in macswap loop > > On Tue, May 03, 2016 at 11:50:31AM +0200, Ivan Boule wrote: > > On 05/03/2016 11:45 AM, Bruce Richardson wrote: > > >On Mon, May 02, 2016 at 05:29:37PM +0530, Jerin Jacob wrote: > > >>prefetch the next packet data address in advance in macswap loop > > >>for performance improvement. > > >> > > >>... > > >> for (i = 0; i < nb_rx; i++) { > > >>+ if (likely(i < nb_rx - 1)) > > >>+ rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[i + 1], > > >>+ void *)); > > > > > >At least on IA platforms, there is no issue with prefetching beyond the end of > > >the array, since it's only a hint to the cpu. If this is true for other platforms, > > >then I suggest we just drop the conditional and just always prefetch. > > > > This is an interesting point. > > Bruce, are you suggesting that prefetching at an invalid [virtual] address > > won't trigger a CPU exception? > > > > Yep. For example, adding "rte_prefetch0(NULL)" at the start of main in testpmd > causes no ill effects when running the app. > One correction - while on IA prefetch(inval_addr) wouldn't cause any functional problems, it still might cause DTLB miss and can be a source of noticeable performance degradation. So it is better to avoid such constructions for performance critical code. Konstantin
diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c index 154889d..c10f4b5 100644 --- a/app/test-pmd/macswap.c +++ b/app/test-pmd/macswap.c @@ -113,6 +113,9 @@ pkt_burst_mac_swap(struct fwd_stream *fs) if (txp->tx_ol_flags & TESTPMD_TX_OFFLOAD_INSERT_QINQ) ol_flags |= PKT_TX_QINQ_PKT; for (i = 0; i < nb_rx; i++) { + if (likely(i < nb_rx - 1)) + rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[i + 1], + void *)); mb = pkts_burst[i]; eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);