• Martin KaFai Lau's avatar
    bpf: Add tests for the LRU bpf_htab · 5db58faf
    Martin KaFai Lau authored
    This patch has some unit tests and a test_lru_dist.
    
    The test_lru_dist reads in the numeric keys from a file.
    The files used here are generated by a modified fio-genzipf tool
    originated from the fio test suit.  The sample data file can be
    found here: https://github.com/iamkafai/bpf-lru
    
    The zipf.* data files have 100k numeric keys and the key is also
    ranged from 1 to 100k.
    
    The test_lru_dist outputs the number of unique keys (nr_unique).
    F.e. The following means, 61239 of them is unique out of 100k keys.
    nr_misses means it cannot be found in the LRU map, so nr_misses
    must be >= nr_unique. test_lru_dist also simulates a perfect LRU
    map as a comparison:
    
    [root@arch-fb-vm1 ~]# ~/devshare/fb-kernel/linux/samples/bpf/test_lru_dist \
    /root/zipf.100k.a1_01.out 4000 1
    ...
    test_parallel_lru_dist (map_type:9 map_flags:0x0):
        task:0 BPF LRU: nr_unique:23093(/100000) nr_misses:31603(/100000)
        task:0 Perfect LRU: nr_unique:23093(/100000 nr_misses:34328(/100000)
    ....
    test_paral...
    5db58faf
Makefile 5.33 KB