1
0
Fork 0
alistair23-linux/samples/bpf
brakmo 4ffd44cfd1 bpf: HBM test script
Script for testing HBM (Host Bandwidth Manager) framework.
It creates a cgroup to use for testing and load a BPF program to limit
egress bandwidht. It then uses iperf3 or netperf to create
loads. The output is the goodput in Mbps (unless -D is used).

It can work on a single host using loopback or among two hosts (with netperf).
When using loopback, it is recommended to also introduce a delay of at least
1ms (-d=1), otherwise the assigned bandwidth is likely to be underutilized.

USAGE: $name [out] [-b=<prog>|--bpf=<prog>] [-c=<cc>|--cc=<cc>] [-D]
             [-d=<delay>|--delay=<delay>] [--debug] [-E]
             [-f=<#flows>|--flows=<#flows>] [-h] [-i=<id>|--id=<id >] [-l]
	     [-N] [-p=<port>|--port=<port>] [-P] [-q=<qdisc>]
             [-R] [-s=<server>|--server=<server] [--stats]
	     [-t=<time>|--time=<time>] [-w] [cubic|dctcp]
  Where:
    out               Egress (default egress)
    -b or --bpf       BPF program filename to load and attach.
                      Default is nrm_out_kern.o for egress,
    -c or -cc         TCP congestion control (cubic or dctcp)
    -d or --delay     Add a delay in ms using netem
    -D                In addition to the goodput in Mbps, it also outputs
                      other detailed information. This information is
                      test dependent (i.e. iperf3 or netperf).
    --debug           Print BPF trace buffer
    -E                Enable ECN (not required for dctcp)
    -f or --flows     Number of concurrent flows (default=1)
    -i or --id        cgroup id (an integer, default is 1)
    -l                Do not limit flows using loopback
    -N                Use netperf instead of iperf3
    -h                Help
    -p or --port      iperf3 port (default is 5201)
    -P                Use an iperf3 instance for each flow
    -q                Use the specified qdisc.
    -r or --rate      Rate in Mbps (default 1s 1Gbps)
    -R                Use TCP_RR for netperf. 1st flow has req
                      size of 10KB, rest of 1MB. Reply in all
                      cases is 1 byte.
                      More detailed output for each flow can be found
                      in the files netperf.<cg>.<flow>, where <cg> is the
                      cgroup id as specified with the -i flag, and <flow>
                      is the flow id starting at 1 and increasing by 1 for
                      flow (as specified by -f).
    -s or --server    hostname of netperf server. Used to create netperf
                      test traffic between to hosts (default is within host)
                      netserver must be running on the host.
    --stats           Get HBM stats (marked, dropped, etc.)
    -t or --time      duration of iperf3 in seconds (default=5)
    -w                Work conserving flag. cgroup can increase its
                      bandwidth beyond the rate limit specified
                      while there is available bandwidth. Current
                      implementation assumes there is only one NIC
                      (eth0), but can be extended to support multiple
                      NICs. This is just a proof of concept.
    cubic or dctcp    specify TCP CC to use

Examples:
 ./do_hbm_test.sh -l -d=1 -D --stats
     Runs a 5 second test, using a single iperf3 flow and with the default
     rate limit of 1Gbps and a delay of 1ms (using netem) using the default
     TCP congestion control on the loopback device (hence we use "-l" to
     enforce bandwidth limit on loopback device). Since no direction is
     specified, it defaults to egress. Since no TCP CC algorithm is
     specified it uses the system default (Cubic for this test).
     With no -D flag, only the value of the AGGREGATE OUTPUT would show.
     id refers to the cgroup id and is useful when running multi cgroup
     tests (supported by a future patch).
     This patchset does not support calling TCP's congesion window
     reduction, even when packets are dropped by the BPF program, resulting
     in a large number of packets dropped. It is recommended that the  current
     HBM implemenation only be used with ECN enabled flows. A future patch
     will add support for reducing TCP's cwnd and will increase the
     performance of non-ECN enabled flows.
   Output:
     Details for HBM in cgroup 1
     id:1
     rate_mbps:493
     duration:4.8 secs
     packets:11355
     bytes_MB:590
     pkts_dropped:4497
     bytes_dropped_MB:292
     pkts_marked_percent: 39.60
     bytes_marked_percent: 49.49
     pkts_dropped_percent: 39.60
     bytes_dropped_percent: 49.49
     PING AVG DELAY:2.075
     AGGREGATE_GOODPUT:505

./do_nrm_test.sh -l -d=1 -D --stats dctcp
     Same as above but using dctcp. Note that fewer bytes are dropped
     (0.01% vs. 49%).
   Output:
     Details for HBM in cgroup 1
     id:1
     rate_mbps:945
     duration:4.9 secs
     packets:16859
     bytes_MB:578
     pkts_dropped:1
     bytes_dropped_MB:0
     pkts_marked_percent: 28.74
     bytes_marked_percent: 45.15
     pkts_dropped_percent:  0.01
     bytes_dropped_percent:  0.01
     PING AVG DELAY:2.083
     AGGREGATE_GOODPUT:965

./do_nrm_test.sh -d=1 -D --stats
     As first example, but without limiting loopback device (i.e. no
     "-l" flag). Since there is no bandwidth limiting, no details for
     HBM are printed out.
   Output:
     Details for HBM in cgroup 1
     PING AVG DELAY:2.019
     AGGREGATE_GOODPUT:42655

./do_hbm.sh -l -d=1 -D --stats -f=2
     Uses iper3 and does 2 flows
./do_hbm.sh -l -d=1 -D --stats -f=4 -P
     Uses iperf3 and does 4 flows, each flow as a separate process.
./do_hbm.sh -l -d=1 -D --stats -f=4 -N
     Uses netperf, 4 flows
./do_hbm.sh -f=1 -r=2000 -t=5 -N -D --stats dctcp -s=<server-name>
     Uses netperf between two hosts. The remote host name is specified
     with -s= and you need to start the program netserver manually on
     the remote host. It will use 1 flow, a rate limit of 2Gbps and dctcp.
./do_hbm.sh -f=1 -r=2000 -t=5 -N -D --stats -w dctcp \
     -s=<server-name>
     As previous, but allows use of extra bandwidth. For this test the
     rate is 8Gbps vs. 1Gbps of the previous test.

Signed-off-by: Lawrence Brakmo <brakmo@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2019-03-02 10:48:27 -08:00
..
.gitignore samples: bpf: remove load_sock_ops in favour of bpftool 2019-03-01 00:53:45 +01:00
Makefile bpf: User program for testing HBM 2019-03-02 10:48:27 -08:00
README.rst samples/bpf: Add documentation on cross compilation 2017-09-21 11:59:16 -07:00
asm_goto_workaround.h samples/bpf: workaround clang asm goto compilation errors 2019-01-15 20:57:30 +01:00
bpf_insn.h selftests: bpf: functional and min/max reasoning unit tests for JMP32 2019-01-26 13:33:02 -08:00
bpf_load.c samples: bpf: fix: seg fault with NULL pointer arg 2018-12-03 23:58:03 +01:00
bpf_load.h samples: bpf: include bpf/bpf.h instead of local libbpf.h 2018-05-14 22:52:10 -07:00
cookie_uid_helper_example.c samples: bpf: rename libbpf.h to bpf_insn.h 2018-05-14 22:52:10 -07:00
cpustat_kern.c samples/bpf: Add program for CPU state statistics 2018-02-26 10:54:02 +01:00
cpustat_user.c samples: bpf: include bpf/bpf.h instead of local libbpf.h 2018-05-14 22:52:10 -07:00
do_hbm_test.sh bpf: HBM test script 2019-03-02 10:48:27 -08:00
fds_example.c samples: bpf: use libbpf where easy 2019-03-01 00:53:45 +01:00
hash_func01.h samples/bpf: add Paul Hsieh's (LGPL 2.1) hash function SuperFastHash 2018-08-10 16:07:49 +02:00
hbm.c bpf: User program for testing HBM 2019-03-02 10:48:27 -08:00
hbm.h bpf: Sample HBM BPF program to limit egress bw 2019-03-02 10:48:27 -08:00
hbm_kern.h bpf: Sample HBM BPF program to limit egress bw 2019-03-02 10:48:27 -08:00
hbm_out_kern.c bpf: Sample HBM BPF program to limit egress bw 2019-03-02 10:48:27 -08:00
lathist_kern.c bpf: BPF based latency tracing 2015-06-23 06:09:58 -07:00
lathist_user.c samples: bpf: include bpf/bpf.h instead of local libbpf.h 2018-05-14 22:52:10 -07:00
lwt_len_hist.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
lwt_len_hist_kern.c bpf: Add tests and samples for LWT-BPF 2016-12-02 10:52:00 -05:00
lwt_len_hist_user.c samples: bpf: include bpf/bpf.h instead of local libbpf.h 2018-05-14 22:52:10 -07:00
map_perf_test_kern.c samples/bpf: Use getppid instead of getpgrp for array map stress 2017-09-21 11:59:16 -07:00
map_perf_test_user.c samples: bpf: include bpf/bpf.h instead of local libbpf.h 2018-05-14 22:52:10 -07:00
offwaketime_kern.c bpf, samples: don't zero data when not needed 2016-04-14 21:40:42 -04:00
offwaketime_user.c samples/bpf: move common-purpose trace functions to selftests 2018-04-29 08:45:54 -07:00
parse_ldabs.c bpf: fix samples to add fake KBUILD_MODNAME 2016-10-29 14:46:12 -04:00
parse_simple.c bpf: fix samples to add fake KBUILD_MODNAME 2016-10-29 14:46:12 -04:00
parse_varlen.c samples/bpf: add missing <linux/if_vlan.h> 2018-07-05 09:58:52 +02:00
run_cookie_uid_helper_example.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sampleip_kern.c bpf/samples: Fix PT_REGS_IP on s390x and use it 2016-11-28 16:26:46 -05:00
sampleip_user.c samples/bpf: remove duplicated includes 2018-09-18 17:49:33 +02:00
sock_example.c samples: bpf: force IPv4 in ping 2019-03-01 00:53:45 +01:00
sock_example.h samples: bpf: include bpf/bpf.h instead of local libbpf.h 2018-05-14 22:52:10 -07:00
sock_flags_kern.c samples/bpf: Update cgroup socket examples to use uid gid helper 2017-09-01 06:05:15 +01:00
sockex1_kern.c samples: bpf: add skb->field examples and tests 2015-03-15 22:02:28 -04:00
sockex1_user.c samples: bpf: use libbpf where easy 2019-03-01 00:53:45 +01:00
sockex2_kern.c samples/bpf: fix compilation failure 2018-09-21 22:51:16 +02:00
sockex2_user.c samples: bpf: use libbpf where easy 2019-03-01 00:53:45 +01:00
sockex3_kern.c samples/bpf: fix compilation failure 2018-09-21 22:51:16 +02:00
sockex3_user.c samples: bpf: force IPv4 in ping 2019-03-01 00:53:45 +01:00
spintest_kern.c samples/bpf: Enable powerpc support 2016-04-06 16:01:29 -04:00
spintest_user.c samples/bpf: move common-purpose trace functions to selftests 2018-04-29 08:45:54 -07:00
syscall_nrs.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
syscall_tp_kern.c bpf: add a test case for syscalls/sys_{enter|exit}_* tracepoints 2017-08-07 14:09:48 -07:00
syscall_tp_user.c samples: bpf: include bpf/bpf.h instead of local libbpf.h 2018-05-14 22:52:10 -07:00
task_fd_query_kern.c samples: bpf: fix: broken sample regarding removed function 2019-02-27 17:27:22 +01:00
task_fd_query_user.c samples: bpf: fix: broken sample regarding removed function 2019-02-27 17:27:22 +01:00
tc_l2_redirect.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
tc_l2_redirect_kern.c bpf: fix samples xdp_tx_iptunnel and tc_l2_redirect with fake KBUILD_MODNAME 2017-01-20 12:04:07 -05:00
tc_l2_redirect_user.c samples: bpf: include bpf/bpf.h instead of local libbpf.h 2018-05-14 22:52:10 -07:00
tcbpf1_kern.c bpf: fix samples to add fake KBUILD_MODNAME 2016-10-29 14:46:12 -04:00
tcp_basertt_kern.c samples: bpf: remove load_sock_ops in favour of bpftool 2019-03-01 00:53:45 +01:00
tcp_bpf.readme samples: bpf: remove load_sock_ops in favour of bpftool 2019-03-01 00:53:45 +01:00
tcp_bufs_kern.c samples: bpf: remove load_sock_ops in favour of bpftool 2019-03-01 00:53:45 +01:00
tcp_clamp_kern.c samples: bpf: remove load_sock_ops in favour of bpftool 2019-03-01 00:53:45 +01:00
tcp_cong_kern.c samples: bpf: remove load_sock_ops in favour of bpftool 2019-03-01 00:53:45 +01:00
tcp_iw_kern.c samples: bpf: remove load_sock_ops in favour of bpftool 2019-03-01 00:53:45 +01:00
tcp_rwnd_kern.c samples: bpf: remove load_sock_ops in favour of bpftool 2019-03-01 00:53:45 +01:00
tcp_synrto_kern.c samples: bpf: remove load_sock_ops in favour of bpftool 2019-03-01 00:53:45 +01:00
tcp_tos_reflect_kern.c samples: bpf: remove load_sock_ops in favour of bpftool 2019-03-01 00:53:45 +01:00
test_cgrp2_array_pin.c samples: bpf: include bpf/bpf.h instead of local libbpf.h 2018-05-14 22:52:10 -07:00
test_cgrp2_attach.c samples: bpf: rename libbpf.h to bpf_insn.h 2018-05-14 22:52:10 -07:00
test_cgrp2_attach2.c selftests/bpf: fix incorrect users of create_and_get_cgroup 2019-01-07 13:15:55 -08:00
test_cgrp2_sock.c samples: bpf: rename libbpf.h to bpf_insn.h 2018-05-14 22:52:10 -07:00
test_cgrp2_sock.sh samples/bpf: detach prog from cgroup 2018-03-02 00:16:36 +01:00
test_cgrp2_sock2.c samples/bpf: test_cgrp2_sock2: fix an off by one 2018-07-16 15:01:09 -07:00
test_cgrp2_sock2.sh samples/bpf: detach prog from cgroup 2018-03-02 00:16:36 +01:00
test_cgrp2_tc.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
test_cgrp2_tc_kern.c bpf: fix samples to add fake KBUILD_MODNAME 2016-10-29 14:46:12 -04:00
test_cls_bpf.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
test_current_task_under_cgroup_kern.c samples/bpf: Add test_current_task_under_cgroup test 2016-08-12 21:49:42 -07:00
test_current_task_under_cgroup_user.c selftests/bpf: fix incorrect users of create_and_get_cgroup 2019-01-07 13:15:55 -08:00
test_ipip.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
test_lru_dist.c samples: bpf: include bpf/bpf.h instead of local libbpf.h 2018-05-14 22:52:10 -07:00
test_lwt_bpf.c bpf: Add tests and samples for LWT-BPF 2016-12-02 10:52:00 -05:00
test_lwt_bpf.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
test_map_in_map_kern.c bpf: Add tests for map-in-map 2017-03-22 15:45:45 -07:00
test_map_in_map_user.c samples: bpf: include bpf/bpf.h instead of local libbpf.h 2018-05-14 22:52:10 -07:00
test_overhead_kprobe_kern.c samples/bpf: add tracepoint vs kprobe performance tests 2016-04-07 21:04:27 -04:00
test_overhead_raw_tp_kern.c samples/bpf: raw tracepoint test 2018-03-28 22:55:19 +02:00
test_overhead_tp_kern.c samples/bpf: add tracepoint vs kprobe performance tests 2016-04-07 21:04:27 -04:00
test_overhead_user.c samples/bpf: Check the error of write() and read() 2018-07-05 09:58:52 +02:00
test_override_return.sh samples/bpf: add a test for bpf_override_return 2017-12-12 09:02:40 -08:00
test_probe_write_user_kern.c samples/bpf: Add test/example of using bpf_probe_write_user bpf helper 2016-07-25 18:07:48 -07:00
test_probe_write_user_user.c samples: bpf: include bpf/bpf.h instead of local libbpf.h 2018-05-14 22:52:10 -07:00
trace_event_kern.c samples/bpf: add example to test reading address 2018-03-08 02:22:34 +01:00
trace_event_user.c samples/bpf: Check the result of system() 2018-07-05 09:58:52 +02:00
trace_output_kern.c samples/bpf: fix trace_output example 2016-04-28 17:29:45 -04:00
trace_output_user.c samples: bpf: include bpf/bpf.h instead of local libbpf.h 2018-05-14 22:52:10 -07:00
tracex1_kern.c bpf, samples: don't zero data when not needed 2016-04-14 21:40:42 -04:00
tracex1_user.c samples: bpf: include bpf/bpf.h instead of local libbpf.h 2018-05-14 22:52:10 -07:00
tracex2_kern.c bpf, samples: don't zero data when not needed 2016-04-14 21:40:42 -04:00
tracex2_user.c samples: bpf: force IPv4 in ping 2019-03-01 00:53:45 +01:00
tracex3_kern.c samples: bpf: fix: broken sample regarding removed function 2019-02-27 17:27:22 +01:00
tracex3_user.c bpf, tracex3_user: erase "ARRAY_SIZE" redefined 2018-10-04 16:31:57 +02:00
tracex4_kern.c samples/bpf: Enable powerpc support 2016-04-06 16:01:29 -04:00
tracex4_user.c samples: bpf: include bpf/bpf.h instead of local libbpf.h 2018-05-14 22:52:10 -07:00
tracex5_kern.c samples/bpf: Fix tracex5 to work with MIPS syscalls. 2017-06-14 15:03:23 -04:00
tracex5_user.c samples: bpf: include bpf/bpf.h instead of local libbpf.h 2018-05-14 22:52:10 -07:00
tracex6_kern.c bpf: add a test case for helper bpf_perf_event_read_value 2017-10-07 23:05:57 +01:00
tracex6_user.c samples: bpf: include bpf/bpf.h instead of local libbpf.h 2018-05-14 22:52:10 -07:00
tracex7_kern.c samples/bpf: add a test for bpf_override_return 2017-12-12 09:02:40 -08:00
tracex7_user.c samples: bpf: include bpf/bpf.h instead of local libbpf.h 2018-05-14 22:52:10 -07:00
xdp1_kern.c bpf: make xdp sample variable names more meaningful 2016-07-20 22:07:24 -07:00
xdp1_user.c samples/bpf: Check the prog id before exiting 2019-02-01 23:37:51 +01:00
xdp2_kern.c bpf: make xdp sample variable names more meaningful 2016-07-20 22:07:24 -07:00
xdp2skb_meta.sh samples/bpf: Fix tc and ip paths in xdp2skb_meta.sh 2018-07-10 09:19:01 +02:00
xdp2skb_meta_kern.c samples/bpf: xdp2skb_meta comment explain why pkt-data pointers are invalidated 2018-01-18 01:49:09 +01:00
xdp_adjust_tail_kern.c bpf: add bpf_xdp_adjust_tail sample prog 2018-04-18 23:34:17 +02:00
xdp_adjust_tail_user.c samples/bpf: Check the prog id before exiting 2019-02-01 23:37:51 +01:00
xdp_fwd_kern.c bpf: Change bpf_fib_lookup to return lookup status 2018-06-29 00:02:02 +02:00
xdp_fwd_user.c samples: bpf: convert xdp_fwd_user.c to libbpf 2018-07-27 07:18:44 +02:00
xdp_monitor_kern.c samples/bpf: xdp_monitor use err code from tracepoint xdp:xdp_devmap_xmit 2018-05-24 18:36:15 -07:00
xdp_monitor_user.c samples/bpf: xdp_monitor use err code from tracepoint xdp:xdp_devmap_xmit 2018-05-24 18:36:15 -07:00
xdp_redirect_cpu_kern.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next 2018-08-13 10:07:23 -07:00
xdp_redirect_cpu_user.c samples/bpf: Check the prog id before exiting 2019-02-01 23:37:51 +01:00
xdp_redirect_kern.c samples/bpf: Fix compilation issue in redirect dummy program 2017-08-31 11:56:57 -07:00
xdp_redirect_map_kern.c samples/bpf: Fix compilation issue in redirect dummy program 2017-08-31 11:56:57 -07:00
xdp_redirect_map_user.c samples/bpf: Fix dummy program unloading for xdp_redirect samples 2019-02-22 16:21:59 +01:00
xdp_redirect_user.c samples/bpf: Fix dummy program unloading for xdp_redirect samples 2019-02-22 16:21:59 +01:00
xdp_router_ipv4_kern.c xdp: Sample xdp program implementing ip forward 2017-11-08 10:39:41 +09:00
xdp_router_ipv4_user.c samples/bpf: Check the prog id before exiting 2019-02-01 23:37:51 +01:00
xdp_rxq_info_kern.c samples/bpf: xdp_rxq_info action XDP_TX must adjust MAC-addrs 2018-06-28 23:50:20 +02:00
xdp_rxq_info_user.c samples/bpf: Check the prog id before exiting 2019-02-01 23:37:51 +01:00
xdp_sample_pkts_kern.c samples/bpf: Add xdp_sample_pkts example 2018-06-27 11:01:03 +02:00
xdp_sample_pkts_user.c samples/bpf: Check the prog id before exiting 2019-02-01 23:37:51 +01:00
xdp_tx_iptunnel_common.h bpf: xdp: Add XDP example for head adjustment 2016-12-08 14:25:13 -05:00
xdp_tx_iptunnel_kern.c bpf: fix samples xdp_tx_iptunnel and tc_l2_redirect with fake KBUILD_MODNAME 2017-01-20 12:04:07 -05:00
xdp_tx_iptunnel_user.c samples/bpf: Check the prog id before exiting 2019-02-01 23:37:51 +01:00
xdpsock_user.c samples/bpf: silence compiler warning for xdpsock_user.c 2019-03-02 01:07:10 +01:00

README.rst

eBPF sample programs
====================

This directory contains a test stubs, verifier test-suite and examples
for using eBPF. The examples use libbpf from tools/lib/bpf.

Build dependencies
==================

Compiling requires having installed:
 * clang >= version 3.4.0
 * llvm >= version 3.7.1

Note that LLVM's tool 'llc' must support target 'bpf', list version
and supported targets with command: ``llc --version``

Kernel headers
--------------

There are usually dependencies to header files of the current kernel.
To avoid installing devel kernel headers system wide, as a normal
user, simply call::

 make headers_install

This will creates a local "usr/include" directory in the git/build top
level directory, that the make system automatically pickup first.

Compiling
=========

For building the BPF samples, issue the below command from the kernel
top level directory::

 make samples/bpf/

Do notice the "/" slash after the directory name.

It is also possible to call make from this directory.  This will just
hide the the invocation of make as above with the appended "/".

Manually compiling LLVM with 'bpf' support
------------------------------------------

Since version 3.7.0, LLVM adds a proper LLVM backend target for the
BPF bytecode architecture.

By default llvm will build all non-experimental backends including bpf.
To generate a smaller llc binary one can use::

 -DLLVM_TARGETS_TO_BUILD="BPF"

Quick sniplet for manually compiling LLVM and clang
(build dependencies are cmake and gcc-c++)::

 $ git clone http://llvm.org/git/llvm.git
 $ cd llvm/tools
 $ git clone --depth 1 http://llvm.org/git/clang.git
 $ cd ..; mkdir build; cd build
 $ cmake .. -DLLVM_TARGETS_TO_BUILD="BPF;X86"
 $ make -j $(getconf _NPROCESSORS_ONLN)

It is also possible to point make to the newly compiled 'llc' or
'clang' command via redefining LLC or CLANG on the make command line::

 make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang

Cross compiling samples
-----------------------
In order to cross-compile, say for arm64 targets, export CROSS_COMPILE and ARCH
environment variables before calling make. This will direct make to build
samples for the cross target.

export ARCH=arm64
export CROSS_COMPILE="aarch64-linux-gnu-"
make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang