summaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorKan Liang <kan.liang@linux.intel.com>2022-09-01 06:09:54 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-12-08 11:16:32 +0100
commit86a4ce251fa9e2aacad82d8040194c014fecfd03 (patch)
tree8b115fbbd31157302b76c8d022e841eae546a531 /include/linux
parent0dd1da5a15eeecb2fe4cf131b3216fb455af783c (diff)
downloadlinux-stable-86a4ce251fa9e2aacad82d8040194c014fecfd03.tar.gz
linux-stable-86a4ce251fa9e2aacad82d8040194c014fecfd03.tar.bz2
linux-stable-86a4ce251fa9e2aacad82d8040194c014fecfd03.zip
perf: Add sample_flags to indicate the PMU-filled sample data
[ Upstream commit 3aac580d5cc3001ca1627725b3b61edb529f341d ] On some platforms, some data e.g., timestamps, can be retrieved from the PMU driver. Usually, the data from the PMU driver is more accurate. The current perf kernel should output the PMU-filled sample data if it's available. To check the availability of the PMU-filled sample data, the current perf kernel initializes the related fields in the perf_sample_data_init(). When outputting a sample, the perf checks whether the field is updated by the PMU driver. If yes, the updated value will be output. If not, the perf uses an SW way to calculate the value or just outputs the initialized value if an SW way is unavailable either. With more and more data being provided by the PMU driver, more fields has to be initialized in the perf_sample_data_init(). That will increase the number of cache lines touched in perf_sample_data_init() and be harmful to the performance. Add new "sample_flags" to indicate the PMU-filled sample data. The PMU driver should set the corresponding PERF_SAMPLE_ flag when the field is updated. The initialization of the corresponding field is not required anymore. The following patches will make use of it and remove the corresponding fields from the perf_sample_data_init(), which will further minimize the number of cache lines touched. Only clear the sample flags that have already been done by the PMU driver in the perf_prepare_sample() for the PERF_RECORD_SAMPLE. For the other PERF_RECORD_ event type, the sample data is not available. 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://lore.kernel.org/r/20220901130959.1285717-2-kan.liang@linux.intel.com Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/perf_event.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 41a3307a971c..5efd8109ad0a 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -899,6 +899,7 @@ struct perf_sample_data {
* Fields set by perf_sample_data_init(), group so as to
* minimize the cachelines touched.
*/
+ u64 sample_flags;
u64 addr;
struct perf_raw_record *raw;
struct perf_branch_stack *br_stack;
@@ -950,6 +951,7 @@ static inline void perf_sample_data_init(struct perf_sample_data *data,
u64 addr, u64 period)
{
/* remaining struct members initialized in perf_prepare_sample() */
+ data->sample_flags = 0;
data->addr = addr;
data->raw = NULL;
data->br_stack = NULL;