[dpdk-dev,1/2] mbuf: fix performance/cache resource issue with 128-byte cache line targets
Message ID | 1449417564-29600-2-git-send-email-jerin.jacob@caviumnetworks.com (mailing list archive) |
---|---|
State | Superseded, archived |
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 007629253; Sun, 6 Dec 2015 17:00:17 +0100 (CET) Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0077.outbound.protection.outlook.com [207.46.100.77]) by dpdk.org (Postfix) with ESMTP id 26D399252 for <dev@dpdk.org>; Sun, 6 Dec 2015 17:00:15 +0100 (CET) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.Jacob@caviumnetworks.com; Received: from localhost.localdomain.localdomain (122.167.201.216) by BLUPR0701MB1714.namprd07.prod.outlook.com (10.163.85.140) with Microsoft SMTP Server (TLS) id 15.1.331.20; Sun, 6 Dec 2015 16:00:10 +0000 From: Jerin Jacob <jerin.jacob@caviumnetworks.com> To: <dev@dpdk.org> Date: Sun, 6 Dec 2015 21:29:23 +0530 Message-ID: <1449417564-29600-2-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1449417564-29600-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1449417564-29600-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [122.167.201.216] X-ClientProxiedBy: PN1PR01CA0038.INDPRD01.PROD.OUTLOOK.COM (25.164.136.138) To BLUPR0701MB1714.namprd07.prod.outlook.com (25.163.85.140) X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1714; 2:OxAywCfK+eeFGhBe0KWIYM3UNzpQbtZbwgEhC4MOP2jNdHxieh+j8ERmVKOhxQ7JZzArG+szzKhSNq2IDv8uQ2Q2sDN7MS3FKu1+PrdEEaVsFzc7r/nXmxJBs04JA/9odueiDfEtaqTTq0D9SABdpA==; 3:gyKFCWulqCGVqYczuoUFkv1TmRY4x3zYauETbAxpMWTMeIueMy9Vb2U23UC618eytOSGhu9JBdLEIuob1KZAhKzNE4Gkt5k+LR7r6EYsJ3RmwGb+wUh9oE1lVDg4sxw2; 25:UN68m7SQtNu77p28hvw608wklwys6XmRnQ4k03FQb35uGxD6OSr7kMGrKLdK8/Io92bGQPwYAPya8Ky1MTyCk/ZFOKA2WoyGyNP/L5VqWeiy7Ax+MvfFzahuZPcmi0/VjZMG4P0G9hRNwmyQM/wU7oNzh/svzo79/T1jqAa11K/o3biPdWUbhCuUZ1lD+MggppWLpuEsWbrHdIAeSymvsPvUqF1qx18MoqYKgGpH5Qr8js/2FRcuyjTy8WCu2wHqYunBwUScRW6/fuoi2A7FQw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0701MB1714; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1714; 20:VxVOV3nNnvaqVjVYdbyj+zTTZmcRN2eI/VhIk5f7sYMNL9Tn2zIPAy0XySH2x3w7ylmQeMe+7iaaJXYQryy0cGQd0AIt8AhpQqyBLvnzDzFPggVHLMUEL5XNK3RTSFF99RgVmifQaNbCMQ7lVO3sIMajI+PrVW6QO3ltF94PxFYAdYeyeVb7HMHDCE+NyDsY5mv6eJEEBBSWhcHsieLEfwyUGN9i5dgCNWC8FHAzAiSknk5LPa5kUmVj4CwvnqXINRLwvKfYtbzsPRfmiAbL1V9gwK6lro+1c997R47juG/9lUj/in9oOyn/nRyLcTmh7DUU1Qi4MErvIo4it1oTKgwilrUwTUv+vTEeMb/zePWFRzMRjf8DlSCLNy9mvCSe+HuF2HF+6gNkwp1FnGFaWhLuxpc0L1HDP/CmlMsKvQKU3QVLVSbnYmro5LD82IR1z/RA9WOh7y9BrauVd/qGIKr8YwR01frQV+Gvf6TIfb67WNXrn+3lkxFPDmd1lVudZqtGBt8wlXG2H7VpaYv1Ad6BGzjwEJrVS89NO61Z4TG0Dj6/sXnejCFOTYoSxQMYTpMsUAY0ZGprdM+NLfEe4lAjGm2GVdQ8rtIBoqvNhVU= X-Microsoft-Antispam-PRVS: <BLUPR0701MB1714FAEC2519E26FD5524F188C0A0@BLUPR0701MB1714.namprd07.prod.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(3002001)(10201501046); SRVR:BLUPR0701MB1714; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB1714; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1714; 4:/Lokj8w0uqN5D+YOl1UHaIEZxyzhxrJxgfE8V9a8kQhIuRuVml8pdADHQWvHy3uPINJU0GDXACPVPAWHBgP92ZuNDO+ZtWiw8xByYSZ/POPAz2vAkEU1KME5e0SM5oGP7blE9rx0jv3QLp3wDPdEtSyAzdZ24dkbIfrnfNejRON1x3PJvkoa7WrHvp6gFJNZcSMMkDUhhG9FZdY/+FUy3fSnO9jCpUlftC1mxytJFBL/tzsRUtCzoJS/l1EeaqQr8IykAFjSw7J4DSfnArvQ04t3k5sg7dbOPHPNhsfk8ZZr69johRqS2+GoZffrhVYkY+Z01WFGC1SEUS7yx67YSj1DPtqt4LWhiCSkDnB2DAuAuLfXr3OAAl/FqFqDgNbJm2vXTDGwy/LoZzfbgRRkS2oLNyWSlM9ZM6KFHKLupYznIIDhFOvvZpFMdXCkOCba X-Forefront-PRVS: 0782EC617F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(199003)(189002)(50466002)(2351001)(40100003)(92566002)(86362001)(5004730100002)(586003)(1096002)(4001430100002)(6116002)(3846002)(110136002)(5008740100001)(105586002)(97736004)(107886002)(5001960100002)(87976001)(81156007)(101416001)(106356001)(33646002)(189998001)(50226001)(76176999)(66066001)(77096005)(122386002)(2950100001)(5003940100001)(229853001)(50986999)(48376002)(42186005)(47776003)(19580405001)(19580395003)(36756003)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB1714; H:localhost.localdomain.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0701MB1714; 23:0UA+P9cJbc+inYUUFoRnwXQBqGUp6yM/255ZxRv?= =?us-ascii?Q?Z+cFzm88ZW+zfZqLxlvvIRQFA16bQWx+rLEjLTh0xDzGs+im0TQX1cAYr3hd?= =?us-ascii?Q?o/f+Fv2/jGJfUTUmg8EU4hdFwIrqBHX0bZCeeK8gcEf5J5sxJBGxUQApgRb1?= =?us-ascii?Q?xw9pYBpWSfARz5dTLCJ8SDB2bKXKlBPZtomCNNZ0izy4e8rwkXLk8cH0Spfd?= =?us-ascii?Q?CZEHk8d5ukNYCT/gKs4UAUstJQL7DSthVM1dUKoHFc62n0j16ga82pGlS2oO?= =?us-ascii?Q?8Vu5pOnrJbLcTIJEm6+vjceHW7peg2C6jRl8bTvo2ujPOroJDpKbJH0xar+f?= =?us-ascii?Q?9boa84Cc4wiJgozh8bVqxm0YxEHK6tQHmAn09CQdTnQo8HbojldvI46hCkMj?= =?us-ascii?Q?c17jQzOyCb+EBQYHGiunOn1Cnv8kKxPw5DoOII1Qdak078phq8iSuZmAdvso?= =?us-ascii?Q?gQzPsP4RiKqCU2eua1wTeJh6aUctuoEyA9nZgUz5589CG/A57C6YGh0GNnkb?= =?us-ascii?Q?W+Uj+c40jchGcdPCBWCfjp/Aitvhl8OAdJgHdoUI/A9KvWZrV5UhppXBQg1E?= =?us-ascii?Q?tJ44eHzhAjOsXVfIBLzDo4A1R6o80eIo/VSlQo0uvxrpCNej/7VSiWyZ/9bb?= =?us-ascii?Q?t5l4TYubLUFKumaoFlhwor7YipdtpRDt+k+eansASi9DAiAyOnYhinV5HFsQ?= =?us-ascii?Q?Hzuj3Y82QxmOAilLtj8AOB6tpXyWqaa7fusj91sL/PIlipIU+gn27bpFNWNx?= =?us-ascii?Q?3d1Yq+zbTaQRxv/FkuCcHLYD2+qLAHKBdvO6MQQ+rWX4O31OBbryLzk8zlEe?= =?us-ascii?Q?SVXRytXGrQ/RFgHrkoIL/9t8XVI1A/pcpSOGmEtAlz9AGgHVqtZl34eP0hNO?= =?us-ascii?Q?zuj/aBHcgWIBYHzxvU4jJxaQnNYLJPwLdA4U2TfM6JDkcH2dxnDBflHw7M7F?= =?us-ascii?Q?dACwgwj7Ip1tZnJXIDm0J+hhPm3N+47YWiUTjJoIXSk8eacKt2XNRbncgMqP?= =?us-ascii?Q?WZUI0b7AIVNrYYQGNFhRKrhJwkw1mRves0+eeT0KZgC0loAlvdfLP4H+gqA1?= =?us-ascii?Q?bMv+dOsF5oF+NL7bcxt8TIjGku02rHfR/qGGjoJ1eAZjZS7utTjDKrOsoug3?= =?us-ascii?Q?UEXQyd2wpfd/osu39W3GGANE3eLTFqQBW?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1714; 5:8Ub1Ot38q4ogDsIdtXh0TvoHfjdSZ23gOYPqqOJjoiv9IMoYrPMcxSQraKuv1sGBtVZITmJQJnx/LDhLml/iFH3ZFhD/6Rw6srcvOZs9q1FCENJZJP4Q2mNFvCGPVkWkWDmAjGmOaFULeCrtyHQBJg==; 24:dvOaAtrKohB+ttFrbu27+Qk8CqZ5nXIbQ0C1rgXxlOhgjX+4zx1hTl9nrH77k+lYJWAzR2hkq655b16nV7s15/oKx/FkNASit90i32PwF2A= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2015 16:00:10.3345 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1714 Subject: [dpdk-dev] [PATCH 1/2] mbuf: fix performance/cache resource issue with 128-byte cache line targets 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
Dec. 6, 2015, 3:59 p.m. UTC
No need to split mbuf structure to two cache lines for 128-byte cache line
size targets as it can fit on a single 128-byte cache line.
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
app/test/test_mbuf.c | 4 ++++
lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 4 ++++
lib/librte_mbuf/rte_mbuf.h | 2 ++
3 files changed, 10 insertions(+)
Comments
Hi Jerin, > -----Original Message----- > From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com] > Sent: Sunday, December 06, 2015 3:59 PM > To: dev@dpdk.org > Cc: thomas.monjalon@6wind.com; Richardson, Bruce; olivier.matz@6wind.com; Dumitrescu, Cristian; Ananyev, Konstantin; Jerin > Jacob > Subject: [dpdk-dev] [PATCH 1/2] mbuf: fix performance/cache resource issue with 128-byte cache line targets > > No need to split mbuf structure to two cache lines for 128-byte cache line > size targets as it can fit on a single 128-byte cache line. > > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> > --- > app/test/test_mbuf.c | 4 ++++ > lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 4 ++++ > lib/librte_mbuf/rte_mbuf.h | 2 ++ > 3 files changed, 10 insertions(+) > > diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c > index b32bef6..5e21075 100644 > --- a/app/test/test_mbuf.c > +++ b/app/test/test_mbuf.c > @@ -930,7 +930,11 @@ test_failing_mbuf_sanity_check(void) > static int > test_mbuf(void) > { > +#if RTE_CACHE_LINE_SIZE == 64 > RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_LINE_SIZE * 2); > +#elif RTE_CACHE_LINE_SIZE == 128 > + RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_LINE_SIZE); > +#endif > > /* create pktmbuf pool if it does not exist */ > if (pktmbuf_pool == NULL) { > diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec- > env/rte_kni_common.h > index bd1cc09..e724af7 100644 > --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h > +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h > @@ -121,8 +121,12 @@ struct rte_kni_mbuf { > uint32_t pkt_len; /**< Total pkt len: sum of all segment data_len. */ > uint16_t data_len; /**< Amount of data in segment buffer. */ > > +#if RTE_CACHE_LINE_SIZE == 64 > /* fields on second cache line */ > char pad3[8] __attribute__((__aligned__(RTE_CACHE_LINE_SIZE))); > +#elif RTE_CACHE_LINE_SIZE == 128 > + char pad3[24]; > +#endif > void *pool; > void *next; > }; > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > index f234ac9..0bf55e0 100644 > --- a/lib/librte_mbuf/rte_mbuf.h > +++ b/lib/librte_mbuf/rte_mbuf.h > @@ -813,8 +813,10 @@ struct rte_mbuf { > > uint16_t vlan_tci_outer; /**< Outer VLAN Tag Control Identifier (CPU order) */ > > +#if RTE_CACHE_LINE_SIZE == 64 > /* second cache line - fields only used in slow path or on TX */ > MARKER cacheline1 __rte_cache_aligned; > +#endif I suppose you'll need to keep same space reserved for first 64B even on systems with 128B cache-line. Otherwise we can endup with different mbuf format for systems with 128B cache-line. Another thing - now we have __rte_cache_aligned all over the places, and I don't know is to double sizes of all these structures is a good idea. Again, #if RTE_CACHE_LINE_SIZE == 64 ... all over the places looks a bit clumsy. Wonder can we have __rte_cache_aligned/ RTE_CACHE_LINE_SIZE architecture specific, but introduce RTE_CACHE_MIN_LINE_SIZE(==64)/ __rte_cache_min_aligned and used it for mbuf (and might be other places). Konstantin
On Mon, Dec 07, 2015 at 03:21:33PM +0000, Ananyev, Konstantin wrote: Hi Konstantin, > Hi Jerin, > > > -----Original Message----- > > From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com] > > Sent: Sunday, December 06, 2015 3:59 PM > > To: dev@dpdk.org > > Cc: thomas.monjalon@6wind.com; Richardson, Bruce; olivier.matz@6wind.com; Dumitrescu, Cristian; Ananyev, Konstantin; Jerin > > Jacob > > Subject: [dpdk-dev] [PATCH 1/2] mbuf: fix performance/cache resource issue with 128-byte cache line targets > > > > No need to split mbuf structure to two cache lines for 128-byte cache line > > size targets as it can fit on a single 128-byte cache line. > > > > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> > > --- > > app/test/test_mbuf.c | 4 ++++ > > lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 4 ++++ > > lib/librte_mbuf/rte_mbuf.h | 2 ++ > > 3 files changed, 10 insertions(+) > > > > diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c > > index b32bef6..5e21075 100644 > > --- a/app/test/test_mbuf.c > > +++ b/app/test/test_mbuf.c > > @@ -930,7 +930,11 @@ test_failing_mbuf_sanity_check(void) > > static int > > test_mbuf(void) > > { > > +#if RTE_CACHE_LINE_SIZE == 64 > > RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_LINE_SIZE * 2); > > +#elif RTE_CACHE_LINE_SIZE == 128 > > + RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_LINE_SIZE); > > +#endif > > > > /* create pktmbuf pool if it does not exist */ > > if (pktmbuf_pool == NULL) { > > diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec- > > env/rte_kni_common.h > > index bd1cc09..e724af7 100644 > > --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h > > +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h > > @@ -121,8 +121,12 @@ struct rte_kni_mbuf { > > uint32_t pkt_len; /**< Total pkt len: sum of all segment data_len. */ > > uint16_t data_len; /**< Amount of data in segment buffer. */ > > > > +#if RTE_CACHE_LINE_SIZE == 64 > > /* fields on second cache line */ > > char pad3[8] __attribute__((__aligned__(RTE_CACHE_LINE_SIZE))); > > +#elif RTE_CACHE_LINE_SIZE == 128 > > + char pad3[24]; > > +#endif > > void *pool; > > void *next; > > }; > > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > > index f234ac9..0bf55e0 100644 > > --- a/lib/librte_mbuf/rte_mbuf.h > > +++ b/lib/librte_mbuf/rte_mbuf.h > > @@ -813,8 +813,10 @@ struct rte_mbuf { > > > > uint16_t vlan_tci_outer; /**< Outer VLAN Tag Control Identifier (CPU order) */ > > > > +#if RTE_CACHE_LINE_SIZE == 64 > > /* second cache line - fields only used in slow path or on TX */ > > MARKER cacheline1 __rte_cache_aligned; > > +#endif > > I suppose you'll need to keep same space reserved for first 64B even on systems with 128B cache-line. > Otherwise we can endup with different mbuf format for systems with 128B cache-line. Just to understand, Is there any issue in mbuf format being different across the systems. I think, we are not sending the mbuf over the wire or sharing with different system etc. right? Yes, I do understand the KNI dependency with mbuf. > Another thing - now we have __rte_cache_aligned all over the places, and I don't know is to double > sizes of all these structures is a good idea. I thought so, the only concern I have, what if, the struct split to 64 and one cache line is shared between two core/two different structs which have the different type of operation(most likely). One extensive write and other one read, The write makes the line dirty start evicting and read core is going to suffer. Any thoughts? If its tradeoff between amount memory and performance, I think, it makes sense to stick the performance in data plane, Hence split option may be not useful? right? > Again, #if RTE_CACHE_LINE_SIZE == 64 ... all over the places looks a bit clumsy. > Wonder can we have __rte_cache_aligned/ RTE_CACHE_LINE_SIZE architecture specific, I think, its architecture specific now > but introduce RTE_CACHE_MIN_LINE_SIZE(==64)/ __rte_cache_min_aligned and used it for mbuf > (and might be other places). Yes, it will help in this specific mbuf case and it make sense if mbuf going to stay within 2 x 64 CL. AND/OR can we introduce something like below to reduce the clutter in other places, macro name is just not correct, trying to share the view #define rte_cacheline_diff(for_64, for_128)\ do {\ #if RTE_CACHE_LINE_SIZE == 64\ for_64; #elif RTE_CACHE_LINE_SIZE == 128\ for_128;\ #endif OR Typedef struct rte_mbuf to new abstract type and define for 64 bytes and 128 byte Jerin > Konstantin > >
> > Hi Konstantin, > > > Hi Jerin, > > > > > -----Original Message----- > > > From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com] > > > Sent: Sunday, December 06, 2015 3:59 PM > > > To: dev@dpdk.org > > > Cc: thomas.monjalon@6wind.com; Richardson, Bruce; olivier.matz@6wind.com; Dumitrescu, Cristian; Ananyev, Konstantin; Jerin > > > Jacob > > > Subject: [dpdk-dev] [PATCH 1/2] mbuf: fix performance/cache resource issue with 128-byte cache line targets > > > > > > No need to split mbuf structure to two cache lines for 128-byte cache line > > > size targets as it can fit on a single 128-byte cache line. > > > > > > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> > > > --- > > > app/test/test_mbuf.c | 4 ++++ > > > lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 4 ++++ > > > lib/librte_mbuf/rte_mbuf.h | 2 ++ > > > 3 files changed, 10 insertions(+) > > > > > > diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c > > > index b32bef6..5e21075 100644 > > > --- a/app/test/test_mbuf.c > > > +++ b/app/test/test_mbuf.c > > > @@ -930,7 +930,11 @@ test_failing_mbuf_sanity_check(void) > > > static int > > > test_mbuf(void) > > > { > > > +#if RTE_CACHE_LINE_SIZE == 64 > > > RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_LINE_SIZE * 2); > > > +#elif RTE_CACHE_LINE_SIZE == 128 > > > + RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_LINE_SIZE); > > > +#endif > > > > > > /* create pktmbuf pool if it does not exist */ > > > if (pktmbuf_pool == NULL) { > > > diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec- > > > env/rte_kni_common.h > > > index bd1cc09..e724af7 100644 > > > --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h > > > +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h > > > @@ -121,8 +121,12 @@ struct rte_kni_mbuf { > > > uint32_t pkt_len; /**< Total pkt len: sum of all segment data_len. */ > > > uint16_t data_len; /**< Amount of data in segment buffer. */ > > > > > > +#if RTE_CACHE_LINE_SIZE == 64 > > > /* fields on second cache line */ > > > char pad3[8] __attribute__((__aligned__(RTE_CACHE_LINE_SIZE))); > > > +#elif RTE_CACHE_LINE_SIZE == 128 > > > + char pad3[24]; > > > +#endif > > > void *pool; > > > void *next; > > > }; > > > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > > > index f234ac9..0bf55e0 100644 > > > --- a/lib/librte_mbuf/rte_mbuf.h > > > +++ b/lib/librte_mbuf/rte_mbuf.h > > > @@ -813,8 +813,10 @@ struct rte_mbuf { > > > > > > uint16_t vlan_tci_outer; /**< Outer VLAN Tag Control Identifier (CPU order) */ > > > > > > +#if RTE_CACHE_LINE_SIZE == 64 > > > /* second cache line - fields only used in slow path or on TX */ > > > MARKER cacheline1 __rte_cache_aligned; > > > +#endif > > > > I suppose you'll need to keep same space reserved for first 64B even on systems with 128B cache-line. > > Otherwise we can endup with different mbuf format for systems with 128B cache-line. > > Just to understand, Is there any issue in mbuf format being different > across the systems. I think, we are not sending the mbuf over the wire > or sharing with different system etc. right? No, we don't have to support that. At least I am not aware about such cases. > > Yes, I do understand the KNI dependency with mbuf. Are you asking about what will be broken (except KNI) if mbuf layout IA and ARM would be different? Probably nothing right now, except vector RX/TX. But they are not supported on ARM anyway, and if someone will implement them in future, it might be completely different from IA one. It just seems wrong to me to have different mbuf layout for each architecture. > > > Another thing - now we have __rte_cache_aligned all over the places, and I don't know is to double > > sizes of all these structures is a good idea. > > I thought so, the only concern I have, what if, the struct split to 64 > and one cache line is shared between two core/two different structs which have > the different type of operation(most likely). One extensive write and other one > read, The write makes the line dirty start evicting and read core is > going to suffer. Any thoughts? > > If its tradeoff between amount memory and performance, I think, it makes sense > to stick the performance in data plane, Hence split option may be not useful? > right? I understand that for most cases you would like to have your data structures CL aligned - to avoid performance penalties. I just suggest to have RTE_CACHE_MIN_LINE_SIZE(==64) for few cases when it might be plausible. As an example: struct rte_mbuf { ... MARKER cacheline1 __rte_cache_min_aligned; ... } _rte_cache_aligned; So we would have mbuf with the same size and layout, but different alignment for IA and ARM. Another example, where RTE_CACHE_MIN_LINE_SIZE could be used: struct rte_eth_(rxq|txq)_info. There is no real need to have them 128B aligned for ARM. The main purpose why they were defined as '__rte_cache_aligned' - just to reserve some space for future expansion. Konstantin > > > > Again, #if RTE_CACHE_LINE_SIZE == 64 ... all over the places looks a bit clumsy. > > Wonder can we have __rte_cache_aligned/ RTE_CACHE_LINE_SIZE architecture specific, > > I think, its architecture specific now > > > but introduce RTE_CACHE_MIN_LINE_SIZE(==64)/ __rte_cache_min_aligned and used it for mbuf > > (and might be other places). > > Yes, it will help in this specific mbuf case and it make sense > if mbuf going to stay within 2 x 64 CL. > > AND/OR > > can we introduce something like below to reduce the clutter in > other places, macro name is just not correct, trying to share the view > > #define rte_cacheline_diff(for_64, for_128)\ > do {\ > #if RTE_CACHE_LINE_SIZE == 64\ > for_64; > #elif RTE_CACHE_LINE_SIZE == 128\ > for_128;\ > #endif > > OR > > Typedef struct rte_mbuf to new abstract type and define for 64 bytes and > 128 byte > > Jerin > > > Konstantin > > > >
On Tue, Dec 08, 2015 at 04:07:46PM +0000, Ananyev, Konstantin wrote: > > > > Hi Konstantin, > > > > > Hi Jerin, > > > > > > > -----Original Message----- > > > > From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com] > > > > Sent: Sunday, December 06, 2015 3:59 PM > > > > To: dev@dpdk.org > > > > Cc: thomas.monjalon@6wind.com; Richardson, Bruce; olivier.matz@6wind.com; Dumitrescu, Cristian; Ananyev, Konstantin; Jerin > > > > Jacob > > > > Subject: [dpdk-dev] [PATCH 1/2] mbuf: fix performance/cache resource issue with 128-byte cache line targets > > > > > > > > No need to split mbuf structure to two cache lines for 128-byte cache line > > > > size targets as it can fit on a single 128-byte cache line. > > > > > > > > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> > > > > --- > > > > app/test/test_mbuf.c | 4 ++++ > > > > lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 4 ++++ > > > > lib/librte_mbuf/rte_mbuf.h | 2 ++ > > > > 3 files changed, 10 insertions(+) > > > > > > > > diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c > > > > index b32bef6..5e21075 100644 > > > > --- a/app/test/test_mbuf.c > > > > +++ b/app/test/test_mbuf.c > > > > @@ -930,7 +930,11 @@ test_failing_mbuf_sanity_check(void) > > > > static int > > > > test_mbuf(void) > > > > { > > > > +#if RTE_CACHE_LINE_SIZE == 64 > > > > RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_LINE_SIZE * 2); > > > > +#elif RTE_CACHE_LINE_SIZE == 128 > > > > + RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_LINE_SIZE); > > > > +#endif > > > > > > > > /* create pktmbuf pool if it does not exist */ > > > > if (pktmbuf_pool == NULL) { > > > > diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec- > > > > env/rte_kni_common.h > > > > index bd1cc09..e724af7 100644 > > > > --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h > > > > +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h > > > > @@ -121,8 +121,12 @@ struct rte_kni_mbuf { > > > > uint32_t pkt_len; /**< Total pkt len: sum of all segment data_len. */ > > > > uint16_t data_len; /**< Amount of data in segment buffer. */ > > > > > > > > +#if RTE_CACHE_LINE_SIZE == 64 > > > > /* fields on second cache line */ > > > > char pad3[8] __attribute__((__aligned__(RTE_CACHE_LINE_SIZE))); > > > > +#elif RTE_CACHE_LINE_SIZE == 128 > > > > + char pad3[24]; > > > > +#endif > > > > void *pool; > > > > void *next; > > > > }; > > > > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > > > > index f234ac9..0bf55e0 100644 > > > > --- a/lib/librte_mbuf/rte_mbuf.h > > > > +++ b/lib/librte_mbuf/rte_mbuf.h > > > > @@ -813,8 +813,10 @@ struct rte_mbuf { > > > > > > > > uint16_t vlan_tci_outer; /**< Outer VLAN Tag Control Identifier (CPU order) */ > > > > > > > > +#if RTE_CACHE_LINE_SIZE == 64 > > > > /* second cache line - fields only used in slow path or on TX */ > > > > MARKER cacheline1 __rte_cache_aligned; > > > > +#endif > > > > > > I suppose you'll need to keep same space reserved for first 64B even on systems with 128B cache-line. > > > Otherwise we can endup with different mbuf format for systems with 128B cache-line. > > > > Just to understand, Is there any issue in mbuf format being different > > across the systems. I think, we are not sending the mbuf over the wire > > or sharing with different system etc. right? > > No, we don't have to support that. > At least I am not aware about such cases. > > > > > Yes, I do understand the KNI dependency with mbuf. > > Are you asking about what will be broken (except KNI) if mbuf layout IA and ARM would be different? > Probably nothing right now, except vector RX/TX. > But they are not supported on ARM anyway, and if someone will implement them in future, it > might be completely different from IA one. > It just seems wrong to me to have different mbuf layout for each architecture. It's not architecture specific, it's machine and PMD specific. Typical ARM machines are 64-bytes CL but ThunderX and Power8 have 128-byte CL. It's PMD specific also, There are some NIC's which can write application interested fields before the packet in DDR, typically one CL size is dedicated for that. So there is an overhead to emulate the standard mbuf layout(Which the application shouldn't care about) i.e - reserve the space for generic mbuf layout - reserve the space for HW mbuf write - on packet receive, copy the content from HW mbuf space to generic buf layout(space and additional cache misses for each packet, bad :-( ) So, It's critical to abstract the mbuf to support such HW capable NICs. The application should be interested in the fields of mbuf, not the actual layout.Maybe we can take up this with external mem pool manager. > > > > > > Another thing - now we have __rte_cache_aligned all over the places, and I don't know is to double > > > sizes of all these structures is a good idea. > > > > I thought so, the only concern I have, what if, the struct split to 64 > > and one cache line is shared between two core/two different structs which have > > the different type of operation(most likely). One extensive write and other one > > read, The write makes the line dirty start evicting and read core is > > going to suffer. Any thoughts? > > > > If its tradeoff between amount memory and performance, I think, it makes sense > > to stick the performance in data plane, Hence split option may be not useful? > > right? > > I understand that for most cases you would like to have your data structures CL aligned - > to avoid performance penalties. > I just suggest to have RTE_CACHE_MIN_LINE_SIZE(==64) for few cases when it might be plausible. > As an example: > struct rte_mbuf { > ... > MARKER cacheline1 __rte_cache_min_aligned; > ... > } _rte_cache_aligned; I agree(in last email also). I will send next revision based on this, But kni muf definition, bitmap change we need to have some #define, so I have proposed some scheme in the last email(See below)[1]. Any thoughts? > > So we would have mbuf with the same size and layout, but different alignment for IA and ARM. > > Another example, where RTE_CACHE_MIN_LINE_SIZE could be used: > struct rte_eth_(rxq|txq)_info. > There is no real need to have them 128B aligned for ARM. > The main purpose why they were defined as '__rte_cache_aligned' - > just to reserve some space for future expansion. makes sense > > Konstantin > > > > > > > > Again, #if RTE_CACHE_LINE_SIZE == 64 ... all over the places looks a bit clumsy. > > > Wonder can we have __rte_cache_aligned/ RTE_CACHE_LINE_SIZE architecture specific, > > > > I think, its architecture specific now > > > > > but introduce RTE_CACHE_MIN_LINE_SIZE(==64)/ __rte_cache_min_aligned and used it for mbuf > > > (and might be other places). > > > > Yes, it will help in this specific mbuf case and it make sense > > if mbuf going to stay within 2 x 64 CL. > > > > AND/OR > > > > can we introduce something like below to reduce the clutter in > > other places, macro name is just not correct, trying to share the view > > > > #define rte_cacheline_diff(for_64, for_128)\ > > do {\ > > #if RTE_CACHE_LINE_SIZE == 64\ > > for_64; > > #elif RTE_CACHE_LINE_SIZE == 128\ > > for_128;\ > > #endif > > > > OR > > > > Typedef struct rte_mbuf to new abstract type and define for 64 bytes and > > 128 byte [1] some proposals list. > > > > Jerin > > > > > Konstantin > > > > > >
Hi Jerin, > From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com] > Sent: Tuesday, December 08, 2015 5:49 PM > To: Ananyev, Konstantin > Cc: dev@dpdk.org; thomas.monjalon@6wind.com; Richardson, Bruce; olivier.matz@6wind.com; Dumitrescu, Cristian > Subject: Re: [dpdk-dev] [PATCH 1/2] mbuf: fix performance/cache resource issue with 128-byte cache line targets > > On Tue, Dec 08, 2015 at 04:07:46PM +0000, Ananyev, Konstantin wrote: > > > > > > Hi Konstantin, > > > > > > > Hi Jerin, > > > > > > > > > -----Original Message----- > > > > > From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com] > > > > > Sent: Sunday, December 06, 2015 3:59 PM > > > > > To: dev@dpdk.org > > > > > Cc: thomas.monjalon@6wind.com; Richardson, Bruce; olivier.matz@6wind.com; Dumitrescu, Cristian; Ananyev, Konstantin; > Jerin > > > > > Jacob > > > > > Subject: [dpdk-dev] [PATCH 1/2] mbuf: fix performance/cache resource issue with 128-byte cache line targets > > > > > > > > > > No need to split mbuf structure to two cache lines for 128-byte cache line > > > > > size targets as it can fit on a single 128-byte cache line. > > > > > > > > > > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> > > > > > --- > > > > > app/test/test_mbuf.c | 4 ++++ > > > > > lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 4 ++++ > > > > > lib/librte_mbuf/rte_mbuf.h | 2 ++ > > > > > 3 files changed, 10 insertions(+) > > > > > > > > > > diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c > > > > > index b32bef6..5e21075 100644 > > > > > --- a/app/test/test_mbuf.c > > > > > +++ b/app/test/test_mbuf.c > > > > > @@ -930,7 +930,11 @@ test_failing_mbuf_sanity_check(void) > > > > > static int > > > > > test_mbuf(void) > > > > > { > > > > > +#if RTE_CACHE_LINE_SIZE == 64 > > > > > RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_LINE_SIZE * 2); > > > > > +#elif RTE_CACHE_LINE_SIZE == 128 > > > > > + RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_LINE_SIZE); > > > > > +#endif > > > > > > > > > > /* create pktmbuf pool if it does not exist */ > > > > > if (pktmbuf_pool == NULL) { > > > > > diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec- > > > > > env/rte_kni_common.h > > > > > index bd1cc09..e724af7 100644 > > > > > --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h > > > > > +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h > > > > > @@ -121,8 +121,12 @@ struct rte_kni_mbuf { > > > > > uint32_t pkt_len; /**< Total pkt len: sum of all segment data_len. */ > > > > > uint16_t data_len; /**< Amount of data in segment buffer. */ > > > > > > > > > > +#if RTE_CACHE_LINE_SIZE == 64 > > > > > /* fields on second cache line */ > > > > > char pad3[8] __attribute__((__aligned__(RTE_CACHE_LINE_SIZE))); > > > > > +#elif RTE_CACHE_LINE_SIZE == 128 > > > > > + char pad3[24]; > > > > > +#endif > > > > > void *pool; > > > > > void *next; > > > > > }; > > > > > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > > > > > index f234ac9..0bf55e0 100644 > > > > > --- a/lib/librte_mbuf/rte_mbuf.h > > > > > +++ b/lib/librte_mbuf/rte_mbuf.h > > > > > @@ -813,8 +813,10 @@ struct rte_mbuf { > > > > > > > > > > uint16_t vlan_tci_outer; /**< Outer VLAN Tag Control Identifier (CPU order) */ > > > > > > > > > > +#if RTE_CACHE_LINE_SIZE == 64 > > > > > /* second cache line - fields only used in slow path or on TX */ > > > > > MARKER cacheline1 __rte_cache_aligned; > > > > > +#endif > > > > > > > > I suppose you'll need to keep same space reserved for first 64B even on systems with 128B cache-line. > > > > Otherwise we can endup with different mbuf format for systems with 128B cache-line. > > > > > > Just to understand, Is there any issue in mbuf format being different > > > across the systems. I think, we are not sending the mbuf over the wire > > > or sharing with different system etc. right? > > > > No, we don't have to support that. > > At least I am not aware about such cases. > > > > > > > > Yes, I do understand the KNI dependency with mbuf. > > > > Are you asking about what will be broken (except KNI) if mbuf layout IA and ARM would be different? > > Probably nothing right now, except vector RX/TX. > > But they are not supported on ARM anyway, and if someone will implement them in future, it > > might be completely different from IA one. > > It just seems wrong to me to have different mbuf layout for each architecture. > > It's not architecture specific, it's machine and PMD specific. > Typical ARM machines are 64-bytes CL but ThunderX and Power8 have > 128-byte CL. Ok, didn't know that. Thanks for clarification. > > It's PMD specific also, There are some NIC's which can write application > interested fields before the packet in DDR, typically one CL size is dedicated > for that. > So there is an overhead to emulate the standard mbuf layout(Which the > application shouldn't care about) i.e > - reserve the space for generic mbuf layout > - reserve the space for HW mbuf write > - on packet receive, copy the content from HW mbuf space to generic > buf layout(space and additional cache misses for each packet, bad :-( ) Each different NIC model has different format of HW descriptors That's what each PMD have to do: read information from HW specific layout, interpret it and fill mbuf. I suppose that's the price all of us have to pay. Otherwise it would mean that DPDK app would be able to work only with one NIC model and if you'll have to rebuild your app each time the underlying HW Is going to change. > > So, It's critical to abstract the mbuf to support such HW capable NICs. > The application should be interested in the fields of mbuf, not the > actual layout.Maybe we can take up this with external mem pool manager. > > > > > > > > > > Another thing - now we have __rte_cache_aligned all over the places, and I don't know is to double > > > > sizes of all these structures is a good idea. > > > > > > I thought so, the only concern I have, what if, the struct split to 64 > > > and one cache line is shared between two core/two different structs which have > > > the different type of operation(most likely). One extensive write and other one > > > read, The write makes the line dirty start evicting and read core is > > > going to suffer. Any thoughts? > > > > > > If its tradeoff between amount memory and performance, I think, it makes sense > > > to stick the performance in data plane, Hence split option may be not useful? > > > right? > > > > I understand that for most cases you would like to have your data structures CL aligned - > > to avoid performance penalties. > > I just suggest to have RTE_CACHE_MIN_LINE_SIZE(==64) for few cases when it might be plausible. > > As an example: > > struct rte_mbuf { > > ... > > MARKER cacheline1 __rte_cache_min_aligned; > > ... > > } _rte_cache_aligned; > > I agree(in last email also). I will send next revision based on this, Ok. > But kni muf definition, bitmap change we need to have some #define, > so I have proposed some scheme in the last email(See below)[1]. Any thoughts? Probably I am missing something, but with RTE_CACHE_MIN_LINE_SIZE, and keeping mbuf layout intact, why do we need: #if RTE_CACHE_LINE_SIZE == 64\ for_64; #elif RTE_CACHE_LINE_SIZE == 128\ for_128;\ #endif for rte_mbuf.h and friends at all? Inside kni_common.h, we can change: - char pad3[8] __attribute__((__aligned__(RTE_CACHE_LINE_SIZE))); + char pad3[8] __attribute__((__aligned__(RTE_CACHE_MIN_LINE_SIZE))); To keep it in sync with rte_mbuf.h Inside test_mbuf.c: - RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_LINE_SIZE * 2); + RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_MIN_LINE_SIZE * 2); For rte_bitmap.h, and similar stuff - if we'll have CONFIG_RTE_CACHE_LINE_SIZE_LOG2 defined in the config file, and will make RTE_CACHE_LINE_SIZE derived from it, then it would fix such problems? Konstantin > > > > > So we would have mbuf with the same size and layout, but different alignment for IA and ARM. > > > > Another example, where RTE_CACHE_MIN_LINE_SIZE could be used: > > struct rte_eth_(rxq|txq)_info. > > There is no real need to have them 128B aligned for ARM. > > The main purpose why they were defined as '__rte_cache_aligned' - > > just to reserve some space for future expansion. > > makes sense > > > > > Konstantin > > > > > > > > > > > > Again, #if RTE_CACHE_LINE_SIZE == 64 ... all over the places looks a bit clumsy. > > > > Wonder can we have __rte_cache_aligned/ RTE_CACHE_LINE_SIZE architecture specific, > > > > > > I think, its architecture specific now > > > > > > > but introduce RTE_CACHE_MIN_LINE_SIZE(==64)/ __rte_cache_min_aligned and used it for mbuf > > > > (and might be other places). > > > > > > Yes, it will help in this specific mbuf case and it make sense > > > if mbuf going to stay within 2 x 64 CL. > > > > > > AND/OR > > > > > > can we introduce something like below to reduce the clutter in > > > other places, macro name is just not correct, trying to share the view > > > > > > #define rte_cacheline_diff(for_64, for_128)\ > > > do {\ > > > #if RTE_CACHE_LINE_SIZE == 64\ > > > for_64; > > > #elif RTE_CACHE_LINE_SIZE == 128\ > > > for_128;\ > > > #endif > > > > > > OR > > > > > > Typedef struct rte_mbuf to new abstract type and define for 64 bytes and > > > 128 byte > > [1] some proposals list. > > > > > > > Jerin > > > > > > > Konstantin > > > > > > > >
On Wed, Dec 09, 2015 at 01:44:44PM +0000, Ananyev, Konstantin wrote: Hi Konstantin, > > Hi Jerin, > > > From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com] > > Sent: Tuesday, December 08, 2015 5:49 PM > > To: Ananyev, Konstantin > > Cc: dev@dpdk.org; thomas.monjalon@6wind.com; Richardson, Bruce; olivier.matz@6wind.com; Dumitrescu, Cristian > > Subject: Re: [dpdk-dev] [PATCH 1/2] mbuf: fix performance/cache resource issue with 128-byte cache line targets > > > > On Tue, Dec 08, 2015 at 04:07:46PM +0000, Ananyev, Konstantin wrote: > > > > > > > > Hi Konstantin, > > > > > > > > > Hi Jerin, > > > > > > > > > > > -----Original Message----- > > > > > > From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com] > > > > > > Sent: Sunday, December 06, 2015 3:59 PM > > > > > > To: dev@dpdk.org > > > > > > Cc: thomas.monjalon@6wind.com; Richardson, Bruce; olivier.matz@6wind.com; Dumitrescu, Cristian; Ananyev, Konstantin; > > Jerin > > > > > > Jacob > > > > > > Subject: [dpdk-dev] [PATCH 1/2] mbuf: fix performance/cache resource issue with 128-byte cache line targets > > > > > > > > > > > > No need to split mbuf structure to two cache lines for 128-byte cache line > > > > > > size targets as it can fit on a single 128-byte cache line. > > > > > > > > > > > > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> > > > > > > --- > > > > > > app/test/test_mbuf.c | 4 ++++ > > > > > > lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | 4 ++++ > > > > > > lib/librte_mbuf/rte_mbuf.h | 2 ++ > > > > > > 3 files changed, 10 insertions(+) > > > > > > > > > > > > diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c > > > > > > index b32bef6..5e21075 100644 > > > > > > --- a/app/test/test_mbuf.c > > > > > > +++ b/app/test/test_mbuf.c > > > > > > @@ -930,7 +930,11 @@ test_failing_mbuf_sanity_check(void) > > > > > > static int > > > > > > test_mbuf(void) > > > > > > { > > > > > > +#if RTE_CACHE_LINE_SIZE == 64 > > > > > > RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_LINE_SIZE * 2); > > > > > > +#elif RTE_CACHE_LINE_SIZE == 128 > > > > > > + RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_LINE_SIZE); > > > > > > +#endif > > > > > > > > > > > > /* create pktmbuf pool if it does not exist */ > > > > > > if (pktmbuf_pool == NULL) { > > > > > > diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec- > > > > > > env/rte_kni_common.h > > > > > > index bd1cc09..e724af7 100644 > > > > > > --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h > > > > > > +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h > > > > > > @@ -121,8 +121,12 @@ struct rte_kni_mbuf { > > > > > > uint32_t pkt_len; /**< Total pkt len: sum of all segment data_len. */ > > > > > > uint16_t data_len; /**< Amount of data in segment buffer. */ > > > > > > > > > > > > +#if RTE_CACHE_LINE_SIZE == 64 > > > > > > /* fields on second cache line */ > > > > > > char pad3[8] __attribute__((__aligned__(RTE_CACHE_LINE_SIZE))); > > > > > > +#elif RTE_CACHE_LINE_SIZE == 128 > > > > > > + char pad3[24]; > > > > > > +#endif > > > > > > void *pool; > > > > > > void *next; > > > > > > }; > > > > > > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > > > > > > index f234ac9..0bf55e0 100644 > > > > > > --- a/lib/librte_mbuf/rte_mbuf.h > > > > > > +++ b/lib/librte_mbuf/rte_mbuf.h > > > > > > @@ -813,8 +813,10 @@ struct rte_mbuf { > > > > > > > > > > > > uint16_t vlan_tci_outer; /**< Outer VLAN Tag Control Identifier (CPU order) */ > > > > > > > > > > > > +#if RTE_CACHE_LINE_SIZE == 64 > > > > > > /* second cache line - fields only used in slow path or on TX */ > > > > > > MARKER cacheline1 __rte_cache_aligned; > > > > > > +#endif > > > > > > > > > > I suppose you'll need to keep same space reserved for first 64B even on systems with 128B cache-line. > > > > > Otherwise we can endup with different mbuf format for systems with 128B cache-line. > > > > > > > > Just to understand, Is there any issue in mbuf format being different > > > > across the systems. I think, we are not sending the mbuf over the wire > > > > or sharing with different system etc. right? > > > > > > No, we don't have to support that. > > > At least I am not aware about such cases. > > > > > > > > > > > Yes, I do understand the KNI dependency with mbuf. > > > > > > Are you asking about what will be broken (except KNI) if mbuf layout IA and ARM would be different? > > > Probably nothing right now, except vector RX/TX. > > > But they are not supported on ARM anyway, and if someone will implement them in future, it > > > might be completely different from IA one. > > > It just seems wrong to me to have different mbuf layout for each architecture. > > > > It's not architecture specific, it's machine and PMD specific. > > Typical ARM machines are 64-bytes CL but ThunderX and Power8 have > > 128-byte CL. > > Ok, didn't know that. > Thanks for clarification. > > > > > It's PMD specific also, There are some NIC's which can write application > > interested fields before the packet in DDR, typically one CL size is dedicated > > for that. > > So there is an overhead to emulate the standard mbuf layout(Which the > > application shouldn't care about) i.e > > - reserve the space for generic mbuf layout > > - reserve the space for HW mbuf write > > - on packet receive, copy the content from HW mbuf space to generic > > buf layout(space and additional cache misses for each packet, bad :-( ) > > Each different NIC model has different format of HW descriptors > That's what each PMD have to do: read information from HW specific layout, > interpret it and fill mbuf. > I suppose that's the price all of us have to pay. > Otherwise it would mean that DPDK app would be able to work only with one > NIC model and if you'll have to rebuild your app each time the underlying HW > Is going to change. Yes, I understood your view. But to accommodate Embedded NW hardware or some enterprise NW version of HW which derived from Embedded version it going to be VERY expensive. I know certain HW that can write complete MBUF info with changing also in HW (== libmbuf/libmempool kind of libraries its not required at all in fast path) So am just thinking, To support all the PMD device at runtime instead of compilation time(the issue you have pointed out correctly), Why can't we "attach" operation of libmuf/libmempool(like get the flags, put and get the buffers etc) to a PMD as function pointers. And if given platform/PMD doesn't have HW support then they can use software based libmbuf/libmempool and attach to PMD driver and if it has HW support then specific PMD can override those function pointers. and application just uses the function pointer associated with PMD to support multiple PMD's at runtime without losing the HW capability of the pool and mbuf management in HW. I think that will improve DPDK capability to deal the multiple variety of NW HWs(Enterprise, Embedded or Hybrid) > > > > > So, It's critical to abstract the mbuf to support such HW capable NICs. > > The application should be interested in the fields of mbuf, not the > > actual layout.Maybe we can take up this with external mem pool manager. > > > > > > > > > > > > > > Another thing - now we have __rte_cache_aligned all over the places, and I don't know is to double > > > > > sizes of all these structures is a good idea. > > > > > > > > I thought so, the only concern I have, what if, the struct split to 64 > > > > and one cache line is shared between two core/two different structs which have > > > > the different type of operation(most likely). One extensive write and other one > > > > read, The write makes the line dirty start evicting and read core is > > > > going to suffer. Any thoughts? > > > > > > > > If its tradeoff between amount memory and performance, I think, it makes sense > > > > to stick the performance in data plane, Hence split option may be not useful? > > > > right? > > > > > > I understand that for most cases you would like to have your data structures CL aligned - > > > to avoid performance penalties. > > > I just suggest to have RTE_CACHE_MIN_LINE_SIZE(==64) for few cases when it might be plausible. > > > As an example: > > > struct rte_mbuf { > > > ... > > > MARKER cacheline1 __rte_cache_min_aligned; > > > ... > > > } _rte_cache_aligned; > > > > I agree(in last email also). I will send next revision based on this, > > Ok. > > > But kni muf definition, bitmap change we need to have some #define, > > so I have proposed some scheme in the last email(See below)[1]. Any thoughts? > > Probably I am missing something, but with RTE_CACHE_MIN_LINE_SIZE, > and keeping mbuf layout intact, why do we need: > #if RTE_CACHE_LINE_SIZE == 64\ > for_64; > #elif RTE_CACHE_LINE_SIZE == 128\ > for_128;\ > #endif > for rte_mbuf.h and friends at all? Not required, I was trying a macro for common code. I think we live without that, That's neat too. Will address in next version. > > Inside kni_common.h, we can change: > - char pad3[8] __attribute__((__aligned__(RTE_CACHE_LINE_SIZE))); > + char pad3[8] __attribute__((__aligned__(RTE_CACHE_MIN_LINE_SIZE))); > To keep it in sync with rte_mbuf.h > > Inside test_mbuf.c: > - RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_LINE_SIZE * 2); > + RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_MIN_LINE_SIZE * 2); > > For rte_bitmap.h, and similar stuff - if we'll have > CONFIG_RTE_CACHE_LINE_SIZE_LOG2 defined in the config file, > and will make RTE_CACHE_LINE_SIZE derived from it, > then it would fix such problems? makes sense. Will address in next version. > > Konstantin > > > > > > > > > > So we would have mbuf with the same size and layout, but different alignment for IA and ARM. > > > > > > Another example, where RTE_CACHE_MIN_LINE_SIZE could be used: > > > struct rte_eth_(rxq|txq)_info. > > > There is no real need to have them 128B aligned for ARM. > > > The main purpose why they were defined as '__rte_cache_aligned' - > > > just to reserve some space for future expansion. > > > > makes sense > > > > > > > > Konstantin > > > > > > > > > > > > > > > > Again, #if RTE_CACHE_LINE_SIZE == 64 ... all over the places looks a bit clumsy. > > > > > Wonder can we have __rte_cache_aligned/ RTE_CACHE_LINE_SIZE architecture specific, > > > > > > > > I think, its architecture specific now > > > > > > > > > but introduce RTE_CACHE_MIN_LINE_SIZE(==64)/ __rte_cache_min_aligned and used it for mbuf > > > > > (and might be other places). > > > > > > > > Yes, it will help in this specific mbuf case and it make sense > > > > if mbuf going to stay within 2 x 64 CL. > > > > > > > > AND/OR > > > > > > > > can we introduce something like below to reduce the clutter in > > > > other places, macro name is just not correct, trying to share the view > > > > > > > > #define rte_cacheline_diff(for_64, for_128)\ > > > > do {\ > > > > #if RTE_CACHE_LINE_SIZE == 64\ > > > > for_64; > > > > #elif RTE_CACHE_LINE_SIZE == 128\ > > > > for_128;\ > > > > #endif > > > > > > > > OR > > > > > > > > Typedef struct rte_mbuf to new abstract type and define for 64 bytes and > > > > 128 byte > > > > [1] some proposals list. > > > > > > > > > > Jerin > > > > > > > > > Konstantin > > > > > > > > > >
diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c index b32bef6..5e21075 100644 --- a/app/test/test_mbuf.c +++ b/app/test/test_mbuf.c @@ -930,7 +930,11 @@ test_failing_mbuf_sanity_check(void) static int test_mbuf(void) { +#if RTE_CACHE_LINE_SIZE == 64 RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_LINE_SIZE * 2); +#elif RTE_CACHE_LINE_SIZE == 128 + RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_LINE_SIZE); +#endif /* create pktmbuf pool if it does not exist */ if (pktmbuf_pool == NULL) { diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h index bd1cc09..e724af7 100644 --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h @@ -121,8 +121,12 @@ struct rte_kni_mbuf { uint32_t pkt_len; /**< Total pkt len: sum of all segment data_len. */ uint16_t data_len; /**< Amount of data in segment buffer. */ +#if RTE_CACHE_LINE_SIZE == 64 /* fields on second cache line */ char pad3[8] __attribute__((__aligned__(RTE_CACHE_LINE_SIZE))); +#elif RTE_CACHE_LINE_SIZE == 128 + char pad3[24]; +#endif void *pool; void *next; }; diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index f234ac9..0bf55e0 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -813,8 +813,10 @@ struct rte_mbuf { uint16_t vlan_tci_outer; /**< Outer VLAN Tag Control Identifier (CPU order) */ +#if RTE_CACHE_LINE_SIZE == 64 /* second cache line - fields only used in slow path or on TX */ MARKER cacheline1 __rte_cache_aligned; +#endif union { void *userdata; /**< Can be used for external metadata */