From patchwork Tue Jan 5 08:57:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nithin Dabilpuram X-Patchwork-Id: 85981 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B06C8A09FF; Tue, 5 Jan 2021 09:57:50 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 383161607B5; Tue, 5 Jan 2021 09:57:50 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 08F9B1607AA for ; Tue, 5 Jan 2021 09:57:47 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1058ueCJ030005; Tue, 5 Jan 2021 00:57:47 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=zzky8aCniI8MSUECufM/OLrZC6bQvAZVrZLfiSIZ9S0=; b=ilaWoNKXHvxArfyUlVMR8v0oghzbH8tYlXqbXBPoSVeMWAc32g2JBM5euVNtsXPadV8Y 1Xin5rr394XqPLzsQyxLzqBgVZCQ5uLlwAnrRRllI1nSjGMQWvl7wFldFepeeZIb4cWl eiLUqE7hDSnVC5fbrlmsnsDWCyc34y+fKwnvTKNvnkKtROpC0OLU+4tDYYlaVdmEPZcY L4/+0QqB2LQWYb5ddL9YIROPBszNXwHJWaTRdJVLfoS4pbRwtffB1DYj82UL9B5vUAzG 7AuZTJ3B5MqgyyBZ8RPx5hOuZHVCel0Mjycc8Vd3K/AjkxyjN120R2r0N/bg/HocexM4 DA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 35ts7rnp72-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 05 Jan 2021 00:57:47 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 5 Jan 2021 00:57:45 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 5 Jan 2021 00:57:45 -0800 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id C4C863F703F; Tue, 5 Jan 2021 00:57:43 -0800 (PST) From: Nithin Dabilpuram To: Cristian Dumitrescu CC: , , Nithin Dabilpuram Date: Tue, 5 Jan 2021 14:27:28 +0530 Message-ID: <20210105085729.2814-1-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20201214102835.19980-1-ndabilpuram@marvell.com> References: <20201214102835.19980-1-ndabilpuram@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2021-01-05_01:2021-01-05, 2021-01-05 signatures=0 Subject: [dpdk-dev] [PATCH v2 1/2] test/bitmap: test scan after half cline is cleared X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Add a test case to test scan operation post clear of half cacheline of slabs. Also fix meson.build to include test_bitmap.c in the compilation. Signed-off-by: Nithin Dabilpuram --- v2: - No change app/test/meson.build | 1 + app/test/test_bitmap.c | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/app/test/meson.build b/app/test/meson.build index 94fd39f..bb06a92 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -13,6 +13,7 @@ test_sources = files('commands.c', 'test_atomic.c', 'test_barrier.c', 'test_bitops.c', + 'test_bitmap.c', 'test_bpf.c', 'test_byteorder.c', 'test_cmdline.c', diff --git a/app/test/test_bitmap.c b/app/test/test_bitmap.c index a8204d3..70d8fff 100644 --- a/app/test/test_bitmap.c +++ b/app/test/test_bitmap.c @@ -16,9 +16,10 @@ static int test_bitmap_scan_operations(struct rte_bitmap *bmp) { - uint32_t pos = 0; uint64_t slab1_magic = 0xBADC0FFEEBADF00D; uint64_t slab2_magic = 0xFEEDDEADDEADF00D; + uint32_t pos = 0, start_pos; + int i, nb_clear, nb_set; uint64_t out_slab = 0; rte_bitmap_reset(bmp); @@ -70,6 +71,37 @@ test_bitmap_scan_operations(struct rte_bitmap *bmp) return TEST_FAILED; } + /* Test scan when a cline is half full */ + rte_bitmap_reset(bmp); + for (i = 0; i < MAX_BITS; i++) + rte_bitmap_set(bmp, i); + + nb_clear = RTE_MIN(RTE_BITMAP_CL_BIT_SIZE / 2, MAX_BITS); + for (i = 0; i < nb_clear; i++) + rte_bitmap_clear(bmp, i); + + /* Find remaining bits set in bmp */ + __rte_bitmap_scan_init(bmp); + + if (rte_bitmap_scan(bmp, &pos, &out_slab) != 1) { + printf("Initial scan failed with half CL empty.\n"); + return TEST_FAILED; + } + + start_pos = pos; + nb_set = 0; + do { + nb_set += __builtin_popcountll(out_slab); + if (!rte_bitmap_scan(bmp, &pos, &out_slab)) + break; + } while (pos != start_pos); + + if ((nb_clear + nb_set) != MAX_BITS) { + printf("Scan failed to find all set bits. " + "Expected %u, found %u.\n", MAX_BITS - nb_clear, nb_set); + return TEST_FAILED; + } + return TEST_SUCCESS; } From patchwork Tue Jan 5 08:57:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nithin Dabilpuram X-Patchwork-Id: 85982 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 03673A09FF; Tue, 5 Jan 2021 09:57:57 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 537741607D3; Tue, 5 Jan 2021 09:57:51 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 52F061607C8 for ; Tue, 5 Jan 2021 09:57:50 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1058v4T4016721; Tue, 5 Jan 2021 00:57:49 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=9CKJdvecYaXD3R65EfWAYWbVgd133Uox3Nbti2KYbcA=; b=O/thmgEuFjqiCCxDaHVpXdkhGf+JjhuREtBKRNV+b/zNWqUWWNBFRvTehI55NfVxxRRn y6lAgcpAMDl5nRKKibXREaosPIomeQPa3fgRoOhxyGlZ02sfA//iDdiegi88NlB3I5cJ xTh4/+ZMesz69hu1hi1s5vERDotPbvGKwImtbjTiuGV+Sw4Pw1CwRbFSKotoeRqBsm25 H80o3UAg7a5VbBYEHgJOkw+TExDhGOCpKNLowGcxqOJjdhkOUVwOJ74fITyIvDJR4sJA Pk4gUGsoKaMsGxvdT2/OQT/WIYw6ryIB0czFy3CWhnoxy4r+iyFeOJbY8PPG9Tlm9XSp 6g== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com with ESMTP id 35tq2udyqk-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 05 Jan 2021 00:57:49 -0800 Received: from SC-EXCH01.marvell.com (10.93.176.81) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 5 Jan 2021 00:57:48 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 5 Jan 2021 00:57:47 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 5 Jan 2021 00:57:47 -0800 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id E06363F7040; Tue, 5 Jan 2021 00:57:45 -0800 (PST) From: Nithin Dabilpuram To: Cristian Dumitrescu CC: , , Nithin Dabilpuram Date: Tue, 5 Jan 2021 14:27:29 +0530 Message-ID: <20210105085729.2814-2-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20210105085729.2814-1-ndabilpuram@marvell.com> References: <20201214102835.19980-1-ndabilpuram@marvell.com> <20210105085729.2814-1-ndabilpuram@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2021-01-05_01:2021-01-05, 2021-01-05 signatures=0 Subject: [dpdk-dev] [PATCH v2 2/2] bitmap: modify bitmap not empty API for 128B cacheline X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Currently bitmap line not empty check API assumes cache line of 64B and only checks 8 slabs. Since in 128B cacheline, we have 16 slabs per cacheline, rte_bitmap_clear() will mark complete line as empty as soon as 8 slabs are empty thereby breaking bitmap scan functionality. Fix it by defining new __rte_bitmap_line_not_empty() for 128B cacheline platform. Signed-off-by: Nithin Dabilpuram Acked-by: Cristian Dumitrescu --- v2: - Fix issue with commit message and add acked-by from Cristian. lib/librte_eal/include/rte_bitmap.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/librte_eal/include/rte_bitmap.h b/lib/librte_eal/include/rte_bitmap.h index 7c90ef3..d9a1b54 100644 --- a/lib/librte_eal/include/rte_bitmap.h +++ b/lib/librte_eal/include/rte_bitmap.h @@ -417,6 +417,7 @@ rte_bitmap_set_slab(struct rte_bitmap *bmp, uint32_t pos, uint64_t slab) *slab1 |= 1llu << offset1; } +#if RTE_BITMAP_CL_SLAB_SIZE == 8 static inline uint64_t __rte_bitmap_line_not_empty(uint64_t *slab2) { @@ -432,6 +433,30 @@ __rte_bitmap_line_not_empty(uint64_t *slab2) return v1 | v3; } +#elif RTE_BITMAP_CL_SLAB_SIZE == 16 +static inline uint64_t +__rte_bitmap_line_not_empty(uint64_t *slab2) +{ + uint64_t v1, v2, v3, v4, v5, v6, v7, v8; + + v1 = slab2[0] | slab2[1]; + v2 = slab2[2] | slab2[3]; + v3 = slab2[4] | slab2[5]; + v4 = slab2[6] | slab2[7]; + v5 = slab2[8] | slab2[9]; + v6 = slab2[10] | slab2[11]; + v7 = slab2[12] | slab2[13]; + v8 = slab2[14] | slab2[15]; + v1 |= v2; + v3 |= v4; + v5 |= v6; + v7 |= v8; + + return v1 | v3 | v5 | v7; +} + +#endif + /** * Bitmap bit clear *