25 Sep, 2019

1 commit

  • We have a direct fprintf() call in the header, so we need stdio.h
    include, otherwise it could fail compilation if there's no prior stdio.h
    include directive.

    Signed-off-by: Jiri Olsa
    Link: http://lkml.kernel.org/n/tip-8hvjgh24olfsa4non0a3ohnq@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     

06 Nov, 2018

1 commit

  • This is the commit that porting the perf for nds32.

    1.Raw event:
    The raw events start with 'r'.
    Usage:
    perf stat -e rXYZ ./app
    X: the index of performance counter.
    YZ: the index(convert to hexdecimal) of events

    Example:
    'perf stat -e r101 ./app' means the counter 1 will count the instruction
    event.

    The index of counter and events can be found in
    "Andes System Privilege Architecture Version 3 Manual".

    Or you can perform the 'perf list' to find the symbolic name of raw events.

    2.Perf mmap2:

    Fix unexpected perf mmap2() page fault

    When the mmap2() called by perf application,
    you will encounter such condition:"failed to write."
    With return value -EFAULT

    This is due to the page fault caused by "reading" buffer
    from the mapped legal address region to write to the descriptor.
    The page_fault handler will get a VM_FAULT_SIGBUS return value,
    which should not happens here.(Due to this is a read request.)

    You can refer to kernel/events/core.c:perf_mmap_fault(...)
    If "(vmf->pgoff && (vmf->flags & FAULT_FLAG_WRITE))" is evaluated
    as true, you will get VM_FAULT_SIGBUS as return value.

    However, this is not an write request. The flags which indicated
    why the page fault happens is wrong.

    Furthermore, NDS32 SPAv3 is not able to detect it is read or write.
    It only know either it is instruction fetch or data access.

    Therefore, by removing the wrong flag assignment(actually, the hardware
    is not able to show the reason), we can fix this bug.

    3.Perf multiple events map to same counter.

    When there are multiple events map to the same counter, the counter
    counts inaccurately. This is because each counter only counts one event
    in the same time.
    So when there are multiple events map to same counter, they have to take
    turns in each context.

    There are two solution:
    1. Print the error message when multiple events map to the same counter.
    But print the error message would let the program hang in loop. The ltp
    (linux test program) would be failed when the program hang in loop.

    2. Don't print the error message, the ltp would pass. But the user need to
    have the knowledge that don't count the events which map to the same
    counter, or the user will get the inaccurate results.

    We choose method 2 for the solution

    Signed-off-by: Nickhu
    Acked-by: Greentime Hu
    Signed-off-by: Greentime Hu

    Nickhu
     

20 Oct, 2018

1 commit

  • Currently, on x86-64, perf uses LFENCE and MFENCE (rmb() and mb(),
    respectively) when processing events from the perf ring buffer which
    is unnecessarily expensive as we can do more lightweight in particular
    given this is critical fast-path in perf.

    According to Peter rmb()/mb() were added back then via a94d342b9cb0
    ("tools/perf: Add required memory barriers") at a time where kernel
    still supported chips that needed it, but nowadays support for these
    has been ditched completely, therefore we can fix them up as well.

    While for x86-64, replacing rmb() and mb() with smp_*() variants would
    result in just a compiler barrier for the former and LOCK + ADD for
    the latter (__sync_synchronize() uses slower MFENCE by the way), Peter
    suggested we can use smp_{load_acquire,store_release}() instead for
    architectures where its implementation doesn't resolve in slower smp_mb().
    Thus, e.g. in x86-64 we would be able to avoid CPU barrier entirely due
    to TSO. For architectures where the latter needs to use smp_mb() e.g.
    on arm, we stick to cheaper smp_rmb() variant for fetching the head.

    This work adds helpers ring_buffer_read_head() and ring_buffer_write_tail()
    for tools infrastructure that either switches to smp_load_acquire() for
    architectures where it is cheaper or uses READ_ONCE() + smp_rmb() barrier
    for those where it's not in order to fetch the data_head from the perf
    control page, and it uses smp_store_release() to write the data_tail.
    Latter is smp_mb() + WRITE_ONCE() combination or a cheaper variant if
    architecture allows for it. Those that rely on smp_rmb() and smp_mb() can
    further improve performance in a follow up step by implementing the two
    under tools/arch/*/include/asm/barrier.h such that they don't have to
    fallback to rmb() and mb() in tools/include/asm/barrier.h.

    Switch perf to use ring_buffer_read_head() and ring_buffer_write_tail()
    so it can make use of the optimizations. Later, we convert libbpf as
    well to use the same helpers.

    Side note [0]: the topic has been raised of whether one could simply use
    the C11 gcc builtins [1] for the smp_load_acquire() and smp_store_release()
    instead:

    __atomic_load_n(ptr, __ATOMIC_ACQUIRE);
    __atomic_store_n(ptr, val, __ATOMIC_RELEASE);

    Kernel and (presumably) tooling shipped along with the kernel has a
    minimum requirement of being able to build with gcc-4.6 and the latter
    does not have C11 builtins. While generally the C11 memory models don't
    align with the kernel's, the C11 load-acquire and store-release alone
    /could/ suffice, however. Issue is that this is implementation dependent
    on how the load-acquire and store-release is done by the compiler and
    the mapping of supported compilers must align to be compatible with the
    kernel's implementation, and thus needs to be verified/tracked on a
    case by case basis whether they match (unless an architecture uses them
    also from kernel side). The implementations for smp_load_acquire() and
    smp_store_release() in this patch have been adapted from the kernel side
    ones to have a concrete and compatible mapping in place.

    [0] http://patchwork.ozlabs.org/patch/985422/
    [1] https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html

    Signed-off-by: Daniel Borkmann
    Acked-by: Peter Zijlstra (Intel)
    Cc: "Paul E. McKenney"
    Cc: Will Deacon
    Cc: Arnaldo Carvalho de Melo
    Signed-off-by: Alexei Starovoitov

    Daniel Borkmann
     

04 Nov, 2017

1 commit

  • After the SPDX license tags were added a number of tooling headers got out of
    sync with their kernel variants, generating lots of build warnings.

    Sync them:

    - tools/arch/x86/include/asm/disabled-features.h,
    tools/arch/x86/include/asm/required-features.h,
    tools/include/linux/hash.h:

    Remove the SPDX tag where the kernel version does not have it.

    - tools/include/asm-generic/bitops/__fls.h,
    tools/include/asm-generic/bitops/arch_hweight.h,
    tools/include/asm-generic/bitops/const_hweight.h,
    tools/include/asm-generic/bitops/fls.h,
    tools/include/asm-generic/bitops/fls64.h,
    tools/include/uapi/asm-generic/ioctls.h,
    tools/include/uapi/asm-generic/mman-common.h,
    tools/include/uapi/sound/asound.h,
    tools/include/uapi/linux/kvm.h,
    tools/include/uapi/linux/perf_event.h,
    tools/include/uapi/linux/sched.h,
    tools/include/uapi/linux/vhost.h,
    tools/include/uapi/sound/asound.h:

    Add the SPDX tag of the respective kernel header.

    - tools/include/uapi/linux/bpf_common.h,
    tools/include/uapi/linux/fcntl.h,
    tools/include/uapi/linux/hw_breakpoint.h,
    tools/include/uapi/linux/mman.h,
    tools/include/uapi/linux/stat.h,

    Change the tag to the kernel header version:

    -/* SPDX-License-Identifier: GPL-2.0 */
    +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */

    Also sync other header details:

    - include/uapi/sound/asound.h:

    Fix pointless end of line whitespace noise the header grew in this cycle.

    - tools/arch/x86/lib/memcpy_64.S:

    Sync the code and add tools/include/asm/export.h with dummy wrappers
    to support building the kernel side code in a tooling header environment.

    - tools/include/uapi/asm-generic/mman.h,
    tools/include/uapi/linux/bpf.h:

    Sync other details that don't impact tooling's use of the ABIs.

    Acked-by: Arnaldo Carvalho de Melo
    Cc: linux-kernel@vger.kernel.org
    Cc: Greg Kroah-Hartman
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: Namhyung Kim
    Cc: Jiri Olsa
    Cc: Stephen Rothwell
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

02 Nov, 2017

1 commit

  • 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
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

05 Jun, 2017

1 commit


28 Jan, 2017

1 commit

  • The definition of WARN_ON being used by the radix tree test suite was
    deficient in two ways: it did not provide a return value, and it stopped
    execution instead of continuing. This version of WARN_ON tells you
    which file & line the assertion was triggered in.

    Signed-off-by: Matthew Wilcox

    Matthew Wilcox
     

15 Dec, 2016

1 commit

  • Patch series "Radix tree patches for 4.10", v3.

    Mostly these are improvements; the only bug fixes in here relate to
    multiorder entries (which are unused in the 4.9 tree).

    This patch (of 32):

    The radix tree uses its own buggy WARN_ON_ONCE. Replace it with the
    definition from asm-generic/bug.h

    Link: http://lkml.kernel.org/r/1480369871-5271-37-git-send-email-mawilcox@linuxonhyperv.com
    Signed-off-by: Matthew Wilcox
    Tested-by: Kirill A. Shutemov
    Cc: Konstantin Khlebnikov
    Cc: Ross Zwisler
    Cc: Matthew Wilcox
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matthew Wilcox
     

13 Jul, 2016

1 commit


09 May, 2015

13 commits


13 Jan, 2014

2 commits

  • Since it uses unlikely() macro inside WARN()

    Signed-off-by: Namhyung Kim
    Cc: Frederic Weisbecker
    Cc: Ingo Molnar
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Steven Rostedt
    Link: http://lkml.kernel.org/r/1389276059-8829-5-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • So that it can be shared with others like libtraceevent.

    Signed-off-by: Namhyung Kim
    Cc: Frederic Weisbecker
    Cc: Ingo Molnar
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Steven Rostedt
    Link: http://lkml.kernel.org/r/1389276059-8829-4-git-send-email-namhyung@kernel.org
    [ Added the new header to tools/perf/MANIFEST ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim