|
@@ -191,12 +191,7 @@ static void test_lru_sanity1(int map_type, int map_flags, unsigned int tgt_free)
|
|
int next_cpu = 0;
|
|
int next_cpu = 0;
|
|
|
|
|
|
if (map_flags & BPF_F_NO_COMMON_LRU)
|
|
if (map_flags & BPF_F_NO_COMMON_LRU)
|
|
- /* Ther percpu lru list (i.e each cpu has its own LRU
|
|
|
|
- * list) does not have a local free list. Hence,
|
|
|
|
- * it will only free old nodes till there is no free
|
|
|
|
- * from the LRU list. Hence, this test does not apply
|
|
|
|
- * to BPF_F_NO_COMMON_LRU
|
|
|
|
- */
|
|
|
|
|
|
+ /* This test is only applicable to common LRU list */
|
|
return;
|
|
return;
|
|
|
|
|
|
printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type,
|
|
printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type,
|
|
@@ -227,7 +222,7 @@ static void test_lru_sanity1(int map_type, int map_flags, unsigned int tgt_free)
|
|
for (key = 1; key < end_key; key++) {
|
|
for (key = 1; key < end_key; key++) {
|
|
assert(!bpf_map_lookup_elem(lru_map_fd, &key, value));
|
|
assert(!bpf_map_lookup_elem(lru_map_fd, &key, value));
|
|
assert(!bpf_map_update_elem(expected_map_fd, &key, value,
|
|
assert(!bpf_map_update_elem(expected_map_fd, &key, value,
|
|
- BPF_NOEXIST));
|
|
|
|
|
|
+ BPF_NOEXIST));
|
|
}
|
|
}
|
|
|
|
|
|
/* Insert 1+tgt_free to 2*tgt_free
|
|
/* Insert 1+tgt_free to 2*tgt_free
|
|
@@ -273,12 +268,7 @@ static void test_lru_sanity2(int map_type, int map_flags, unsigned int tgt_free)
|
|
int next_cpu = 0;
|
|
int next_cpu = 0;
|
|
|
|
|
|
if (map_flags & BPF_F_NO_COMMON_LRU)
|
|
if (map_flags & BPF_F_NO_COMMON_LRU)
|
|
- /* Ther percpu lru list (i.e each cpu has its own LRU
|
|
|
|
- * list) does not have a local free list. Hence,
|
|
|
|
- * it will only free old nodes till there is no free
|
|
|
|
- * from the LRU list. Hence, this test does not apply
|
|
|
|
- * to BPF_F_NO_COMMON_LRU
|
|
|
|
- */
|
|
|
|
|
|
+ /* This test is only applicable to common LRU list */
|
|
return;
|
|
return;
|
|
|
|
|
|
printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type,
|
|
printf("%s (map_type:%d map_flags:0x%X): ", __func__, map_type,
|
|
@@ -290,11 +280,7 @@ static void test_lru_sanity2(int map_type, int map_flags, unsigned int tgt_free)
|
|
assert(batch_size * 2 == tgt_free);
|
|
assert(batch_size * 2 == tgt_free);
|
|
|
|
|
|
map_size = tgt_free + batch_size;
|
|
map_size = tgt_free + batch_size;
|
|
- if (map_flags & BPF_F_NO_COMMON_LRU)
|
|
|
|
- lru_map_fd = create_map(map_type, map_flags,
|
|
|
|
- map_size * nr_cpus);
|
|
|
|
- else
|
|
|
|
- lru_map_fd = create_map(map_type, map_flags, map_size);
|
|
|
|
|
|
+ lru_map_fd = create_map(map_type, map_flags, map_size);
|
|
assert(lru_map_fd != -1);
|
|
assert(lru_map_fd != -1);
|
|
|
|
|
|
expected_map_fd = create_map(BPF_MAP_TYPE_HASH, 0, map_size);
|
|
expected_map_fd = create_map(BPF_MAP_TYPE_HASH, 0, map_size);
|
|
@@ -341,7 +327,7 @@ static void test_lru_sanity2(int map_type, int map_flags, unsigned int tgt_free)
|
|
assert(!bpf_map_lookup_elem(lru_map_fd, &key, value));
|
|
assert(!bpf_map_lookup_elem(lru_map_fd, &key, value));
|
|
assert(value[0] == 4321);
|
|
assert(value[0] == 4321);
|
|
assert(!bpf_map_update_elem(expected_map_fd, &key, value,
|
|
assert(!bpf_map_update_elem(expected_map_fd, &key, value,
|
|
- BPF_NOEXIST));
|
|
|
|
|
|
+ BPF_NOEXIST));
|
|
}
|
|
}
|
|
|
|
|
|
value[0] = 1234;
|
|
value[0] = 1234;
|
|
@@ -361,7 +347,7 @@ static void test_lru_sanity2(int map_type, int map_flags, unsigned int tgt_free)
|
|
assert(!bpf_map_update_elem(lru_map_fd, &key, value,
|
|
assert(!bpf_map_update_elem(lru_map_fd, &key, value,
|
|
BPF_NOEXIST));
|
|
BPF_NOEXIST));
|
|
assert(!bpf_map_update_elem(expected_map_fd, &key, value,
|
|
assert(!bpf_map_update_elem(expected_map_fd, &key, value,
|
|
- BPF_NOEXIST));
|
|
|
|
|
|
+ BPF_NOEXIST));
|
|
}
|
|
}
|
|
|
|
|
|
assert(map_equal(lru_map_fd, expected_map_fd));
|
|
assert(map_equal(lru_map_fd, expected_map_fd));
|
|
@@ -419,7 +405,7 @@ static void test_lru_sanity3(int map_type, int map_flags, unsigned int tgt_free)
|
|
for (key = 1; key < end_key; key++) {
|
|
for (key = 1; key < end_key; key++) {
|
|
assert(!bpf_map_lookup_elem(lru_map_fd, &key, value));
|
|
assert(!bpf_map_lookup_elem(lru_map_fd, &key, value));
|
|
assert(!bpf_map_update_elem(expected_map_fd, &key, value,
|
|
assert(!bpf_map_update_elem(expected_map_fd, &key, value,
|
|
- BPF_NOEXIST));
|
|
|
|
|
|
+ BPF_NOEXIST));
|
|
}
|
|
}
|
|
|
|
|
|
/* Add 1+2*tgt_free to tgt_free*5/2
|
|
/* Add 1+2*tgt_free to tgt_free*5/2
|
|
@@ -431,7 +417,7 @@ static void test_lru_sanity3(int map_type, int map_flags, unsigned int tgt_free)
|
|
assert(!bpf_map_update_elem(lru_map_fd, &key, value,
|
|
assert(!bpf_map_update_elem(lru_map_fd, &key, value,
|
|
BPF_NOEXIST));
|
|
BPF_NOEXIST));
|
|
assert(!bpf_map_update_elem(expected_map_fd, &key, value,
|
|
assert(!bpf_map_update_elem(expected_map_fd, &key, value,
|
|
- BPF_NOEXIST));
|
|
|
|
|
|
+ BPF_NOEXIST));
|
|
}
|
|
}
|
|
|
|
|
|
assert(map_equal(lru_map_fd, expected_map_fd));
|
|
assert(map_equal(lru_map_fd, expected_map_fd));
|
|
@@ -491,7 +477,7 @@ static void test_lru_sanity4(int map_type, int map_flags, unsigned int tgt_free)
|
|
assert(!bpf_map_update_elem(lru_map_fd, &key, value,
|
|
assert(!bpf_map_update_elem(lru_map_fd, &key, value,
|
|
BPF_NOEXIST));
|
|
BPF_NOEXIST));
|
|
assert(!bpf_map_update_elem(expected_map_fd, &key, value,
|
|
assert(!bpf_map_update_elem(expected_map_fd, &key, value,
|
|
- BPF_NOEXIST));
|
|
|
|
|
|
+ BPF_NOEXIST));
|
|
}
|
|
}
|
|
|
|
|
|
assert(map_equal(lru_map_fd, expected_map_fd));
|
|
assert(map_equal(lru_map_fd, expected_map_fd));
|