Skip to content

Commit

Permalink
cpu: sched_runtime can be set. This need at least kernel 6.12
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmm committed Nov 24, 2024
1 parent f2de3a9 commit cc785a0
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ void Backend::setTimerSlack(const int& value) {
Q_EMIT timerSlackChanged();
}

auto Backend::schedRuntime() const -> int {
auto Backend::schedRuntime() const -> double {
return _schedRuntime;
}

void Backend::setSchedRuntime(const int& value) {
void Backend::setSchedRuntime(const double& value) {
_schedRuntime = value;

Q_EMIT schedRuntimeChanged();
Expand Down
11 changes: 6 additions & 5 deletions src/cpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Backend : public QObject {

Q_PROPERTY(int autogroupNiceness READ autogroupNiceness WRITE setAutogroupNiceness NOTIFY autogroupNicenessChanged)

Q_PROPERTY(int schedRuntime READ schedRuntime WRITE setSchedRuntime NOTIFY schedRuntimeChanged)
Q_PROPERTY(double schedRuntime READ schedRuntime WRITE setSchedRuntime NOTIFY schedRuntimeChanged)

Q_PROPERTY(QString gameAffinity READ gameAffinity WRITE setGameAffinity NOTIFY gameAffinityChanged)

Expand All @@ -53,7 +53,7 @@ class Backend : public QObject {
[[nodiscard]] auto pcieAspmPolicy() -> std::string;
[[nodiscard]] auto workqueueAffinityScope() -> std::string;
[[nodiscard]] auto timerSlack() const -> int;
[[nodiscard]] auto schedRuntime() const -> int;
[[nodiscard]] auto schedRuntime() const -> double;
[[nodiscard]] auto cpuIntensiveThreshold() const -> int;
[[nodiscard]] auto niceness() const -> int;
[[nodiscard]] auto autogroupNiceness() const -> int;
Expand All @@ -67,11 +67,11 @@ class Backend : public QObject {
void setFrequencyGovernor(const std::string& value);
void setPcieAspmPolicy(const std::string& value);
void setWorkqueueAffinityScope(const std::string& value);
void setTimerSlack(const int& value);
void setSchedRuntime(const int& value);
void setSchedRuntime(const double& value);
void setCpuIntensiveThreshold(const int& value);
void setNiceness(const int& value);
void setAutogroupNiceness(const int& value);
void setTimerSlack(const int& value);
void setGameAffinity(const QString& value);
void setWineServerAffinity(const QString& value);

Expand Down Expand Up @@ -101,11 +101,12 @@ class Backend : public QObject {
int _pcieAspmPolicy;
int _workqueueAffinityScope;
int _timerSlack;
int _schedRuntime;
int _cpuIntensiveThreshold;
int _niceness;
int _autogroupNiceness;

double _schedRuntime;

QString _gameAffinity;
QString _wineServerAffinity;

Expand Down
2 changes: 1 addition & 1 deletion src/fastgame_apply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int {
auto use_realtime_wineserver = root.get<bool>("cpu.use-realtime-wineserver", false);
int niceness = root.get<int>("cpu.niceness", 0);
int autogroup_niceness = root.get<int>("cpu.autogroup-niceness", 0);
int sched_runtime = root.get<int>("cpu.sched-runtime", util::get_sched_runtime(0, 0));
double sched_runtime = root.get<double>("cpu.sched-runtime", util::get_sched_runtime(0, 0));

update_system_setting("/proc/sys/kernel/watchdog", root.get<bool>("cpu.enable-watchdog", true));

Expand Down
2 changes: 1 addition & 1 deletion src/presets_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ bool Backend::loadPreset(const QString& name) {
cpuBackend.setCpuIntensiveThreshold(
root.get<int>("cpu.workqueue.cpu-intensive-threshold", cpuBackend.cpuIntensiveThreshold()));

cpuBackend.setSchedRuntime(root.get<int>("cpu.sched-runtime", cpuBackend.schedRuntime()));
cpuBackend.setSchedRuntime(root.get<double>("cpu.sched-runtime", cpuBackend.schedRuntime()));

// memory

Expand Down
2 changes: 1 addition & 1 deletion src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void set_process_scheduler(const int& pid, const int& policy_index, const int& p
sched_setscheduler(pid, policy_index, &policy_params);
}

void set_sched_runtime(const int& pid, const uint64_t& value, const int& policy_index, const uint& flags) {
void set_sched_runtime(const int& pid, const double& value, const int& policy_index, const uint& flags) {
sched_attr attr = {};

attr.size = sizeof(sched_attr);
Expand Down
2 changes: 1 addition & 1 deletion src/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void clear_cpu_affinity(const int& pid);

void set_process_scheduler(const int& pid, const int& policy_index, const int& priority);

void set_sched_runtime(const int& pid, const uint64_t& value, const int& policy_index, const uint& flags);
void set_sched_runtime(const int& pid, const double& value, const int& policy_index, const uint& flags);

auto get_sched_runtime(const int& pid, const uint& flags) -> uint64_t;

Expand Down

0 comments on commit cc785a0

Please sign in to comment.