* [FFmpeg-devel] [PATCH v2 2/2] avutil/macos_kperf: Fix assert which makes kperf failed to run
[not found] <20240617170400.59734-1-quinkblack@foxmail.com>
@ 2024-06-17 17:04 ` Zhao Zhili
2024-06-17 20:05 ` Martin Storsjö
0 siblings, 1 reply; 2+ messages in thread
From: Zhao Zhili @ 2024-06-17 17:04 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Zhao Zhili
From: Zhao Zhili <zhilizhao@tencent.com>
On m1, kpc_get_counter_count(KPC_MASK) return 8 in my test. The
exact value doesn't matter in our case, as long as we have a
sufficiently large array
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
---
libavutil/macos_kperf.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/libavutil/macos_kperf.c b/libavutil/macos_kperf.c
index 9fb047eeee..b2c1d164ac 100644
--- a/libavutil/macos_kperf.c
+++ b/libavutil/macos_kperf.c
@@ -67,14 +67,15 @@ KPERF_LIST
#define KPC_CLASS_POWER_MASK (1 << 2)
#define KPC_CLASS_RAWPMU_MASK (1 << 3)
-#define COUNTERS_COUNT 10
+#define KPC_MAX_COUNTERS 32
#define CONFIG_COUNT 8
#define KPC_MASK (KPC_CLASS_CONFIGURABLE_MASK | KPC_CLASS_FIXED_MASK)
static void kperf_init(void)
{
- uint64_t config[COUNTERS_COUNT] = {0};
+ uint64_t config[CONFIG_COUNT] = {0};
void *kperf = NULL;
+ uint32_t n;
av_assert0(kperf = dlopen("/System/Library/PrivateFrameworks/kperf.framework/Versions/A/kperf", RTLD_LAZY));
@@ -82,8 +83,10 @@ static void kperf_init(void)
KPERF_LIST
#undef F
- av_assert0(kpc_get_counter_count(KPC_MASK) == COUNTERS_COUNT);
- av_assert0(kpc_get_config_count(KPC_MASK) == CONFIG_COUNT);
+ n = kpc_get_counter_count(KPC_MASK);
+ av_assert0(n <= KPC_MAX_COUNTERS);
+ n = kpc_get_config_count(KPC_MASK);
+ av_assert0(n <= CONFIG_COUNT);
config[0] = CPMU_CORE_CYCLE | CFGWORD_EL0A64EN_MASK;
// config[3] = CPMU_INST_BRANCH | CFGWORD_EL0A64EN_MASK;
@@ -104,8 +107,9 @@ void ff_kperf_init(void)
uint64_t ff_kperf_cycles(void)
{
- uint64_t counters[COUNTERS_COUNT];
- if (kpc_get_thread_counters(0, COUNTERS_COUNT, counters)) {
+ uint64_t counters[KPC_MAX_COUNTERS];
+
+ if (kpc_get_thread_counters(0, KPC_MAX_COUNTERS, counters)) {
return -1;
}
--
2.42.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 2/2] avutil/macos_kperf: Fix assert which makes kperf failed to run
2024-06-17 17:04 ` [FFmpeg-devel] [PATCH v2 2/2] avutil/macos_kperf: Fix assert which makes kperf failed to run Zhao Zhili
@ 2024-06-17 20:05 ` Martin Storsjö
0 siblings, 0 replies; 2+ messages in thread
From: Martin Storsjö @ 2024-06-17 20:05 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Zhao Zhili
On Tue, 18 Jun 2024, Zhao Zhili wrote:
> From: Zhao Zhili <zhilizhao@tencent.com>
>
> On m1, kpc_get_counter_count(KPC_MASK) return 8 in my test. The
> exact value doesn't matter in our case, as long as we have a
> sufficiently large array
>
> Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
> ---
> libavutil/macos_kperf.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
Both these patche LGTM, thanks!
// Martin
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-17 20:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20240617170400.59734-1-quinkblack@foxmail.com>
2024-06-17 17:04 ` [FFmpeg-devel] [PATCH v2 2/2] avutil/macos_kperf: Fix assert which makes kperf failed to run Zhao Zhili
2024-06-17 20:05 ` Martin Storsjö
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git