Skip to contentSkip to conversation

lib/crc_kunit.c: update comment in crc_benchmark()

PATCH In review Eric Biggers 1 participant 2 messages Mar 5, 2025 – Mar 6, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/crc_kunit.c: update comment in crc_benchmark()

From: Eric Biggers <[email protected]>

None of the CRC library functions use __pure anymore, so the comment in crc_benchmark() is outdated. But the comment was not really correct anyway, since the CRC computation could (in principle) be optimized out regardless of __pure. Update the comment to have a proper explanation.

---
 lib/crc_kunit.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
lib/crc_kunit.c +3 -2
index 40b4b41f2184..d5a5045fd9ab 100644
@@ -222,12 +222,13 @@ crc_benchmark(struct kunit *test,
 	static const size_t lens_to_test[] = {
 		1, 16, 64, 127, 128, 200, 256, 511, 512, 1024, 3173, 4096, 16384,
 	};
 	size_t len, i, j, num_iters;
 	/*
-	 * Some of the CRC library functions are marked as __pure, so use
-	 * volatile to ensure that all calls are really made as intended.
+	 * The CRC value that this function computes in a series of calls to
+	 * crc_func is never actually used, so use volatile to ensure that the
+	 * computations are done as intended and don't all get optimized out.
 	 */
 	volatile u64 crc = 0;
 	u64 t;
 
 	if (!IS_ENABLED(CONFIG_CRC_BENCHMARK))

base-commit: 13f3d13d88b5dcba104a204fcbee61c75f8407d0

Signature · 1 line
2.48.1
#1 lore raw
Quoted 11 lines · Eric Biggers

From: Eric Biggers <[email protected]>

None of the CRC library functions use __pure anymore, so the comment in crc_benchmark() is outdated. But the comment was not really correct anyway, since the CRC computation could (in principle) be optimized out regardless of __pure. Update the comment to have a proper explanation.

---
 lib/crc_kunit.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Applied to
https://web.git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=crc-next

- Eric