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 B301DA0577; Tue, 7 Apr 2020 08:19:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 980292B86; Tue, 7 Apr 2020 08:19:45 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2058.outbound.protection.outlook.com [40.107.21.58]) by dpdk.org (Postfix) with ESMTP id E2544FFA for ; Tue, 7 Apr 2020 08:19:43 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aFKCnb6ws8vXZSrp21rTOs7+IHjU6MKT9H5X+qxY4FFwIPHFNhgDuLz382qyTUg21dbmgs8RDjpml1Psnic5z7kOkdQahSqBew6IhKGuWRxcxN2X56IJbrd06ILKXfpUuo8t8L9K+43l4cWA4H1I4lNUlosA7B7RB+eVzNmmLypKqrPi/IOONcRAv2Fu9xtnvV3jJEqML9JjZx66OBfq87IaR/m6Oq0aMLwBW6FTz/EKUXPHtNYSDM3WVrlCnd5v64sVVl/MxYlqky2OzyX9zJN6jkZ32PFf5gnVDtb+kGRZEE65ZFWPFr/OLD7r4v4KxDaqZo29pIyE/9aMQvFdrg== 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=55m0RPxoEvuNvLX/Nk148qRMtgg7hXB7OsxUo+u/FHU=; b=W+1N+qcwrIQW0f4ehru9qJB9/hyhenvmwgwvA+tb4nBOethEtAQuW0jUk9KGnRq5CZeidmKUdTpWO7CsyddL/kqtw1tc6g6/Bmren4MPx49dyzazGULq0fngyinAzYWaL5k9EZX7AVbU4AGHNGuLNZ3xlaW4S50las9Pejrw9sAec6BmS31RlhGOaNy6qRQtkwo2CAYNtkeA5Guwox7zb0bpOwCOLQROz7iiDHQOEdV2Xw8NMFtjYVJ/lliGQRTbo4d+YcYmdLFxx8JAajb/D3KbN5LLq9duMJLB16X7vd0IePQ6ZqVxdZoF9H5oiKWXGp1nFSIeKY+JeghQ+w350A== 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=55m0RPxoEvuNvLX/Nk148qRMtgg7hXB7OsxUo+u/FHU=; b=QhNrOYkDPfyrBmolmY/PaDmOKnIeCYKAucoVNyhfFhwqVI9mWypHQa75bRV44V74td4qqLG5MLyCqACTmynCAAIIaSYCRiaPDnstuqI6KlZm+0d1FkJnL39pqTbXaxe0phf3sudDX44P4xxE76shLNOqqR1juQSxyaabY4WxPVw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=suanmingm@mellanox.com; Received: from HE1PR05MB3484.eurprd05.prod.outlook.com (2603:10a6:7:2f::12) by HE1PR05MB3275.eurprd05.prod.outlook.com (2603:10a6:7:2d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.20; Tue, 7 Apr 2020 06:19:42 +0000 Received: from HE1PR05MB3484.eurprd05.prod.outlook.com ([fe80::e44a:abcc:6e96:cb00]) by HE1PR05MB3484.eurprd05.prod.outlook.com ([fe80::e44a:abcc:6e96:cb00%7]) with mapi id 15.20.2878.022; Tue, 7 Apr 2020 06:19:42 +0000 To: Andrzej Ostruszka , dev@dpdk.org References: <1583828479-204084-1-git-send-email-suanmingm@mellanox.com> <1583828479-204084-2-git-send-email-suanmingm@mellanox.com> From: Suanming Mou Message-ID: <43d443c3-59e2-1b18-cc12-0827b1773c88@mellanox.com> Date: Tue, 7 Apr 2020 14:19:32 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-ClientProxiedBy: SG2PR0302CA0008.apcprd03.prod.outlook.com (2603:1096:3:2::18) To HE1PR05MB3484.eurprd05.prod.outlook.com (2603:10a6:7:2f::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.31.73] (115.193.231.72) by SG2PR0302CA0008.apcprd03.prod.outlook.com (2603:1096:3:2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.6 via Frontend Transport; Tue, 7 Apr 2020 06:19:40 +0000 X-Originating-IP: [115.193.231.72] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ad909f0e-9acc-4726-1cd4-08d7dabba88b X-MS-TrafficTypeDiagnostic: HE1PR05MB3275: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-Forefront-PRVS: 036614DD9C X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:HE1PR05MB3484.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(396003)(346002)(136003)(366004)(39850400004)(376002)(26005)(8936002)(52116002)(5660300002)(186003)(6486002)(478600001)(2616005)(31696002)(36756003)(81166006)(956004)(53546011)(8676002)(81156014)(316002)(16576012)(16526019)(86362001)(2906002)(66476007)(66946007)(6666004)(66556008)(31686004); 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: ZfgB53JAH+VWA9yKChvedJPQENEUNUNOmrfobyE2Ey73DKkK2JTSweUoLXCMMndPrC2qzDalf+V8634aBpsWYwq5yMRLJaKlvbmDYc62DXKP1vI86S/5wtMY8g9JtRHwyoIAL1Aud7lZKn1ph5kFQf0tJCigNioYKgTTch4ECCRpA4NCPx6JwnFWSTLxQoAxWLC7V6UuFCpjKrtJ4o6Rx7h0fHuf+I4l9RelL1Frdsl+mASDohTXE10ftShlR7XpvczucCN73AMOjFkhYec6xh+zd8CYq/I7gcKNx2wmbxJFVgxejyfLD5Hha+wg5Uv3tu0y563vjhyeZnHrjYh9kqyeHRPsopb8jldIQFzNyxjzwUaVTY/78NS6xbzyyVwT3ATXlXSgoRmt2I2N96PVZ8VP9HYUaSrf6cNG3Kwtu2eAzTIaJgb410UBwd8QyLsV X-MS-Exchange-AntiSpam-MessageData: yWTROsFTD6od3DLUo439bNnEIUNIyparwmpyp63/J0ht1p4Hn0D11izx4DshLff1gJRpuhRpAWlv8EqZbgdL4qNXeKiom6BcLVUxxmk3HWrsP8iPGdostbbHwymLyv6ZnMcNs+ubZLXX2fCcUJ4IHQ== X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad909f0e-9acc-4726-1cd4-08d7dabba88b X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2020 06:19:41.9891 (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: gR0GoxG1d2LIKiIOWrRdOza4g9wwiOZcDQr76Dtj7gFGJHaBQK4hHo6bseacrzqoVMPpiO3wMey86nSy0wYlfg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR05MB3275 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" On 4/3/2020 10:49 PM, Andrzej Ostruszka wrote: > 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. Hi Andrzej , thanks for your suggestions. > > 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. Good idea. In fact, the first proposal was to add a new function which can set all the n_bits. Since currently, the bitmap struct does not contain n_bits, the rte_bitmap_init_with_all_set() was introduced. > >> + /* 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. The RTE_BITMAP_CL_BIT_SIZE is 512 with cache_line size 64. Maybe for most of the cases which creates the bitmap less than 4K bits will not have chance with the memset. Anyway, will add it. > >> + /* 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 >