bpf: lru: Cleanup test_lru_map.c
authorMartin KaFai Lau <kafai@fb.com>
Fri, 14 Apr 2017 17:30:26 +0000 (10:30 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 17 Apr 2017 17:55:52 +0000 (13:55 -0400)
This patch does the following cleanup on test_lru_map.c
1) Fix indentation (Replace spaces by tabs)
2) Remove redundant BPF_F_NO_COMMON_LRU test
3) Simplify some comments

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/bpf/test_lru_map.c

index 04b2242937cce9f89e010d1b15e3030180278b7f..87c05e5bdfdda217c5b845048b58f18eca4ee44f 100644 (file)
@@ -191,12 +191,7 @@ static void test_lru_sanity1(int map_type, int map_flags, unsigned int tgt_free)
        int next_cpu = 0;
 
        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;
 
        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++) {
                assert(!bpf_map_lookup_elem(lru_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
@@ -273,12 +268,7 @@ static void test_lru_sanity2(int map_type, int map_flags, unsigned int tgt_free)
        int next_cpu = 0;
 
        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;
 
        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);
 
        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);
 
        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(value[0] == 4321);
                assert(!bpf_map_update_elem(expected_map_fd, &key, value,
-                                           BPF_NOEXIST));
+                                           BPF_NOEXIST));
        }
 
        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,
                                            BPF_NOEXIST));
                assert(!bpf_map_update_elem(expected_map_fd, &key, value,
-                                           BPF_NOEXIST));
+                                           BPF_NOEXIST));
        }
 
        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++) {
                assert(!bpf_map_lookup_elem(lru_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
@@ -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,
                                            BPF_NOEXIST));
                assert(!bpf_map_update_elem(expected_map_fd, &key, value,
-                                           BPF_NOEXIST));
+                                           BPF_NOEXIST));
        }
 
        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,
                                            BPF_NOEXIST));
                assert(!bpf_map_update_elem(expected_map_fd, &key, value,
-                                           BPF_NOEXIST));
+                                           BPF_NOEXIST));
        }
 
        assert(map_equal(lru_map_fd, expected_map_fd));