1. 14 5月, 2018 1 次提交
  2. 29 3月, 2018 1 次提交
  3. 26 2月, 2018 1 次提交
    • L
      samples/bpf: Add program for CPU state statistics · c5350777
      Leo Yan 提交于
      CPU is active when have running tasks on it and CPUFreq governor can
      select different operating points (OPP) according to different workload;
      we use 'pstate' to present CPU state which have running tasks with one
      specific OPP.  On the other hand, CPU is idle which only idle task on
      it, CPUIdle governor can select one specific idle state to power off
      hardware logics; we use 'cstate' to present CPU idle state.
      
      Based on trace events 'cpu_idle' and 'cpu_frequency' we can accomplish
      the duration statistics for every state.  Every time when CPU enters
      into or exits from idle states, the trace event 'cpu_idle' is recorded;
      trace event 'cpu_frequency' records the event for CPU OPP changing, so
      it's easily to know how long time the CPU stays in the specified OPP,
      and the CPU must be not in any idle state.
      
      This patch is to utilize the mentioned trace events for pstate and
      cstate statistics.  To achieve more accurate profiling data, the program
      uses below sequence to insure CPU running/idle time aren't missed:
      
      - Before profiling the user space program wakes up all CPUs for once, so
        can avoid to missing account time for CPU staying in idle state for
        long time; the program forces to set 'scaling_max_freq' to lowest
        frequency and then restore 'scaling_max_freq' to highest frequency,
        this can ensure the frequency to be set to lowest frequency and later
        after start to run workload the frequency can be easily to be changed
        to higher frequency;
      
      - User space program reads map data and update statistics for every 5s,
        so this is same with other sample bpf programs for avoiding big
        overload introduced by bpf program self;
      
      - When send signal to terminate program, the signal handler wakes up
        all CPUs, set lowest frequency and restore highest frequency to
        'scaling_max_freq'; this is exactly same with the first step so
        avoid to missing account CPU pstate and cstate time during last
        stage.  Finally it reports the latest statistics.
      
      The program has been tested on Hikey board with octa CA53 CPUs, below
      is one example for statistics result, the format mainly follows up
      Jesper Dangaard Brouer suggestion.
      
      Jesper reminds to 'get printf to pretty print with thousands separators
      use %' and setlocale(LC_NUMERIC, "en_US")', tried three different arm64
      GCC toolchains (5.4.0 20160609, 6.2.1 20161016, 6.3.0 20170516) but all
      of them cannot support printf flag character %' on arm64 platform, so go
      back print number without grouping mode.
      
      CPU states statistics:
      state(ms)  cstate-0    cstate-1    cstate-2    pstate-0    pstate-1    pstate-2    pstate-3    pstate-4
      CPU-0      767         6111        111863      561         31          756         853         190
      CPU-1      241         10606       107956      484         125         646         990         85
      CPU-2      413         19721       98735       636         84          696         757         89
      CPU-3      84          11711       79989       17516       909         4811        5773        341
      CPU-4      152         19610       98229       444         53          649         708         1283
      CPU-5      185         8781        108697      666         91          671         677         1365
      CPU-6      157         21964       95825       581         67          566         684         1284
      CPU-7      125         15238       102704      398         20          665         786         1197
      
      Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
      Cc: Vincent Guittot <vincent.guittot@linaro.org>
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      c5350777
  4. 03 2月, 2018 1 次提交
    • E
      libbpf: add error reporting in XDP · bbf48c18
      Eric Leblond 提交于
      Parse netlink ext attribute to get the error message returned by
      the card. Code is partially take from libnl.
      
      We add netlink.h to the uapi include of tools. And we need to
      avoid include of userspace netlink header to have a successful
      build of sample so nlattr.h has a define to avoid
      the inclusion. Using a direct define could have been an issue
      as NLMSGERR_ATTR_MAX can change in the future.
      
      We also define SOL_NETLINK if not defined to avoid to have to
      copy socket.h for a fixed value.
      Signed-off-by: NEric Leblond <eric@regit.org>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      bbf48c18
  5. 27 1月, 2018 1 次提交
  6. 11 1月, 2018 1 次提交
    • J
      samples/bpf: xdp2skb_meta shows transferring info from XDP to SKB · 36e04a2d
      Jesper Dangaard Brouer 提交于
      Creating a bpf sample that shows howto use the XDP 'data_meta'
      infrastructure, created by Daniel Borkmann.  Very few drivers support
      this feature, but I wanted a functional sample to begin with, when
      working on adding driver support.
      
      XDP data_meta is about creating a communication channel between BPF
      programs.  This can be XDP tail-progs, but also other SKB based BPF
      hooks, like in this case the TC clsact hook. In this sample I show
      that XDP can store info named "mark", and TC/clsact chooses to use
      this info and store it into the skb->mark.
      
      It is a bit annoying that XDP and TC samples uses different tools/libs
      when attaching their BPF hooks.  As the XDP and TC programs need to
      cooperate and agree on a struct-layout, it is best/easiest if the two
      programs can be contained within the same BPF restricted-C file.
      
      As the bpf-loader, I choose to not use bpf_load.c (or libbpf), but
      instead wrote a bash shell scripted named xdp2skb_meta.sh, which
      demonstrate howto use the iproute cmdline tools 'tc' and 'ip' for
      loading BPF programs.  To make it easy for first time users, the shell
      script have command line parsing, and support --verbose and --dry-run
      mode, if you just want to see/learn the tc+ip command syntax:
      
       # ./xdp2skb_meta.sh --dev ixgbe2 --dry-run
       # Dry-run mode: enable VERBOSE and don't call TC+IP
       tc qdisc del dev ixgbe2 clsact
       tc qdisc add dev ixgbe2 clsact
       tc filter add dev ixgbe2 ingress prio 1 handle 1 bpf da obj ./xdp2skb_meta_kern.o sec tc_mark
       # Flush XDP on device: ixgbe2
       ip link set dev ixgbe2 xdp off
       ip link set dev ixgbe2 xdp obj ./xdp2skb_meta_kern.o sec xdp_mark
      Signed-off-by: NJesper Dangaard Brouer <brouer@redhat.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      36e04a2d
  7. 06 1月, 2018 1 次提交
    • J
      samples/bpf: program demonstrating access to xdp_rxq_info · 0fca931a
      Jesper Dangaard Brouer 提交于
      This sample program can be used for monitoring and reporting how many
      packets per sec (pps) are received per NIC RX queue index and which
      CPU processed the packet. In itself it is a useful tool for quickly
      identifying RSS imbalance issues, see below.
      
      The default XDP action is XDP_PASS in-order to provide a monitor
      mode. For benchmarking purposes it is possible to specify other XDP
      actions on the cmdline --action.
      
      Output below shows an imbalance RSS case where most RXQ's deliver to
      CPU-0 while CPU-2 only get packets from a single RXQ.  Looking at
      things from a CPU level the two CPUs are processing approx the same
      amount, BUT looking at the rx_queue_index levels it is clear that
      RXQ-2 receive much better service, than other RXQs which all share CPU-0.
      
      Running XDP on dev:i40e1 (ifindex:3) action:XDP_PASS
      XDP stats       CPU     pps         issue-pps
      XDP-RX CPU      0       900,473     0
      XDP-RX CPU      2       906,921     0
      XDP-RX CPU      total   1,807,395
      
      RXQ stats       RXQ:CPU pps         issue-pps
      rx_queue_index    0:0   180,098     0
      rx_queue_index    0:sum 180,098
      rx_queue_index    1:0   180,098     0
      rx_queue_index    1:sum 180,098
      rx_queue_index    2:2   906,921     0
      rx_queue_index    2:sum 906,921
      rx_queue_index    3:0   180,098     0
      rx_queue_index    3:sum 180,098
      rx_queue_index    4:0   180,082     0
      rx_queue_index    4:sum 180,082
      rx_queue_index    5:0   180,093     0
      rx_queue_index    5:sum 180,093
      Signed-off-by: NJesper Dangaard Brouer <brouer@redhat.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      0fca931a
  8. 13 12月, 2017 1 次提交
  9. 18 11月, 2017 1 次提交
  10. 11 11月, 2017 2 次提交
  11. 08 11月, 2017 1 次提交
  12. 05 11月, 2017 1 次提交
  13. 02 11月, 2017 1 次提交
    • G
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman 提交于
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      
      How this work was done:
      
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      
      Further patches will be generated in subsequent months to fix up cases
      where non-standard license headers were used, and references to license
      had to be inferred by heuristics based on keywords.
      
      The analysis to determine which SPDX License Identifier to be applied to
      a file was done in a spreadsheet of side by side results from of the
      output of two independent scanners (ScanCode & Windriver) producing SPDX
      tag:value files created by Philippe Ombredanne.  Philippe prepared the
      base worksheet, and did an initial spot review of a few 1000 files.
      
      The 4.13 kernel was the starting point of the analysis with 60,537 files
      assessed.  Kate Stewart did a file by file comparison of the scanner
      results in the spreadsheet to determine which SPDX license identifier(s)
      to be applied to the file. She confirmed any determination that was not
      immediately clear with lawyers working with the Linux Foundation.
      
      Criteria used to select files for SPDX license identifier tagging was:
       - Files considered eligible had to be source code files.
       - Make and config files were included as candidates if they contained >5
         lines of source
       - File already had some variant of a license header in it (even if <5
         lines).
      
      All documentation files were explicitly excluded.
      
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
      
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
      
         For non */uapi/* files that summary was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0                                              11139
      
         and resulted in the first patch in this series.
      
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0 WITH Linux-syscall-note                        930
      
         and resulted in the second patch in this series.
      
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|------
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
      
         and that resulted in the third patch in this series.
      
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
      
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
      
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
      
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
      
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      Reviewed-by: NKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: NPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318
  14. 22 10月, 2017 1 次提交
  15. 18 10月, 2017 1 次提交
    • J
      samples/bpf: add cpumap sample program xdp_redirect_cpu · fad3917e
      Jesper Dangaard Brouer 提交于
      This sample program show how to use cpumap and the associated
      tracepoints.
      
      It provides command line stats, which shows how the XDP-RX process,
      cpumap-enqueue and cpumap kthread dequeue is cooperating on a per CPU
      basis.  It also utilize the xdp_exception and xdp_redirect_err
      transpoints to allow users quickly to identify setup issues.
      
      One issue with ixgbe driver is that the driver reset the link when
      loading XDP.  This reset the procfs smp_affinity settings.  Thus,
      after loading the program, these must be reconfigured.  The easiest
      workaround it to reduce the RX-queue to e.g. two via:
      
       # ethtool --set-channels ixgbe1 combined 2
      
      And then add CPUs above 0 and 1, like:
      
       # xdp_redirect_cpu --dev ixgbe1 --prog 2 --cpu 2 --cpu 3 --cpu 4
      
      Another issue with ixgbe is that the page recycle mechanism is tied to
      the RX-ring size.  And the default setting of 512 elements is too
      small.  This is the same issue with regular devmap XDP_REDIRECT.
      To overcome this I've been using 1024 rx-ring size:
      
       # ethtool -G ixgbe1 rx 1024 tx 1024
      
      V3:
       - whitespace cleanups
       - bpf tracepoint cannot access top part of struct
      
      V4:
       - report on kthread sched events, according to tracepoint change
       - report average bulk enqueue size
      
      V5:
       - bpf_map_lookup_elem on cpumap not allowed from bpf_prog
         use separate map to mark CPUs not available
      
      V6:
       - correct kthread sched summary output
      
      V7:
       - Added a --stress-mode for concurrently changing underlying cpumap
      Signed-off-by: NJesper Dangaard Brouer <brouer@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      fad3917e
  16. 17 10月, 2017 1 次提交
  17. 22 9月, 2017 2 次提交
  18. 30 8月, 2017 1 次提交
    • J
      samples/bpf: xdp_monitor tool based on tracepoints · 3ffab546
      Jesper Dangaard Brouer 提交于
      This tool xdp_monitor demonstrate how to use the different xdp_redirect
      tracepoints xdp_redirect{,_map}{,_err} from a BPF program.
      
      The default mode is to only monitor the error counters, to avoid
      affecting the per packet performance. Tracepoints comes with a base
      overhead of 25 nanosec for an attached bpf_prog, and 48 nanosec for
      using a full perf record (with non-matching filter).  Thus, default
      loading the --stats mode could affect the maximum performance.
      
      This version of the tool is very simple and count all types of errors
      as one.  It will be natural to extend this later with the different
      types of errors that can occur, which should help users quickly
      identify common mistakes.
      
      Because the TP_STRUCT was kept in sync all the tracepoints loads the
      same BPF code.  It would also be natural to extend the map version to
      demonstrate how the map information could be used.
      Signed-off-by: NJesper Dangaard Brouer <brouer@redhat.com>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3ffab546
  19. 08 8月, 2017 1 次提交
  20. 18 7月, 2017 2 次提交
  21. 12 7月, 2017 1 次提交
    • Y
      samples/bpf: fix a build issue · 53335022
      Yonghong Song 提交于
      With latest net-next:
      
      ====
      clang  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/6.3.1/include -I./arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h  -Isamples/bpf \
          -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
          -Wno-compare-distinct-pointer-types \
          -Wno-gnu-variable-sized-type-not-at-end \
          -Wno-address-of-packed-member -Wno-tautological-compare \
          -Wno-unknown-warning-option \
          -O2 -emit-llvm -c samples/bpf/tcp_synrto_kern.c -o -| llc -march=bpf -filetype=obj -o samples/bpf/tcp_synrto_kern.o
      samples/bpf/tcp_synrto_kern.c:20:10: fatal error: 'bpf_endian.h' file not found
                ^~~~~~~~~~~~~~
      1 error generated.
      ====
      
      net has the same issue.
      
      Add support for ntohl and htonl in tools/testing/selftests/bpf/bpf_endian.h.
      Also move bpf_helpers.h from samples/bpf to selftests/bpf and change
      compiler include logic so that programs in samples/bpf can access the headers
      in selftests/bpf, but not the other way around.
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Acked-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NLawrence Brakmo <brakmo@fb.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      53335022
  22. 02 7月, 2017 7 次提交
  23. 22 6月, 2017 1 次提交
    • Y
      samples/bpf: fix a build problem · 00a3855d
      Yonghong Song 提交于
      tracex5_kern.c build failed with the following error message:
        ../samples/bpf/tracex5_kern.c:12:10: fatal error: 'syscall_nrs.h' file not found
        #include "syscall_nrs.h"
      The generated file syscall_nrs.h is put in build/samples/bpf directory,
      but this directory is not in include path, hence build failed.
      
      The fix is to add $(obj) into the clang compilation path.
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      00a3855d
  24. 15 6月, 2017 1 次提交
  25. 25 4月, 2017 1 次提交
    • A
      samples/bpf: add -Wno-unknown-warning-option to clang · 69b6a7f7
      Alexander Alemayhu 提交于
      I was initially going to remove '-Wno-address-of-packed-member' because I
      thought it was not supposed to be there but Daniel suggested using
      '-Wno-unknown-warning-option'.
      
      This silences several warnings similiar to the one below
      
      warning: unknown warning option '-Wno-address-of-packed-member' [-Wunknown-warning-option]
      1 warning generated.
      clang  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/6.3.1/include -I./arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated  -I./include
       -I./arch/x86/include/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h  \
              -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
              -Wno-compare-distinct-pointer-types \
              -Wno-gnu-variable-sized-type-not-at-end \
              -Wno-address-of-packed-member -Wno-tautological-compare \
              -O2 -emit-llvm -c samples/bpf/xdp_tx_iptunnel_kern.c -o -| llc -march=bpf -filetype=obj -o samples/bpf/xdp_tx_iptunnel_kern.o
      
      $ clang --version
      
       clang version 3.9.1 (tags/RELEASE_391/final)
       Target: x86_64-unknown-linux-gnu
       Thread model: posix
       InstalledDir: /usr/bin
      Signed-off-by: NAlexander Alemayhu <alexander@alemayhu.com>
      Acked-by: NDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      69b6a7f7
  26. 24 3月, 2017 1 次提交
  27. 23 3月, 2017 1 次提交
  28. 20 12月, 2016 3 次提交
    • J
      samples/bpf: Move open_raw_sock to separate header · 9899694a
      Joe Stringer 提交于
      This function was declared in libbpf.c and was the only remaining
      function in this library, but has nothing to do with BPF. Shift it out
      into a new header, sock_example.h, and include it from the relevant
      samples.
      Signed-off-by: NJoe Stringer <joe@ovn.org>
      Cc: Alexei Starovoitov <ast@fb.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/20161209024620.31660-8-joe@ovn.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9899694a
    • J
      samples/bpf: Remove perf_event_open() declaration · 205c8ada
      Joe Stringer 提交于
      This declaration was made in samples/bpf/libbpf.c for convenience, but
      there's already one in tools/perf/perf-sys.h. Reuse that one.
      
      Committer notes:
      
      Testing it:
      
        $ make -j4 O=../build/v4.9.0-rc8+ samples/bpf/
        make[1]: Entering directory '/home/build/v4.9.0-rc8+'
          CHK     include/config/kernel.release
          GEN     ./Makefile
          CHK     include/generated/uapi/linux/version.h
          Using /home/acme/git/linux as source for kernel
          CHK     include/generated/utsrelease.h
          CHK     include/generated/timeconst.h
          CHK     include/generated/bounds.h
          CHK     include/generated/asm-offsets.h
          CALL    /home/acme/git/linux/scripts/checksyscalls.sh
          HOSTCC  samples/bpf/test_verifier.o
          HOSTCC  samples/bpf/libbpf.o
          HOSTCC  samples/bpf/../../tools/lib/bpf/bpf.o
          HOSTCC  samples/bpf/test_maps.o
          HOSTCC  samples/bpf/sock_example.o
          HOSTCC  samples/bpf/bpf_load.o
      <SNIP>
          HOSTLD  samples/bpf/trace_event
          HOSTLD  samples/bpf/sampleip
          HOSTLD  samples/bpf/tc_l2_redirect
        make[1]: Leaving directory '/home/build/v4.9.0-rc8+'
        $
      
      Also tested the offwaketime resulting from the rebuild, seems to work as
      before.
      Signed-off-by: NJoe Stringer <joe@ovn.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexei Starovoitov <ast@fb.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/20161209024620.31660-7-joe@ovn.org
      [ Use -I$(srctree)/tools/lib/ to support out of source code tree builds ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      205c8ada
    • J
      samples/bpf: Switch over to libbpf · 43371c83
      Joe Stringer 提交于
      Now that libbpf under tools/lib/bpf/* is synced with the version from
      samples/bpf, we can get rid most of the libbpf library here.
      
      Committer notes:
      
      Built it in a docker fedora rawhide container and ran it in the f25 host, seems
      to work just like it did before this patch, i.e. the switch to tools/lib/bpf/
      doesn't seem to have introduced problems and Joe said he tested it with
      all the entries in samples/bpf/ and other code he found:
      
        [root@f5065a7d6272 linux]# make -j4 O=/tmp/build/linux headers_install
        <SNIP>
        [root@f5065a7d6272 linux]# rm -rf /tmp/build/linux/samples/bpf/
        [root@f5065a7d6272 linux]# make -j4 O=/tmp/build/linux samples/bpf/
        make[1]: Entering directory '/tmp/build/linux'
          CHK     include/config/kernel.release
          HOSTCC  scripts/basic/fixdep
          GEN     ./Makefile
          CHK     include/generated/uapi/linux/version.h
          Using /git/linux as source for kernel
          CHK     include/generated/utsrelease.h
          HOSTCC  scripts/basic/bin2c
          HOSTCC  arch/x86/tools/relocs_32.o
          HOSTCC  arch/x86/tools/relocs_64.o
          LD      samples/bpf/built-in.o
        <SNIP>
          HOSTCC  samples/bpf/fds_example.o
          HOSTCC  samples/bpf/sockex1_user.o
        /git/linux/samples/bpf/fds_example.c: In function 'bpf_prog_create':
        /git/linux/samples/bpf/fds_example.c:63:6: warning: passing argument 2 of 'bpf_load_program' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
              insns, insns_cnt, "GPL", 0,
              ^~~~~
        In file included from /git/linux/samples/bpf/libbpf.h:5:0,
                         from /git/linux/samples/bpf/bpf_load.h:4,
                         from /git/linux/samples/bpf/fds_example.c:15:
        /git/linux/tools/lib/bpf/bpf.h:31:5: note: expected 'struct bpf_insn *' but argument is of type 'const struct bpf_insn *'
         int bpf_load_program(enum bpf_prog_type type, struct bpf_insn *insns,
             ^~~~~~~~~~~~~~~~
          HOSTCC  samples/bpf/sockex2_user.o
        <SNIP>
          HOSTCC  samples/bpf/xdp_tx_iptunnel_user.o
        clang  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/6.2.1/include -I/git/linux/arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated  -I/git/linux/include -I./include -I/git/linux/arch/x86/include/uapi -I/git/linux/include/uapi -I./include/generated/uapi -include /git/linux/include/linux/kconfig.h  \
      	  -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
      	  -Wno-compare-distinct-pointer-types \
      	  -Wno-gnu-variable-sized-type-not-at-end \
      	  -Wno-address-of-packed-member -Wno-tautological-compare \
      	  -O2 -emit-llvm -c /git/linux/samples/bpf/sockex1_kern.c -o -| llc -march=bpf -filetype=obj -o samples/bpf/sockex1_kern.o
          HOSTLD  samples/bpf/tc_l2_redirect
        <SNIP>
          HOSTLD  samples/bpf/lwt_len_hist
          HOSTLD  samples/bpf/xdp_tx_iptunnel
        make[1]: Leaving directory '/tmp/build/linux'
        [root@f5065a7d6272 linux]#
      
      And then, in the host:
      
        [root@jouet bpf]# mount | grep "docker.*devicemapper\/"
        /dev/mapper/docker-253:0-1705076-9bd8aa1e0af33adce89ff42090847868ca676932878942be53941a06ec5923f9 on /var/lib/docker/devicemapper/mnt/9bd8aa1e0af33adce89ff42090847868ca676932878942be53941a06ec5923f9 type xfs (rw,relatime,context="system_u:object_r:container_file_t:s0:c73,c276",nouuid,attr2,inode64,sunit=1024,swidth=1024,noquota)
        [root@jouet bpf]# cd /var/lib/docker/devicemapper/mnt/9bd8aa1e0af33adce89ff42090847868ca676932878942be53941a06ec5923f9/rootfs/tmp/build/linux/samples/bpf/
        [root@jouet bpf]# file offwaketime
        offwaketime: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=f423d171e0487b2f802b6a792657f0f3c8f6d155, not stripped
        [root@jouet bpf]# readelf -SW offwaketime
        offwaketime         offwaketime_kern.o  offwaketime_user.o
        [root@jouet bpf]# readelf -SW offwaketime_kern.o
        There are 11 section headers, starting at offset 0x700:
      
        Section Headers:
          [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
          [ 0]                   NULL            0000000000000000 000000 000000 00      0   0  0
          [ 1] .strtab           STRTAB          0000000000000000 000658 0000a8 00      0   0  1
          [ 2] .text             PROGBITS        0000000000000000 000040 000000 00  AX  0   0  4
          [ 3] kprobe/try_to_wake_up PROGBITS        0000000000000000 000040 0000d8 00  AX  0   0  8
          [ 4] .relkprobe/try_to_wake_up REL             0000000000000000 0005a8 000020 10     10   3  8
          [ 5] tracepoint/sched/sched_switch PROGBITS        0000000000000000 000118 000318 00  AX  0   0  8
          [ 6] .reltracepoint/sched/sched_switch REL             0000000000000000 0005c8 000090 10     10   5  8
          [ 7] maps              PROGBITS        0000000000000000 000430 000050 00  WA  0   0  4
          [ 8] license           PROGBITS        0000000000000000 000480 000004 00  WA  0   0  1
          [ 9] version           PROGBITS        0000000000000000 000484 000004 00  WA  0   0  4
          [10] .symtab           SYMTAB          0000000000000000 000488 000120 18      1   4  8
        Key to Flags:
          W (write), A (alloc), X (execute), M (merge), S (strings)
          I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
          O (extra OS processing required) o (OS specific), p (processor specific)
          [root@jouet bpf]# ./offwaketime | head -3
        qemu-system-x86;entry_SYSCALL_64_fastpath;sys_ppoll;do_sys_poll;poll_schedule_timeout;schedule_hrtimeout_range;schedule_hrtimeout_range_clock;schedule;__schedule;-;try_to_wake_up;hrtimer_wakeup;__hrtimer_run_queues;hrtimer_interrupt;local_apic_timer_interrupt;smp_apic_timer_interrupt;__irqentry_text_start;cpuidle_enter_state;cpuidle_enter;call_cpuidle;cpu_startup_entry;rest_init;start_kernel;x86_64_start_reservations;x86_64_start_kernel;start_cpu;;swapper/0 4
        firefox;entry_SYSCALL_64_fastpath;sys_poll;do_sys_poll;poll_schedule_timeout;schedule_hrtimeout_range;schedule_hrtimeout_range_clock;schedule;__schedule;-;try_to_wake_up;pollwake;__wake_up_common;__wake_up_sync_key;pipe_write;__vfs_write;vfs_write;sys_write;entry_SYSCALL_64_fastpath;;Timer 1
        swapper/2;start_cpu;start_secondary;cpu_startup_entry;schedule_preempt_disabled;schedule;__schedule;-;---;; 61
        [root@jouet bpf]#
      Signed-off-by: NJoe Stringer <joe@ovn.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexei Starovoitov <ast@fb.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: netdev@vger.kernel.org
      Link: https://github.com/joestringer/linux/commit/5c40f54a52b1f437123c81e21873f4b4b1f9bd55.patch
      Link: http://lkml.kernel.org/n/tip-xr8twtx7sjh5821g8qw47yxk@git.kernel.org
      [ Use -I$(srctree)/tools/lib/ to support out of source code tree builds, as noticed by Wang Nan ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      43371c83
  29. 11 12月, 2016 1 次提交