Commit 97cc8f18 authored by Brendan Gregg's avatar Brendan Gregg Committed by Alastair Robertson

handle older kernels that lack the per-CPU hash

parent 2ced3ad2
#include <iostream>
#include <unistd.h>
#include <linux/version.h>
#include "common.h"
#include "libbpf.h"
......@@ -21,8 +22,11 @@ Map::Map(const std::string &name, const SizedType &type, const MapKey &key)
key_size = 8;
enum bpf_map_type map_type;
if (type.type == Type::quantize || type.type == Type::count)
map_type = BPF_MAP_TYPE_PERCPU_HASH;
if ((type.type == Type::quantize || type.type == Type::count) &&
(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)))
{
map_type = BPF_MAP_TYPE_PERCPU_HASH;
}
else
map_type = BPF_MAP_TYPE_HASH;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment