1. 22 10月, 2017 1 次提交
  2. 20 10月, 2017 4 次提交
  3. 18 10月, 2017 4 次提交
    • J
      bpf: disallow arithmetic operations on context pointer · 28e33f9d
      Jakub Kicinski 提交于
      Commit f1174f77 ("bpf/verifier: rework value tracking")
      removed the crafty selection of which pointer types are
      allowed to be modified.  This is OK for most pointer types
      since adjust_ptr_min_max_vals() will catch operations on
      immutable pointers.  One exception is PTR_TO_CTX which is
      now allowed to be offseted freely.
      
      The intent of aforementioned commit was to allow context
      access via modified registers.  The offset passed to
      ->is_valid_access() verifier callback has been adjusted
      by the value of the variable offset.
      
      What is missing, however, is taking the variable offset
      into account when the context register is used.  Or in terms
      of the code adding the offset to the value passed to the
      ->convert_ctx_access() callback.  This leads to the following
      eBPF user code:
      
           r1 += 68
           r0 = *(u32 *)(r1 + 8)
           exit
      
      being translated to this in kernel space:
      
         0: (07) r1 += 68
         1: (61) r0 = *(u32 *)(r1 +180)
         2: (95) exit
      
      Offset 8 is corresponding to 180 in the kernel, but offset
      76 is valid too.  Verifier will "accept" access to offset
      68+8=76 but then "convert" access to offset 8 as 180.
      Effective access to offset 248 is beyond the kernel context.
      (This is a __sk_buff example on a debug-heavy kernel -
      packet mark is 8 -> 180, 76 would be data.)
      
      Dereferencing the modified context pointer is not as easy
      as dereferencing other types, because we have to translate
      the access to reading a field in kernel structures which is
      usually at a different offset and often of a different size.
      To allow modifying the pointer we would have to make sure
      that given eBPF instruction will always access the same
      field or the fields accessed are "compatible" in terms of
      offset and size...
      
      Disallow dereferencing modified context pointers and add
      to selftests the test case described here.
      
      Fixes: f1174f77 ("bpf/verifier: rework value tracking")
      Signed-off-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Acked-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NEdward Cree <ecree@solarflare.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      28e33f9d
    • L
      perf test shell trace+probe_libc_inet_pton.sh: Be compatible with Debian/Ubuntu · 74f8e22c
      Li Zhijian 提交于
      In debian/ubuntu, libc.so is located at a different place,
      /lib/x86_64-linux-gnu/libc-2.23.so, so it outputs like this when testing:
      
        PING ::1(::1) 56 data bytes
        64 bytes from ::1: icmp_seq=1 ttl=64 time=0.040 ms
      
        --- ::1 ping statistics ---
        1 packets transmitted, 1 received, 0% packet loss, time 0ms
        rtt min/avg/max/mdev = 0.040/0.040/0.040/0.000 ms
        0.000 probe_libc:inet_pton:(7f0e2db741c0))
        __GI___inet_pton (/lib/x86_64-linux-gnu/libc-2.23.so)
        getaddrinfo (/lib/x86_64-linux-gnu/libc-2.23.so)
        [0xffffa9d40f34ff4d] (/bin/ping)
      
      Fix up the libc path to make sure this test works in more OSes.
      
      Committer testing:
      
      When this test fails one can use 'perf test -v', i.e. in verbose mode, where
      it'll show the expected backtrace, so, after applying this test:
      
      On Fedora 26:
      
        # perf test -v ping
        62: probe libc's inet_pton & backtrace it with ping       :
        --- start ---
        test child forked, pid 23322
        PING ::1(::1) 56 data bytes
        64 bytes from ::1: icmp_seq=1 ttl=64 time=0.058 ms
        --- ::1 ping statistics ---
        1 packets transmitted, 1 received, 0% packet loss, time 0ms
        rtt min/avg/max/mdev = 0.058/0.058/0.058/0.000 ms
        0.000 probe_libc:inet_pton:(7fe344310d80))
        __GI___inet_pton (/usr/lib64/libc-2.25.so)
        getaddrinfo (/usr/lib64/libc-2.25.so)
        _init (/usr/bin/ping)
        test child finished with 0
        ---- end ----
        probe libc's inet_pton & backtrace it with ping: Ok
        #
      Signed-off-by: NLi Zhijian <lizhijian@cn.fujitsu.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@arm.com>
      Cc: Li Zhijian <lizhijian@cn.fujitsu.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Philip Li <philip.li@intel.com>
      Link: http://lkml.kernel.org/r/1508315649-18836-1-git-send-email-lizhijian@cn.fujitsu.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      74f8e22c
    • J
      perf xyarray: Fix wrong processing when closing evsel fd · 3d8bba95
      Jin Yao 提交于
      In current xyarray code, xyarray__max_x() returns max_y, and xyarray__max_y()
      returns max_x.
      
      It's confusing and for code logic it looks not correct.
      
      Error happens when closing evsel fd. Let's see this scenario:
      
      1. Allocate an fd (pseudo-code)
      
        perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
        {
      	evsel->fd = xyarray__new(ncpus, nthreads, sizeof(int));
        }
      
        xyarray__new(int xlen, int ylen, size_t entry_size)
        {
      	size_t row_size = ylen * entry_size;
      	struct xyarray *xy = zalloc(sizeof(*xy) + xlen * row_size);
      
      	xy->entry_size = entry_size;
      	xy->row_size   = row_size;
      	xy->entries    = xlen * ylen;
      	xy->max_x      = xlen;
      	xy->max_y      = ylen;
      	......
        }
      
      So max_x is ncpus, max_y is nthreads and row_size = nthreads * 4.
      
      2. Use perf syscall and get the fd
      
        int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
      		     struct thread_map *threads)
        {
      	for (cpu = 0; cpu < cpus->nr; cpu++) {
      
      		for (thread = 0; thread < nthreads; thread++) {
      			int fd, group_fd;
      
      			fd = sys_perf_event_open(&evsel->attr, pid, cpus->map[cpu],
      						 group_fd, flags);
      
      			FD(evsel, cpu, thread) = fd;
      	}
        }
      
        static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
        {
      	return &xy->contents[x * xy->row_size + y * xy->entry_size];
        }
      
      These codes don't have issues. The issue happens in the closing of fd.
      
      3. Close fd.
      
        void perf_evsel__close_fd(struct perf_evsel *evsel)
        {
      	int cpu, thread;
      
      	for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++)
      		for (thread = 0; thread < xyarray__max_y(evsel->fd); ++thread) {
      			close(FD(evsel, cpu, thread));
      			FD(evsel, cpu, thread) = -1;
      		}
        }
      
        Since xyarray__max_x() returns max_y (nthreads) and xyarry__max_y()
        returns max_x (ncpus), so above code is actually to be:
      
              for (cpu = 0; cpu < nthreads; cpu++)
                      for (thread = 0; thread < ncpus; ++thread) {
                              close(FD(evsel, cpu, thread));
                              FD(evsel, cpu, thread) = -1;
                      }
      
        It's not correct!
      
      This change is introduced by "475fb533" ("perf evsel: Fix buffer overflow
      while freeing events")
      
      This fix is to let xyarray__max_x() return max_x (ncpus) and
      let xyarry__max_y() return max_y (nthreads)
      
      Committer note:
      
      This was also fixed by Ravi Bangoria, who provided the same patch,
      noticing the problem with 'perf record':
      
      <quote Ravi>
      I see 'perf record -p <pid>' crashes with following log:
      
         *** Error in `./perf': free(): invalid next size (normal): 0x000000000298b340 ***
         ======= Backtrace: =========
         /lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f7fd85c87e5]
         /lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f7fd85d137a]
         /lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f7fd85d553c]
         ./perf(perf_evsel__close+0xb4)[0x4b7614]
         ./perf(perf_evlist__delete+0x100)[0x4ab180]
         ./perf(cmd_record+0x1d9)[0x43a5a9]
         ./perf[0x49aa2f]
         ./perf(main+0x631)[0x427841]
         /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f7fd8571830]
         ./perf(_start+0x29)[0x427a59]
      </>
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Fixes: d74be476 ("perf xyarray: Save max_x, max_y")
      Link: http://lkml.kernel.org/r/1508339478-26674-1-git-send-email-yao.jin@linux.intel.com
      Link: http://lkml.kernel.org/r/1508327446-15302-1-git-send-email-ravi.bangoria@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3d8bba95
    • L
      Revert "tools/power turbostat: stop migrating, unless '-m'" · c97cc7db
      Len Brown 提交于
      This reverts commit c91fc851.
      
      That change caused a C6 and PC6 residency regression on large idle systems.
      
      Users also complained about new output indicating jitter:
      
      turbostat: cpu6 jitter 3794 9142
      Signed-off-by: NLen Brown <len.brown@intel.com>
      Cc: 4.13+ <stable@vger.kernel.org> # v4.13+
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      c97cc7db
  4. 17 10月, 2017 2 次提交
    • N
      perf buildid-list: Fix crash when processing PERF_RECORD_NAMESPACE · 7f0cd236
      Namhyung Kim 提交于
      Thomas reported that 'perf buildid-list' gets a SEGFAULT due to NULL
      pointer deref when he ran it on a data with namespace events.  It was
      because the buildid_id__mark_dso_hit_ops lacks the namespace event
      handler and perf_too__fill_default() didn't set it.
      
        Program received signal SIGSEGV, Segmentation fault.
        0x0000000000000000 in ?? ()
        Missing separate debuginfos, use: dnf debuginfo-install audit-libs-2.7.7-1.fc25.s390x bzip2-libs-1.0.6-21.fc25.s390x elfutils-libelf-0.169-1.fc25.s390x
        +elfutils-libs-0.169-1.fc25.s390x libcap-ng-0.7.8-1.fc25.s390x numactl-libs-2.0.11-2.ibm.fc25.s390x openssl-libs-1.1.0e-1.1.ibm.fc25.s390x perl-libs-5.24.1-386.fc25.s390x
        +python-libs-2.7.13-2.fc25.s390x slang-2.3.0-7.fc25.s390x xz-libs-5.2.3-2.fc25.s390x zlib-1.2.8-10.fc25.s390x
        (gdb) where
        #0  0x0000000000000000 in ?? ()
        #1  0x00000000010fad6a in machines__deliver_event (machines=<optimized out>, machines@entry=0x2c6fd18,
            evlist=<optimized out>, event=event@entry=0x3fffdf00470, sample=0x3ffffffe880, sample@entry=0x3ffffffe888,
            tool=tool@entry=0x1312968 <build_id.mark_dso_hit_ops>, file_offset=1136) at util/session.c:1287
        #2  0x00000000010fbf4e in perf_session__deliver_event (file_offset=1136, tool=0x1312968 <build_id.mark_dso_hit_ops>,
            sample=0x3ffffffe888, event=0x3fffdf00470, session=0x2c6fc30) at util/session.c:1340
        #3  perf_session__process_event (session=0x2c6fc30, session@entry=0x0, event=event@entry=0x3fffdf00470,
            file_offset=file_offset@entry=1136) at util/session.c:1522
        #4  0x00000000010fddde in __perf_session__process_events (file_size=11880, data_size=<optimized out>,
            data_offset=<optimized out>, session=0x0) at util/session.c:1899
        #5  perf_session__process_events (session=0x0, session@entry=0x2c6fc30) at util/session.c:1953
        #6  0x000000000103b2ac in perf_session__list_build_ids (with_hits=<optimized out>, force=<optimized out>)
            at builtin-buildid-list.c:83
        #7  cmd_buildid_list (argc=<optimized out>, argv=<optimized out>) at builtin-buildid-list.c:115
        #8  0x00000000010a026c in run_builtin (p=0x1311f78 <commands+24>, argc=argc@entry=2, argv=argv@entry=0x3fffffff3c0)
            at perf.c:296
        #9  0x000000000102bc00 in handle_internal_command (argv=<optimized out>, argc=2) at perf.c:348
        #10 run_argv (argcp=<synthetic pointer>, argv=<synthetic pointer>) at perf.c:392
        #11 main (argc=<optimized out>, argv=0x3fffffff3c0) at perf.c:536
        (gdb)
      
      Fix it by adding a stub event handler for namespace event.
      
      Committer testing:
      
      Further clarifying, plain using 'perf buildid-list' will not end up in a
      SEGFAULT when processing a perf.data file with namespace info:
      
        # perf record -a --namespaces sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 2.024 MB perf.data (1058 samples) ]
        # perf buildid-list | wc -l
        38
        # perf buildid-list | head -5
        e2a171c7b905826fc8494f0711ba76ab6abbd604 /lib/modules/4.14.0-rc3+/build/vmlinux
        874840a02d8f8a31cedd605d0b8653145472ced3 /lib/modules/4.14.0-rc3+/kernel/arch/x86/kvm/kvm-intel.ko
        ea7223776730cd8a22f320040aae4d54312984bc /lib/modules/4.14.0-rc3+/kernel/drivers/gpu/drm/i915/i915.ko
        5961535e6732a8edb7f22b3f148bb2fa2e0be4b9 /lib/modules/4.14.0-rc3+/kernel/drivers/gpu/drm/drm.ko
        f045f54aa78cf1931cc893f78b6cbc52c72a8cb1 /usr/lib64/libc-2.25.so
        #
      
      It is only when one asks for checking what of those entries actually had
      samples, i.e. when we use either -H or --with-hits, that we will process
      all the PERF_RECORD_ events, and since tools/perf/builtin-buildid-list.c
      neither explicitely set a perf_tool.namespaces() callback nor the
      default stub was set that we end up, when processing a
      PERF_RECORD_NAMESPACE record, causing a SEGFAULT:
      
        # perf buildid-list -H
        Segmentation fault (core dumped)
        ^C
        #
      Reported-and-Tested-by: NThomas-Mich Richter <tmricht@linux.vnet.ibm.com>
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Hari Bathini <hbathini@linux.vnet.ibm.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
      Fixes: f3b3614a ("perf tools: Add PERF_RECORD_NAMESPACES to include namespaces related info")
      Link: http://lkml.kernel.org/r/20171017132900.11043-1-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7f0cd236
    • T
      perf record: Fix documentation for a inexistent option '-l' · 3f50f614
      Taeung Song 提交于
      'perf record' had a '-l' option that meant "scale counter values" a very
      long time ago, but it currently belongs to 'perf stat' as '-c'.  So
      remove it. I found this problem in the below case.
      
          $ perf record -e cycles -l sleep 3
            Error: unknown switch `l
      Signed-off-by: NTaeung Song <treeze.taeung@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/r/1507907412-19813-1-git-send-email-treeze.taeung@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3f50f614
  5. 14 10月, 2017 4 次提交
  6. 10 10月, 2017 2 次提交
    • A
      tools include uapi bpf.h: Sync kernel ABI header with tooling header · aa7b4e02
      Arnaldo Carvalho de Melo 提交于
      Silences the checker:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf.h' differs from latest version at 'include/uapi/linux/bpf.h'
      
      The 90caccdd ("bpf: fix bpf_tail_call() x64 JIT") cset only updated
      a comment in uapi/bpf.h.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@fb.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-rwx2cqbf0x1lwa1krsr6e6hd@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      aa7b4e02
    • M
      perf pmu: Unbreak perf record for arm/arm64 with events with explicit PMU · 66ec1191
      Mark Rutland 提交于
      Currently, perf record is broken on arm/arm64 systems when the PMU is
      specified explicitly as part of the event, e.g.
      
      $ ./perf record -e armv8_cortex_a53/cpu_cycles/u true
      
      In such cases, perf record fails to open events unless
      perf_event_paranoid is set to -1, even if the PMU in question supports
      mode exclusion. Further, even when perf_event_paranoid is toggled, no
      samples are recorded.
      
      This is an unintended side effect of commit:
      
        e3ba76de ("perf tools: Force uncore events to system wide monitoring)
      
      ... which assumes that if a PMU has an associated cpu_map, it is an
      uncore PMU, and forces events for such PMUs to be system-wide.
      
      This is not true for arm/arm64 systems, which can have heterogeneous
      CPUs. To account for this, multiple CPU PMUs are exposed, each with a
      "cpus" field under sysfs, which the perf tool parses into a cpu_map. ARM
      PMUs do not have a "cpumask" file, and only have a "cpus" file. For the
      gory details as to why, see commit:
      
       7e3fcffe ("perf pmu: Support alternative sysfs cpumask")
      
      Given all of this, we can instead identify uncore PMUs by explicitly
      checking for a "cpumask" file, and restore arm/arm64 PMU support back to
      a working state. This patch does so, adding a new perf_pmu::is_uncore
      field, and splitting the existing cpumask parsing so that it can be
      reused.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Tested-by Will Deacon <will.deacon@arm.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: 4.12+ <stable@vger.kernel.org>
      Fixes: e3ba76de ("perf tools: Force uncore events to system wide monitoring)
      Link: http://lkml.kernel.org/r/1507315102-5942-1-git-send-email-mark.rutland@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      66ec1191
  7. 06 10月, 2017 4 次提交
    • M
      perf script: Add missing separator for "-F ip,brstack" (and brstackoff) · e9516c08
      Mark Santaniello 提交于
      Prior to commit 55b9b508 ("perf script: Support -F brstack,dso and
      brstacksym,dso"), we were printing a space before the brstack data. It
      seems that this space was important.  Without it, parsing is difficult.
      
      Very sorry for the mistake.
      
      Notice here how the "ip" and "brstack" run together:
      
      $ perf script -F ip,brstack | head -n 1
                22e18c40x22e19e2/0x22e190b/P/-/-/0 0x22e19a1/0x22e19d0/P/-/-/0 0x22e195d/0x22e1990/P/-/-/0 0x22e18e9/0x22e1943/P/-/-/0 0x22e1a69/0x22e18c0/P/-/-/0 0x22e19f7/0x22e1a20/P/-/-/0 0x22e1910/0x22e19ee/P/-/-/0 0x22e19e2/0x22e190b/P/-/-/0 0x22e19a1/0x22e19d0/P/-/-/0 0x22e195d/0x22e1990/P/-/-/0 0x22e18e9/0x22e1943/P/-/-/0 0x22e1a69/0x22e18c0/P/-/-/0 0x22e19f7/0x22e1a20/P/-/-/0 0x22e1910/0x22e19ee/P/-/-/0 0x22e19e2/0x22e190b/P/-/-/0 0x22e19a1/0x22e19d0/P/-/-/0
      
      After this diff, sanity is restored:
      
      $ perf script -F ip,brstack | head -n 1
                22e18c4 0x22e19e2/0x22e190b/P/-/-/0  0x22e19a1/0x22e19d0/P/-/-/0  0x22e195d/0x22e1990/P/-/-/0  0x22e18e9/0x22e1943/P/-/-/0  0x22e1a69/0x22e18c0/P/-/-/0  0x22e19f7/0x22e1a20/P/-/-/0  0x22e1910/0x22e19ee/P/-/-/0  0x22e19e2/0x22e190b/P/-/-/0  0x22e19a1/0x22e19d0/P/-/-/0  0x22e195d/0x22e1990/P/-/-/0  0x22e18e9/0x22e1943/P/-/-/0  0x22e1a69/0x22e18c0/P/-/-/0  0x22e19f7/0x22e1a20/P/-/-/0  0x22e1910/0x22e19ee/P/-/-/0  0x22e19e2/0x22e190b/P/-/-/0  0x22e19a1/0x22e19d0/P/-/-/0
      Signed-off-by: NMark Santaniello <marksan@fb.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: 4.13+ <stable@vger.kernel.org>
      Fixes: 55b9b508 ("perf script: Support -F brstack,dso and brstacksym,dso")
      Link: http://lkml.kernel.org/r/20171006080722.3442046-1-marksan@fb.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e9516c08
    • D
      selftests/net: rxtimestamp: Fix an off by one · 1561b326
      Dan Carpenter 提交于
      The > should be >= so that we don't write one element beyond the end of
      the array.
      
      Fixes: 16e78122 ("selftests/net: Add a test to validate behavior of rx timestamps")
      Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1561b326
    • S
      selftests: mqueue: fix regression in silencing output from RUN_TESTS · ea344f6a
      Shuah Khan 提交于
      Fix fix regression in silencing output from RUN_TESTS introduced by
      commit <8230b905> selftests: mqueue: Use full path to run tests
      from Makefile
      Signed-off-by: NShuah Khan <shuahkh@osg.samsung.com>
      ea344f6a
    • S
      selftests: x86: sysret_ss_attrs doesn't build on a PIE build · 3346a6a4
      Shuah Khan 提交于
      sysret_ss_attrs fails to compile leading x86 test run to fail on systems
      configured to build using PIE by default. Add -no-pie fix it.
      
      Relocation might still fail if relocated above 4G. For now this change
      fixes the build and runs x86 tests.
      
      tools/testing/selftests/x86$ make
      gcc -m64 -o .../tools/testing/selftests/x86/single_step_syscall_64 -O2
      -g -std=gnu99 -pthread -Wall  single_step_syscall.c -lrt -ldl
      gcc -m64 -o .../tools/testing/selftests/x86/sysret_ss_attrs_64 -O2 -g
      -std=gnu99 -pthread -Wall  sysret_ss_attrs.c thunks.S -lrt -ldl
      /usr/bin/ld: /tmp/ccS6pvIh.o: relocation R_X86_64_32S against `.text'
      can not be used when making a shared object; recompile with -fPIC
      /usr/bin/ld: final link failed: Nonrepresentable section on output
      collect2: error: ld returned 1 exit status
      Makefile:49: recipe for target
      '.../tools/testing/selftests/x86/sysret_ss_attrs_64' failed
      make: *** [.../tools/testing/selftests/x86/sysret_ss_attrs_64] Error 1
      Suggested-by: NAndy Lutomirski <luto@kernel.org>
      Signed-off-by: NShuah Khan <shuahkh@osg.samsung.com>
      3346a6a4
  8. 05 10月, 2017 1 次提交
  9. 29 9月, 2017 2 次提交
  10. 28 9月, 2017 1 次提交
    • J
      objtool: Support unoptimized frame pointer setup · 607a4029
      Josh Poimboeuf 提交于
      Arnd Bergmann reported a bunch of warnings like:
      
        crypto/jitterentropy.o: warning: objtool: jent_fold_time()+0x3b: call without frame pointer save/setup
        crypto/jitterentropy.o: warning: objtool: jent_stuck()+0x1d: call without frame pointer save/setup
        crypto/jitterentropy.o: warning: objtool: jent_unbiased_bit()+0x15: call without frame pointer save/setup
        crypto/jitterentropy.o: warning: objtool: jent_read_entropy()+0x32: call without frame pointer save/setup
        crypto/jitterentropy.o: warning: objtool: jent_entropy_collector_free()+0x19: call without frame pointer save/setup
      
      and
      
        arch/x86/events/core.o: warning: objtool: collect_events uses BP as a scratch register
        arch/x86/events/core.o: warning: objtool: events_ht_sysfs_show()+0x22: call without frame pointer save/setup
      
      With certain rare configurations, GCC sometimes sets up the frame
      pointer with:
      
        lea    (%rsp),%rbp
      
      instead of:
      
        mov    %rsp,%rbp
      
      The instructions are equivalent, so treat the former like the latter.
      Reported-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/a468af8b28a69b83fffc6d7668be9b6fcc873699.1506526584.git.jpoimboe@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      607a4029
  11. 26 9月, 2017 8 次提交
  12. 25 9月, 2017 5 次提交
    • A
      perf tools: Fix syscalltbl build failure · 090657c9
      Akemi Yagi 提交于
      The build of kernel v4.14-rc1 for i686 fails on RHEL 6 with the error
      in tools/perf:
      
        util/syscalltbl.c:157: error: expected ';', ',' or ')' before '__maybe_unused'
        mv: cannot stat `util/.syscalltbl.o.tmp': No such file or directory
      
      Fix it by placing/moving:
      
        #include <linux/compiler.h>
      
        outside of #ifdef HAVE_SYSCALL_TABLE block.
      Signed-off-by: NAkemi Yagi <toracat@elrepo.org>
      Cc: Alan Bartlett <ajb@elrepo.org>
      Link: http://lkml.kernel.org/r/oq41r8$1v9$1@blaine.gmane.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      090657c9
    • M
      perf report: Fix debug messages with --call-graph option · 9789e7e9
      Mengting Zhang 提交于
      With --call-graph option, perf report can display call chains using
      type, min percent threshold, optional print limit and order. And the
      default call-graph parameter is 'graph,0.5,caller,function,percent'.
      
      Before this patch, 'perf report --call-graph' shows incorrect debug
      messages as below:
      
        # perf report --call-graph
        Invalid callchain mode: 0.5
        Invalid callchain order: 0.5
        Invalid callchain sort key: 0.5
        Invalid callchain config key: 0.5
        Invalid callchain mode: caller
        Invalid callchain mode: function
        Invalid callchain order: function
        Invalid callchain mode: percent
        Invalid callchain order: percent
        Invalid callchain sort key: percent
      
      That is because in function __parse_callchain_report_opt(),each field of
      the call-graph parameter is passed to parse_callchain_{mode,order,
      sort_key,value} in turn until it meets the matching value.
      
      For example, the order field "caller" is passed to
      parse_callchain_mode() firstly and obviously it doesn't match any mode
      field. Therefore parse_callchain_mode() will shows the debug message
      "Invalid callchain mode: caller", which could confuse users.
      
      The patch fixes this issue by moving the warning out of the function
      parse_callchain_{mode,order,sort_key,value}.
      Signed-off-by: NMengting Zhang <zhangmengting@huawei.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Krister Johansen <kjlx@templeofstupid.com>
      Cc: Li Bin <huawei.libin@huawei.com>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Yao Jin <yao.jin@linux.intel.com>
      Link: http://lkml.kernel.org/r/1506154694-39691-1-git-send-email-zhangmengting@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9789e7e9
    • A
      perf evsel: Fix attr.exclude_kernel setting for default cycles:p · f1e52f14
      Arnaldo Carvalho de Melo 提交于
      Yet another fix for probing the max attr.precise_ip setting: it is not
      enough settting attr.exclude_kernel for !root users, as they _can_
      profile the kernel if the kernel.perf_event_paranoid sysctl is set to
      -1, so check that as well.
      
      Testing it:
      
      As non root:
      
        $ sysctl kernel.perf_event_paranoid
        kernel.perf_event_paranoid = 2
        $ perf record sleep 1
        $ perf evlist -v
        cycles:uppp: ..., exclude_kernel: 1, ... precise_ip: 3, ...
      
      Now as non-root, but with kernel.perf_event_paranoid set set to the
      most permissive value, -1:
      
        $ sysctl kernel.perf_event_paranoid
        kernel.perf_event_paranoid = -1
        $ perf record sleep 1
        $ perf evlist -v
        cycles:ppp: ..., exclude_kernel: 0, ... precise_ip: 3, ...
        $
      
      I.e. non-root, default kernel.perf_event_paranoid: :uppp modifier = not allowed to sample the kernel,
           non-root, most permissible kernel.perf_event_paranoid: :ppp = allowed to sample the kernel.
      
      In both cases, use the highest available precision: attr.precise_ip = 3.
      Reported-and-Tested-by: NIngo Molnar <mingo@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: d37a3697 ("perf evsel: Fix attr.exclude_kernel setting for default cycles:p")
      Link: http://lkml.kernel.org/n/tip-nj2qkf75xsd6pw6hhjzfqqdx@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f1e52f14
    • I
      tools include: Sync kernel ABI headers with tooling headers · 549a3976
      Ingo Molnar 提交于
      Time for a sync with ABI/uapi headers with the upcoming v4.14 kernel.
      
      None of the ABI changes require any source code level changes to our
      existing in-kernel tooling code:
      
        - tools/arch/s390/include/uapi/asm/kvm.h:
      
            New KVM_S390_VM_TOD_EXT ABI, not used by in-kernel tooling.
      
        - tools/arch/x86/include/asm/cpufeatures.h:
          tools/arch/x86/include/asm/disabled-features.h:
      
            New PCID, SME and VGIF x86 CPU feature bits defined.
      
        - tools/include/asm-generic/hugetlb_encode.h:
          tools/include/uapi/asm-generic/mman-common.h:
          tools/include/uapi/linux/mman.h:
      
            Two new madvise() flags, plus a hugetlb system call mmap flags
            restructuring/extension changes.
      
        - tools/include/uapi/drm/drm.h:
          tools/include/uapi/drm/i915_drm.h:
      
            New drm_syncobj_create flags definitions, new drm_syncobj_wait
            and drm_syncobj_array ABIs. DRM_I915_PERF_* calls and a new
            I915_PARAM_HAS_EXEC_FENCE_ARRAY ABI for the Intel driver.
      
        - tools/include/uapi/linux/bpf.h:
      
            New bpf_sock fields (::mark and ::priority), new XDP_REDIRECT
            action, new kvm_ppc_smmu_info fields (::data_keys, instr_keys)
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Yao Jin <yao.jin@linux.intel.com>
      Link: http://lkml.kernel.org/r/20170913073823.lxmi4c7ejqlfabjx@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      549a3976
    • A
      perf tools: Get all of tools/{arch,include}/ in the MANIFEST · 89975bd3
      Arnaldo Carvalho de Melo 提交于
      Now that I'm switching the container builds from using a local volume
      pointing to the kernel repository with the perf sources, instead getting
      a detached tarball to be able to use a container cluster, some places
      broke because I forgot to put some of the required files in
      tools/perf/MANIFEST, namely some bitsperlong.h files.
      
      So, to fix it do the same as for tools/build/ and pack the whole
      tools/arch/ directory.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-wmenpjfjsobwdnfde30qqncj@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      89975bd3
  13. 23 9月, 2017 2 次提交
    • J
      x86/asm: Fix inline asm call constraints for Clang · f5caf621
      Josh Poimboeuf 提交于
      For inline asm statements which have a CALL instruction, we list the
      stack pointer as a constraint to convince GCC to ensure the frame
      pointer is set up first:
      
        static inline void foo()
        {
      	register void *__sp asm(_ASM_SP);
      	asm("call bar" : "+r" (__sp))
        }
      
      Unfortunately, that pattern causes Clang to corrupt the stack pointer.
      
      The fix is easy: convert the stack pointer register variable to a global
      variable.
      
      It should be noted that the end result is different based on the GCC
      version.  With GCC 6.4, this patch has exactly the same result as
      before:
      
      	defconfig	defconfig-nofp	distro		distro-nofp
       before	9820389		9491555		8816046		8516940
       after	9820389		9491555		8816046		8516940
      
      With GCC 7.2, however, GCC's behavior has changed.  It now changes its
      behavior based on the conversion of the register variable to a global.
      That somehow convinces it to *always* set up the frame pointer before
      inserting *any* inline asm.  (Therefore, listing the variable as an
      output constraint is a no-op and is no longer necessary.)  It's a bit
      overkill, but the performance impact should be negligible.  And in fact,
      there's a nice improvement with frame pointers disabled:
      
      	defconfig	defconfig-nofp	distro		distro-nofp
       before	9796316		9468236		9076191		8790305
       after	9796957		9464267		9076381		8785949
      
      So in summary, while listing the stack pointer as an output constraint
      is no longer necessary for newer versions of GCC, it's still needed for
      older versions.
      Suggested-by: NAndrey Ryabinin <aryabinin@virtuozzo.com>
      Reported-by: NMatthias Kaehlcke <mka@chromium.org>
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Dmitriy Vyukov <dvyukov@google.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/3db862e970c432ae823cf515c52b54fec8270e0e.1505942196.git.jpoimboe@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      f5caf621
    • J
      objtool: Handle another GCC stack pointer adjustment bug · 0d0970ee
      Josh Poimboeuf 提交于
      The kbuild bot reported the following warning with GCC 4.4 and a
      randconfig:
      
        net/socket.o: warning: objtool: compat_sock_ioctl()+0x1083: stack state mismatch: cfa1=7+160 cfa2=-1+0
      
      This is caused by another GCC non-optimization, where it backs up and
      restores the stack pointer for no apparent reason:
      
          2f91:       48 89 e0                mov    %rsp,%rax
          2f94:       4c 89 e7                mov    %r12,%rdi
          2f97:       4c 89 f6                mov    %r14,%rsi
          2f9a:       ba 20 00 00 00          mov    $0x20,%edx
          2f9f:       48 89 c4                mov    %rax,%rsp
      
      This issue would have been happily ignored before the following commit:
      
        dd88a0a0 ("objtool: Handle GCC stack pointer adjustment bug")
      
      But now that objtool is paying attention to such stack pointer writes
      to/from a register, it needs to understand them properly.  In this case
      that means recognizing that the "mov %rsp, %rax" instruction is
      potentially a backup of the stack pointer.
      Reported-by: Nkbuild test robot <fengguang.wu@intel.com>
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Dmitriy Vyukov <dvyukov@google.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matthias Kaehlcke <mka@chromium.org>
      Cc: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Fixes: dd88a0a0 ("objtool: Handle GCC stack pointer adjustment bug")
      Link: http://lkml.kernel.org/r/8c7aa8e9a36fbbb6655d9d8e7cea58958c912da8.1505942196.git.jpoimboe@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      0d0970ee