From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8DE24A0577; Tue, 7 Apr 2020 20:00:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 81FDC1BF1B; Tue, 7 Apr 2020 20:00:01 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id EE1581BEF2 for ; Tue, 7 Apr 2020 19:59:56 +0200 (CEST) IronPort-SDR: 063iLl2R8RdfA3UhA5J9mn18PNBpTnp3XM2mFwXGLbvN33PYDG4EG+O3nqWGuytIW5AU7GBjMm vTH9z0TMfhcQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2020 10:48:20 -0700 IronPort-SDR: /LqH73DOzxZccG+SQbHEQufcEla8BInt1CWAD7HB3JYXeO4tkgSRRkf7TBM7uli9hTgk7OxHmP L+Z22FT7dujg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,356,1580803200"; d="scan'208";a="254535640" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga006.jf.intel.com with ESMTP; 07 Apr 2020 10:48:20 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 7 Apr 2020 10:48:20 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 7 Apr 2020 10:48:19 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 7 Apr 2020 10:48:19 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.103) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 7 Apr 2020 10:48:18 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oCTe+MnNSw43CfvCc+ass3zbtspVd8/4BzymNSRvtPAY6xsRrFihmiiO+ovR1Vqpt5dxYHJ/AGxOtnV5Gd3C0nR0lwIUlchsZMttngaP//elekqI6k5qMGk714XmjmR+4MznCr6/p1mX/IO8NpAKzJnTKLU2uAcRWJp1Kb4coIEpqHudDLoEbdyl9smDb/yapHY49EKNBmXhA//F4XAtntu5lexyhfNUlNy7qprmE4p7AP9mlhCTs+HE3uSOSOOjb6kp3kQcexzqIuNNrTx2veWK+EYuxTndY7eghc5wVGnkJthfxZGzSYSSFuG91iK+dZTtju6IPYs7DMSLh/6f0Q== 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=mNkzGSgUlD0fyscsp0GRaMrb1E9nzUIoPYnt6sCIw5g=; b=LG3Yp4BOr5o546xskWrllnZfU1NNvqL67ev1x7pvE1XeD0uC+FvUhIghT/kCuGVvvuFMhy1ZViAYJ686tZn8HVSC6nIGj8f3KRtWdOj7mCOuPt5DzwK0spBxrDaCnHWYPdgJ64Fi4C5XN+sAPK7FzHT4M3Cm2Y1a/ezV9TRbsm/SuZjmAsSfz+oeuIq2tDo+vw4PiPZw1p0nxfZbl1XkVisMVtj/nA6y2SPsmI2KDKrO3wyYpze3LudV3b7qr5S8X0IBsIsYZSn4MeztMsMeTcYdIM4UKVEeItWkDXKQIcJPgK8yBJfOx1bcgsOH6tTwE4iOt4B/PB9+4pFnDmgtyQ== 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=mNkzGSgUlD0fyscsp0GRaMrb1E9nzUIoPYnt6sCIw5g=; b=BwpA/8CmRp55Kg+e3cBWcsSj9i96sn1/vHqfT9SzTqCAoXdw96TXzOW/2AijvEi0SMvVdK0C3GfovSgxEYhOn+agWn8h0aRfEvA+JsWH3KgaK31oB7azOXcvMuUz/8122DCtJpbMEQbJF/MiHpJy+krfhf2FrJeOosaMA369dAg= Received: from BYAPR11MB2935.namprd11.prod.outlook.com (2603:10b6:a03:82::24) by BYAPR11MB2646.namprd11.prod.outlook.com (2603:10b6:a02:c6::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.19; Tue, 7 Apr 2020 17:48:17 +0000 Received: from BYAPR11MB2935.namprd11.prod.outlook.com ([fe80::786e:a42b:df03:a829]) by BYAPR11MB2935.namprd11.prod.outlook.com ([fe80::786e:a42b:df03:a829%5]) with mapi id 15.20.2878.021; Tue, 7 Apr 2020 17:48:17 +0000 From: "Dumitrescu, Cristian" To: Suanming Mou CC: "dev@dpdk.org" Thread-Topic: [PATCH 1/2] bitmap: add create bitmap with all bits set Thread-Index: AQHV9rT7O0i16/CzukOl0au0uly6GKhuG59Q Date: Tue, 7 Apr 2020 17:48:17 +0000 Message-ID: References: <1583828479-204084-1-git-send-email-suanmingm@mellanox.com> <1583828479-204084-2-git-send-email-suanmingm@mellanox.com> In-Reply-To: <1583828479-204084-2-git-send-email-suanmingm@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-reaction: no-action dlp-product: dlpe-windows authentication-results: spf=none (sender IP is ) smtp.mailfrom=cristian.dumitrescu@intel.com; x-originating-ip: [192.198.151.160] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1808523b-99ec-4e72-b79d-08d7db1bda88 x-ms-traffictypediagnostic: BYAPR11MB2646: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-forefront-prvs: 036614DD9C x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB2935.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10019020)(346002)(39860400002)(376002)(136003)(366004)(396003)(7696005)(2906002)(33656002)(26005)(53546011)(52536014)(8936002)(6506007)(9686003)(316002)(55016002)(4326008)(186003)(81156014)(81166006)(8676002)(5660300002)(71200400001)(6916009)(478600001)(86362001)(66476007)(66556008)(76116006)(64756008)(66446008)(66946007); DIR:OUT; SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 0/+J489WK9vzFdtygNnoF4fKZkGSYlAtCdeR31yD2FbwONcye5KMvexkru3q1iYgZ8BAnwTr49IRtP3az/K55lKxDTQWgrcpGtErTmhCerw6VYahcRmTfd6L8jUJWc3NAIae41lcesYCdUt84L3ip8sPMO9NqDdwHlgTGd6aBSuYfcBfGJnTNBgs56ZsTz6YiVbaMY4Zq0ZUVcMpWA3zsLodWK905+QSsHTmNS/inVrsOji77QJ8glYNttB2lJWwCWqRmL9Wm7MUeIaneJYcGJV/mijoY6c1DyGAjeJ6B3OmBT2EF2YFvvH6JQREBLFR4mkZiuNWEx4CZ18Ho6BPZw31KxKrprUl3boO0Rzb1jq9lLk2Xs8KB5SM7AQv4+FN60Eg14MapXREXPxNS510e/pbTPJQ4hfIvmORCqFbh2mkHg+FMdVmPBrpjfyBIaof x-ms-exchange-antispam-messagedata: lj731NWFy4rMYlgeEonKyBKTFdwsyjPGZgUxAQSfXkEt043nIGlEZa6iSLF8bZWQvzpOpbM92WYPqgwuv4690tbm4vatvSkLHsBsLNyzSuDYqUIRtnuFeJ4PSU2T1k9N4oRnoBCYAiX+2wjHvy9EyQ== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 1808523b-99ec-4e72-b79d-08d7db1bda88 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Apr 2020 17:48:17.1388 (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: nj+IG//PQ+l+krJIfHy+6YkrCtK4kGViQRfpduPtiDTGRyiDtFzKnfc9gO5DmrXpi8aoI/lO/j/QIcdXShwh/Y1YPGM1rm99SmPappVsmuw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB2646 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH 1/2] bitmap: add create bitmap with all bits set X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Hi Suanming, > -----Original Message----- > From: Suanming Mou > Sent: Tuesday, March 10, 2020 8:21 AM > To: Dumitrescu, Cristian > Cc: dev@dpdk.org > Subject: [PATCH 1/2] bitmap: add create bitmap with all bits set >=20 > Currently, in the case to use bitmap as resource allocator, after > bitmap creation, all the bitmap bits should be set to indicate the > bit available. Every time when allocate one bit, search for the set > bits and clear it to make it in use. >=20 > Add a new rte_bitmap_init_with_all_set() function to have a quick > fill up the bitmap bits. >=20 > Comparing with the case create the bitmap as empty and set the bitmap > one by one, the new function costs less cycles. >=20 > Signed-off-by: Suanming Mou > --- > lib/librte_eal/common/include/rte_bitmap.h | 32 > ++++++++++++++++++++++++++++++ > 1 file changed, 32 insertions(+) >=20 > diff --git a/lib/librte_eal/common/include/rte_bitmap.h > b/lib/librte_eal/common/include/rte_bitmap.h > index 6b846f2..36b32e4 100644 > --- a/lib/librte_eal/common/include/rte_bitmap.h > +++ b/lib/librte_eal/common/include/rte_bitmap.h > @@ -483,6 +483,38 @@ struct rte_bitmap { > return 0; > } >=20 > +/** > + * Bitmap initialization with all bits set > + * > + * @param n_bits > + * Number of pre-allocated bits in array2. > + * @param mem > + * Base address of array1 and array2. > + * @param mem_size > + * Minimum expected size of bitmap. > + * @return > + * Handle to bitmap instance. > + */ > +static inline struct rte_bitmap * > +rte_bitmap_init_with_all_set(uint32_t n_bits, uint8_t *mem, uint32_t > mem_size) > +{ > + uint32_t i; > + uint32_t slabs =3D n_bits / RTE_BITMAP_SLAB_BIT_SIZE; > + struct rte_bitmap *bmp =3D rte_bitmap_init(n_bits, mem, mem_size); > + > + if (!bmp) > + return NULL; > + /* Fill the arry2 byte aligned bits. */ > + memset(bmp->array2, 0xff, slabs * sizeof(bmp->array2[0])); > + /* Fill the arry1 bits. */ > + for (i =3D 0; i < n_bits; i +=3D RTE_BITMAP_CL_BIT_SIZE) > + rte_bitmap_set(bmp, i); > + /* Fill the arry2 left not byte aligned bits. */ > + for (i =3D slabs * RTE_BITMAP_SLAB_BIT_SIZE; i < n_bits; i++) > + rte_bitmap_set(bmp, i); > + return bmp; > +} > + > #ifdef __cplusplus > } > #endif > -- > 1.8.3.1 I agree that starting with all bits set could be very useful for some apps. I agree that having a customized implementation for starting with all bits = set -- as opposed to simply start with all bits cleared and calling the API= in a loop to set each bit -- could be useful, as it could reduce the initi= alization time. What I don't understand is your implementation of it: why still calling the= API to set all bits in a loop? If we are to add this, I suggest we create = a fully customized implementation that sets the fields on struct rte_bitmap= to the right values. Makes sense? Thanks, Cristian