mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-04 19:10:35 +02:00
Calling sched_setscheduler twice every sample period has high CPU
overhead. For intel and panfrost, their dump_perfcnt is preemptible and
they don't need the scheduler change.
For freedreno, simply makes the main thread RT at all time. This solves
most of the cpu overhead issue.
v2: removed pthread_t param and just change the scheduler for the
calling thread
Acked-by: Rob Clark <robdclark@chromium.org> (v1)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19668>
38 lines
824 B
C++
38 lines
824 B
C++
/*
|
|
* Copyright © 2020 Collabora, Ltd.
|
|
* Author: Antonio Caggiano <antonio.caggiano@collabora.com>
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include "pps.h"
|
|
|
|
#include <cerrno>
|
|
#include <cstring>
|
|
|
|
#include <sched.h>
|
|
|
|
namespace pps
|
|
{
|
|
bool check(int res, const char *msg)
|
|
{
|
|
if (res < 0) {
|
|
char *err_msg = std::strerror(errno);
|
|
PERFETTO_ELOG("%s: %s", msg, err_msg);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
void make_thread_rt()
|
|
{
|
|
// Use FIFO policy to avoid preemption while collecting counters
|
|
int sched_policy = SCHED_FIFO;
|
|
// Do not use max priority to avoid starving migration and watchdog threads
|
|
int priority_value = sched_get_priority_max(sched_policy) - 1;
|
|
sched_param priority_param { priority_value };
|
|
sched_setscheduler(0, sched_policy, &priority_param);
|
|
}
|
|
|
|
} // namespace pps
|