From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 25B05A0C44; Mon, 14 Jun 2021 17:54:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A42CA4067E; Mon, 14 Jun 2021 17:54:33 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id E4A034067A for ; Mon, 14 Jun 2021 17:54:31 +0200 (CEST) IronPort-SDR: RVelcrU5BCuSo7PLq+7iCY+OMCvvaS9KCKGx01EnxbHK7Mwe7goqoOd6Ri4/23CqFkmXgWbutu q+LAjL4FAQ1Q== X-IronPort-AV: E=McAfee;i="6200,9189,10015"; a="192947463" X-IronPort-AV: E=Sophos;i="5.83,273,1616482800"; d="scan'208";a="192947463" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2021 08:54:28 -0700 IronPort-SDR: mRUQ4BkbvldJ/9MZ/5ueHP8boMLTWOFQd/2LHsvufbuLdqvnDVQ0exBAPuNcoBY1zwpUSbROt9 xQG+6IECFjAw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,273,1616482800"; d="scan'208";a="420821404" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga002.jf.intel.com with ESMTP; 14 Jun 2021 08:54:28 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Mon, 14 Jun 2021 08:54:27 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4 via Frontend Transport; Mon, 14 Jun 2021 08:54:27 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.171) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.4; Mon, 14 Jun 2021 08:54:24 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XFdu9JXOFL6AzRw0JykoKZChhSvcWamvsYRvqkDVBhuH/dQVN3OdDMKgBdMrPICCTZ+hJ0qF3I76PhZp7JJRe4sMeJS2IgDATXbcPcAvJ8SQXH9jssNIzlNgs2Kny+UoqUF1+3x5zaPcQMXPyO+VE+RNMUNUimiGSEnxpDqB7TRhBng3lq7S5CZEkDbd85EE4ebMpmmJrsZ9s/Malll4tc8SHaBqm3+eqEhdUDwfKyPknwkc9EcBvNpgVUAi4NhQJXpx3V3O3cYeY9i+d5V9DxFeS85iWqbtNJyZ4Uuff+pzbGZ98ItW6aoqMTQGLa5i9w+nUkQLBSfsas4Ziel2iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gKbE7f6Lahmi7sTeJ/wzF0AVkIXi6C0WrO7C0lQJYf0=; b=P4EY00kBAamNDX6n/PCEjXgq4Nqfo2RQHPoxlusGXsG+EBWGldBthriMpzl4wis2YCJ3dz7vAU5aWQTaS1415WwkvQ4vZCCoddSX9bqER9s7qALp/Ykno2FIHrBChJqG+aeifEEwoDU1ftx701oCgQtuF5RX+aInSHRhgVFBEzv52jPnVGb04xDihGwBCYIyjXu9ZJWrg1U7GqXR3oLKVwhAJbCkLxNaTBElSoCKSIcUzQz8RqAA4qeku8uozGoF6l+CvXgCpV8vwKnsYCNLQdaK+3PIqH+XC9Ifac8ZmK2bTRS3SJJKN47Q6iF9Q8C9OfKTzKQ9quz85EmWRArLoA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gKbE7f6Lahmi7sTeJ/wzF0AVkIXi6C0WrO7C0lQJYf0=; b=giQ55LeDNo9T3iZNSfTj3JubbsqoXk7UYKEXLdm6zWaXEqYEkBzUIXQDhSMA/6PKHu/URR6RxtzGMJwoh24NcYXMtlU147F6AvHN5ozqBroE0saODNDvj0tgUaohaJPGbExMTDavWwLiF8T0rDmPKeoXOIZ7Lby/H4Hv1MJSj0A= Received: from DM6PR11MB4491.namprd11.prod.outlook.com (2603:10b6:5:204::19) by DM6PR11MB2826.namprd11.prod.outlook.com (2603:10b6:5:c0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.24; Mon, 14 Jun 2021 15:54:19 +0000 Received: from DM6PR11MB4491.namprd11.prod.outlook.com ([fe80::7dc4:66b0:f76b:6d48]) by DM6PR11MB4491.namprd11.prod.outlook.com ([fe80::7dc4:66b0:f76b:6d48%7]) with mapi id 15.20.4219.025; Mon, 14 Jun 2021 15:54:19 +0000 From: "Ananyev, Konstantin" To: "Ananyev, Konstantin" , Thomas Monjalon , "Richardson, Bruce" CC: =?iso-8859-1?Q?Morten_Br=F8rup?= , "dev@dpdk.org" , "olivier.matz@6wind.com" , "andrew.rybchenko@oktetlabs.ru" , "honnappa.nagarahalli@arm.com" , "Yigit, Ferruh" , "jerinj@marvell.com" , "gakhil@marvell.com" Thread-Topic: [dpdk-dev] [PATCH] parray: introduce internal API for dynamic arrays Thread-Index: AQHXYQxT3nKj3OToOE+g04oypCLg2asTbdkAgAAOoICAAATCgIAAFeZggAAOq/A= Date: Mon, 14 Jun 2021 15:54:19 +0000 Message-ID: References: <20210614105839.3379790-1-thomas@monjalon.net> <98CBD80474FA8B44BF855DF32C47DC35C6184E@smartserver.smartshare.dk> <2004320.XGyPsaEoyj@thomas> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [109.255.184.192] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d1c34b19-4126-4244-4a9f-08d92f4cabe1 x-ms-traffictypediagnostic: DM6PR11MB2826: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: nFV47MIrsdGw8oFwPqwiBsJFWIzKLNoEciZcku8g3kjRa7Tesea8hUvD7g6T/JeR4GdugnBxxgwzJaenmvojqsWbfaoyWXoFGhBimBpPVljpgcB2Y7esTAdLFDiVC1XgOmVkDVnzPKGRz2DRpTFtCohfjGGwjR/VV4S1ilKxIRTZ/lE53DiXZ3B5AX3dC2UBk1RUoV7GTQmTes5EuYba3baxMKPXftEAWyV7pxHChC25v3oP0vWff/SUACfCj/NhZBlQU4vlmI7HkMNEd3C7/AjASmZlah6Hk9yPYO3eOym08q0XtJCisoEEIIZMYZhooRGF88gD77T2WAHPsPBd3ZvgvWoGYy217HtIUU5ZBV8rfKjgohxNVNX5MecKyCPwFTgnNIKvTYFd4pCNXcCeamIWZH/74bNlkt+ZzIrHk+B1u0t2mLtcYWJlyP59ETJmdppFjdW5dmQdPXORBtRVllPuO/8DX2IsJCYtnKsqvbJ4nndxPqKkDJl+cZHeWVaS29ZLEx0EuO7ZTo4jiKqNyvkPPMaXm7GPhb18KwNhzBsGB+FLl2teu65yCuPWn/CVVUOA6vWio2Yid/j39/yiFArWFsCS9HcsgefXJ50hlHk= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB4491.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(376002)(136003)(396003)(39860400002)(366004)(86362001)(64756008)(66556008)(66476007)(66446008)(122000001)(2906002)(38100700002)(76116006)(186003)(71200400001)(316002)(66946007)(26005)(52536014)(33656002)(110136005)(6636002)(6506007)(8936002)(8676002)(7696005)(55236004)(478600001)(55016002)(83380400001)(66574015)(9686003)(4326008)(2940100002)(5660300002)(54906003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?3DTSSzAqVmDKCUcHoHUuOORm2oQDHjWH/Jz39MU2A5f8HaEJ9HW24HkGXH?= =?iso-8859-1?Q?yfD057zoODSBp+0r0iUM4GB9fJXbMItZz+rBg1HCXUW/nLvQL/o3je96hD?= =?iso-8859-1?Q?BOJYyPeYd1yErIA+bqK5uX9h1QhzVaqKgOMutoFv44dUYnNF2ND4HWKWIm?= =?iso-8859-1?Q?uvv75wElZr2wFd/D8knBxN/6Ada/vsObg8r4QScrMYKiLydJ6UvQhlXNMo?= =?iso-8859-1?Q?wnKLVB3weE+f4+xIXMoEc47riJ0hBDQ4wYw4TumgRMNh4g6DkWG18V1soH?= =?iso-8859-1?Q?Tq49/FgFX5CMs80mZ5LBgcWun8jNjnrvkr6q2YQ1XHPq4aPlV37qDTDP8u?= =?iso-8859-1?Q?l3zXL6/zIpRlVzqAiNKJm0ip9kloL5thzY3n40t0QezRpwm5KmBcbYOz6+?= =?iso-8859-1?Q?e1yni8Exzt9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mw?= =?iso-8859-1?Q?C782tRLc7IZEBK5dR0z7Nwe4opPrahZtDt/EV7t5kXm8oSVaIT3sU+iv34?= =?iso-8859-1?Q?v0PIXwWTy7?= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB4491.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1c34b19-4126-4244-4a9f-08d92f4cabe1 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Jun 2021 15:54:19.6115 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: nCegvxP1z0cwuKAag8k34u8ROIw1XHpxSZZ+8mIy+buq+LxeuceiHEYGAYPzLZqEZ1PId4YZx+t3C5gW9hVeVcFGoSOOdxuUQNgsTSZmQko= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2826 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH] parray: introduce internal API for dynamic arrays X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > > > > 14/06/2021 15:15, Bruce Richardson: > > > On Mon, Jun 14, 2021 at 02:22:42PM +0200, Morten Br=F8rup wrote: > > > > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thomas Monja= lon > > > > > Sent: Monday, 14 June 2021 12.59 > > > > > > > > > > Performance of access in a fixed-size array is very good > > > > > because of cache locality > > > > > and because there is a single pointer to dereference. > > > > > The only drawback is the lack of flexibility: > > > > > the size of such an array cannot be increase at runtime. > > > > > > > > > > An approach to this problem is to allocate the array at runtime, > > > > > being as efficient as static arrays, but still limited to a maxim= um. > > > > > > > > > > That's why the API rte_parray is introduced, > > > > > allowing to declare an array of pointer which can be resized > > > > > dynamically > > > > > and automatically at runtime while keeping a good read performanc= e. > > > > > > > > > > After resize, the previous array is kept until the next resize > > > > > to avoid crashs during a read without any lock. > > > > > > > > > > Each element is a pointer to a memory chunk dynamically allocated= . > > > > > This is not good for cache locality but it allows to keep the sam= e > > > > > memory per element, no matter how the array is resized. > > > > > Cache locality could be improved with mempools. > > > > > The other drawback is having to dereference one more pointer > > > > > to read an element. > > > > > > > > > > There is not much locks, so the API is for internal use only. > > > > > This API may be used to completely remove some compilation-time > > > > > maximums. > > > > > > > > I get the purpose and overall intention of this library. > > > > > > > > I probably already mentioned that I prefer "embedded style programm= ing" with fixed size arrays, rather than runtime configurability. > It's > > my personal opinion, and the DPDK Tech Board clearly prefers reducing t= he amount of compile time configurability, so there is no way for > > me to stop this progress, and I do not intend to oppose to this library= . :-) > > > > > > > > This library is likely to become a core library of DPDK, so I think= it is important getting it right. Could you please mention a few > examples > > where you think this internal library should be used, and where it shou= ld not be used. Then it is easier to discuss if the border line between > > control path and data plane is correct. E.g. this library is not intend= ed to be used for dynamically sized packet queues that grow and shrink > in > > the fast path. > > > > > > > > If the library becomes a core DPDK library, it should probably be p= ublic instead of internal. E.g. if the library is used to make > > RTE_MAX_ETHPORTS dynamic instead of compile time fixed, then some appli= cations might also need dynamically sized arrays for their > > application specific per-port runtime data, and this library could serv= e that purpose too. > > > > > > > > > > Thanks Thomas for starting this discussion and Morten for follow-up. > > > > > > My thinking is as follows, and I'm particularly keeping in mind the c= ases > > > of e.g. RTE_MAX_ETHPORTS, as a leading candidate here. > > > > > > While I dislike the hard-coded limits in DPDK, I'm also not convinced= that > > > we should switch away from the flat arrays or that we need fully dyna= mic > > > arrays that grow/shrink at runtime for ethdevs. I would suggest a hal= f-way > > > house here, where we keep the ethdevs as an array, but one allocated/= sized > > > at runtime rather than statically. This would allow us to have a > > > compile-time default value, but, for use cases that need it, allow us= e of a > > > flag e.g. "max-ethdevs" to change the size of the parameter given to= the > > > malloc call for the array. This max limit could then be provided to = apps > > > too if they want to match any array sizes. [Alternatively those apps = could > > > check the provided size and error out if the size has been increased = beyond > > > what the app is designed to use?]. There would be no extra dereferenc= es per > > > rx/tx burst call in this scenario so performance should be the same a= s > > > before (potentially better if array is in hugepage memory, I suppose)= . > > > > I think we need some benchmarks to decide what is the best tradeoff. > > I spent time on this implementation, but sorry I won't have time for be= nchmarks. > > Volunteers? >=20 > I had only a quick look at your approach so far. > But from what I can read, in MT environment your suggestion will require > extra synchronization for each read-write access to such parray element (= lock, rcu, ...). > I think what Bruce suggests will be much ligther, easier to implement and= less error prone. > At least for rte_ethdevs[] and friends. > Konstantin One more thought here - if we are talking about rte_ethdev[] in particular,= I think we can: 1. move public function pointers (rx_pkt_burst(), etc.) from rte_ethdev int= o a separate flat array. We can keep it public to still use inline functions for 'fast' calls rte_et= h_rx_burst(), etc. to avoid any regressions. That could still be flat array with max_size specified at application start= up. 2. Hide rest of rte_ethdev struct in .c. That will allow us to change the struct itself and the whole rte_ethdev[] t= able in a way we like (flat array, vector, hash, linked list) without ABI/API breakages. Yes, it would require all PMDs to change prototype for pkt_rx_burst() funct= ion (to accept port_id, queue_id instead of queue pointer), but the change is m= echanical one. Probably some macro can be provided to simplify it. The only significant complication I can foresee with implementing that appr= oach - we'll need a an array of 'fast' function pointers per queue, not per device= as we have now (to avoid extra indirection for callback implementation). Though as a bonus we'll have ability to use different RX/TX funcions per qu= eue. =20