1. 27 May, 2022 5 commits
    • Arnaldo Carvalho de Melo's avatar
      tools arch x86: Sync the msr-index.h copy with the kernel sources · 9dde6cad
      Arnaldo Carvalho de Melo authored
      To pick up the changes in:
      
        db1af129 ("x86/msr-index: Define INTEGRITY_CAPABILITIES MSR")
        089be16d ("x86/msr: Add PerfCntrGlobal* registers")
        f52ba931 ("tools/power turbostat: Add Power Limit4 support")
      
      Addressing these tools/perf build warnings:
      
          diff -u tools/arch/x86/include/asm/msr-index.h arch/x86/include/asm/msr-index.h
          Warning: Kernel ABI header at 'tools/arch/x86/include/asm/msr-index.h' differs from latest version at 'arch/x86/include/asm/msr-index.h'
      
      That makes the beautification scripts to pick some new entries:
      
        $ tools/perf/trace/beauty/tracepoints/x86_msr.sh > before
        $ cp arch/x86/include/asm/msr-index.h tools/arch/x86/include/asm/msr-index.h
        $ tools/perf/trace/beauty/tracepoints/x86_msr.sh > after
        $ diff -u before after
        --- before	2022-05-26 12:50:01.228612839 -0300
        +++ after	2022-05-26 12:50:07.699776166 -0300
        @@ -116,6 +116,7 @@
         	[0x0000026f] = "MTRRfix4K_F8000",
         	[0x00000277] = "IA32_CR_PAT",
         	[0x00000280] = "IA32_MC0_CTL2",
        +	[0x000002d9] = "INTEGRITY_CAPS",
         	[0x000002ff] = "MTRRdefType",
         	[0x00000309] = "CORE_PERF_FIXED_CTR0",
         	[0x0000030a] = "CORE_PERF_FIXED_CTR1",
        @@ -176,6 +177,7 @@
         	[0x00000586] = "IA32_RTIT_ADDR3_A",
         	[0x00000587] = "IA32_RTIT_ADDR3_B",
         	[0x00000600] = "IA32_DS_AREA",
        +	[0x00000601] = "VR_CURRENT_CONFIG",
         	[0x00000606] = "RAPL_POWER_UNIT",
         	[0x0000060a] = "PKGC3_IRTL",
         	[0x0000060b] = "PKGC6_IRTL",
        @@ -260,6 +262,10 @@
         	[0xc0000102 - x86_64_specific_MSRs_offset] = "KERNEL_GS_BASE",
         	[0xc0000103 - x86_64_specific_MSRs_offset] = "TSC_AUX",
         	[0xc0000104 - x86_64_specific_MSRs_offset] = "AMD64_TSC_RATIO",
        +	[0xc000010f - x86_64_specific_MSRs_offset] = "AMD_DBG_EXTN_CFG",
        +	[0xc0000300 - x86_64_specific_MSRs_offset] = "AMD64_PERF_CNTR_GLOBAL_STATUS",
        +	[0xc0000301 - x86_64_specific_MSRs_offset] = "AMD64_PERF_CNTR_GLOBAL_CTL",
        +	[0xc0000302 - x86_64_specific_MSRs_offset] = "AMD64_PERF_CNTR_GLOBAL_STATUS_CLR",
         };
      
         #define x86_AMD_V_KVM_MSRs_offset 0xc0010000
        @@ -318,4 +324,5 @@
         	[0xc00102b4 - x86_AMD_V_KVM_MSRs_offset] = "AMD_CPPC_STATUS",
         	[0xc00102f0 - x86_AMD_V_KVM_MSRs_offset] = "AMD_PPIN_CTL",
         	[0xc00102f1 - x86_AMD_V_KVM_MSRs_offset] = "AMD_PPIN",
        +	[0xc0010300 - x86_AMD_V_KVM_MSRs_offset] = "AMD_SAMP_BR_FROM",
         };
        $
      
      Now one can trace systemwide asking to see backtraces to where those
      MSRs are being read/written, see this example with a previous update:
      
        # perf trace -e msr:*_msr/max-stack=32/ --filter="msr>=IA32_U_CET && msr<=IA32_INT_SSP_TAB"
        ^C#
      
      If we use -v (verbose mode) we can see what it does behind the scenes:
      
        # perf trace -v -e msr:*_msr/max-stack=32/ --filter="msr>=IA32_U_CET && msr<=IA32_INT_SSP_TAB"
        Using CPUID AuthenticAMD-25-21-0
        0x6a0
        0x6a8
        New filter for msr:read_msr: (msr>=0x6a0 && msr<=0x6a8) && (common_pid != 597499 && common_pid != 3313)
        0x6a0
        0x6a8
        New filter for msr:write_msr: (msr>=0x6a0 && msr<=0x6a8) && (common_pid != 597499 && common_pid != 3313)
        mmap size 528384B
        ^C#
      
      Example with a frequent msr:
      
        # perf trace -v -e msr:*_msr/max-stack=32/ --filter="msr==IA32_SPEC_CTRL" --max-events 2
        Using CPUID AuthenticAMD-25-21-0
        0x48
        New filter for msr:read_msr: (msr==0x48) && (common_pid != 2612129 && common_pid != 3841)
        0x48
        New filter for msr:write_msr: (msr==0x48) && (common_pid != 2612129 && common_pid != 3841)
        mmap size 528384B
        Looking at the vmlinux_path (8 entries long)
        symsrc__init: build id mismatch for vmlinux.
        Using /proc/kcore for kernel data
        Using /proc/kallsyms for symbols
           0.000 Timer/2525383 msr:write_msr(msr: IA32_SPEC_CTRL, val: 6)
                                             do_trace_write_msr ([kernel.kallsyms])
                                             do_trace_write_msr ([kernel.kallsyms])
                                             __switch_to_xtra ([kernel.kallsyms])
                                             __switch_to ([kernel.kallsyms])
                                             __schedule ([kernel.kallsyms])
                                             schedule ([kernel.kallsyms])
                                             futex_wait_queue_me ([kernel.kallsyms])
                                             futex_wait ([kernel.kallsyms])
                                             do_futex ([kernel.kallsyms])
                                             __x64_sys_futex ([kernel.kallsyms])
                                             do_syscall_64 ([kernel.kallsyms])
                                             entry_SYSCALL_64_after_hwframe ([kernel.kallsyms])
                                             __futex_abstimed_wait_common64 (/usr/lib64/libpthread-2.33.so)
           0.030 :0/0 msr:write_msr(msr: IA32_SPEC_CTRL, val: 2)
                                             do_trace_write_msr ([kernel.kallsyms])
                                             do_trace_write_msr ([kernel.kallsyms])
                                             __switch_to_xtra ([kernel.kallsyms])
                                             __switch_to ([kernel.kallsyms])
                                             __schedule ([kernel.kallsyms])
                                             schedule_idle ([kernel.kallsyms])
                                             do_idle ([kernel.kallsyms])
                                             cpu_startup_entry ([kernel.kallsyms])
                                             secondary_startup_64_no_verify ([kernel.kallsyms])
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Len Brown <len.brown@intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sumeet Pawnikar <sumeet.r.pawnikar@intel.com>
      Cc: Tony Luck <tony.luck@intel.com>
      Link: https://lore.kernel.org/lkml/Yo+i%252Fj5+UtE9dcix@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9dde6cad
    • Leo Yan's avatar
      perf scripts python: Support Arm CoreSight trace data disassembly · 12fdd6c0
      Leo Yan authored
      This commit adds python script to parse CoreSight tracing event and
      print out source line and disassembly, it generates readable program
      execution flow for easier humans inspecting.
      
      The script receives CoreSight tracing packet with below format:
      
                      +------------+------------+------------+
        packet(n):    |    addr    |    ip      |    cpu     |
                      +------------+------------+------------+
        packet(n+1):  |    addr    |    ip      |    cpu     |
                      +------------+------------+------------+
      
      packet::addr presents the start address of the coming branch sample, and
      packet::ip is the last address of the branch smple.  Therefore, a code
      section between branches starts from packet(n)::addr and it stops at
      packet(n+1)::ip.  As results we combines the two continuous packets to
      generate the address range for instructions:
      
        [ sample(n)::addr .. sample(n+1)::ip ]
      
      The script supports both objdump or llvm-objdump for disassembly with
      specifying option '-d'.  If doesn't specify option '-d', the script
      simply outputs source lines and symbols.
      
      Below shows usages with llvm-objdump or objdump to output disassembly.
      
        # perf script -s scripts/python/arm-cs-trace-disasm.py -- -d llvm-objdump-11 -k ./vmlinux
        ARM CoreSight Trace Data Assembler Dump
        	ffff800008eb3198 <etm4_enable_hw>:
        	ffff800008eb3310: c0 38 00 35  	cbnz	w0, 0xffff800008eb3a28 <etm4_enable_hw+0x890>
        	ffff800008eb3314: 9f 3f 03 d5  	dsb	sy
        	ffff800008eb3318: df 3f 03 d5  	isb
        	ffff800008eb331c: f5 5b 42 a9  	ldp	x21, x22, [sp, #32]
        	ffff800008eb3320: fb 73 45 a9  	ldp	x27, x28, [sp, #80]
        	ffff800008eb3324: e0 82 40 39  	ldrb	w0, [x23, #32]
        	ffff800008eb3328: 60 00 00 34  	cbz	w0, 0xffff800008eb3334 <etm4_enable_hw+0x19c>
        	ffff800008eb332c: e0 03 19 aa  	mov	x0, x25
        	ffff800008eb3330: 8c fe ff 97  	bl	0xffff800008eb2d60 <etm4_cs_lock.isra.0.part.0>
                    main  6728/6728  [0004]         0.000000000  etm4_enable_hw+0x198                    [kernel.kallsyms]
        	ffff800008eb2d60 <etm4_cs_lock.isra.0.part.0>:
        	ffff800008eb2d60: 1f 20 03 d5  	nop
        	ffff800008eb2d64: 1f 20 03 d5  	nop
        	ffff800008eb2d68: 3f 23 03 d5  	hint	#25
        	ffff800008eb2d6c: 00 00 40 f9  	ldr	x0, [x0]
        	ffff800008eb2d70: 9f 3f 03 d5  	dsb	sy
        	ffff800008eb2d74: 00 c0 3e 91  	add	x0, x0, #4016
        	ffff800008eb2d78: 1f 00 00 b9  	str	wzr, [x0]
        	ffff800008eb2d7c: bf 23 03 d5  	hint	#29
        	ffff800008eb2d80: c0 03 5f d6  	ret
                    main  6728/6728  [0004]         0.000000000  etm4_cs_lock.isra.0.part.0+0x20
      
        # perf script -s scripts/python/arm-cs-trace-disasm.py -- -d objdump -k ./vmlinux
        ARM CoreSight Trace Data Assembler Dump
        	ffff800008eb3310 <etm4_enable_hw+0x178>:
        	ffff800008eb3310:	350038c0 	cbnz	w0, ffff800008eb3a28 <etm4_enable_hw+0x890>
        	ffff800008eb3314:	d5033f9f 	dsb	sy
        	ffff800008eb3318:	d5033fdf 	isb
        	ffff800008eb331c:	a9425bf5 	ldp	x21, x22, [sp, #32]
        	ffff800008eb3320:	a94573fb 	ldp	x27, x28, [sp, #80]
        	ffff800008eb3324:	394082e0 	ldrb	w0, [x23, #32]
        	ffff800008eb3328:	34000060 	cbz	w0, ffff800008eb3334 <etm4_enable_hw+0x19c>
        	ffff800008eb332c:	aa1903e0 	mov	x0, x25
        	ffff800008eb3330:	97fffe8c 	bl	ffff800008eb2d60 <etm4_cs_lock.isra.0.part.0>
                    main  6728/6728  [0004]         0.000000000  etm4_enable_hw+0x198                    [kernel.kallsyms]
        	ffff800008eb2d60 <etm4_cs_lock.isra.0.part.0>:
        	ffff800008eb2d60:	d503201f 	nop
        	ffff800008eb2d64:	d503201f 	nop
        	ffff800008eb2d68:	d503233f 	paciasp
        	ffff800008eb2d6c:	f9400000 	ldr	x0, [x0]
        	ffff800008eb2d70:	d5033f9f 	dsb	sy
        	ffff800008eb2d74:	913ec000 	add	x0, x0, #0xfb0
        	ffff800008eb2d78:	b900001f 	str	wzr, [x0]
        	ffff800008eb2d7c:	d50323bf 	autiasp
        	ffff800008eb2d80:	d65f03c0 	ret
                    main  6728/6728  [0004]         0.000000000  etm4_cs_lock.isra.0.part.0+0x20
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Co-authored-by: default avatarAl Grant <al.grant@arm.com>
      Co-authored-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Co-authored-by: default avatarTor Jeremiassen <tor@ti.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Eelco Chaudron <echaudro@redhat.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephen Brennan <stephen.s.brennan@oracle.com>
      Cc: Tanmay Jagdale <tanmay@marvell.com>
      Cc: coresight@lists.linaro.org
      Cc: zengshun . wu <zengshun.wu@outlook.com>
      Link: https://lore.kernel.org/r/20220521130446.4163597-3-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      12fdd6c0
    • Leo Yan's avatar
      perf scripting python: Expose dso and map information · c4f46223
      Leo Yan authored
      This change adds dso build_id and corresponding map's start and end
      address.  The info of dso build_id can be used to find dso file path,
      and we can validate if a branch address falls into the range of map's
      start and end addresses.
      
      In addition, the map's start address can be used as an offset for
      disassembly.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Al Grant <al.grant@arm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Eelco Chaudron <echaudro@redhat.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephen Brennan <stephen.s.brennan@oracle.com>
      Cc: Tanmay Jagdale <tanmay@marvell.com>
      Cc: coresight@lists.linaro.org
      Cc: zengshun . wu <zengshun.wu@outlook.com>
      Link: https://lore.kernel.org/r/20220521130446.4163597-2-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c4f46223
    • Zhengjun Xing's avatar
      perf jevents: Fix event syntax error caused by ExtSel · f4df0dbb
      Zhengjun Xing authored
      In the origin code, when "ExtSel" is 1, the eventcode will change to
      "eventcode |= 1 << 21”. For event “UNC_Q_RxL_CREDITS_CONSUMED_VN0.DRS",
      its "ExtSel" is "1", its eventcode will change from 0x1E to 0x20001E,
      but in fact the eventcode should <=0x1FF, so this will cause the parse
      fail:
      
        # perf stat -e "UNC_Q_RxL_CREDITS_CONSUMED_VN0.DRS" -a sleep 0.1
        event syntax error: '.._RxL_CREDITS_CONSUMED_VN0.DRS'
                                          \___ value too big for format, maximum is 511
      
      On the perf kernel side, the kernel assumes the valid bits are continuous.
      It will adjust the 0x100 (bit 8 for perf tool) to bit 21 in HW.
      
      DEFINE_UNCORE_FORMAT_ATTR(event_ext, event, "config:0-7,21");
      
      So the perf tool follows the kernel side and just set bit8 other than bit21.
      
      Fixes: fedb2b51 ("perf jevents: Add support for parsing uncore json files")
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarXing Zhengjun <zhengjun.xing@linux.intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220525140410.1706851-1-zhengjun.xing@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f4df0dbb
    • James Clark's avatar
      perf tools arm64: Add support for VG register · 2be00431
      James Clark authored
      Add the name of the VG register so it can be used in --user-regs
      
      The event will fail to open if the register is requested but not
      available so only add it to the mask if the kernel supports sve and also
      if it supports that specific register.
      
      Committer notes:
      
      Add conditional definition of HWCAP_SVE, as suggested by Leo Yan, to
      build on older systems where this is not available in the system
      headers.
      Reviewed-by: default avatarLeo Yan <leo.yan@linaro.org>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20220525154114.718321-6-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2be00431
  2. 26 May, 2022 35 commits
    • James Clark's avatar
      perf unwind arm64: Decouple Libunwind register names from Perf · d511578b
      James Clark authored
      DWARF register numbers and real register numbers on aarch64 are
      equivalent. Remove the references to the register names from Libunwind
      so that new registers are supported without having to add build time
      feature checks for each new register.
      
      The unwinder won't ask for a register that it doesn't know about and
      Perf will already report an error for an unknown or unrecorded register
      in the perf_reg_value() function so extra validation isn't needed.
      
      After this change the new VG register can be read by libunwind.
      Reviewed-by: default avatarLeo Yan <leo.yan@linaro.org>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20220525154114.718321-5-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d511578b
    • James Clark's avatar
      perf unwind: Use dynamic register set for DWARF unwind · 72105204
      James Clark authored
      Architectures can detect availability of extra registers at runtime so
      use this more complete set for unwinding. This will include the VG
      register on arm64 in a later commit.
      
      If the function isn't implemented then PERF_REGS_MASK is returned and
      there is no change.
      
      Committer notes:
      
      Added util/perf_regs.c to tools/perf/util/python-ext-sources so that
      'perf test python' passes, i.e. the perf python binding has all the
      symbols it needs, addressing:
      
        $ perf test -v python
         19: 'import perf' in python                                         :
        --- start ---
        test child forked, pid 2037817
        python usage test: "echo "import sys ; sys.path.append('/tmp/build/perf/python'); import perf" | '/usr/bin/python3' "
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        ImportError: /tmp/build/perf/python/perf.cpython-310-x86_64-linux-gnu.so: undefined symbol: arch__user_reg_mask
        test child finished with -1
        ---- end ----
        'import perf' in python: FAILED!
        $
      Reviewed-by: default avatarLeo Yan <leo.yan@linaro.org>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20220525154114.718321-4-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      72105204
    • James Clark's avatar
      perf tools arm64: Copy perf_regs.h from the kernel · f450f11b
      James Clark authored
      Get the updated header for the newly added VG register.
      Reviewed-by: default avatarLeo Yan <leo.yan@linaro.org>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Cc: <broonie@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20220525154114.718321-3-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f450f11b
    • James Clark's avatar
      perf unwind arm64: Use perf's copy of kernel headers · 8803880f
      James Clark authored
      Fix this include path to use perf's copy of the kernel header rather
      than the one from the root of the repo.
      
      This fixes build errors when only applying the perf tools part of a
      patchset rather than both sides.
      Reported-by: default avatarGerman Gomez <german.gomez@arm.com>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Tested-by: default avatarGerman Gomez <german.gomez@arm.com>
      Cc: <broonie@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20220525154114.718321-2-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8803880f
    • Leo Yan's avatar
      perf c2c: Use stdio interface if slang is not supported · c4040212
      Leo Yan authored
      If the slang lib is not installed on the system, perf c2c tool disables TUI
      mode and roll back to use stdio mode;  but the flag 'c2c.use_stdio' is
      missed to set true and thus it wrongly applies UI quirks in the function
      ui_quirks().
      
      This commit forces to use stdio interface if slang is not supported, and
      it can avoid to apply the UI quirks and show the correct metric header.
      
      Before:
      
      =================================================
            Shared Cache Line Distribution Pareto
      =================================================
        -------------------------------------------------------------------------------
            0        0        0       99        0        0        0      0xaaaac17d6000
        -------------------------------------------------------------------------------
          0.00%    0.00%    6.06%    0.00%    0.00%    0.00%   0x20   N/A       0      0xaaaac17c25ac         0         0        43       375    18469         2  [.] 0x00000000000025ac  memstress         memstress[25ac]   0
          0.00%    0.00%   93.94%    0.00%    0.00%    0.00%   0x29   N/A       0      0xaaaac17c3e88         0         0       173       180      135         2  [.] 0x0000000000003e88  memstress         memstress[3e88]   0
      
      After:
      
      =================================================
            Shared Cache Line Distribution Pareto
      =================================================
        -------------------------------------------------------------------------------
            0        0        0       99        0        0        0      0xaaaac17d6000
        -------------------------------------------------------------------------------
                 0.00%    0.00%    6.06%    0.00%    0.00%    0.00%                0x20   N/A       0      0xaaaac17c25ac         0         0        43       375    18469         2  [.] 0x00000000000025ac  memstress         memstress[25ac]   0
                 0.00%    0.00%   93.94%    0.00%    0.00%    0.00%                0x29   N/A       0      0xaaaac17c3e88         0         0       173       180      135         2  [.] 0x0000000000003e88  memstress         memstress[3e88]   0
      
      Fixes: 5a1a99cd ("perf c2c report: Add main TUI browser")
      Reported-by: default avatarJoe Mario <jmario@redhat.com>
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20220526145400.611249-1-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c4040212
    • Namhyung Kim's avatar
      perf test: Add a basic offcpu profiling test · 831d06c8
      Namhyung Kim authored
        $ sudo ./perf test -v offcpu
         88: perf record offcpu profiling tests                              :
        --- start ---
        test child forked, pid 685966
        Basic off-cpu test
        Basic off-cpu test [Success]
        test child finished with 0
        ---- end ----
        perf record offcpu profiling tests: Ok
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Blake Jones <blakejones@google.com>
      Cc: Hao Luo <haoluo@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20220518224725.742882-7-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      831d06c8
    • Namhyung Kim's avatar
      perf record: Add cgroup support for off-cpu profiling · 685439a7
      Namhyung Kim authored
      This covers two different use cases.  The first one is cgroup
      filtering given by -G/--cgroup option which controls the off-cpu
      profiling for tasks in the given cgroups only.
      
      The other use case is cgroup sampling which is enabled by
      --all-cgroups option and it adds PERF_SAMPLE_CGROUP to the sample_type
      to set the cgroup id of the task in the sample data.
      
      Example output.
      
        $ sudo perf record -a --off-cpu --all-cgroups sleep 1
      
        $ sudo perf report --stdio -s comm,cgroup --call-graph=no
        ...
        # Samples: 144  of event 'offcpu-time'
        # Event count (approx.): 48452045427
        #
        # Children      Self  Command          Cgroup
        # ........  ........  ...............  ..........................................
        #
            61.57%     5.60%  Chrome_ChildIOT  /user.slice/user-657345.slice/user@657345.service/app.slice/...
            29.51%     7.38%  Web Content      /user.slice/user-657345.slice/user@657345.service/app.slice/...
            17.48%     1.59%  Chrome_IOThread  /user.slice/user-657345.slice/user@657345.service/app.slice/...
            16.48%     4.12%  pipewire-pulse   /user.slice/user-657345.slice/user@657345.service/session.slice/...
            14.48%     2.07%  perf             /user.slice/user-657345.slice/user@657345.service/app.slice/...
            14.30%     7.15%  CompositorTileW  /user.slice/user-657345.slice/user@657345.service/app.slice/...
            13.33%     6.67%  Timer            /user.slice/user-657345.slice/user@657345.service/app.slice/...
        ...
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Blake Jones <blakejones@google.com>
      Cc: Hao Luo <haoluo@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20220518224725.742882-6-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      685439a7
    • Namhyung Kim's avatar
      perf record: Handle argument change in sched_switch · b36888f7
      Namhyung Kim authored
      Recently sched_switch tracepoint added a new argument for prev_state,
      but it's hard to handle the change in a BPF program.  Instead, we can
      check the function prototype in BTF before loading the program.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Blake Jones <blakejones@google.com>
      Cc: Hao Luo <haoluo@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20220518224725.742882-5-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b36888f7
    • Namhyung Kim's avatar
      perf record: Implement basic filtering for off-cpu · 10742d0c
      Namhyung Kim authored
      It should honor cpu and task filtering with -a, -C or -p, -t options.
      
      Committer testing:
      
        # perf record --off-cpu --cpu 1 perf bench sched messaging -l 1000
        # Running 'sched/messaging' benchmark:
        # 20 sender and receiver processes per group
        # 10 groups == 400 processes run
      
             Total time: 1.722 [sec]
        [ perf record: Woken up 2 times to write data ]
        [ perf record: Captured and wrote 1.446 MB perf.data (7248 samples) ]
        #
        # perf script | head -20
                    perf 97164 [001] 38287.696761:          1      cycles:  ffffffffb6070174 native_write_msr+0x4 (vmlinux)
                    perf 97164 [001] 38287.696764:          1      cycles:  ffffffffb6070174 native_write_msr+0x4 (vmlinux)
                    perf 97164 [001] 38287.696765:          9      cycles:  ffffffffb6070174 native_write_msr+0x4 (vmlinux)
                    perf 97164 [001] 38287.696767:        212      cycles:  ffffffffb6070176 native_write_msr+0x6 (vmlinux)
                    perf 97164 [001] 38287.696768:       5130      cycles:  ffffffffb6070176 native_write_msr+0x6 (vmlinux)
                    perf 97164 [001] 38287.696770:     123063      cycles:  ffffffffb6e0011e syscall_return_via_sysret+0x38 (vmlinux)
                    perf 97164 [001] 38287.696803:    2292748      cycles:  ffffffffb636c82d __fput+0xad (vmlinux)
                 swapper     0 [001] 38287.702852:    1927474      cycles:  ffffffffb6761378 mwait_idle_with_hints.constprop.0+0x48 (vmlinux)
                  :97513 97513 [001] 38287.767207:    1172536      cycles:  ffffffffb612ff65 newidle_balance+0x5 (vmlinux)
                 swapper     0 [001] 38287.769567:    1073081      cycles:  ffffffffb618216d ktime_get_mono_fast_ns+0xd (vmlinux)
                  :97533 97533 [001] 38287.770962:     984460      cycles:  ffffffffb65b2900 selinux_socket_sendmsg+0x0 (vmlinux)
                  :97540 97540 [001] 38287.772242:     883462      cycles:  ffffffffb6d0bf59 irqentry_exit_to_user_mode+0x9 (vmlinux)
                 swapper     0 [001] 38287.773633:     741963      cycles:  ffffffffb6761378 mwait_idle_with_hints.constprop.0+0x48 (vmlinux)
                  :97552 97552 [001] 38287.774539:     606680      cycles:  ffffffffb62eda0a page_add_file_rmap+0x7a (vmlinux)
                  :97556 97556 [001] 38287.775333:     502254      cycles:  ffffffffb634f964 get_obj_cgroup_from_current+0xc4 (vmlinux)
                  :97561 97561 [001] 38287.776163:     427891      cycles:  ffffffffb61b1522 cgroup_rstat_updated+0x22 (vmlinux)
                 swapper     0 [001] 38287.776854:     359030      cycles:  ffffffffb612fc5e load_balance+0x9ce (vmlinux)
                  :97567 97567 [001] 38287.777312:     330371      cycles:  ffffffffb6a8d8d0 skb_set_owner_w+0x0 (vmlinux)
                  :97566 97566 [001] 38287.777589:     311622      cycles:  ffffffffb614a7a8 native_queued_spin_lock_slowpath+0x148 (vmlinux)
                  :97512 97512 [001] 38287.777671:     307851      cycles:  ffffffffb62e0f35 find_vma+0x55 (vmlinux)
        #
        # perf record --off-cpu --cpu 4 perf bench sched messaging -l 1000
        # Running 'sched/messaging' benchmark:
        # 20 sender and receiver processes per group
        # 10 groups == 400 processes run
      
             Total time: 1.613 [sec]
        [ perf record: Woken up 2 times to write data ]
        [ perf record: Captured and wrote 1.415 MB perf.data (6729 samples) ]
        # perf script | head -20
                    perf 97650 [004] 38323.728036:          1      cycles:  ffffffffb6070174 native_write_msr+0x4 (vmlinux)
                    perf 97650 [004] 38323.728040:          1      cycles:  ffffffffb6070174 native_write_msr+0x4 (vmlinux)
                    perf 97650 [004] 38323.728041:          9      cycles:  ffffffffb6070174 native_write_msr+0x4 (vmlinux)
                    perf 97650 [004] 38323.728042:        208      cycles:  ffffffffb6070176 native_write_msr+0x6 (vmlinux)
                    perf 97650 [004] 38323.728044:       5026      cycles:  ffffffffb6070176 native_write_msr+0x6 (vmlinux)
                    perf 97650 [004] 38323.728046:     119970      cycles:  ffffffffb6d0bebc syscall_exit_to_user_mode+0x1c (vmlinux)
                    perf 97650 [004] 38323.728078:    2190103      cycles:            54b756 perf_tool__process_synth_event+0x16 (/home/acme/bin/perf)
                 swapper     0 [004] 38323.783357:    1593139      cycles:  ffffffffb6761378 mwait_idle_with_hints.constprop.0+0x48 (vmlinux)
                 swapper     0 [004] 38323.785352:    1593139      cycles:  ffffffffb6761378 mwait_idle_with_hints.constprop.0+0x48 (vmlinux)
                 swapper     0 [004] 38323.797330:    1418936      cycles:  ffffffffb6761378 mwait_idle_with_hints.constprop.0+0x48 (vmlinux)
                 swapper     0 [004] 38323.802350:    1418936      cycles:  ffffffffb6761378 mwait_idle_with_hints.constprop.0+0x48 (vmlinux)
                 swapper     0 [004] 38323.806333:    1418936      cycles:  ffffffffb6761378 mwait_idle_with_hints.constprop.0+0x48 (vmlinux)
                  :97996 97996 [004] 38323.807145:    1418936      cycles:      7f5db9be6917 [unknown] ([unknown])
                  :97959 97959 [004] 38323.807730:    1445074      cycles:  ffffffffb6329d36 memcg_slab_post_alloc_hook+0x146 (vmlinux)
                  :97959 97959 [004] 38323.808103:    1341584      cycles:  ffffffffb62fd90f get_page_from_freelist+0x112f (vmlinux)
                  :97959 97959 [004] 38323.808451:    1227537      cycles:  ffffffffb65b2905 selinux_socket_sendmsg+0x5 (vmlinux)
                  :97959 97959 [004] 38323.808768:    1184321      cycles:  ffffffffb6d1ba35 _raw_spin_lock_irqsave+0x15 (vmlinux)
                  :97959 97959 [004] 38323.809073:    1153017      cycles:  ffffffffb6a8d92d skb_set_owner_w+0x5d (vmlinux)
                  :97959 97959 [004] 38323.809402:    1126875      cycles:  ffffffffb6329c64 memcg_slab_post_alloc_hook+0x74 (vmlinux)
                  :97959 97959 [004] 38323.809695:    1073248      cycles:  ffffffffb6e0001d entry_SYSCALL_64+0x1d (vmlinux)
        #
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Blake Jones <blakejones@google.com>
      Cc: Hao Luo <haoluo@google.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20220518224725.742882-4-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      10742d0c
    • Namhyung Kim's avatar
      perf record: Enable off-cpu analysis with BPF · edc41a10
      Namhyung Kim authored
      Add --off-cpu option to enable the off-cpu profiling with BPF.  It'd
      use a bpf_output event and rename it to "offcpu-time".  Samples will
      be synthesized at the end of the record session using data from a BPF
      map which contains the aggregated off-cpu time at context switches.
      So it needs root privilege to get the off-cpu profiling.
      
      Each sample will have a separate user stacktrace so it will skip
      kernel threads.  The sample ip will be set from the stacktrace and
      other sample data will be updated accordingly.  Currently it only
      handles some basic sample types.
      
      The sample timestamp is set to a dummy value just not to bother with
      other events during the sorting.  So it has a very big initial value
      and increase it on processing each samples.
      
      Good thing is that it can be used together with regular profiling like
      cpu cycles.  If you don't want to that, you can use a dummy event to
      enable off-cpu profiling only.
      
      Example output:
        $ sudo perf record --off-cpu perf bench sched messaging -l 1000
      
        $ sudo perf report --stdio --call-graph=no
        # Total Lost Samples: 0
        #
        # Samples: 41K of event 'cycles'
        # Event count (approx.): 42137343851
        ...
      
        # Samples: 1K of event 'offcpu-time'
        # Event count (approx.): 587990831640
        #
        # Children      Self  Command          Shared Object       Symbol
        # ........  ........  ...............  ..................  .........................
        #
            81.66%     0.00%  sched-messaging  libc-2.33.so        [.] __libc_start_main
            81.66%     0.00%  sched-messaging  perf                [.] cmd_bench
            81.66%     0.00%  sched-messaging  perf                [.] main
            81.66%     0.00%  sched-messaging  perf                [.] run_builtin
            81.43%     0.00%  sched-messaging  perf                [.] bench_sched_messaging
            40.86%    40.86%  sched-messaging  libpthread-2.33.so  [.] __read
            37.66%    37.66%  sched-messaging  libpthread-2.33.so  [.] __write
             2.91%     2.91%  sched-messaging  libc-2.33.so        [.] __poll
        ...
      
      As you can see it spent most of off-cpu time in read and write in
      bench_sched_messaging().  The --call-graph=no was added just to make
      the output concise here.
      
      It uses perf hooks facility to control BPF program during the record
      session rather than adding new BPF/off-cpu specific calls.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Blake Jones <blakejones@google.com>
      Cc: Hao Luo <haoluo@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20220518224725.742882-3-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      edc41a10
    • Namhyung Kim's avatar
      perf report: Do not extend sample type of bpf-output event · 303ead45
      Namhyung Kim authored
      Currently evsel__new_idx() sets more sample_type bits when it finds a
      BPF-output event.  But it should honor what's recorded in the perf
      data file rather than blindly sets the bits.  Otherwise it could lead
      to a parse error when it recorded with a modified sample_type.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Blake Jones <blakejones@google.com>
      Cc: Hao Luo <haoluo@google.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20220518224725.742882-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      303ead45
    • Claire Jensen's avatar
      perf test: Add checking for perf stat CSV output. · 7473ee56
      Claire Jensen authored
      Counts expected fields for various commands. No testing added for
      summary mode since it is broken.
      
      An example of the summary output is:
      
               summary,263831,,instructions:u,1435072,100.0,0.46,insn per cycle
      ,,,,,1.37,stalled cycles per insn
      
      This should be:
      
               summary,263831,,instructions:u,1435072,100.0,0.46,insn per cycle
               summary,,,,,,1.37,stalled cycles per insn
      
      The output has 7 fields when it should have 8. Additionally, the newline
      spacing is wrong, so it was excluded from testing until a fix is made.
      
      Committer testing:
      
        $ perf test "perf stat CSV output"
         88: perf stat CSV output linter                                     : Ok
        $
      
        $ perf test -v "perf stat CSV output"
        Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc
         88: perf stat CSV output linter                                     :
        --- start ---
        test child forked, pid 2622839
        Checking CSV output: no args [Success]
        Checking CSV output: system wide [Skip] paranoid and not root
        Checking CSV output: system wide [Skip] paranoid and not root
        Checking CSV output: interval [Success]
        Checking CSV output: event [Success]
        Checking CSV output: per core [Skip] paranoid and not root
        Checking CSV output: per thread [Skip] paranoid and not root
        Checking CSV output: per die [Skip] paranoid and not root
        Checking CSV output: per node [Skip] paranoid and not root
        Checking CSV output: per socket [Skip] paranoid and not root
        test child finished with 0
        ---- end ----
        perf stat CSV output linter: Ok
        $
      
      I did a s/parnoia/paranoid/g on the [Skip] lines.
      Signed-off-by: default avatarClaire Jensen <cjense@google.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alyssa Ross <hi@alyssa.is>
      Cc: Claire Jensen <clairej735@gmail.com>
      Cc: Florian Fischer <florian.fischer@muhq.space>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Like Xu <likexu@tencent.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20220525053814.3265216-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7473ee56
    • Adrian Hunter's avatar
      perf tools: Allow system-wide events to keep their own threads · a41e24f6
      Adrian Hunter authored
      System-wide events do not have threads, so do not propagate threads to
      them.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Link: https://lore.kernel.org/r/20220524075436.29144-16-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a41e24f6
    • Adrian Hunter's avatar
      perf tools: Allow system-wide events to keep their own CPUs · 298613b8
      Adrian Hunter authored
      Currently, user_requested_cpus supplants system-wide CPUs when the evlist
      has_user_cpus. Change that so that system-wide events retain their own
      CPUs and they are added to all_cpus.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Link: https://lore.kernel.org/r/20220524075436.29144-15-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      298613b8
    • Adrian Hunter's avatar
      libperf evsel: Add comments for booleans · f5fb6d4e
      Adrian Hunter authored
      Add comments for 'system_wide' and 'requires_cpu' booleans
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Link: https://lore.kernel.org/r/20220524075436.29144-14-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f5fb6d4e
    • Adrian Hunter's avatar
      perf stat: Add requires_cpu flag for uncore · d3345fec
      Adrian Hunter authored
      Uncore events require a CPU i.e. it cannot be -1.
      
      The evsel system_wide flag is intended for events that should be on every
      CPU, which does not make sense for uncore events because uncore events do
      not map one-to-one with CPUs.
      
      These 2 requirements are not exactly the same, so introduce a new flag
      'requires_cpu' for the uncore case.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Link: https://lore.kernel.org/r/20220524075436.29144-13-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d3345fec
    • Adrian Hunter's avatar
      libperf evlist: Check nr_mmaps is correct · 4ce47d84
      Adrian Hunter authored
      Print an error message if the predetermined number of mmaps is
      incorrect.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Link: https://lore.kernel.org/r/20220524075436.29144-12-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4ce47d84
    • Adrian Hunter's avatar
      libperf evlist: Allow mixing per-thread and per-cpu mmaps · ae4f8ae1
      Adrian Hunter authored
      mmap_per_evsel() will skip events that do not match the CPU, so all CPUs
      can be iterated in any case.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Link: https://lore.kernel.org/r/20220524075436.29144-11-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ae4f8ae1
    • Adrian Hunter's avatar
      perf tools: Allow all_cpus to be a superset of user_requested_cpus · 7be1fedd
      Adrian Hunter authored
      To support collection of system-wide events with user requested CPUs,
      all_cpus must be a superset of user_requested_cpus.
      
      In order to support all_cpus to be a superset of user_requested_cpus,
      all_cpus must be used instead of user_requested_cpus when dealing with CPUs
      of all events instead of CPUs of requested events.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Link: https://lore.kernel.org/r/20220524075436.29144-10-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7be1fedd
    • Adrian Hunter's avatar
      perf intel-pt: Track sideband system-wide when needed · 7d189cad
      Adrian Hunter authored
      User space tasks can migrate between CPUs, so when tracing selected CPUs,
      sideband for all CPUs is still needed. This is in preparation for allowing
      system-wide events on all CPUs while the user requested events are on only
      user requested CPUs.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Link: https://lore.kernel.org/r/20220524075436.29144-9-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7d189cad
    • Adrian Hunter's avatar
      perf intel-pt: Use evlist__add_dummy_on_all_cpus() for switch tracking · e665c82a
      Adrian Hunter authored
      Use evlist__add_dummy_on_all_cpus() for switch tracking in preparation for
      allowing system-wide events on all CPUs while the user requested events are
      on only user requested CPUs.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Link: https://lore.kernel.org/r/20220524075436.29144-8-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e665c82a
    • Adrian Hunter's avatar
      perf record: Use evlist__add_dummy_on_all_cpus() in record__config_text_poke() · 921e3be5
      Adrian Hunter authored
      Use evlist__add_dummy_on_all_cpus() in record__config_text_poke() in
      preparation for allowing system-wide events on all CPUs while the user
      requested events are on only user requested CPUs.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Link: https://lore.kernel.org/r/20220524075436.29144-7-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      921e3be5
    • Adrian Hunter's avatar
      perf evlist: Add evlist__add_dummy_on_all_cpus() · 126d68fd
      Adrian Hunter authored
      Add evlist__add_dummy_on_all_cpus() to enable creating a system-wide dummy
      event that sets up the system-wide maps before map propagation.
      
      For convenience, add evlist__add_aux_dummy() so that the logic can be used
      whether or not the event needs to be system-wide.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Link: https://lore.kernel.org/r/20220524075436.29144-6-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      126d68fd
    • Adrian Hunter's avatar
      perf evlist: Factor out evlist__dummy_event() · 82944899
      Adrian Hunter authored
      Factor out evlist__dummy_event() so it can be reused.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Link: https://lore.kernel.org/r/20220524075436.29144-5-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      82944899
    • Adrian Hunter's avatar
      perf auxtrace: Remove auxtrace_mmap_params__set_idx() per_cpu parameter · 84bd5aba
      Adrian Hunter authored
      Remove auxtrace_mmap_params__set_idx() per_cpu parameter because it isn't
      needed.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Link: https://lore.kernel.org/r/20220524075436.29144-4-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      84bd5aba
    • Adrian Hunter's avatar
      perf auxtrace: Add mmap_needed to auxtrace_mmap_params · d01508f2
      Adrian Hunter authored
      Add mmap_needed to auxtrace_mmap_params.
      
      Currently an auxtrace mmap is always attempted even if the event is not an
      auxtrace event. That works because, when AUX area tracing, there is always
      an auxtrace event first for every mmap. Prepare for that not being the
      case, which it won't be when sideband tracking events are allowed on
      all CPUs even when auxtrace is limited to selected CPUs.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Link: https://lore.kernel.org/r/20220524075436.29144-3-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d01508f2
    • Adrian Hunter's avatar
      perf intel-pt: Add a test for system-wide side band · 1097b38f
      Adrian Hunter authored
      Add a test for system-wide side band even when tracing selected CPUs.
      
      The test fails before the patches up to "perf tools: Allow system-wide
      events to keep their own CPUs" are applied, passes afterwards.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Link: https://lore.kernel.org/r/20220524075436.29144-2-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1097b38f
    • Arnaldo Carvalho de Melo's avatar
      perf build: Stop using __weak bpf_map_create() to handle older libbpf versions · df76e003
      Arnaldo Carvalho de Melo authored
      By adding a feature test for bpf_map_create() and providing a fallback if
      it isn't present in older versions of libbpf.
      
      This also fixes the build with torvalds/master at this point:
      
        $ git log --oneline -5 torvalds/master
        babf0bb9 (torvalds/master) Merge tag 'xfs-5.19-for-linus' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
        e375780b Merge tag 'fsnotify_for_v5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
        8b728edc Merge tag 'fs_for_v5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
        3f306ea2 Merge tag 'dma-mapping-5.19-2022-05-25' of git://git.infradead.org/users/hch/dma-mapping
        fbe86dac Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
        $
      
      Coping with:
      
        $ git log --oneline -2 d16495a9
        d16495a9 libbpf: remove bpf_create_map*() APIs
        e2371b16 libbpf: start 1.0 development cycle
        $
      
      As the __weak function fails to build as it calls the now removed
      bpf_create_map() API.
      
      Testing:
      
        $ rpm -q libbpf-devel
        libbpf-devel-0.4.0-2.fc35.x86_64
        $
        $ make -C tools/perf BUILD_BPF_SKEL=1 LIBBPF_DYNAMIC=1 O=/tmp/build/perf install-bin
        $ cat /tmp/build/perf/feature/test-libbpf-bpf_map_create.make.output
        test-libbpf-bpf_map_create.c: In function ‘main’:
        test-libbpf-bpf_map_create.c:6:16: error: implicit declaration of function ‘bpf_map_create’; did you mean ‘bpf_map_freeze’? [-Werror=implicit-function-declaration]
            6 |         return bpf_map_create(0 /* map_type */, NULL /* map_name */, 0, /* key_size */,
              |                ^~~~~~~~~~~~~~
              |                bpf_map_freeze
        test-libbpf-bpf_map_create.c:6:87: error: expected expression before ‘,’ token
            6 |         return bpf_map_create(0 /* map_type */, NULL /* map_name */, 0, /* key_size */,
              |                                                                                       ^
        cc1: all warnings being treated as errors
        $
        $ objdump -dS /tmp/build/perf/perf | grep '<bpf_map_create>:' -A20
        000000000058b290 <bpf_map_create>:
        {
          58b290:	55                   	push   %rbp
          58b291:	48 89 e5             	mov    %rsp,%rbp
          58b294:	48 83 ec 10          	sub    $0x10,%rsp
          58b298:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
          58b29f:	00 00
          58b2a1:	48 89 45 f8          	mov    %rax,-0x8(%rbp)
          58b2a5:	31 c0                	xor    %eax,%eax
        	return bpf_create_map(map_type, key_size, value_size, max_entries, 0);
          58b2a7:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
          58b2ab:	64 48 2b 04 25 28 00 	sub    %fs:0x28,%rax
          58b2b2:	00 00
          58b2b4:	75 10                	jne    58b2c6 <bpf_map_create+0x36>
        }
          58b2b6:	c9                   	leave
          58b2b7:	89 d6                	mov    %edx,%esi
          58b2b9:	89 ca                	mov    %ecx,%edx
          58b2bb:	44 89 c1             	mov    %r8d,%ecx
        	return bpf_create_map(map_type, key_size, value_size, max_entries, 0);
          58b2be:	45 31 c0             	xor    %r8d,%r8d
        $
      
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ilya Leoshkevich <iii@linux.ibm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: http://lore.kernel.org/linux-perf-users/Yo+XvQNKL4K5khl2@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      df76e003
    • Jiri Olsa's avatar
      perf build: Stop using __weak btf__raw_data() to handle older libbpf versions · 982be477
      Jiri Olsa authored
      By adding a feature test for btf__raw_data() and providing a fallback if
      it isn't present in older versions of libbpf.
      
      Committer testing:
      
        $ rpm -q libbpf-devel
        libbpf-devel-0.4.0-2.fc35.x86_64
        $ make -C tools/perf LIBBPF_DYNAMIC=1 O=/tmp/build/perf install-bin
        $ cat /tmp/build/perf/feature/test-libbpf-btf__raw_data.make.output
        test-libbpf-btf__raw_data.c: In function ‘main’:
        test-libbpf-btf__raw_data.c:6:9: error: implicit declaration of function ‘btf__raw_data’; did you mean ‘btf__get_raw_data’? [-Werror=implicit-function-declaration]
            6 |         btf__raw_data(NULL /* btf_ro */, NULL /* size */);
              |         ^~~~~~~~~~~~~
              |         btf__get_raw_data
        cc1: all warnings being treated as errors
        $ objdump -dS /tmp/build/perf/perf | grep '<btf__raw_data>:' -A20
        00000000005b3050 <btf__raw_data>:
        {
          5b3050:	55                   	push   %rbp
          5b3051:	48 89 e5             	mov    %rsp,%rbp
          5b3054:	48 83 ec 10          	sub    $0x10,%rsp
          5b3058:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
          5b305f:	00 00
          5b3061:	48 89 45 f8          	mov    %rax,-0x8(%rbp)
          5b3065:	31 c0                	xor    %eax,%eax
      	  return btf__get_raw_data(btf_ro, size);
          5b3067:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
          5b306b:	64 48 2b 04 25 28 00 	sub    %fs:0x28,%rax
          5b3072:	00 00
          5b3074:	75 06                	jne    5b307c <btf__raw_data+0x2c>
        }
          5b3076:	c9                   	leave
      	  return btf__get_raw_data(btf_ro, size);
          5b3077:	e9 14 99 e5 ff       	jmp    40c990 <btf__get_raw_data@plt>
          5b307c:	e8 af a7 e5 ff       	call   40d830 <__stack_chk_fail@plt>
          5b3081:	66 66 2e 0f 1f 84 00 	data16 cs nopw 0x0(%rax,%rax,1)
          5b3088:	00 00 00 00
          $
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ilya Leoshkevich <iii@linux.ibm.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: http://lore.kernel.org/linux-perf-users/YozLKby7ITEtchC9@kravaSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      982be477
    • Jiri Olsa's avatar
      perf build: Stop using __weak bpf_object__next_map() to handle older libbpf versions · 739c9180
      Jiri Olsa authored
      By adding a feature test for bpf_object__next_map() and providing a fallback if
      it isn't present in older versions of libbpf.
      
      Committer testing:
      
        $ rpm -q libbpf-devel
        libbpf-devel-0.4.0-2.fc35.x86_64
        $ make -C tools/perf LIBBPF_DYNAMIC=1 O=/tmp/build/perf install-bin
        $ cat /tmp/build/perf/feature/test-libbpf-bpf_object__next_map.make.output
        test-libbpf-bpf_object__next_map.c: In function ‘main’:
        test-libbpf-bpf_object__next_map.c:6:9: error: implicit declaration of function ‘bpf_object__next_map’; did you mean ‘bpf_object__next’? [-Werror=implicit-function-declaration]
            6 |         bpf_object__next_map(NULL /* obj */, NULL /* prev */);
              |         ^~~~~~~~~~~~~~~~~~~~
              |         bpf_object__next
          cc1: all warnings being treated as errors
        $
        $ objdump -dS /tmp/build/perf/perf | grep '<bpf_object__next_map>:' -A20
        00000000005b2e00 <bpf_object__next_map>:
        {
          5b2e00:	55                   	push   %rbp
          5b2e01:	48 89 e5             	mov    %rsp,%rbp
          5b2e04:	48 83 ec 10          	sub    $0x10,%rsp
          5b2e08:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
          5b2e0f:	00 00
          5b2e11:	48 89 45 f8          	mov    %rax,-0x8(%rbp)
          5b2e15:	31 c0                	xor    %eax,%eax
      	  return bpf_map__next(prev, obj);
          5b2e17:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
          5b2e1b:	64 48 2b 04 25 28 00 	sub    %fs:0x28,%rax
          5b2e22:	00 00
          5b2e24:	75 0f                	jne    5b2e35 <bpf_object__next_map+0x35>
        }
          5b2e26:	c9                   	leave
          5b2e27:	49 89 f8             	mov    %rdi,%r8
          5b2e2a:	48 89 f7             	mov    %rsi,%rdi
      	  return bpf_map__next(prev, obj);
          5b2e2d:	4c 89 c6             	mov    %r8,%rsi
          5b2e30:	e9 cb b1 e5 ff       	jmp    40e000 <bpf_map__next@plt>
        $
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ilya Leoshkevich <iii@linux.ibm.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: http://lore.kernel.org/linux-perf-users/YozLKby7ITEtchC9@kravaSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      739c9180
    • Jiri Olsa's avatar
      perf build: Stop using __weak bpf_object__next_program() to handle older libbpf versions · 8916d725
      Jiri Olsa authored
      By adding a feature test for bpf_object__next_program() and providing a fallback if
      it isn't present in older versions of libbpf.
      
      Committer testing:
      
        $ rpm -q libbpf-devel
        libbpf-devel-0.4.0-2.fc35.x86_64
        $ make -C tools/perf LIBBPF_DYNAMIC=1 O=/tmp/build/perf install-bin
        $ cat /tmp/build/perf/feature/test-libbpf-bpf_object__next_program.make.output
        test-libbpf-bpf_object__next_program.c: In function ‘main’:
        test-libbpf-bpf_object__next_program.c:6:9: error: implicit declaration of function ‘bpf_object__next_program’; did you mean ‘bpf_object__unpin_programs’? [-Werror=implicit-function-declaration]
            6 |         bpf_object__next_program(NULL /* obj */, NULL /* prev */);
              |         ^~~~~~~~~~~~~~~~~~~~~~~~
              |         bpf_object__unpin_programs
        cc1: all warnings being treated as errors
        $
        $ objdump -dS /tmp/build/perf/perf | grep '<bpf_object__next_program>:' -A20
        00000000005b2dc0 <bpf_object__next_program>:
        {
          5b2dc0:	55                   	push   %rbp
          5b2dc1:	48 89 e5             	mov    %rsp,%rbp
          5b2dc4:	48 83 ec 10          	sub    $0x10,%rsp
          5b2dc8:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
          5b2dcf:	00 00
          5b2dd1:	48 89 45 f8          	mov    %rax,-0x8(%rbp)
          5b2dd5:	31 c0                	xor    %eax,%eax
      	  return bpf_program__next(prev, obj);
          5b2dd7:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
          5b2ddb:	64 48 2b 04 25 28 00 	sub    %fs:0x28,%rax
          5b2de2:	00 00
          5b2de4:	75 0f                	jne    5b2df5 <bpf_object__next_program+0x35>
        }
          5b2de6:	c9                   	leave
          5b2de7:	49 89 f8             	mov    %rdi,%r8
          5b2dea:	48 89 f7             	mov    %rsi,%rdi
      	  return bpf_program__next(prev, obj);
          5b2ded:	4c 89 c6             	mov    %r8,%rsi
          5b2df0:	e9 3b b4 e5 ff       	jmp    40e230 <bpf_program__next@plt>
          $
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ilya Leoshkevich <iii@linux.ibm.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: http://lore.kernel.org/linux-perf-users/YozLKby7ITEtchC9@kravaSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8916d725
    • Jiri Olsa's avatar
      perf build: Stop using __weak bpf_prog_load() to handle older libbpf versions · 5c83eff3
      Jiri Olsa authored
      By adding a feature test for bpf_prog_load() and providing a fallback if
      it isn't present in older versions of libbpf.
      
      Committer testing:
      
        $ rpm -q libbpf-devel
        libbpf-devel-0.4.0-2.fc35.x86_64
        $ make -C tools/perf LIBBPF_DYNAMIC=1 O=/tmp/build/perf install-bin
        $ cat /tmp/build/perf/feature/test-libbpf-bpf_prog_load.make.output
        test-libbpf-bpf_prog_load.c: In function ‘main’:
        test-libbpf-bpf_prog_load.c:6:16: error: implicit declaration of function ‘bpf_prog_load’ [-Werror=implicit-function-declaration]
            6 |         return bpf_prog_load(0 /* prog_type */, NULL /* prog_name */,
              |                ^~~~~~~~~~~~~
        cc1: all warnings being treated as errors
        $
      
        $ objdump -dS /tmp/build/perf/perf | grep '<bpf_prog_load>:' -A20
        00000000005b2d70 <bpf_prog_load>:
        {
          5b2d70:	55                   	push   %rbp
          5b2d71:	48 89 ce             	mov    %rcx,%rsi
          5b2d74:	4c 89 c8             	mov    %r9,%rax
          5b2d77:	49 89 d2             	mov    %rdx,%r10
          5b2d7a:	4c 89 c2             	mov    %r8,%rdx
          5b2d7d:	48 89 e5             	mov    %rsp,%rbp
          5b2d80:	48 83 ec 18          	sub    $0x18,%rsp
          5b2d84:	64 48 8b 0c 25 28 00 	mov    %fs:0x28,%rcx
          5b2d8b:	00 00
          5b2d8d:	48 89 4d f8          	mov    %rcx,-0x8(%rbp)
          5b2d91:	31 c9                	xor    %ecx,%ecx
        	return bpf_load_program(prog_type, insns, insn_cnt, license,
          5b2d93:	41 8b 49 5c          	mov    0x5c(%r9),%ecx
          5b2d97:	51                   	push   %rcx
          5b2d98:	4d 8b 49 60          	mov    0x60(%r9),%r9
          5b2d9c:	4c 89 d1             	mov    %r10,%rcx
          5b2d9f:	44 8b 40 1c          	mov    0x1c(%rax),%r8d
          5b2da3:	e8 f8 aa e5 ff       	call   40d8a0 <bpf_load_program@plt>
        }
        $
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ilya Leoshkevich <iii@linux.ibm.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: http://lore.kernel.org/linux-perf-users/YozLKby7ITEtchC9@kravaSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5c83eff3
    • Jiri Olsa's avatar
      perf build: Fix btf__load_from_kernel_by_id() feature check · 73534617
      Jiri Olsa authored
      The btf__load_from_kernel_by_id() only takes one arg, not two.
      
      Committer notes:
      
      I tested it just with an older libbpf, one where
      btf__load_from_kernel_by_id() wasn't introduced yet.
      
      A test with a newer dynamic libbpf would fail because the
      btf__load_from_kernel_by_id() is there, but takes just one arg.
      
      Fixes: 0ae065a5 ("perf build: Fix check for btf__load_from_kernel_by_id() in libbpf")
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ilya Leoshkevich <iii@linux.ibm.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: http://lore.kernel.org/linux-perf-users/YozLKby7ITEtchC9@kravaSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      73534617
    • Linus Torvalds's avatar
      Merge tag 'xfs-5.19-for-linus' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux · babf0bb9
      Linus Torvalds authored
      Pull xfs updates from Dave Chinner:
       "This is a big update with lots of new code. The summary below them
        all, so I'll just touch on teh higlights. The two main new features
        are Large Extent Counts and Logged Attribute Replay - these are two
        new foundational features that we are building more complex future
        features on top of.
      
        For upcoming functionality, we need to be able to store hundreds of
        millions of xattrs per inode. The Large Extent Count feature removes
        the limits that prevent this scale of xattr storage, and while we were
        modifying the on disk extent count format we also increased the number
        of data extents we support per inode from 2^32 to 2^47.
      
        We also need to be able to modify xattrs as part of larger atomic
        transactions rather than as standalone transactions. The Logged
        Attribute Replay feature introduces the infrastructure that allows us
        to use intents to record the attribute modifications in the journal
        before we start them, hence allowing other atomic transactions to log
        attribute modification intents and then defer the actual modification
        to later. If we then crash, log recovery then guarantees that the
        attribute is replayed in the context of the atomic transaction that
        logged the intent.
      
        A significant chunk of the commits in this merge are for the base
        attribute replay functionality along with fixes, improvements and
        cleanups related to this new functioanlity. Allison deserves a big
        round of thanks for her ongoing work to get this functionality into
        XFS.
      
        There are also many other smaller changes and improvements, so overall
        this is one of the bigger XFS merge requests in some time.
      
        I will be following up next week with another smaller pull request -
        we already have another round of fixes and improvements to the logged
        attribute replay functionality just about ready to go. They'll soak
        and test over the next week, and I'll send a pull request for them
        near the end of the merge window.
      
        Summary:
      
         - support for printk message indexing.
      
         - large extent counts to provide support for up to 2^47 data extents
           and 2^32 attribute extents, allowing us to scale beyond 4 billion
           data extents to billions of xattrs per inode.
      
         - conversion of various flags fields to be consistently declared as
           unsigned bit fields.
      
         - improvements to realtime extent accounting and converts them to
           per-cpu counters to match all the other block and inode accounting.
      
         - reworks core log formatting code to reduce iterations, have a
           shorter, cleaner fast path and generally be easier to understand
           and maintain.
      
         - improvements to rmap btree searches that reduce overhead by up to
           30% resulting in xfs_scrub runtime reductions of 15%.
      
         - improvements to reflink that remove the size limitations in
           remapping operations and greatly reduce the size of transaction
           reservations.
      
         - reworks the minimum log size calculations to allow us to change
           transaction reservations without changing the minimum supported log
           size.
      
         - removal of quota warning support as it has never been used on
           Linux.
      
         - intent whiteouts to allow us to cancel intents that are completed
           entirely in memory rather than having use CPU and disk bandwidth
           formatting and writing them into the journal when it is not
           necessary. This makes rmap, reflink and extent freeing slightly
           more efficient, but provides massive improvements for....
      
         - Logged Attribute Replay feature support. This is a fundamental
           change to the way we modify attributes, laying the foundation for
           future integration of attribute modifications as part of other
           atomic transactional operations the filesystem performs.
      
         - Lots of cleanups and fixes for the logged attribute replay
           functionality"
      
      * tag 'xfs-5.19-for-linus' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: (124 commits)
        xfs: can't use kmem_zalloc() for attribute buffers
        xfs: detect empty attr leaf blocks in xfs_attr3_leaf_verify
        xfs: ATTR_REPLACE algorithm with LARP enabled needs rework
        xfs: use XFS_DA_OP flags in deferred attr ops
        xfs: remove xfs_attri_remove_iter
        xfs: switch attr remove to xfs_attri_set_iter
        xfs: introduce attr remove initial states into xfs_attr_set_iter
        xfs: xfs_attr_set_iter() does not need to return EAGAIN
        xfs: clean up final attr removal in xfs_attr_set_iter
        xfs: remote xattr removal in xfs_attr_set_iter() is conditional
        xfs: XFS_DAS_LEAF_REPLACE state only needed if !LARP
        xfs: split remote attr setting out from replace path
        xfs: consolidate leaf/node states in xfs_attr_set_iter
        xfs: kill XFS_DAC_LEAF_ADDNAME_INIT
        xfs: separate out initial attr_set states
        xfs: don't set quota warning values
        xfs: remove warning counters from struct xfs_dquot_res
        xfs: remove quota warning limit from struct xfs_quota_limits
        xfs: rework deferred attribute operation setup
        xfs: make xattri_leaf_bp more useful
        ...
      babf0bb9
    • Linus Torvalds's avatar
      Merge tag 'fsnotify_for_v5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs · e375780b
      Linus Torvalds authored
      Pull fsnotify updates from Jan Kara:
       "The biggest part of this is support for fsnotify inode marks that
        don't pin inodes in memory but rather get evicted together with the
        inode (they are useful if userspace needs to exclude receipt of events
        from potentially large subtrees using fanotify ignore marks).
      
        There is also a fix for more consistent handling of events sent to
        parent and a fix of sparse(1) complaints"
      
      * tag 'fsnotify_for_v5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
        fanotify: fix incorrect fmode_t casts
        fsnotify: consistent behavior for parent not watching children
        fsnotify: introduce mark type iterator
        fanotify: enable "evictable" inode marks
        fanotify: use fsnotify group lock helpers
        fanotify: implement "evictable" inode marks
        fanotify: factor out helper fanotify_mark_update_flags()
        fanotify: create helper fanotify_mark_user_flags()
        fsnotify: allow adding an inode mark without pinning inode
        dnotify: use fsnotify group lock helpers
        nfsd: use fsnotify group lock helpers
        audit: use fsnotify group lock helpers
        inotify: use fsnotify group lock helpers
        fsnotify: create helpers for group mark_mutex lock
        fsnotify: make allow_dups a property of the group
        fsnotify: pass flags argument to fsnotify_alloc_group()
        fsnotify: fix wrong lockdep annotations
        inotify: move control flags from mask to mark flags
        inotify: show inotify mask flags in proc fdinfo
      e375780b