OpenCloudOS-Kernel/arch/powerpc
Kan Liang bc2637e898 perf/core: Add PERF_SAMPLE_WEIGHT_STRUCT
commit 2a6c6b7d7a upstream.

Current PERF_SAMPLE_WEIGHT sample type is very useful to expresses the
cost of an action represented by the sample. This allows the profiler
to scale the samples to be more informative to the programmer. It could
also help to locate a hotspot, e.g., when profiling by memory latencies,
the expensive load appear higher up in the histograms. But current
PERF_SAMPLE_WEIGHT sample type is solely determined by one factor. This
could be a problem, if users want two or more factors to contribute to
the weight. For example, Golden Cove core PMU can provide both the
instruction latency and the cache Latency information as factors for the
memory profiling.

For current X86 platforms, although meminfo::latency is defined as a
u64, only the lower 32 bits include the valid data in practice (No
memory access could last than 4G cycles). The higher 32 bits can be used
to store new factors.

Add a new sample type, PERF_SAMPLE_WEIGHT_STRUCT, to indicate the new
sample weight structure. It shares the same space as the
PERF_SAMPLE_WEIGHT sample type.

Users can apply either the PERF_SAMPLE_WEIGHT sample type or the
PERF_SAMPLE_WEIGHT_STRUCT sample type to retrieve the sample weight, but
they cannot apply both sample types simultaneously.

Currently, only X86 and PowerPC use the PERF_SAMPLE_WEIGHT sample type.
- For PowerPC, there is nothing changed for the PERF_SAMPLE_WEIGHT
  sample type. There is no effect for the new PERF_SAMPLE_WEIGHT_STRUCT
  sample type. PowerPC can re-struct the weight field similarly later.
- For X86, the same value will be dumped for the PERF_SAMPLE_WEIGHT
  sample type or the PERF_SAMPLE_WEIGHT_STRUCT sample type for now.
  The following patches will apply the new factors for the
  PERF_SAMPLE_WEIGHT_STRUCT sample type.

The field in the union perf_sample_weight should be shared among
different architectures. A generic name is required, but it's hard to
abstract a name that applies to all architectures. For example, on X86,
the fields are to store all kinds of latency. While on PowerPC, it
stores MMCRA[TECX/TECM], which should not be latency. So a general name
prefix 'var$NUM' is used here.

Intel-SIG: commit 2a6c6b7d7a perf/core: Add PERF_SAMPLE_WEIGHT_STRUCT
Backport for Sapphire Rapids core PMU support.
Note: This backported patch has some deviations from upstream version.
To avoid enum hole in perf_event_sample_format struct, we added
PERF_SAMPLE_{AUX,CGROUP,DATA_PAGE_SIZE,CODE_PAGE_SIZE} to file
include/uapi/linux/perf_event.h, but didn't backport the full patchsets
that introducing these enumeration values. To avoid mishandling of these
sampling formats, we added check to perf_copy_attr() in
kernel/events/core.c, to make sure -EINVAL always being returned for
these lack-of-kernel-support sampling formats.

Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/1611873611-156687-2-git-send-email-kan.liang@linux.intel.com
[ Yunying Sun: amend commit log ]
Signed-off-by: Yunying Sun <yunying.sun@intel.com>
Signed-off-by: Xinghui Li <korantli@tencent.com>
2024-06-11 21:18:41 +08:00
..
boot ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
configs ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
crypto treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
include dma-direct: unify the dma_capable definitions 2024-06-11 21:11:18 +08:00
kernel ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
kvm ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
lib ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
math-emu treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
mm dma-mapping: drop the dev argument to arch_sync_dma_for_* 2024-06-11 21:11:18 +08:00
net ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
oprofile treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 333 2019-06-05 17:37:06 +02:00
perf perf/core: Add PERF_SAMPLE_WEIGHT_STRUCT 2024-06-11 21:18:41 +08:00
platforms dma-direct: provide mmap and get_sgtable method overrides 2024-06-11 21:11:17 +08:00
purgatory treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441 2019-06-05 17:37:17 +02:00
sysdev dma-mapping: treat dev->bus_dma_mask as a DMA limit 2024-06-11 21:11:19 +08:00
tools tkernel: add base tlinux kernel interfaces 2024-06-11 20:09:33 +08:00
xmon ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
Kbuild treewide: Add SPDX license identifier - Kbuild 2019-05-30 11:32:33 -07:00
Kconfig PCI/MSI: Make arch_.*_msi_irq[s] fallbacks selectable 2024-06-11 21:11:38 +08:00
Kconfig.debug ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
Makefile ock: sync codes to ock 5.4.119-20.0009.21 2024-06-11 20:27:38 +08:00
Makefile.postlink tkernel: add base tlinux kernel interfaces 2024-06-11 20:09:33 +08:00