mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-06-06 15:47:20 +02:00
fixed more coding style errors
This commit is contained in:
parent
912d4bdc19
commit
81dc3f95e5
@ -35,8 +35,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <linux/limits.h>
|
#include <linux/limits.h>
|
||||||
|
|
||||||
#include "common-external.h"
|
|
||||||
#include "common-cpu.h"
|
#include "common-cpu.h"
|
||||||
|
#include "common-external.h"
|
||||||
#include "common-helpers.h"
|
#include "common-helpers.h"
|
||||||
#include "common-logging.h"
|
#include "common-logging.h"
|
||||||
|
|
||||||
@ -86,12 +86,13 @@ static int walk_sysfs(char *cpulist, char **buf, size_t *buflen, GameModeCPUInfo
|
|||||||
CPU_SET_S((size_t)cpu, CPU_ALLOC_SIZE(info->num_cpu), info->online);
|
CPU_SET_S((size_t)cpu, CPU_ALLOC_SIZE(info->num_cpu), info->online);
|
||||||
|
|
||||||
/* check for L3 cache non-uniformity among the cores */
|
/* check for L3 cache non-uniformity among the cores */
|
||||||
int ret = snprintf(path, PATH_MAX, "/sys/devices/system/cpu/cpu%ld/cache/index3/size", cpu);
|
int ret =
|
||||||
|
snprintf(path, PATH_MAX, "/sys/devices/system/cpu/cpu%ld/cache/index3/size", cpu);
|
||||||
|
|
||||||
if (ret > 0 && ret < PATH_MAX) {
|
if (ret > 0 && ret < PATH_MAX) {
|
||||||
if (read_small_file(path, buf, buflen)) {
|
if (read_small_file(path, buf, buflen)) {
|
||||||
char *endp;
|
char *endp;
|
||||||
unsigned long long cache_size = strtoull (*buf, &endp, 10);
|
unsigned long long cache_size = strtoull(*buf, &endp, 10);
|
||||||
|
|
||||||
if (*endp == 'K') {
|
if (*endp == 'K') {
|
||||||
cache_size *= 1024;
|
cache_size *= 1024;
|
||||||
@ -115,11 +116,14 @@ static int walk_sysfs(char *cpulist, char **buf, size_t *buflen, GameModeCPUInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check for frequency non-uniformity among the cores */
|
/* check for frequency non-uniformity among the cores */
|
||||||
ret = snprintf(path, PATH_MAX, "/sys/devices/system/cpu/cpu%ld/cpufreq/cpuinfo_max_freq", cpu);
|
ret = snprintf(path,
|
||||||
|
PATH_MAX,
|
||||||
|
"/sys/devices/system/cpu/cpu%ld/cpufreq/cpuinfo_max_freq",
|
||||||
|
cpu);
|
||||||
|
|
||||||
if (ret > 0 && ret < PATH_MAX) {
|
if (ret > 0 && ret < PATH_MAX) {
|
||||||
if (read_small_file(path, buf, buflen)) {
|
if (read_small_file(path, buf, buflen)) {
|
||||||
unsigned long long freq = strtoull (*buf, NULL, 10);
|
unsigned long long freq = strtoull(*buf, NULL, 10);
|
||||||
unsigned long long cutoff = (freq * 5) / 100;
|
unsigned long long cutoff = (freq * 5) / 100;
|
||||||
|
|
||||||
if (freq > max_freq) {
|
if (freq > max_freq) {
|
||||||
@ -136,13 +140,15 @@ static int walk_sysfs(char *cpulist, char **buf, size_t *buflen, GameModeCPUInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CPU_EQUAL_S(CPU_ALLOC_SIZE(info->num_cpu), info->online, info->to_keep) || CPU_COUNT_S(CPU_ALLOC_SIZE(info->num_cpu), info->to_keep) == 0) {
|
if (CPU_EQUAL_S(CPU_ALLOC_SIZE(info->num_cpu), info->online, info->to_keep) ||
|
||||||
|
CPU_COUNT_S(CPU_ALLOC_SIZE(info->num_cpu), info->to_keep) == 0) {
|
||||||
LOG_MSG("cpu L3 cache was uniform, this is not a x3D with multiple chiplets\n");
|
LOG_MSG("cpu L3 cache was uniform, this is not a x3D with multiple chiplets\n");
|
||||||
|
|
||||||
CPU_FREE(info->to_keep);
|
CPU_FREE(info->to_keep);
|
||||||
info->to_keep = freq_cores;
|
info->to_keep = freq_cores;
|
||||||
|
|
||||||
if (CPU_EQUAL_S(CPU_ALLOC_SIZE(info->num_cpu), info->online, info->to_keep) || CPU_COUNT_S(CPU_ALLOC_SIZE(info->num_cpu), info->to_keep) == 0)
|
if (CPU_EQUAL_S(CPU_ALLOC_SIZE(info->num_cpu), info->online, info->to_keep) ||
|
||||||
|
CPU_COUNT_S(CPU_ALLOC_SIZE(info->num_cpu), info->to_keep) == 0)
|
||||||
LOG_MSG("cpu frequency was uniform, this is not a big.LITTLE type of system\n");
|
LOG_MSG("cpu frequency was uniform, this is not a big.LITTLE type of system\n");
|
||||||
} else {
|
} else {
|
||||||
CPU_FREE(freq_cores);
|
CPU_FREE(freq_cores);
|
||||||
@ -195,9 +201,11 @@ int game_mode_initialise_cpu(GameModeConfig *config, GameModeCPUInfo **info)
|
|||||||
int park_or_pin = -1;
|
int park_or_pin = -1;
|
||||||
|
|
||||||
if (pin_cores[0] != '\0') {
|
if (pin_cores[0] != '\0') {
|
||||||
if (strcasecmp(pin_cores, "no") == 0 || strcasecmp(pin_cores, "false") == 0 || strcmp(pin_cores, "0") == 0) {
|
if (strcasecmp(pin_cores, "no") == 0 || strcasecmp(pin_cores, "false") == 0 ||
|
||||||
|
strcmp(pin_cores, "0") == 0) {
|
||||||
park_or_pin = -2;
|
park_or_pin = -2;
|
||||||
} else if (strcasecmp(pin_cores, "yes") == 0 || strcasecmp(pin_cores, "true") == 0 || strcmp(pin_cores, "1") == 0) {
|
} else if (strcasecmp(pin_cores, "yes") == 0 || strcasecmp(pin_cores, "true") == 0 ||
|
||||||
|
strcmp(pin_cores, "1") == 0) {
|
||||||
pin_cores[0] = '\0';
|
pin_cores[0] = '\0';
|
||||||
park_or_pin = 1;
|
park_or_pin = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -206,12 +214,14 @@ int game_mode_initialise_cpu(GameModeConfig *config, GameModeCPUInfo **info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (park_or_pin < 1 && park_cores[0] != '\0') {
|
if (park_or_pin < 1 && park_cores[0] != '\0') {
|
||||||
if (strcasecmp(park_cores, "no") == 0 || strcasecmp(park_cores, "false") == 0 || strcmp(park_cores, "0") == 0) {
|
if (strcasecmp(park_cores, "no") == 0 || strcasecmp(park_cores, "false") == 0 ||
|
||||||
|
strcmp(park_cores, "0") == 0) {
|
||||||
if (park_or_pin == -2)
|
if (park_or_pin == -2)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
park_or_pin = -1;
|
park_or_pin = -1;
|
||||||
} else if (strcasecmp(park_cores, "yes") == 0 || strcasecmp(park_cores, "true") == 0 || strcmp(park_cores, "1") == 0) {
|
} else if (strcasecmp(park_cores, "yes") == 0 || strcasecmp(park_cores, "true") == 0 ||
|
||||||
|
strcmp(park_cores, "1") == 0) {
|
||||||
park_cores[0] = '\0';
|
park_cores[0] = '\0';
|
||||||
park_or_pin = 0;
|
park_or_pin = 0;
|
||||||
} else {
|
} else {
|
||||||
@ -264,7 +274,8 @@ int game_mode_initialise_cpu(GameModeConfig *config, GameModeCPUInfo **info)
|
|||||||
goto error_exit;
|
goto error_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (park_or_pin == 0 && CPU_EQUAL_S(CPU_ALLOC_SIZE(new_info->num_cpu), new_info->online, new_info->to_keep)) {
|
if (park_or_pin == 0 &&
|
||||||
|
CPU_EQUAL_S(CPU_ALLOC_SIZE(new_info->num_cpu), new_info->online, new_info->to_keep)) {
|
||||||
game_mode_free_cpu(&new_info);
|
game_mode_free_cpu(&new_info);
|
||||||
LOG_MSG("I can find no reason to perform core parking on this system!\n");
|
LOG_MSG("I can find no reason to perform core parking on this system!\n");
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
@ -272,20 +283,22 @@ int game_mode_initialise_cpu(GameModeConfig *config, GameModeCPUInfo **info)
|
|||||||
|
|
||||||
if (CPU_COUNT_S(CPU_ALLOC_SIZE(new_info->num_cpu), new_info->to_keep) < 4) {
|
if (CPU_COUNT_S(CPU_ALLOC_SIZE(new_info->num_cpu), new_info->to_keep) < 4) {
|
||||||
game_mode_free_cpu(&new_info);
|
game_mode_free_cpu(&new_info);
|
||||||
LOG_MSG("logic or config would result in less than 4 active cores, will not apply cpu core parking/pinning!\n");
|
LOG_MSG(
|
||||||
|
"logic or config would result in less than 4 active cores, will not apply cpu core "
|
||||||
|
"parking/pinning!\n");
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
*info = new_info;
|
*info = new_info;
|
||||||
|
|
||||||
early_exit:
|
early_exit:
|
||||||
free (buf);
|
free(buf);
|
||||||
free (buf2);
|
free(buf2);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_exit:
|
error_exit:
|
||||||
free (buf);
|
free(buf);
|
||||||
free (buf2);
|
free(buf2);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +319,7 @@ static int log_state(char *cpulist, int *pos, const long first, const long last)
|
|||||||
if (first == last)
|
if (first == last)
|
||||||
ret = snprintf(cpulist + *pos, ARG_MAX - (size_t)*pos, "%ld", first);
|
ret = snprintf(cpulist + *pos, ARG_MAX - (size_t)*pos, "%ld", first);
|
||||||
else
|
else
|
||||||
ret = snprintf(cpulist + *pos, ARG_MAX - (size_t)*pos, "%ld-%ld", first,last);
|
ret = snprintf(cpulist + *pos, ARG_MAX - (size_t)*pos, "%ld-%ld", first, last);
|
||||||
|
|
||||||
if (ret < 0 || (size_t)ret >= (ARG_MAX - (size_t)*pos)) {
|
if (ret < 0 || (size_t)ret >= (ARG_MAX - (size_t)*pos)) {
|
||||||
LOG_ERROR("snprintf failed, will not apply cpu core parking!\n");
|
LOG_ERROR("snprintf failed, will not apply cpu core parking!\n");
|
||||||
@ -328,7 +341,8 @@ int game_mode_park_cpu(const GameModeCPUInfo *info)
|
|||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
for (long cpu = 0; cpu < (long)(info->num_cpu); cpu++) {
|
for (long cpu = 0; cpu < (long)(info->num_cpu); cpu++) {
|
||||||
if (CPU_ISSET_S((size_t)cpu, CPU_ALLOC_SIZE(info->num_cpu), info->online) && !CPU_ISSET_S((size_t)cpu, CPU_ALLOC_SIZE(info->num_cpu), info->to_keep)) {
|
if (CPU_ISSET_S((size_t)cpu, CPU_ALLOC_SIZE(info->num_cpu), info->online) &&
|
||||||
|
!CPU_ISSET_S((size_t)cpu, CPU_ALLOC_SIZE(info->num_cpu), info->to_keep)) {
|
||||||
if (first == -1) {
|
if (first == -1) {
|
||||||
first = cpu;
|
first = cpu;
|
||||||
last = cpu;
|
last = cpu;
|
||||||
@ -372,7 +386,8 @@ int game_mode_unpark_cpu(const GameModeCPUInfo *info)
|
|||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
for (long cpu = 0; cpu < (long)(info->num_cpu); cpu++) {
|
for (long cpu = 0; cpu < (long)(info->num_cpu); cpu++) {
|
||||||
if (CPU_ISSET_S((size_t)cpu, CPU_ALLOC_SIZE(info->num_cpu), info->online) && !CPU_ISSET_S((size_t)cpu, CPU_ALLOC_SIZE(info->num_cpu), info->to_keep)) {
|
if (CPU_ISSET_S((size_t)cpu, CPU_ALLOC_SIZE(info->num_cpu), info->online) &&
|
||||||
|
!CPU_ISSET_S((size_t)cpu, CPU_ALLOC_SIZE(info->num_cpu), info->to_keep)) {
|
||||||
if (first == -1) {
|
if (first == -1) {
|
||||||
first = cpu;
|
first = cpu;
|
||||||
last = cpu;
|
last = cpu;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user