DPDK patches and discussions
 help / color / mirror / Atom feed
From: Suanming Mou <suanmingm@mellanox.com>
To: "Dumitrescu, Cristian" <cristian.dumitrescu@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 1/2] bitmap: add create bitmap with all bits set
Date: Wed, 8 Apr 2020 02:57:55 +0000	[thread overview]
Message-ID: <VI1PR05MB3487942B7F394264E4078675CCC00@VI1PR05MB3487.eurprd05.prod.outlook.com> (raw)
In-Reply-To: <BYAPR11MB29351CDD7F320DBC21378CDCEBC30@BYAPR11MB2935.namprd11.prod.outlook.com>

Hi 

> -----Original Message-----
> From: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> Sent: Wednesday, April 8, 2020 1:48 AM
> To: Suanming Mou <suanmingm@mellanox.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH 1/2] bitmap: add create bitmap with all bits set
> 
> Hi Suanming,
> 
> > -----Original Message-----
> > From: Suanming Mou <suanmingm@mellanox.com>
> > Sent: Tuesday, March 10, 2020 8:21 AM
> > To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> > 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 <suanmingm@mellanox.com>
> > ---
> >  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 = n_bits / RTE_BITMAP_SLAB_BIT_SIZE;
> > +	struct rte_bitmap *bmp = 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 = 0; i < n_bits; i += RTE_BITMAP_CL_BIT_SIZE)
> > +		rte_bitmap_set(bmp, i);
> > +	/* Fill the arry2 left not byte aligned bits. */
> > +	for (i = 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 initialization 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 for the suggestion. Will update.
> 
> Thanks,
> Cristian

  reply	other threads:[~2020-04-08  2:57 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-10  8:21 [dpdk-dev] [PATCH 0/2] " Suanming Mou
2020-03-10  8:21 ` [dpdk-dev] [PATCH 1/2] " Suanming Mou
2020-04-03 14:49   ` Andrzej Ostruszka
2020-04-07  6:19     ` Suanming Mou
2020-04-07 15:00       ` Suanming Mou
2020-04-07 17:48   ` Dumitrescu, Cristian
2020-04-08  2:57     ` Suanming Mou [this message]
2020-03-10  8:21 ` [dpdk-dev] [PATCH 2/2] test/bitmap: add bitmap create with all bits set case Suanming Mou
2020-03-25 13:25 ` [dpdk-dev] [PATCH 0/2] bitmap: add create bitmap with all bits set Thomas Monjalon
2020-04-02 13:44   ` Suanming Mou
2020-04-08  3:05 ` [dpdk-dev] [PATCH v2 " Suanming Mou
2020-04-08  3:05   ` [dpdk-dev] [PATCH v2 1/2] " Suanming Mou
2020-04-09 14:16     ` Dumitrescu, Cristian
2020-04-10 10:34       ` Suanming Mou
2020-04-10 11:21         ` Dumitrescu, Cristian
2020-04-10 12:30           ` Suanming Mou
2020-04-08  3:05   ` [dpdk-dev] [PATCH v2 2/2] test/bitmap: add bitmap create with all bits set case Suanming Mou
2020-04-10 12:46 ` [dpdk-dev] [PATCH v3 0/2] bitmap: add create bitmap with all bits set Suanming Mou
2020-04-10 12:46   ` [dpdk-dev] [PATCH v3 1/2] " Suanming Mou
2020-04-10 16:04     ` Dumitrescu, Cristian
2020-04-10 12:46   ` [dpdk-dev] [PATCH v3 2/2] test/bitmap: add bitmap create with all bits set case Suanming Mou
2020-04-15 14:15 ` [dpdk-dev] [PATCH v4] bitmap: add init with all bits set Thomas Monjalon
2020-04-15 14:22   ` Suanming Mou
2020-04-15 14:42     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VI1PR05MB3487942B7F394264E4078675CCC00@VI1PR05MB3487.eurprd05.prod.outlook.com \
    --to=suanmingm@mellanox.com \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).