All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.1 v3 0/1] selftests: bpf: fix test_lru_sanity3
@ 2026-09-25 15:27 Eva Kurchatova
  2026-09-25 15:27 ` [Devel] [PATCH hci-8.1 v3 1/1] selftests: bpf: size the map in test_lru_sanity3 to whole refills Eva Kurchatova
  2026-09-25 17:26 ` [Devel] [PATCH hci-8.1 v3 0/1] selftests: bpf: fix test_lru_sanity3 Konstantin Khorenko
  0 siblings, 2 replies; 4+ messages in thread
From: Eva Kurchatova @ 2026-09-25 15:27 UTC (permalink / raw)
  To: khorenko; +Cc: devel

Patchset for tast https://virtuozzo.atlassian.net/browse/VSTOR-139677

Changes in v3:
- Skip the test where __tgt_size(tgt_free) is 0 instead of forcing
  batch_size to 1. With one element per refill the forced shrink on the
  last insert evicts a live key, so v2 failed above 128 cpus, where the
  original test still passed by degenerating.
- Drop assert(__tgt_size(map_size) == batch_size), it holds for every
  batch_size and cpu count and checked nothing.
- Cut the comment above map_size to one line.
- Reword to better understand the cause of the failure.
- Sent alone, the rest of the v2 series is merged.

Link to v2: https://lists.openvz.org/pipermail/devel/2026-September/084969.html

Changes in v2:
- Single spaces in the message, the code is unchanged.

Link to v1: https://lists.openvz.org/pipermail/devel/2026-August/084690.html

Eva Kurchatova (1):
  selftests: bpf: size the map in test_lru_sanity3 to whole refills

 tools/testing/selftests/bpf/test_lru_map.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

-- 
2.55.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Devel] [PATCH hci-8.1 v3 1/1] selftests: bpf: size the map in test_lru_sanity3 to whole refills
  2026-09-25 15:27 [Devel] [PATCH hci-8.1 v3 0/1] selftests: bpf: fix test_lru_sanity3 Eva Kurchatova
@ 2026-09-25 15:27 ` Eva Kurchatova
  2026-09-25 17:16   ` Konstantin Khorenko
  2026-09-25 17:26 ` [Devel] [PATCH hci-8.1 v3 0/1] selftests: bpf: fix test_lru_sanity3 Konstantin Khorenko
  1 sibling, 1 reply; 4+ messages in thread
From: Eva Kurchatova @ 2026-09-25 15:27 UTC (permalink / raw)
  To: khorenko; +Cc: devel

test_lru_sanity3 fills a map of tgt_free * 2 elements, and then reads
back all but the last few. Whether that passes depends on the cpu
count alone; on a machine with six it does not:

  test_lru_sanity3 (map_type:9 map_flags:0x0): test_lru_map.c:463:
  test_lru_sanity3: Assertion `!bpf_map_lookup_elem_with_ref_bit(
  lru_map_fd, key, value)' failed.

The kernel hands elements out in refills of lru->target_free, which is
clamp((size / nr_cpus) / 2, 1, LOCAL_FREE_TARGET), that is 128 / nr_cpus
rounded down. A refill the global free list cannot satisfy in full
calls __bpf_lru_list_shrink() for the remainder, and that evicts live
elements. Filling the map therefore evicts nothing only when computed
128 / nr_cpus is a power of two. Any other nr_cpus variation fails.

batch_size is already __tgt_size(tgt_free), the refill size of a map
is __map_size(batch_size) elements, so size the map that way and the
fill consumes whole refills. Start the keys of the last insert at
map_size + 1, just past the new size.

Above 128 cpus __tgt_size(tgt_free) is 0 and there is no size to build
on. Skip the test there.

Fixes: 5e9388f7984a ("selftests/bpf: adapt one more case in test_lru_map to the new target_free")

https://virtuozzo.atlassian.net/browse/VSTOR-139677
Feature: fix selftests

Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 tools/testing/selftests/bpf/test_lru_map.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/test_lru_map.c b/tools/testing/selftests/bpf/test_lru_map.c
index 0921939532c6..84e9a930471a 100644
--- a/tools/testing/selftests/bpf/test_lru_map.c
+++ b/tools/testing/selftests/bpf/test_lru_map.c
@@ -441,8 +441,15 @@ static void test_lru_sanity3(int map_type, int map_flags, unsigned int tgt_free)
 	assert(sched_next_online(0, &next_cpu) != -1);
 
 	batch_size = __tgt_size(tgt_free);
+	if (!batch_size) {
+		/* More cpus than this tgt_free gives a refill for */
+		printf("Skip\n");
+		return;
+	}
+
+	/* A partial refill shrinks the LRU and evicts live elements */
+	map_size = __map_size(batch_size);
 
-	map_size = tgt_free * 2;
 	lru_map_fd = create_map(map_type, map_flags, map_size);
 	assert(lru_map_fd != -1);
 
@@ -466,7 +473,7 @@ static void test_lru_sanity3(int map_type, int map_flags, unsigned int tgt_free)
 	}
 
 	/* Insert new batch_size: replaces the non-referenced elements */
-	key = 2 * tgt_free + 1;
+	key = 1 + map_size;
 	end_key = key + batch_size;
 	for (; key < end_key; key++) {
 		assert(!bpf_map_update_elem(lru_map_fd, &key, value,
-- 
2.55.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Devel] [PATCH hci-8.1 v3 1/1] selftests: bpf: size the map in test_lru_sanity3 to whole refills
  2026-09-25 15:27 ` [Devel] [PATCH hci-8.1 v3 1/1] selftests: bpf: size the map in test_lru_sanity3 to whole refills Eva Kurchatova
@ 2026-09-25 17:16   ` Konstantin Khorenko
  0 siblings, 0 replies; 4+ messages in thread
From: Konstantin Khorenko @ 2026-09-25 17:16 UTC (permalink / raw)
  To: Eva Kurchatova; +Cc: devel

On 9/25/26 17:27, Eva Kurchatova wrote:
> test_lru_sanity3 fills a map of tgt_free * 2 elements, and then reads
> back all but the last few. Whether that passes depends on the cpu
> count alone; on a machine with six it does not:
> 
>   test_lru_sanity3 (map_type:9 map_flags:0x0): test_lru_map.c:463:
>   test_lru_sanity3: Assertion `!bpf_map_lookup_elem_with_ref_bit(
>   lru_map_fd, key, value)' failed.
> 
> The kernel hands elements out in refills of lru->target_free, which is
> clamp((size / nr_cpus) / 2, 1, LOCAL_FREE_TARGET), that is 128 / nr_cpus
> rounded down. A refill the global free list cannot satisfy in full
> calls __bpf_lru_list_shrink() for the remainder, and that evicts live
> elements. Filling the map therefore evicts nothing only when computed
> 128 / nr_cpus is a power of two. Any other nr_cpus variation fails.
> 
> batch_size is already __tgt_size(tgt_free), the refill size of a map
> is __map_size(batch_size) elements, so size the map that way and the
> fill consumes whole refills. Start the keys of the last insert at
> map_size + 1, just past the new size.
> 
> Above 128 cpus __tgt_size(tgt_free) is 0 and there is no size to build
> on. Skip the test there.

  One inaccuracy in the commit message.

  The message says the skip kicks in above 128 cpus. It actually kicks in above 64. The skip fires when __tgt_size(128) =
  (128 / nr_cpus) / 2 reaches zero, and that happens already at 65 cpus: 128 / 65 = 1, then 1 / 2 = 0.

  I think 128 comes from the old map. For the 256-element map the kernel computes target_free as roughly 128 / nr_cpus, and
  that reaches zero only past 128 cpus. But the skip is driven by the test's batch_size, which is roughly 64 / nr_cpus,
  twice smaller.

  The code is fine as is, it tests batch_size == 0 directly. Only the number in the sentence needs fixing, and the same
  "above 128 cpus" appears in the v3 changelog of the cover letter. While at it, the cover letter says "Patchset for tast",
  should be "task".

> 
> Fixes: 5e9388f7984a ("selftests/bpf: adapt one more case in test_lru_map to the new target_free")
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-139677
> Feature: fix selftests
> 
> Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
> ---
>  tools/testing/selftests/bpf/test_lru_map.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/test_lru_map.c b/tools/testing/selftests/bpf/test_lru_map.c
> index 0921939532c6..84e9a930471a 100644
> --- a/tools/testing/selftests/bpf/test_lru_map.c
> +++ b/tools/testing/selftests/bpf/test_lru_map.c
> @@ -441,8 +441,15 @@ static void test_lru_sanity3(int map_type, int map_flags, unsigned int tgt_free)
>  	assert(sched_next_online(0, &next_cpu) != -1);
>  
>  	batch_size = __tgt_size(tgt_free);
> +	if (!batch_size) {
> +		/* More cpus than this tgt_free gives a refill for */
> +		printf("Skip\n");
> +		return;
> +	}
> +
> +	/* A partial refill shrinks the LRU and evicts live elements */
> +	map_size = __map_size(batch_size);
>  
> -	map_size = tgt_free * 2;
>  	lru_map_fd = create_map(map_type, map_flags, map_size);
>  	assert(lru_map_fd != -1);
>  
> @@ -466,7 +473,7 @@ static void test_lru_sanity3(int map_type, int map_flags, unsigned int tgt_free)
>  	}
>  
>  	/* Insert new batch_size: replaces the non-referenced elements */
> -	key = 2 * tgt_free + 1;
> +	key = 1 + map_size;
>  	end_key = key + batch_size;
>  	for (; key < end_key; key++) {
>  		assert(!bpf_map_update_elem(lru_map_fd, &key, value,

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Devel] [PATCH hci-8.1 v3 0/1] selftests: bpf: fix test_lru_sanity3
  2026-09-25 15:27 [Devel] [PATCH hci-8.1 v3 0/1] selftests: bpf: fix test_lru_sanity3 Eva Kurchatova
  2026-09-25 15:27 ` [Devel] [PATCH hci-8.1 v3 1/1] selftests: bpf: size the map in test_lru_sanity3 to whole refills Eva Kurchatova
@ 2026-09-25 17:26 ` Konstantin Khorenko
  1 sibling, 0 replies; 4+ messages in thread
From: Konstantin Khorenko @ 2026-09-25 17:26 UTC (permalink / raw)
  To: Eva Kurchatova; +Cc: devel

On Fri, 25 Sep 2026 18:27:54 +0300, Eva Kurchatova wrote:
> selftests: bpf: fix test_lru_sanity3
> 
> Patchset for tast https://virtuozzo.atlassian.net/browse/VSTOR-139677
> 
> Changes in v3:
> - Skip the test where __tgt_size(tgt_free) is 0 instead of forcing
>   batch_size to 1. With one element per refill the forced shrink on the
>   last insert evicts a live key, so v2 failed above 128 cpus, where the
>   original test still passed by degenerating.
> - Drop assert(__tgt_size(map_size) == batch_size), it holds for every
>   batch_size and cpu count and checked nothing.
> - Cut the comment above map_size to one line.
> - Reword to better understand the cause of the failure.
> - Sent alone, the rest of the v2 series is merged.
> 
> [...]

Applied to branch-rh10-6.12.0-211.52.1.22.x.vz10-ovz, will be released in rh10-6.12.0-211.52.1.22.4.vz10, thanks!

[1/1] selftests: bpf: size the map in test_lru_sanity3 to whole refills
      https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/34899b07b40f

-- 
Konstantin Khorenko <khorenko@virtuozzo.com>

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-25 17:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-25 15:27 [Devel] [PATCH hci-8.1 v3 0/1] selftests: bpf: fix test_lru_sanity3 Eva Kurchatova
2026-09-25 15:27 ` [Devel] [PATCH hci-8.1 v3 1/1] selftests: bpf: size the map in test_lru_sanity3 to whole refills Eva Kurchatova
2026-09-25 17:16   ` Konstantin Khorenko
2026-09-25 17:26 ` [Devel] [PATCH hci-8.1 v3 0/1] selftests: bpf: fix test_lru_sanity3 Konstantin Khorenko

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.