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 9CE9AA0597; Wed, 8 Apr 2020 04:57:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8688F1BF0B; Wed, 8 Apr 2020 04:57:58 +0200 (CEST) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130085.outbound.protection.outlook.com [40.107.13.85]) by dpdk.org (Postfix) with ESMTP id 13C531BF02 for ; Wed, 8 Apr 2020 04:57:57 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LYoeyymdPvVgx83ygmMXQGMvvDrC7Cmm7w/6Zn7lRpEboiV1FpQWTtwgeMwN4wsEDU+Bi9362ADX4akXqKwNt1npUMKxWM09WU+DLM1MSRuvlPYdoeJo/8XOIe0gxxqGbv+Ipu5upRms4aXKqKaql822/F7Et2HVEyjpe5TzsRP+ge/lazj460ykCs1XdJmKlOSHLNrcw4tUyhZQkTFeWgcqLpNGz/1aTjKQvYTO6eglq1HI0uHo3p1te4gkceZwyKUbAS1PmdlLhX5cNAdUvARt66BFVnanSIJgThHtfLUgDnNmITwEfDI+BASulzjuwK3pnAJZM5qal4TPtgLEyA== 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=Xfg0IGRUEgC7LNVOK31QshzzuJh6HZdaCdcgzScDKN8=; b=fh6OIM+XUvnjChSmGWU85LwUA0KGRX0bXroNYGjykYraLl0z2ukcAB4QFcvDGlcLRPlu3IWo9MxsV8p3072h6dBC+hRSai6RU1FP1iN4z6qNWbXFwHEYn8FUEQ0zlr2ODd2YVPevVerMvA5WGDP7cvhu4Jp3bd68iD3A9t55v60WEhv2AEmXcQqOWLRXydhDKTA27bY7griAzP1762dKE6jYkefUfLohu2Rpa5S4Rt9O1iP1w608v2cPA7CsHdQfzCuN4ujAVHADc40vgp82lEmKEKQZ22AkKyLDEaXPnp4gGTxcDrpUD7Xqczc8ij9yDQ/bh5OIMkokjJX5In+05Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Xfg0IGRUEgC7LNVOK31QshzzuJh6HZdaCdcgzScDKN8=; b=LEXse8toK3Uu2MA1IKHMs89xmH3a8DZ10kfDWUE8rrMAAKk30Vy9YjsbSLNohflcD3YkeVUZMSyFTahF99h7pj+q2laY/WBtsOI8XlZD9URZ2qQcuYJjr1I9cXZYXHPbs7G3bv5QvPY6esrBWbdrWmxJwx8xt0n8naYACeSMn4c= Received: from VI1PR05MB3487.eurprd05.prod.outlook.com (2603:10a6:802:1e::29) by VI1PR05MB4895.eurprd05.prod.outlook.com (2603:10a6:803:5c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.15; Wed, 8 Apr 2020 02:57:56 +0000 Received: from VI1PR05MB3487.eurprd05.prod.outlook.com ([fe80::3cd4:5309:6e02:de88]) by VI1PR05MB3487.eurprd05.prod.outlook.com ([fe80::3cd4:5309:6e02:de88%4]) with mapi id 15.20.2856.019; Wed, 8 Apr 2020 02:57:55 +0000 From: Suanming Mou To: "Dumitrescu, Cristian" CC: "dev@dpdk.org" Thread-Topic: [PATCH 1/2] bitmap: add create bitmap with all bits set Thread-Index: AQHV9rT7O0i16/CzukOl0au0uly6GKhuG59QgACZw+A= Date: Wed, 8 Apr 2020 02:57:55 +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: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=suanmingm@mellanox.com; x-originating-ip: [115.193.231.72] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 0a6ce5a6-7d59-436b-1152-08d7db68a335 x-ms-traffictypediagnostic: VI1PR05MB4895: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-forefront-prvs: 0367A50BB1 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR05MB3487.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(39850400004)(346002)(136003)(396003)(376002)(366004)(86362001)(6506007)(53546011)(316002)(2906002)(71200400001)(81166007)(33656002)(52536014)(66446008)(64756008)(5660300002)(81156014)(8676002)(66476007)(66946007)(66556008)(76116006)(7696005)(478600001)(55016002)(4326008)(26005)(186003)(8936002)(9686003)(6916009); DIR:OUT; SFP:1101; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Lc/8w61peC8Zq1y5R4PZso2RL2xQ2/hE/NOXSsEIkNbSFYKtQQ173uCD+itw71dL/rgUpcYyDBbe/LP/se+yLFLZu+SFw1kGs3ZKagRDH6O300A0aZxQDIjYi/1R1Lt5oxFkMc0R8kdUWJFLykudS4mbs6dFNqfmhOIeNJrSc87zst7pUV/XWBqpYMlhV3ULgLjDpT0T5HjQjFjYtGzQzl8zo6RuhlNo/t7a+vfLv6iLoq263wgSFgQUa8hbhFIvNK7rP3nstEDHQu3RgF1WzXrTNsjbCYS2tAp+wiZeKfIBed6wTYklEj8Zf7xU4881aCuXGg3fAG6JOGB1UD513fXvrnTAK5nsVdPW+8EU26MDTRHmXqlereNVtslY+LSTBx35l3uZxz9+A3S89RQyDOP/1XjvtOQhGWy9kcQ6ie/VLbanVhRYw4IA/MfKmjWV x-ms-exchange-antispam-messagedata: 7LhtCCJTJvgCRnX0aX2nz0Jn8qTz2Pn7K8hpfZkeW4Y1q4pAJCWB75WejRGcloj/c6/ycOOo/jDPmWwtbHNvxM4o0Q79GETUsBO4LgHL12tfNlcav1+ltv9PhX/l3DskdAtorZDYo3f4FlvHr4NrCw== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0a6ce5a6-7d59-436b-1152-08d7db68a335 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2020 02:57:55.5971 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: MwKWv4qYvRgNMa8/eKNsuKig3JIsgmrt4hu76RpnTTyk1EPJD8FY083hbhqKtXbcRTnMnrmCQvaPC7sYQ4WSAg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4895 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=20 > -----Original Message----- > From: Dumitrescu, Cristian > Sent: Wednesday, April 8, 2020 1:48 AM > To: Suanming Mou > Cc: dev@dpdk.org > Subject: RE: [PATCH 1/2] bitmap: add create bitmap with all bits set >=20 > Hi Suanming, >=20 > > -----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 > > > > 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. > > > > Add a new rte_bitmap_init_with_all_set() function to have a quick fill > > up the bitmap bits. > > > > Comparing with the case create the bitmap as empty and set the bitmap > > one by one, the new function costs less cycles. > > > > Signed-off-by: Suanming Mou > > --- > > lib/librte_eal/common/include/rte_bitmap.h | 32 > > ++++++++++++++++++++++++++++++ > > 1 file changed, 32 insertions(+) > > > > 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; > > } > > > > +/** > > + * 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 >=20 > I agree that starting with all bits set could be very useful for some app= s. >=20 > I agree that having a customized implementation for starting with all bit= s 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 initialization time. >=20 > What I don't understand is your implementation of it: why still calling t= he API to > set all bits in a loop? If we are to add this, I suggest we create a full= y customized > implementation that sets the fields on struct rte_bitmap to the right val= ues. > Makes sense? Thanks for the suggestion. Will update. >=20 > Thanks, > Cristian