All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nithin Dabilpuram <ndabilpuram@marvell.com>
To: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Cc: <jerinj@marvell.com>, <dev@dpdk.org>,
	Nithin Dabilpuram <ndabilpuram@marvell.com>
Subject: [dpdk-dev] [PATCH 1/2] test/bitmap: add test case to scan after half cline is cleared
Date: Mon, 14 Dec 2020 15:58:34 +0530	[thread overview]
Message-ID: <20201214102835.19980-1-ndabilpuram@marvell.com> (raw)

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 <ndabilpuram@marvell.com>
---
 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;
 }
 
-- 
2.8.4


             reply	other threads:[~2020-12-14 10:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-14 10:28 Nithin Dabilpuram [this message]
2020-12-14 10:28 ` [dpdk-dev] [PATCH 2/2] bitmap: fix bitmap not empty API for 128B cacheline Nithin Dabilpuram
2021-01-04 11:09   ` Dumitrescu, Cristian
2021-01-05  8:57 ` [dpdk-dev] [PATCH v2 1/2] test/bitmap: test scan after half cline is cleared Nithin Dabilpuram
2021-01-05  8:57   ` [dpdk-dev] [PATCH v2 2/2] bitmap: modify bitmap not empty API for 128B cacheline Nithin Dabilpuram
2021-01-17 21:48     ` 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=20201214102835.19980-1-ndabilpuram@marvell.com \
    --to=ndabilpuram@marvell.com \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.