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 0A081A0562; Fri, 3 Apr 2020 16:49:33 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3A9511C033; Fri, 3 Apr 2020 16:49:33 +0200 (CEST) Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by dpdk.org (Postfix) with ESMTP id F07051BFEF for ; Fri, 3 Apr 2020 16:49:31 +0200 (CEST) Received: by mail-lj1-f194.google.com with SMTP id f20so7263866ljm.0 for ; Fri, 03 Apr 2020 07:49:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=MkHTRkl+EE5j9guvJ1SyeO6lgTe8ZuPRIFEGeohyjis=; b=bPwYfFIiiMuU9kzdhV5eAkmniQFdtfmN62mywnegLKu/3hrBYAY3k7rx8Yk4pHCuCt mhtjx1kWBRJlysz/4SOcKTxMoLN8G7hkUJTbdkGi2g1eE7ej/6c+gSjdbU7itSiblQOR Ok2TJs3I658GEPAoiiIY0YvNRQF0GL7H+vO4wBoqk037o2L+ZkO4T/lKXQCaupzMy1pP lbQG8ahmjFatUf+hsilsajNliMVVRZz9YWC8v135hd2tGipW3BWxIfATIQTPbgolnFrv dyQUVeBvNm5ehxbsjOU5Uc5ME2bzr7hjov+BtiwhoFDoI4nJRJRhz3YoAaUWwkZA3xev pZCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=MkHTRkl+EE5j9guvJ1SyeO6lgTe8ZuPRIFEGeohyjis=; b=KkGOHMpWcxZ38SBA7IIOtr/MScfyZZSpoaq6ryt5ieIQJcC9gYUdRsu5PrWOnE+VHp s8iKiOwqWqRWlHXAgW1ebcLWfqnOTpjAft4r4wD6kyHlyuF9rX+palSkZBFNac+2cRE8 3eeR16pTdpYtIueD9i3F+M7so9EOCoXDltJI49svRqLT4wDixX8VZdWaTK35wt9BqI8e EZYRX0x8zvCr5A6pIdLdybtfeBeB0yoqm68V4kwZBBUuU7TzA2O3a1zs38BgSMGZcWo1 a9n4cAXk8yvW9rhWqMb2PX/OjPAJdJ4PwIvimJ3Nb3WaOHfwzpTWHYvsGSwmU9Kq4iHS c7IA== X-Gm-Message-State: AGi0PuYzSV+HMYoZcaoSrzrAZM93RhENttJmOzqKKfvWeSWx/BsQfjd5 19889+RZMBuCcwvZ2Kk9i8hiLuzJbE8= X-Google-Smtp-Source: APiQypIT8PC1Cq1WxBo7pd0KmzQBMLiYugqylnE72GXjQhYkjlwlfi1Kn5CZ6uByu1XNt/C68fXY2A== X-Received: by 2002:a2e:9c9:: with SMTP id 192mr4666639ljj.77.1585925370377; Fri, 03 Apr 2020 07:49:30 -0700 (PDT) Received: from [192.168.8.100] (user-5-173-41-10.play-internet.pl. [5.173.41.10]) by smtp.gmail.com with ESMTPSA id x28sm5142826ljd.24.2020.04.03.07.49.29 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 03 Apr 2020 07:49:29 -0700 (PDT) To: dev@dpdk.org References: <1583828479-204084-1-git-send-email-suanmingm@mellanox.com> <1583828479-204084-2-git-send-email-suanmingm@mellanox.com> From: Andrzej Ostruszka Message-ID: Date: Fri, 3 Apr 2020 16:49:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <1583828479-204084-2-git-send-email-suanmingm@mellanox.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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" Hello Suanming Please find my comments below. However please note that so far I have never used DPDK bitmaps so I might not be the best person to comment - this patch needs some attention so I spent some time on it. Overall I'm fine with the changes however since this is a performance enhancement I've added some remarks/comments. On 3/10/20 9:21 AM, Suanming Mou wrote: > 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 = 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])); In rte_bitmap_init() we clear memory with 0 and now we set it with 1s. Maybe separating the configuration from the actual initialization would be better? So that you call __rte_bitmap_init() and later zero in rte_bitmap_init() and set to 1s here. > + /* Fill the arry1 bits. */ > + for (i = 0; i < n_bits; i += RTE_BITMAP_CL_BIT_SIZE) > + rte_bitmap_set(bmp, i); Maybe you could here also compute the number of array1 bytes that can be set to FF and use memset() and for the remaining user rte_bitmap_set()? Right now you are also touching array2 memory which was already set above. > + /* 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; > +} > + With regards Andrzej Ostruszka