1. 14 Mar, 2022 2 commits
    • Kees Cook's avatar
      MIPS: boot/compressed: Use array reference for image bounds · 4d409ca3
      Kees Cook authored
      As done with other image addresses in other architectures, use an
      explicit flexible array instead of "address of char", which can trip
      bounds checking done by the compiler. Found when building with
      -Warray-bounds:
      
      In file included from ./include/linux/byteorder/little_endian.h:5,
                       from ./arch/mips/include/uapi/asm/byteorder.h:15,
                       from ./arch/mips/include/asm/bitops.h:21,
                       from ./include/linux/bitops.h:33,
                       from ./include/linux/kernel.h:22,
                       from arch/mips/boot/compressed/decompress.c:13:
      arch/mips/boot/compressed/decompress.c: In function 'decompress_kernel':
      ./include/asm-generic/unaligned.h:14:8: warning: array subscript -1 is outside array bounds of 'unsigned char[1]' [-Warray-bounds]
         14 |  __pptr->x;        \
            |  ~~~~~~^~~
      ./include/uapi/linux/byteorder/little_endian.h:35:51: note: in definition of macro '__le32_to_cpu'
         35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
            |                                                   ^
      ./include/asm-generic/unaligned.h:32:21: note: in expansion of macro '__get_unaligned_t'
         32 |  return le32_to_cpu(__get_unaligned_t(__le32, p));
            |                     ^~~~~~~~~~~~~~~~~
      arch/mips/boot/compressed/decompress.c:29:37: note: while referencing '__image_end'
         29 | extern unsigned char __image_begin, __image_end;
            |                                     ^~~~~~~~~~~
      
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: linux-mips@vger.kernel.org
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      4d409ca3
    • Miaoqian Lin's avatar
      mips: cdmm: Fix refcount leak in mips_cdmm_phys_base · 4528668c
      Miaoqian Lin authored
      The of_find_compatible_node() function returns a node pointer with
      refcount incremented, We should use of_node_put() on it when done
      Add the missing of_node_put() to release the refcount.
      
      Fixes: 2121aa3e ("mips: cdmm: Add mti,mips-cdmm dtb node support")
      Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
      Acked-by: default avatarSerge Semin <fancer.lancer@gmail.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      4528668c
  2. 07 Mar, 2022 6 commits
    • Xi Ruoyao's avatar
      mips: remove reference to "newer Loongson-3" · 3f059a7e
      Xi Ruoyao authored
      Newest Loongson-3 processors have moved to use LoongArch architecture.
      Sadly, the LL/SC issue is still existing on both latest Loongson-3
      processors using MIPS64 (Loongson-3A4000) and LoongArch
      (Loongson-3A5000).
      
      As it's very unlikely there will be new Loongson-3 processors using
      MIPS64, let's stop people from false hoping.
      Signed-off-by: default avatarXi Ruoyao <xry111@mengyan1223.wang>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      3f059a7e
    • Paul Cercueil's avatar
      mips: Always permit to build u-boot images · 34275ac2
      Paul Cercueil authored
      The platforms where the kernel should be loaded above 0x8000.0000 do not
      support loading u-boot images, that doesn't mean that we shouldn't be
      able to generate them.
      
      Additionally, since commit 79876cc1 ("MIPS: new Kconfig option
      ZBOOT_LOAD_ADDRESS"), the $(zload-y) variable was no longer hardcoded,
      which made it impossible to use the uzImage.bin target.
      
      Fixes: 79876cc1 ("MIPS: new Kconfig option ZBOOT_LOAD_ADDRESS")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarPaul Cercueil <paul@crapouillou.net>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      34275ac2
    • Maciej W. Rozycki's avatar
      MIPS: Sanitise Cavium switch cases in TLB handler synthesizers · 6ddcba9d
      Maciej W. Rozycki authored
      It makes no sense to fall through to `break'.  Therefore reorder the
      switch statements so as to have the Cavium cases first, followed by the
      default case, which improves readability and pacifies code analysis
      tools.  No change in semantics, assembly produced is exactly the same.
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
      Fixes: bc431d21 ("MIPS: Fix fall-through warnings for Clang")
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      6ddcba9d
    • Maciej W. Rozycki's avatar
      DEC: Limit PMAX memory probing to R3k systems · 244eae91
      Maciej W. Rozycki authored
      Recent tightening of the opcode table in binutils so as to consistently
      disallow the assembly or disassembly of CP0 instructions not supported
      by the processor architecture chosen has caused a regression like below:
      
      arch/mips/dec/prom/locore.S: Assembler messages:
      arch/mips/dec/prom/locore.S:29: Error: opcode not supported on this processor: r4600 (mips3) `rfe'
      
      in a piece of code used to probe for memory with PMAX DECstation models,
      which have non-REX firmware.  Those computers always have an R2000 CPU
      and consequently the exception handler used in memory probing uses the
      RFE instruction, which those processors use.
      
      While adding 64-bit support this code was correctly excluded for 64-bit
      configurations, however it should have also been excluded for irrelevant
      32-bit configurations.  Do this now then, and only enable PMAX memory
      probing for R3k systems.
      Reported-by: default avatarJan-Benedict Glaw <jbglaw@lug-owl.de>
      Reported-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable@vger.kernel.org # v2.6.12+
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      244eae91
    • Randy Dunlap's avatar
      mips: DEC: honor CONFIG_MIPS_FP_SUPPORT=n · 97bf0395
      Randy Dunlap authored
      Include the DECstation interrupt handler in opting out of
      FPU support.
      
      Fixes a linker error:
      
      mips-linux-ld: arch/mips/dec/int-handler.o: in function `fpu':
      (.text+0x148): undefined reference to `handle_fpe_int'
      
      Fixes: 183b40f9 ("MIPS: Allow FP support to be disabled")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Cc: Paul Burton <paulburton@kernel.org>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Maciej W. Rozycki <macro@orcam.me.uk>
      Cc: linux-mips@vger.kernel.org
      Acked-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      97bf0395
    • Alexander Lobakin's avatar
      MIPS: fix fortify panic when copying asm exception handlers · d17b6641
      Alexander Lobakin authored
      With KCFLAGS="-O3", I was able to trigger a fortify-source
      memcpy() overflow panic on set_vi_srs_handler().
      Although O3 level is not supported in the mainline, under some
      conditions that may've happened with any optimization settings,
      it's just a matter of inlining luck. The panic itself is correct,
      more precisely, 50/50 false-positive and not at the same time.
      From the one side, no real overflow happens. Exception handler
      defined in asm just gets copied to some reserved places in the
      memory.
      But the reason behind is that C code refers to that exception
      handler declares it as `char`, i.e. something of 1 byte length.
      It's obvious that the asm function itself is way more than 1 byte,
      so fortify logics thought we are going to past the symbol declared.
      The standard way to refer to asm symbols from C code which is not
      supposed to be called from C is to declare them as
      `extern const u8[]`. This is fully correct from any point of view,
      as any code itself is just a bunch of bytes (including 0 as it is
      for syms like _stext/_etext/etc.), and the exact size is not known
      at the moment of compilation.
      Adjust the type of the except_vec_vi_*() and related variables.
      Make set_handler() take `const` as a second argument to avoid
      cast-away warnings and give a little more room for optimization.
      Signed-off-by: default avatarAlexander Lobakin <alobakin@pm.me>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      d17b6641
  3. 01 Mar, 2022 3 commits
  4. 23 Feb, 2022 1 commit
    • Kees Cook's avatar
      MIPS: Modernize READ_IMPLIES_EXEC · fbb1d4b3
      Kees Cook authored
      I'm doing some thread necromancy of
      https://lore.kernel.org/lkml/202007081624.82FA0CC1EA@keescook/
      
      x86, arm64, and arm32 adjusted their READ_IMPLIES_EXEC logic to better
      align with the safer defaults and the interactions with other mappings,
      which I illustrated with this comment on x86:
      
      /*
       * An executable for which elf_read_implies_exec() returns TRUE will
       * have the READ_IMPLIES_EXEC personality flag set automatically.
       *
       * The decision process for determining the results are:
       *
       *                 CPU: | lacks NX*  | has NX, ia32     | has NX, x86_64 |
       * ELF:                 |            |                  |                |
       * ---------------------|------------|------------------|----------------|
       * missing PT_GNU_STACK | exec-all   | exec-all         | exec-none      |
       * PT_GNU_STACK == RWX  | exec-stack | exec-stack       | exec-stack     |
       * PT_GNU_STACK == RW   | exec-none  | exec-none        | exec-none      |
       *
       *  exec-all  : all PROT_READ user mappings are executable, except when
       *              backed by files on a noexec-filesystem.
       *  exec-none : only PROT_EXEC user mappings are executable.
       *  exec-stack: only the stack and PROT_EXEC user mappings are
       *  executable.
       *
       *  *this column has no architectural effect: NX markings are ignored by
       *   hardware, but may have behavioral effects when "wants X" collides with
       *   "cannot be X" constraints in memory permission flags, as in
       *   https://lkml.kernel.org/r/20190418055759.GA3155@mellanox.com
       *
       */
      
      For MIPS, the "lacks NX" above is the "!cpu_has_rixi" check. On x86,
      we decided that the READ_IMPLIES_EXEC flag needed to reflect the
      expectations, not the architectural behavior due to bad interactions
      as noted above, as always returning "1" on non-NX hardware breaks
      some mappings.
      
      The other part of the issue is "what does the MIPS toolchain do for
      PT_GNU_STACK?" The answer seems to be "by default, include PT_GNU_STACK,
      but mark it executable" (likely due to concerns over non-NX hardware):
      
      $ mipsel-linux-gnu-gcc -o hello_world hello_world.c
      $ llvm-readelf -lW hellow_world | grep GNU_STACK
        GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x10
      
      Given that older hardware doesn't support non-executable memory, it
      seems safe to make the "PT_GNU_STACK is absent" logic mean "assume
      non-executable", but this might break very old software running on
      modern MIPS. This situation matches the ia32-on-x86_64 logic x86
      uses (which assumes needing READ_IMPLIES_EXEC in that situation). But
      modern toolchains on modern MIPS hardware should follow a safer default
      (assume NX stack).
      
      A follow-up to this change would be to switch the MIPS toolchain to emit
      a non-executable PT_GNU_STACK, as this seems to be unneeded.
      
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Xuefeng Li <lixuefeng@loongson.cn>
      Cc: Juxin Gao <gaojuxin@loongson.cn>
      Cc: linux-mips@vger.kernel.org
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      fbb1d4b3
  5. 22 Feb, 2022 6 commits
  6. 09 Feb, 2022 1 commit
    • Nathan Chancellor's avatar
      MIPS: Malta: Enable BLK_DEV_INITRD · c47c7ab9
      Nathan Chancellor authored
      This configuration is useful for boot testing malta_defconfig in QEMU
      with just a simple cpio initrd, instead of a full ext4 rootfs.
      
      This results in an increase of ~164KB of vmlinux (with GCC 11.2.0):
      
      $ diskus vmlinux.before
      11.19 MB (11,194,368 bytes)
      
      $ diskus vmlinux.after
      11.36 MB (11,358,208 bytes)
      
      This size increase comes from the fact that usr/Kconfig is sourced when
      CONFIG_BLK_DEV_INITRD is enabled, which defaults to supporting several
      decompression algorithms for compressed initrds. This seems like a
      reasonable tradeoff but these configurations could be disabled in the
      future if there are complaints about the size increase.
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      c47c7ab9
  7. 07 Feb, 2022 4 commits
  8. 06 Feb, 2022 17 commits
    • Linus Torvalds's avatar
      Linux 5.17-rc3 · dfd42fac
      Linus Torvalds authored
      dfd42fac
    • Linus Torvalds's avatar
      Merge tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4 · d8ad2ce8
      Linus Torvalds authored
      Pull ext4 fixes from Ted Ts'o:
       "Various bug fixes for ext4 fast commit and inline data handling.
      
        Also fix regression introduced as part of moving to the new mount API"
      
      * tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
        fs/ext4: fix comments mentioning i_mutex
        ext4: fix incorrect type issue during replay_del_range
        jbd2: fix kernel-doc descriptions for jbd2_journal_shrink_{scan,count}()
        ext4: fix potential NULL pointer dereference in ext4_fill_super()
        jbd2: refactor wait logic for transaction updates into a common function
        jbd2: cleanup unused functions declarations from jbd2.h
        ext4: fix error handling in ext4_fc_record_modified_inode()
        ext4: remove redundant max inline_size check in ext4_da_write_inline_data_begin()
        ext4: fix error handling in ext4_restore_inline_data()
        ext4: fast commit may miss file actions
        ext4: fast commit may not fallback for ineligible commit
        ext4: modify the logic of ext4_mb_new_blocks_simple
        ext4: prevent used blocks from being allocated during fast commit replay
      d8ad2ce8
    • Linus Torvalds's avatar
      Merge tag 'perf-tools-fixes-for-v5.17-2022-02-06' of... · 18118a42
      Linus Torvalds authored
      Merge tag 'perf-tools-fixes-for-v5.17-2022-02-06' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
      
      Pull perf tools fixes from Arnaldo Carvalho de Melo:
      
       - Fix display of grouped aliased events in 'perf stat'.
      
       - Add missing branch_sample_type to perf_event_attr__fprintf().
      
       - Apply correct label to user/kernel symbols in branch mode.
      
       - Fix 'perf ftrace' system_wide tracing, it has to be set before
         creating the maps.
      
       - Return error if procfs isn't mounted for PID namespaces when
         synthesizing records for pre-existing processes.
      
       - Set error stream of objdump process for 'perf annotate' TUI, to avoid
         garbling the screen.
      
       - Add missing arm64 support to perf_mmap__read_self(), the kernel part
         got into 5.17.
      
       - Check for NULL pointer before dereference writing debug info about a
         sample.
      
       - Update UAPI copies for asound, perf_event, prctl and kvm headers.
      
       - Fix a typo in bpf_counter_cgroup.c.
      
      * tag 'perf-tools-fixes-for-v5.17-2022-02-06' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
        perf ftrace: system_wide collection is not effective by default
        libperf: Add arm64 support to perf_mmap__read_self()
        tools include UAPI: Sync sound/asound.h copy with the kernel sources
        perf stat: Fix display of grouped aliased events
        perf tools: Apply correct label to user/kernel symbols in branch mode
        perf bpf: Fix a typo in bpf_counter_cgroup.c
        perf synthetic-events: Return error if procfs isn't mounted for PID namespaces
        perf session: Check for NULL pointer before dereference
        perf annotate: Set error stream of objdump process for TUI
        perf tools: Add missing branch_sample_type to perf_event_attr__fprintf()
        tools headers UAPI: Sync linux/kvm.h with the kernel sources
        tools headers UAPI: Sync linux/prctl.h with the kernel sources
        perf beauty: Make the prctl arg regexp more strict to cope with PR_SET_VMA
        tools headers cpufeatures: Sync with the kernel sources
        tools headers UAPI: Sync linux/perf_event.h with the kernel sources
        tools include UAPI: Sync sound/asound.h copy with the kernel sources
      18118a42
    • Linus Torvalds's avatar
      Merge tag 'perf_urgent_for_v5.17_rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · c3bf8a14
      Linus Torvalds authored
      Pull perf fixes from Borislav Petkov:
      
       - Intel/PT: filters could crash the kernel
      
       - Intel: default disable the PMU for SMM, some new-ish EFI firmware has
         started using CPL3 and the PMU CPL filters don't discriminate against
         SMM, meaning that CPL3 (userspace only) events now also count EFI/SMM
         cycles.
      
       - Fixup for perf_event_attr::sig_data
      
      * tag 'perf_urgent_for_v5.17_rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        perf/x86/intel/pt: Fix crash with stop filters in single-range mode
        perf: uapi: Document perf_event_attr::sig_data truncation on 32 bit architectures
        selftests/perf_events: Test modification of perf_event_attr::sig_data
        perf: Copy perf_event_attr::sig_data on modification
        x86/perf: Default set FREEZE_ON_SMI for all
      c3bf8a14
    • Linus Torvalds's avatar
      Merge tag 'objtool_urgent_for_v5.17_rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · aeabe1e0
      Linus Torvalds authored
      Pull objtool fix from Borislav Petkov:
       "Fix a potential truncated string warning triggered by gcc12"
      
      * tag 'objtool_urgent_for_v5.17_rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        objtool: Fix truncated string warning
      aeabe1e0
    • Linus Torvalds's avatar
      Merge tag 'irq_urgent_for_v5.17_rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · b72e40b1
      Linus Torvalds authored
      Pull irq fix from Borislav Petkov:
       "Remove a bogus warning introduced by the recent PCI MSI irq affinity
        overhaul"
      
      * tag 'irq_urgent_for_v5.17_rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        PCI/MSI: Remove bogus warning in pci_irq_get_affinity()
      b72e40b1
    • Linus Torvalds's avatar
      Merge tag 'edac_urgent_for_v5.17_rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/ras/ras · 898b5841
      Linus Torvalds authored
      Pull EDAC fixes from Borislav Petkov:
       "Fix altera and xgene EDAC drivers to propagate the correct error code
        from platform_get_irq() so that deferred probing still works"
      
      * tag 'edac_urgent_for_v5.17_rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/ras/ras:
        EDAC/xgene: Fix deferred probing
        EDAC/altera: Fix deferred probing
      898b5841
    • Changbin Du's avatar
      perf ftrace: system_wide collection is not effective by default · fceb6212
      Changbin Du authored
      The ftrace.target.system_wide must be set before invoking
      evlist__create_maps(), otherwise it has no effect.
      
      Fixes: 53be5028 ("perf ftrace: Add 'latency' subcommand")
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Acked-by: default avatarNamhyung Kim <namhyung@gmail.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220127132010.4836-1-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fceb6212
    • Rob Herring's avatar
      libperf: Add arm64 support to perf_mmap__read_self() · 407eb43a
      Rob Herring authored
      Add the arm64 variants for read_perf_counter() and read_timestamp().
      Unfortunately the counter number is encoded into the instruction, so the
      code is a bit verbose to enumerate all possible counters.
      Tested-by: default avatarMasayoshi Mizuma <m.mizuma@jp.fujitsu.com>
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Tested-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Link: https://lore.kernel.org/r/20220201214056.702854-1-robh@kernel.org
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-perf-users@vger.kernel.org
      407eb43a
    • Arnaldo Carvalho de Melo's avatar
      tools include UAPI: Sync sound/asound.h copy with the kernel sources · 4f249273
      Arnaldo Carvalho de Melo authored
      Picking the changes from:
      
        06feec60 ("ASoC: hdmi-codec: Fix OOB memory accesses")
      
      Which entails no changes in the tooling side as it doesn't introduce new
      SNDRV_PCM_IOCTL_ ioctls.
      
      To silence this perf tools build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/sound/asound.h' differs from latest version at 'include/uapi/sound/asound.h'
        diff -u tools/include/uapi/sound/asound.h include/uapi/sound/asound.h
      
      Cc: Dmitry Osipenko <digetx@gmail.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Takashi Iwai <tiwai@suse.de>
      Link: https://lore.kernel.org/lkml/Yf+6OT+2eMrYDEeX@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4f249273
    • Ian Rogers's avatar
      perf stat: Fix display of grouped aliased events · b2b1aa73
      Ian Rogers authored
      An event may have a number of uncore aliases that when added to the
      evlist are consecutive.
      
      If there are multiple uncore events in a group then
      parse_events__set_leader_for_uncore_aliase will reorder the evlist so
      that events on the same PMU are adjacent.
      
      The collect_all_aliases function assumes that aliases are in blocks so
      that only the first counter is printed and all others are marked merged.
      
      The reordering for groups breaks the assumption and so all counts are
      printed.
      
      This change removes the assumption from collect_all_aliases
      that the events are in blocks and instead processes the entire evlist.
      
      Before:
      
        ```
        $ perf stat -e '{UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE,UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE},duration_time' -a -A -- sleep 1
      
         Performance counter stats for 'system wide':
      
        CPU0                  256,866      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 494,413      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      967      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,738      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  285,161      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 429,920      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      955      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,443      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  310,753      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 416,657      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,231      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,573      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  416,067      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 405,966      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,481      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,447      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  312,911      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 408,154      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,086      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,380      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  333,994      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 370,349      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,287      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,335      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  188,107      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 302,423      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      701      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,070      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  307,221      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 383,642      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,036      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,158      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  318,479      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 821,545      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,028      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   2,550      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  227,618      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 372,272      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      903      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,456      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  376,783      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 419,827      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,406      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,453      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  286,583      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 429,956      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      999      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,436      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  313,867      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 370,159      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,114      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,291      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  342,083      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 409,111      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,399      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,684      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  365,828      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 376,037      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,378      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,411      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  382,456      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 621,743      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,232      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,955      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  342,316      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 385,067      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,176      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,268      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  373,588      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 386,163      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,394      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,464      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  381,206      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 546,891      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,266      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,712      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  221,176      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 392,069      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      831      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,456      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  355,401      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 705,595      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,235      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   2,216      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  371,436      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 428,103      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,306      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,442      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  384,352      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 504,200      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,468      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,860      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  228,856      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 287,976      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      832      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,060      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  215,121      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 334,162      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      681      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,026      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  296,179      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 436,083      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,084      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,525      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  262,296      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 416,573      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      986      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,533      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  285,852      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 359,842      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,073      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,326      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  303,379      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 367,222      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,008      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,156      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  273,487      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 425,449      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      932      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,367      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  297,596      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 414,793      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,140      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,601      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  342,365      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 360,422      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,291      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,342      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  327,196      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 580,858      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,122      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   2,014      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  296,564      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 452,817      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,087      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,694      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  375,002      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 389,393      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,478      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,540      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  365,213      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 594,685      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,401      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   2,222      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0            1,000,749,060 ns   duration_time
      
               1.000749060 seconds time elapsed
        ```
      
      After:
      
        ```
         Performance counter stats for 'system wide':
      
        CPU0               20,547,434      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36              45,202,862      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                   82,001      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                 159,688      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0            1,000,464,828 ns   duration_time
      
               1.000464828 seconds time elapsed
        ```
      
      Fixes: 3cdc5c2c ("perf parse-events: Handle uncore event aliases in small groups properly")
      Reviewed-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
      Cc: Asaf Yaffe <asaf.yaffe@intel.com>
      Cc: Caleb Biggers <caleb.biggers@intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kshipra Bopardikar <kshipra.bopardikar@intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Perry Taylor <perry.taylor@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Vineet Singh <vineet.singh@intel.com>
      Cc: Zhengjun Xing <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20220205010941.1065469-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b2b1aa73
    • German Gomez's avatar
      perf tools: Apply correct label to user/kernel symbols in branch mode · 05b5a9d6
      German Gomez authored
      In branch mode, the branch symbols were being displayed with incorrect
      cpumode labels. So fix this.
      
      For example, before:
        # perf record -b -a -- sleep 1
        # perf report -b
      
        Overhead  Command  Source Shared Object  Source Symbol               Target Symbol
           0.08%  swapper  [kernel.kallsyms]     [k] rcu_idle_enter          [k] cpuidle_enter_state
       ==> 0.08%  cmd0     [kernel.kallsyms]     [.] psi_group_change        [.] psi_group_change
           0.08%  cmd1     [kernel.kallsyms]     [k] psi_group_change        [k] psi_group_change
      
      After:
        # perf report -b
      
        Overhead  Command  Source Shared Object  Source Symbol               Target Symbol
           0.08%  swapper  [kernel.kallsyms]     [k] rcu_idle_enter          [k] cpuidle_enter_state
           0.08%  cmd0     [kernel.kallsyms]     [k] psi_group_change        [k] pei_group_change
           0.08%  cmd1     [kernel.kallsyms]     [k] psi_group_change        [k] psi_group_change
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarGerman Gomez <german.gomez@arm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20220126105927.3411216-1-german.gomez@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      05b5a9d6
    • Masanari Iida's avatar
      perf bpf: Fix a typo in bpf_counter_cgroup.c · a2887b9b
      Masanari Iida authored
      This patch fixes a spelling typo in error message.
      Signed-off-by: default avatarMasanari Iida <standby24x7@gmail.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20211225005558.503935-1-standby24x7@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a2887b9b
    • Leo Yan's avatar
      perf synthetic-events: Return error if procfs isn't mounted for PID namespaces · bc9c806e
      Leo Yan authored
      For perf recording, it retrieves process info by iterating nodes in proc
      fs.  If we run perf in a non-root PID namespace with command:
      
        # unshare --fork --pid perf record -e cycles -a -- test_program
      
      ... in this case, unshare command creates a child PID namespace and
      launches perf tool in it, but the issue is the proc fs is not mounted
      for the non-root PID namespace, this leads to the perf tool gathering
      process info from its parent PID namespace.
      
      We can use below command to observe the process nodes under proc fs:
      
        # unshare --pid --fork ls /proc
      1    137   1968  2128  3    342  48  62   78	     crypto	  kcore        net	      uptime
      10   138   2	 2142  30   35	 49  63   8	     devices	  keys	       pagetypeinfo   version
      11   139   20	 2143  304  36	 50  64   82	     device-tree  key-users    partitions     vmallocinfo
      12   14    2011  22    305  37	 51  65   83	     diskstats	  kmsg	       self	      vmstat
      128  140   2038  23    307  39	 52  656  84	     driver	  kpagecgroup  slabinfo       zoneinfo
      129  15    2074  24    309  4	 53  67   9	     execdomains  kpagecount   softirqs
      13   16    2094  241   31   40	 54  68   asound     fb		  kpageflags   stat
      130  164   2096  242   310  41	 55  69   buddyinfo  filesystems  loadavg      swaps
      131  17    2098  25    317  42	 56  70   bus	     fs		  locks        sys
      132  175   21	 26    32   43	 57  71   cgroups    interrupts   meminfo      sysrq-trigger
      133  179   2102  263   329  44	 58  75   cmdline    iomem	  misc	       sysvipc
      134  1875  2103  27    330  45	 59  76   config.gz  ioports	  modules      thread-self
      135  19    2117  29    333  46	 6   77   consoles   irq	  mounts       timer_list
      136  1941  2121  298   34   47	 60  773  cpuinfo    kallsyms	  mtd	       tty
      
      So it shows many existed tasks, since unshared command has not mounted
      the proc fs for the new created PID namespace, it still accesses the
      proc fs of the root PID namespace.  This leads to two prominent issues:
      
      - Firstly, PID values are mismatched between thread info and samples.
        The gathered thread info are coming from the proc fs of the root PID
        namespace, but samples record its PID from the child PID namespace.
      
      - The second issue is profiled program 'test_program' returns its forked
        PID number from the child PID namespace, perf tool wrongly uses this
        PID number to retrieve the process info via the proc fs of the root
        PID namespace.
      
      To avoid issues, we need to mount proc fs for the child PID namespace
      with the option '--mount-proc' when use unshare command:
      
        # unshare --fork --pid --mount-proc perf record -e cycles -a -- test_program
      
      Conversely, when the proc fs of the root PID namespace is used by child
      namespace, perf tool can detect the multiple PID levels and
      nsinfo__is_in_root_namespace() returns false, this patch reports error
      for this case:
      
        # unshare --fork --pid perf record -e cycles -a -- test_program
        Couldn't synthesize bpf events.
        Perf runs in non-root PID namespace but it tries to gather process info from its parent PID namespace.
        Please mount the proc file system properly, e.g. add the option '--mount-proc' for unshare command.
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: KP Singh <kpsingh@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/r/20211224124014.2492751-1-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bc9c806e
    • Ameer Hamza's avatar
      perf session: Check for NULL pointer before dereference · d792a7a9
      Ameer Hamza authored
      Move NULL pointer check before dereferencing the variable.
      
      Addresses-Coverity: 1497622 ("Derereference before null check")
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarAmeer Hamza <amhamza.mgc@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Link: https://lore.kernel.org/r/20220125121141.18347-1-amhamza.mgc@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d792a7a9
    • Namhyung Kim's avatar
      perf annotate: Set error stream of objdump process for TUI · a663520f
      Namhyung Kim authored
      The stderr should be set to a pipe when using TUI.  Otherwise it'd
      print to stdout and break TUI windows with an error message.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20220202070828.143303-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a663520f
    • Anshuman Khandual's avatar
      perf tools: Add missing branch_sample_type to perf_event_attr__fprintf() · ae65b443
      Anshuman Khandual authored
      This updates branch sample type with missing PERF_SAMPLE_BRANCH_TYPE_SAVE.
      Suggested-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lore.kernel.org/lkml/1643799443-15109-1-git-send-email-anshuman.khandual@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ae65b443