1. 19 Aug, 2022 21 commits
    • Namhyung Kim's avatar
      perf tools: Support reading PERF_FORMAT_LOST · f52679b7
      Namhyung Kim authored
      The recent kernel added lost count can be read from either read(2) or
      ring buffer data with PERF_SAMPLE_READ.  As it's a variable length data
      we need to access it according to the format info.
      
      But for perf tools use cases, PERF_FORMAT_ID is always set.  So we can
      only check PERF_FORMAT_LOST bit to determine the data format.
      
      Add sample_read_value_size() and next_sample_read_value() helpers to
      make it a bit easier to access.  Use them in all places where it reads
      the struct sample_read_value.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220819003644.508916-5-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f52679b7
    • Namhyung Kim's avatar
      libperf: Add a test case for read formats · 6d395a51
      Namhyung Kim authored
      It checks a various combination of the read format settings and verify
      it return the value in a proper position.  The test uses task-clock
      software events to guarantee it's always active and sets enabled/running
      time.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220819003644.508916-4-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6d395a51
    • Namhyung Kim's avatar
      libperf: Handle read format in perf_evsel__read() · 89e3106f
      Namhyung Kim authored
      The perf_counts_values should be increased to read the new lost data.
      Also adjust values after read according the read format.
      
      This supports PERF_FORMAT_GROUP which has a different data format but
      it's only available for leader events.  Currently it doesn't have an API
      to read sibling (member) events in the group.  But users may read the
      sibling event directly.
      
      Also reading from mmap would be disabled when the read format has ID or
      LOST bit as it's not exposed via mmap.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220819003644.508916-3-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      89e3106f
    • Namhyung Kim's avatar
      tools headers UAPI: Sync linux/perf_event.h with the kernel sources · 65ba872a
      Namhyung Kim authored
      To pick the trivial change in:
      
        119a784c ("perf/core: Add a new read format to get a number of lost samples")
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220819003644.508916-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      65ba872a
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync x86's asm/kvm.h with the kernel sources · e5bc0dea
      Arnaldo Carvalho de Melo authored
      To pick the changes in:
      
        43bb9e00 ("KVM: x86: Tweak name of MONITOR/MWAIT #UD quirk to make it #UD specific")
        94dfc73e ("treewide: uapi: Replace zero-length arrays with flexible-array members")
        bfbcc81b ("KVM: x86: Add a quirk for KVM's "MONITOR/MWAIT are NOPs!" behavior")
        b1728622 ("KVM: x86: PIT: Preserve state of speaker port data bit")
        ed235117 ("KVM: x86: Extend KVM_{G,S}ET_VCPU_EVENTS to support pending triple fault")
      
      That just rebuilds kvm-stat.c on x86, no change in functionality.
      
      This silences these perf build warning:
      
        Warning: Kernel ABI header at 'tools/arch/x86/include/uapi/asm/kvm.h' differs from latest version at 'arch/x86/include/uapi/asm/kvm.h'
        diff -u tools/arch/x86/include/uapi/asm/kvm.h arch/x86/include/uapi/asm/kvm.h
      
      Cc: Chenyi Qiang <chenyi.qiang@intel.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Paul Durrant <pdurrant@amazon.com>
      Link: https://lore.kernel.org/lkml/Yv6OMPKYqYSbUxwZ@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e5bc0dea
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync KVM's vmx.h header with the kernel sources · eea085d1
      Arnaldo Carvalho de Melo authored
      To pick the changes in:
      
        2f4073e0 ("KVM: VMX: Enable Notify VM exit")
      
      That makes 'perf kvm-stat' aware of this new NOTIFY exit reason, thus
      addressing the following perf build warning:
      
        Warning: Kernel ABI header at 'tools/arch/x86/include/uapi/asm/vmx.h' differs from latest version at 'arch/x86/include/uapi/asm/vmx.h'
        diff -u tools/arch/x86/include/uapi/asm/vmx.h arch/x86/include/uapi/asm/vmx.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Tao Xu <tao3.xu@intel.com>
      Link: http://lore.kernel.org/lkml/Yv6LavXMZ+njijpq@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      eea085d1
    • Arnaldo Carvalho de Melo's avatar
      tools include UAPI: Sync linux/vhost.h with the kernel sources · 898d2403
      Arnaldo Carvalho de Melo authored
      To get the changes in:
      
        f345a014 ("vhost-vdpa: uAPI to suspend the device")
      
      Silencing this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/vhost.h' differs from latest version at 'include/uapi/linux/vhost.h'
        diff -u tools/include/uapi/linux/vhost.h include/uapi/linux/vhost.h
      
      To pick up these changes and support them:
      
        $ tools/perf/trace/beauty/vhost_virtio_ioctl.sh > before
        $ cp include/uapi/linux/vhost.h tools/include/uapi/linux/vhost.h
        $ tools/perf/trace/beauty/vhost_virtio_ioctl.sh > after
        $ diff -u before after
        --- before	2022-08-18 09:46:12.355958316 -0300
        +++ after	2022-08-18 09:46:19.701182822 -0300
        @@ -29,6 +29,7 @@
         	[0x75] = "VDPA_SET_VRING_ENABLE",
         	[0x77] = "VDPA_SET_CONFIG_CALL",
         	[0x7C] = "VDPA_SET_GROUP_ASID",
        +	[0x7D] = "VDPA_SUSPEND",
         };
         = {
         	[0x00] = "GET_FEATURES",
        $
      
      For instance, see how those 'cmd' ioctl arguments get translated, now
      VDPA_SUSPEND will be as well:
      
        # perf trace -a -e ioctl --max-events=10
             0.000 ( 0.011 ms): pipewire/2261 ioctl(fd: 60, cmd: SNDRV_PCM_HWSYNC, arg: 0x1)                        = 0
            21.353 ( 0.014 ms): pipewire/2261 ioctl(fd: 60, cmd: SNDRV_PCM_HWSYNC, arg: 0x1)                        = 0
            25.766 ( 0.014 ms): gnome-shell/2196 ioctl(fd: 14, cmd: DRM_I915_IRQ_WAIT, arg: 0x7ffe4a22c740)            = 0
            25.845 ( 0.034 ms): gnome-shel:cs0/2212 ioctl(fd: 14, cmd: DRM_I915_IRQ_EMIT, arg: 0x7fd43915dc70)            = 0
            25.916 ( 0.011 ms): gnome-shell/2196 ioctl(fd: 9, cmd: DRM_MODE_ADDFB2, arg: 0x7ffe4a22c8a0)               = 0
            25.941 ( 0.025 ms): gnome-shell/2196 ioctl(fd: 9, cmd: DRM_MODE_ATOMIC, arg: 0x7ffe4a22c840)               = 0
            32.915 ( 0.009 ms): gnome-shell/2196 ioctl(fd: 9, cmd: DRM_MODE_RMFB, arg: 0x7ffe4a22cf9c)                 = 0
            42.522 ( 0.013 ms): gnome-shell/2196 ioctl(fd: 14, cmd: DRM_I915_IRQ_WAIT, arg: 0x7ffe4a22c740)            = 0
            42.579 ( 0.031 ms): gnome-shel:cs0/2212 ioctl(fd: 14, cmd: DRM_I915_IRQ_EMIT, arg: 0x7fd43915dc70)            = 0
            42.644 ( 0.010 ms): gnome-shell/2196 ioctl(fd: 9, cmd: DRM_MODE_ADDFB2, arg: 0x7ffe4a22c8a0)               = 0
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Eugenio Pérez <eperezma@redhat.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/Yv6Kb4OESuNJuH6X@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      898d2403
    • Arnaldo Carvalho de Melo's avatar
      tools headers kvm s390: Sync headers with the kernel sources · 25f30895
      Arnaldo Carvalho de Melo authored
      To pick the changes in:
      
        f5ecfee9 ("KVM: s390: resetting the Topology-Change-Report")
      
      None of them trigger any changes in tooling, this time this is just to silence
      these perf build warnings:
      
        Warning: Kernel ABI header at 'tools/arch/s390/include/uapi/asm/kvm.h' differs from latest version at 'arch/s390/include/uapi/asm/kvm.h'
        diff -u tools/arch/s390/include/uapi/asm/kvm.h arch/s390/include/uapi/asm/kvm.h
      
      Cc: Janosch Frank <frankja@linux.ibm.com>
      Cc: Pierre Morel <pmorel@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/YvzwMXzaIzOU4WAY@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      25f30895
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync linux/kvm.h with the kernel sources · bf465ca8
      Arnaldo Carvalho de Melo authored
      To pick the changes in:
      
        8a061562 ("RISC-V: KVM: Add extensible CSR emulation framework")
        f5ecfee9 ("KVM: s390: resetting the Topology-Change-Report")
        450a5639 ("KVM: stats: Fix value for KVM_STATS_UNIT_MAX for boolean stats")
        1b870fa5 ("kvm: stats: tell userspace which values are boolean")
        db1c875e ("KVM: s390: add KVM_S390_ZPCI_OP to manage guest zPCI devices")
        94dfc73e ("treewide: uapi: Replace zero-length arrays with flexible-array members")
        084cc29f ("KVM: x86/MMU: Allow NX huge pages to be disabled on a per-vm basis")
        2f4073e0 ("KVM: VMX: Enable Notify VM exit")
        ed235117 ("KVM: x86: Extend KVM_{G,S}ET_VCPU_EVENTS to support pending triple fault")
        e9bf3acb ("KVM: s390: Add KVM_CAP_S390_PROTECTED_DUMP")
        8aba0958 ("KVM: s390: Add CPU dump functionality")
        0460eb35 ("KVM: s390: Add configuration dump functionality")
        fe9a93e0 ("KVM: s390: pv: Add query dump information")
        35d02493 ("KVM: s390: pv: Add query interface")
        c24a950e ("KVM, SEV: Add KVM_EXIT_SHUTDOWN metadata for SEV-ES")
        ffbb61d0 ("KVM: x86: Accept KVM_[GS]ET_TSC_KHZ as a VM ioctl.")
        661a20fa ("KVM: x86/xen: Advertise and document KVM_XEN_HVM_CONFIG_EVTCHN_SEND")
        fde0451b ("KVM: x86/xen: Support per-vCPU event channel upcall via local APIC")
        28d1629f ("KVM: x86/xen: Kernel acceleration for XENVER_version")
        53639526 ("KVM: x86/xen: handle PV timers oneshot mode")
        942c2490 ("KVM: x86/xen: Add KVM_XEN_VCPU_ATTR_TYPE_VCPU_ID")
        2fd6df2f ("KVM: x86/xen: intercept EVTCHNOP_send from guests")
        35025735 ("KVM: x86/xen: Support direct injection of event channel events")
      
      That just rebuilds perf, as these patches add just an ioctl that is S390
      specific and may clash with other arches, so are so far being excluded
      in the harvester script:
      
        $ tools/perf/trace/beauty/kvm_ioctl.sh > before
        $ cp include/uapi/linux/kvm.h tools/include/uapi/linux/kvm.h
        $ tools/perf/trace/beauty/kvm_ioctl.sh > after
        $ diff -u before after
        $ grep 390 tools/perf/trace/beauty/kvm_ioctl.sh
        	egrep -v " ((ARM|PPC|S390)_|[GS]ET_(DEBUGREGS|PIT2|XSAVE|TSC_KHZ)|CREATE_SPAPR_TCE_64)" | \
        $
      
      This is also by now used by tools/testing/selftests/kvm/, a simple test
      build succeeded.
      
      This silences this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/kvm.h' differs from latest version at 'include/uapi/linux/kvm.h'
        diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
      
      Cc: Anup Patel <anup@brainfault.org>
      Cc: Ben Gardon <bgardon@google.com>
      Cc: Chenyi Qiang <chenyi.qiang@intel.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: David Woodhouse <dwmw@amazon.co.uk>
      Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
      Cc: Janosch Frank <frankja@linux.ibm.com>
      Cc: João Martins <joao.m.martins@oracle.com>
      Cc: Matthew Rosato <mjrosato@linux.ibm.com>
      Cc: Oliver Upton <oupton@google.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Gonda <pgonda@google.com>
      Cc: Pierre Morel <pmorel@linux.ibm.com>
      Cc: Tao Xu <tao3.xu@intel.com>
      Link: https://lore.kernel.org/lkml/YvzuryClcn%2FvA0Gn@kernel.org/Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bf465ca8
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync drm/i915_drm.h with the kernel sources · 54cd4cde
      Arnaldo Carvalho de Melo authored
      To pick up the changes in:
      
        a913bde8 ("drm/i915: Update i915 uapi documentation")
        525e93f6 ("drm/i915/uapi: add NEEDS_CPU_ACCESS hint")
        141f733b ("drm/i915/uapi: expose the avail tracking")
        3f4309cb ("drm/i915/uapi: add probed_cpu_visible_size")
        a50794f2 ("uapi/drm/i915: Document memory residency and Flat-CCS capability of obj")
      
      That don't add any new ioctl, so no changes in tooling.
      
      This silences this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/drm/i915_drm.h' differs from latest version at 'include/uapi/drm/i915_drm.h'
        diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Matthew Auld <matthew.auld@intel.com>
      Cc: Matt Roper <matthew.d.roper@intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
      Cc: Ramalingam C <ramalingam.c@intel.com>
      Link: http://lore.kernel.org/lkml/Yvzrp9RFIeEkb5fI@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      54cd4cde
    • Arnaldo Carvalho de Melo's avatar
      tools headers cpufeatures: Sync with the kernel sources · 62ed93d1
      Arnaldo Carvalho de Melo authored
      To pick the changes from:
      
        2b129932 ("x86/speculation: Add RSB VM Exit protections")
        28a99e95 ("x86/amd: Use IBPB for firmware calls")
        4ad3278d ("x86/speculation: Disable RRSBA behavior")
        26aae8cc ("x86/cpu/amd: Enumerate BTC_NO")
        9756bba2 ("x86/speculation: Fill RSB on vmexit for IBRS")
        3ebc1700 ("x86/bugs: Add retbleed=ibpb")
        2dbb887e ("x86/entry: Add kernel IBRS implementation")
        6b80b59b ("x86/bugs: Report AMD retbleed vulnerability")
        a149180f ("x86: Add magic AMD return-thunk")
        15e67227 ("x86: Undo return-thunk damage")
        a883d624 ("x86/cpufeatures: Move RETPOLINE flags to word 11")
        aae99a7c ("x86/cpufeatures: Introduce x2AVIC CPUID bit")
        6f33a9da ("x86: Fix comment for X86_FEATURE_ZEN")
        51802186 ("x86/speculation/mmio: Enumerate Processor MMIO Stale Data bug")
      
      This only causes these perf files to be rebuilt:
      
        CC       /tmp/build/perf/bench/mem-memcpy-x86-64-asm.o
        CC       /tmp/build/perf/bench/mem-memset-x86-64-asm.o
      
      And addresses this perf build warning:
      
        Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
        diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexandre Chartre <alexandre.chartre@oracle.com>
      Cc: Andrew Cooper <andrew.cooper3@citrix.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Daniel Sneddon <daniel.sneddon@linux.intel.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Josh Poimboeuf <jpoimboe@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
      Cc: Wyes Karny <wyes.karny@amd.com>
      Link: https://lore.kernel.org/lkml/Yvznmu5oHv0ZDN2w@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      62ed93d1
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync linux/fscrypt.h with the kernel sources · fabe0c61
      Arnaldo Carvalho de Melo authored
      To pick the changes from:
      
        6b2a51ff ("fscrypt: Add HCTR2 support for filename encryption")
      
      That don't result in any changes in tooling, just causes this to be
      rebuilt:
      
        CC      /tmp/build/perf-urgent/trace/beauty/sync_file_range.o
        LD      /tmp/build/perf-urgent/trace/beauty/perf-in.o
      
      addressing this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/fscrypt.h' differs from latest version at 'include/uapi/linux/fscrypt.h'
        diff -u tools/include/uapi/linux/fscrypt.h include/uapi/linux/fscrypt.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Huckleberry <nhuck@google.com>
      Link: https://lore.kernel.org/lkml/Yvzl8C7O1b+hf9GS@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fabe0c61
    • Arnaldo Carvalho de Melo's avatar
      tools arch x86: Sync the msr-index.h copy with the kernel sources · 7f7f86a7
      Arnaldo Carvalho de Melo authored
      To pick up the changes in:
      
        2b129932 ("x86/speculation: Add RSB VM Exit protections")
        4af184ee ("tools/power turbostat: dump secondary Turbo-Ratio-Limit")
        4ad3278d ("x86/speculation: Disable RRSBA behavior")
        d7caac99 ("x86/cpu/amd: Add Spectral Chicken")
        6ad0ad2b ("x86/bugs: Report Intel retbleed vulnerability")
        c59a1f10 ("KVM: x86/pmu: Add IA32_PEBS_ENABLE MSR emulation for extended PEBS")
        465932db ("x86/cpu: Add new VMX feature, Tertiary VM-Execution control")
        027bbb88 ("KVM: x86/speculation: Disable Fill buffer clear within guests")
        51802186 ("x86/speculation/mmio: Enumerate Processor MMIO Stale Data bug")
      
      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-08-17 09:05:13.938246475 -0300
        +++ after	2022-08-17 09:05:22.221455851 -0300
        @@ -161,6 +161,7 @@
         	[0x0000048f] = "IA32_VMX_TRUE_EXIT_CTLS",
         	[0x00000490] = "IA32_VMX_TRUE_ENTRY_CTLS",
         	[0x00000491] = "IA32_VMX_VMFUNC",
        +	[0x00000492] = "IA32_VMX_PROCBASED_CTLS3",
         	[0x000004c1] = "IA32_PMC0",
         	[0x000004d0] = "IA32_MCG_EXT_CTL",
         	[0x00000560] = "IA32_RTIT_OUTPUT_BASE",
        @@ -212,6 +213,7 @@
         	[0x0000064D] = "PLATFORM_ENERGY_STATUS",
         	[0x0000064e] = "PPERF",
         	[0x0000064f] = "PERF_LIMIT_REASONS",
        +	[0x00000650] = "SECONDARY_TURBO_RATIO_LIMIT",
         	[0x00000658] = "PKG_WEIGHTED_CORE_C0_RES",
         	[0x00000659] = "PKG_ANY_CORE_C0_RES",
         	[0x0000065A] = "PKG_ANY_GFXE_C0_RES",
        $
      
      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: Daniel Sneddon <daniel.sneddon@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Len Brown <len.brown@intel.com>
      Cc: Like Xu <like.xu@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Robert Hoo <robert.hu@linux.intel.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Link: https://lore.kernel.org/lkml/YvzbT24m2o5U%2F7+q@kernel.org/Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7f7f86a7
    • Arnaldo Carvalho de Melo's avatar
      perf beauty: Update copy of linux/socket.h with the kernel sources · cf1258ac
      Arnaldo Carvalho de Melo authored
      To pick the changes in:
      
        7fa875b8 ("net: copy from user before calling __copy_msghdr")
        ebe73a28 ("net: Allow custom iter handler in msghdr")
        7c701d92 ("skbuff: carry external ubuf_info in msghdr")
        c0424532 ("net: make __sys_accept4_file() static")
      
      That don't result in any changes in the tables generated from that
      header.
      
      This silences this perf build warning:
      
        Warning: Kernel ABI header at 'tools/perf/trace/beauty/include/linux/socket.h' differs from latest version at 'include/linux/socket.h'
        diff -u tools/perf/trace/beauty/include/linux/socket.h include/linux/socket.h
      
      Cc: David Ahern <dsahern@kernel.org>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Dylan Yudaken <dylany@fb.com>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Pavel Begunkov <asml.silence@gmail.com>
      Cc: Yajun Deng <yajun.deng@linux.dev>
      Link: https://lore.kernel.org/lkml/YvzYs+F+Xzq8Hvvp@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      cf1258ac
    • Ian Rogers's avatar
      perf cpumap: Fix alignment for masks in event encoding · b2f10cd4
      Ian Rogers authored
      A mask encoding of a cpu map is laid out as:
      
        u16 nr
        u16 long_size
        unsigned long mask[];
      
      However, the mask may be 8-byte aligned meaning there is a 4-byte pad
      after long_size. This means 32-bit and 64-bit builds see the mask as
      being at different offsets. On top of this the structure is in the byte
      data[] encoded as:
      
        u16 type
        char data[]
      
      This means the mask's struct isn't the required 4 or 8 byte aligned, but
      is offset by 2. Consequently the long reads and writes are causing
      undefined behavior as the alignment is broken.
      
      Fix the mask struct by creating explicit 32 and 64-bit variants, use a
      union to avoid data[] and casts; the struct must be packed so the
      layout matches the existing perf.data layout. Taking an address of a
      member of a packed struct breaks alignment so pass the packed
      perf_record_cpu_map_data to functions, so they can access variables with
      the right alignment.
      
      As the 64-bit version has 4 bytes of padding, optimizing writing to only
      write the 32-bit version.
      
      Committer notes:
      
      Disable warnings about 'packed' that break the build in some arches like
      riscv64, but just around that specific struct.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      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: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Colin Ian King <colin.king@intel.com>
      Cc: Dave Marchevsky <davemarchevsky@fb.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Kees Kook <keescook@chromium.org>
      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>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20220614143353.1559597-5-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b2f10cd4
    • Ian Rogers's avatar
      perf cpumap: Compute mask size in constant time · 28526478
      Ian Rogers authored
      perf_cpu_map__max() computes the cpumap's maximum value, no need to
      iterate over all values.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      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: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Colin Ian King <colin.king@intel.com>
      Cc: Dave Marchevsky <davemarchevsky@fb.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Kees Kook <keescook@chromium.org>
      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>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20220614143353.1559597-4-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      28526478
    • Ian Rogers's avatar
      perf cpumap: Synthetic events and const/static · 35ae6f09
      Ian Rogers authored
      Make the cpumap arguments const to make it clearer they are in rather
      than out arguments. Make two functions static and remove external
      declarations.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      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: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Colin Ian King <colin.king@intel.com>
      Cc: Dave Marchevsky <davemarchevsky@fb.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Kees Kook <keescook@chromium.org>
      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>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20220614143353.1559597-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      35ae6f09
    • Ian Rogers's avatar
      perf cpumap: Const map for max() · e989bc3d
      Ian Rogers authored
      Allows max() to be used with 'const struct perf_cpu_maps *'.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      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: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Colin Ian King <colin.king@intel.com>
      Cc: Dave Marchevsky <davemarchevsky@fb.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Kees Kook <keescook@chromium.org>
      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>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20220614143353.1559597-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e989bc3d
    • Linus Torvalds's avatar
      Merge tag 'net-6.0-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net · 4c2d0b03
      Linus Torvalds authored
      Pull networking fixes from Jakub Kicinski:
       "Including fixes from netfilter.
      
        Current release - regressions:
      
         - tcp: fix cleanup and leaks in tcp_read_skb() (the new way BPF
           socket maps get data out of the TCP stack)
      
         - tls: rx: react to strparser initialization errors
      
         - netfilter: nf_tables: fix scheduling-while-atomic splat
      
         - net: fix suspicious RCU usage in bpf_sk_reuseport_detach()
      
        Current release - new code bugs:
      
         - mlxsw: ptp: fix a couple of races, static checker warnings and
           error handling
      
        Previous releases - regressions:
      
         - netfilter:
            - nf_tables: fix possible module reference underflow in error path
            - make conntrack helpers deal with BIG TCP (skbs > 64kB)
            - nfnetlink: re-enable conntrack expectation events
      
         - net: fix potential refcount leak in ndisc_router_discovery()
      
        Previous releases - always broken:
      
         - sched: cls_route: disallow handle of 0
      
         - neigh: fix possible local DoS due to net iface start/stop loop
      
         - rtnetlink: fix module refcount leak in rtnetlink_rcv_msg
      
         - sched: fix adding qlen to qcpu->backlog in gnet_stats_add_queue_cpu
      
         - virtio_net: fix endian-ness for RSS
      
         - dsa: mv88e6060: prevent crash on an unused port
      
         - fec: fix timer capture timing in `fec_ptp_enable_pps()`
      
         - ocelot: stats: fix races, integer wrapping and reading incorrect
           registers (the change of register definitions here accounts for
           bulk of the changed LoC in this PR)"
      
      * tag 'net-6.0-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (77 commits)
        net: moxa: MAC address reading, generating, validity checking
        tcp: handle pure FIN case correctly
        tcp: refactor tcp_read_skb() a bit
        tcp: fix tcp_cleanup_rbuf() for tcp_read_skb()
        tcp: fix sock skb accounting in tcp_read_skb()
        igb: Add lock to avoid data race
        dt-bindings: Fix incorrect "the the" corrections
        net: genl: fix error path memory leak in policy dumping
        stmmac: intel: Add a missing clk_disable_unprepare() call in intel_eth_pci_remove()
        net: ethernet: mtk_eth_soc: fix possible NULL pointer dereference in mtk_xdp_run
        net/mlx5e: Allocate flow steering storage during uplink initialization
        net: mscc: ocelot: report ndo_get_stats64 from the wraparound-resistant ocelot->stats
        net: mscc: ocelot: keep ocelot_stat_layout by reg address, not offset
        net: mscc: ocelot: make struct ocelot_stat_layout array indexable
        net: mscc: ocelot: fix race between ndo_get_stats64 and ocelot_check_stats_work
        net: mscc: ocelot: turn stats_lock into a spinlock
        net: mscc: ocelot: fix address of SYS_COUNT_TX_AGING counter
        net: mscc: ocelot: fix incorrect ndo_get_stats64 packet counters
        net: dsa: felix: fix ethtool 256-511 and 512-1023 TX packet counters
        net: dsa: don't warn in dsa_port_set_state_now() when driver doesn't support it
        ...
      4c2d0b03
    • Linus Torvalds's avatar
      Merge tag 'linux-kselftest-next-6.0-rc2' of... · 90b6b686
      Linus Torvalds authored
      Merge tag 'linux-kselftest-next-6.0-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
      
      Pull Kselftest fix from Shuah Khan:
      
       - fix landlock test build regression
      
      * tag 'linux-kselftest-next-6.0-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
        selftests/landlock: fix broken include of linux/landlock.h
      90b6b686
    • Linus Torvalds's avatar
      Merge tag 'trace-rtla-v6.0' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace · 0de277d4
      Linus Torvalds authored
      Pull rtla tool fixes from Steven Rostedt:
       "Fixes for the Real-Time Linux Analysis tooling:
      
         - Fix tracer name in comments and prints
      
         - Fix setting up symlinks
      
         - Allow extra flags to be set in build
      
         - Consolidate and show all necessary libraries not found in build
           error"
      
      * tag 'trace-rtla-v6.0' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
        rtla: Consolidate and show all necessary libraries that failed for building
        tools/rtla: Build with EXTRA_{C,LD}FLAGS
        tools/rtla: Fix command symlinks
        rtla: Fix tracer name
      0de277d4
  2. 18 Aug, 2022 19 commits