linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf: Consolidate branch sample filter helpers
@ 2022-09-06  8:44 Anshuman Khandual
  2022-09-06 10:09 ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: Anshuman Khandual @ 2022-09-06  8:44 UTC (permalink / raw)
  To: linux-kernel, linux-perf-users, linux-arm-kernel, peterz
  Cc: Anshuman Khandual, Ingo Molnar, Arnaldo Carvalho de Melo

Besides the branch type filtering requests, 'event.attr.branch_sample_type'
also contains various flags indicating which additional information should
be captured, along with the base branch record. These flags help configure
the underlying hardware, and capture the branch records appropriately when
required e.g after PMU interrupt. But first, this moves an existing helper
perf_sample_save_hw_index() into the header before adding some more helpers
for other branch sample filter flags.

Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
Hello Peter,

Could you please consider taking this patch along with others on the perf
ABI series. This patch has been part of the original BRBE driver series,
which will have one less patch to include going forward. Thank you.

- Anshuman

This applies on v6.0-rc4 but after applying the following patch series

https://lore.kernel.org/all/20220824044822.70230-1-anshuman.khandual@arm.com/

 include/linux/perf_event.h | 26 ++++++++++++++++++++++++++
 kernel/events/core.c       |  9 ++-------
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index ee8b9ecdc03b..236375938eeb 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -1684,4 +1684,30 @@ static inline void perf_lopwr_cb(bool mode)
 }
 #endif
 
+#ifdef CONFIG_PERF_EVENTS
+static inline bool branch_sample_no_flags(const struct perf_event *event)
+{
+	return event->attr.branch_sample_type & PERF_SAMPLE_BRANCH_NO_FLAGS;
+}
+
+static inline bool branch_sample_no_cycles(const struct perf_event *event)
+{
+	return event->attr.branch_sample_type & PERF_SAMPLE_BRANCH_NO_CYCLES;
+}
+
+static inline bool branch_sample_type(const struct perf_event *event)
+{
+	return event->attr.branch_sample_type & PERF_SAMPLE_BRANCH_TYPE_SAVE;
+}
+
+static inline bool branch_sample_hw_index(const struct perf_event *event)
+{
+	return event->attr.branch_sample_type & PERF_SAMPLE_BRANCH_HW_INDEX;
+}
+
+static inline bool branch_sample_priv(const struct perf_event *event)
+{
+	return event->attr.branch_sample_type & PERF_SAMPLE_BRANCH_PRIV_SAVE;
+}
+#endif /* CONFIG_PERF_EVENTS */
 #endif /* _LINUX_PERF_EVENT_H */
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 2621fd24ad26..ff62d357a27b 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6967,11 +6967,6 @@ static void perf_output_read(struct perf_output_handle *handle,
 		perf_output_read_one(handle, event, enabled, running);
 }
 
-static inline bool perf_sample_save_hw_index(struct perf_event *event)
-{
-	return event->attr.branch_sample_type & PERF_SAMPLE_BRANCH_HW_INDEX;
-}
-
 void perf_output_sample(struct perf_output_handle *handle,
 			struct perf_event_header *header,
 			struct perf_sample_data *data,
@@ -7060,7 +7055,7 @@ void perf_output_sample(struct perf_output_handle *handle,
 			     * sizeof(struct perf_branch_entry);
 
 			perf_output_put(handle, data->br_stack->nr);
-			if (perf_sample_save_hw_index(event))
+			if (branch_sample_hw_index(event))
 				perf_output_put(handle, data->br_stack->hw_idx);
 			perf_output_copy(handle, data->br_stack->entries, size);
 		} else {
@@ -7354,7 +7349,7 @@ void perf_prepare_sample(struct perf_event_header *header,
 	if (sample_type & PERF_SAMPLE_BRANCH_STACK) {
 		int size = sizeof(u64); /* nr */
 		if (data->br_stack) {
-			if (perf_sample_save_hw_index(event))
+			if (branch_sample_hw_index(event))
 				size += sizeof(u64);
 
 			size += data->br_stack->nr
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf: Consolidate branch sample filter helpers
  2022-09-06  8:44 [PATCH] perf: Consolidate branch sample filter helpers Anshuman Khandual
@ 2022-09-06 10:09 ` Peter Zijlstra
  2022-09-07  6:21   ` Anshuman Khandual
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2022-09-06 10:09 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-kernel, linux-perf-users, linux-arm-kernel, Ingo Molnar,
	Arnaldo Carvalho de Melo

On Tue, Sep 06, 2022 at 02:14:14PM +0530, Anshuman Khandual wrote:
> Besides the branch type filtering requests, 'event.attr.branch_sample_type'
> also contains various flags indicating which additional information should
> be captured, along with the base branch record. These flags help configure
> the underlying hardware, and capture the branch records appropriately when
> required e.g after PMU interrupt. But first, this moves an existing helper
> perf_sample_save_hw_index() into the header before adding some more helpers
> for other branch sample filter flags.
> 
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: linux-perf-users@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
> Hello Peter,
> 
> Could you please consider taking this patch along with others on the perf
> ABI series. This patch has been part of the original BRBE driver series,
> which will have one less patch to include going forward. Thank you.
> 
> - Anshuman
> 
> This applies on v6.0-rc4 but after applying the following patch series
> 
> https://lore.kernel.org/all/20220824044822.70230-1-anshuman.khandual@arm.com/
> 

Yeah, but it doesn't cleanly apply to tip/perf/core....

The conflict looks trivial, let me stomp on it to make it fit :-)

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf: Consolidate branch sample filter helpers
  2022-09-06 10:09 ` Peter Zijlstra
@ 2022-09-07  6:21   ` Anshuman Khandual
  0 siblings, 0 replies; 3+ messages in thread
From: Anshuman Khandual @ 2022-09-07  6:21 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-kernel, linux-perf-users, linux-arm-kernel, Ingo Molnar,
	Arnaldo Carvalho de Melo



On 9/6/22 15:39, Peter Zijlstra wrote:
> On Tue, Sep 06, 2022 at 02:14:14PM +0530, Anshuman Khandual wrote:
>> Besides the branch type filtering requests, 'event.attr.branch_sample_type'
>> also contains various flags indicating which additional information should
>> be captured, along with the base branch record. These flags help configure
>> the underlying hardware, and capture the branch records appropriately when
>> required e.g after PMU interrupt. But first, this moves an existing helper
>> perf_sample_save_hw_index() into the header before adding some more helpers
>> for other branch sample filter flags.
>>
>> Cc: Peter Zijlstra <peterz@infradead.org>
>> Cc: Ingo Molnar <mingo@redhat.com>
>> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
>> Cc: linux-perf-users@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org
>> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>> ---
>> Hello Peter,
>>
>> Could you please consider taking this patch along with others on the perf
>> ABI series. This patch has been part of the original BRBE driver series,
>> which will have one less patch to include going forward. Thank you.
>>
>> - Anshuman
>>
>> This applies on v6.0-rc4 but after applying the following patch series
>>
>> https://lore.kernel.org/all/20220824044822.70230-1-anshuman.khandual@arm.com/
>>
> 
> Yeah, but it doesn't cleanly apply to tip/perf/core....
> 
> The conflict looks trivial, let me stomp on it to make it fit :-)

Thank you.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-07  6:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-06  8:44 [PATCH] perf: Consolidate branch sample filter helpers Anshuman Khandual
2022-09-06 10:09 ` Peter Zijlstra
2022-09-07  6:21   ` Anshuman Khandual

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).