Apply clang-format to CPU pinning and parking code

The original PR #416 failed the format check, but this wasn't apparent
until after merging.
This commit is contained in:
Ahsan Fayaz 2023-12-04 15:33:15 +00:00
parent 775c93001c
commit fad889db45
6 changed files with 32 additions and 37 deletions

View File

@ -29,10 +29,10 @@ POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdlib.h>
#include <sched.h>
#include "common-cpu.h" #include "common-cpu.h"
#include "common-logging.h" #include "common-logging.h"
#include <sched.h>
#include <stdlib.h>
char *parse_cpulist(char *cpulist, long *from, long *to) char *parse_cpulist(char *cpulist, long *from, long *to)
{ {

View File

@ -44,4 +44,3 @@ struct GameModeCPUInfo {
/* parses a list of cpu cores in the format "a,b-c,d-e,f" */ /* parses a list of cpu cores in the format "a,b-c,d-e,f" */
char *parse_cpulist(char *cpulist, long *from, long *to); char *parse_cpulist(char *cpulist, long *from, long *to);

View File

@ -124,7 +124,6 @@ void config_get_amd_performance_level(GameModeConfig *self, char value[CONFIG_VA
void config_get_cpu_park_cores(GameModeConfig *self, char value[CONFIG_VALUE_MAX]); void config_get_cpu_park_cores(GameModeConfig *self, char value[CONFIG_VALUE_MAX]);
void config_get_cpu_pin_cores(GameModeConfig *self, char value[CONFIG_VALUE_MAX]); void config_get_cpu_pin_cores(GameModeConfig *self, char value[CONFIG_VALUE_MAX]);
/** /**
* Functions to get supervisor config permissions * Functions to get supervisor config permissions
*/ */

View File

@ -32,9 +32,9 @@ POSSIBILITY OF SUCH DAMAGE.
#define _GNU_SOURCE #define _GNU_SOURCE
#include <sched.h>
#include <linux/limits.h>
#include <dirent.h> #include <dirent.h>
#include <linux/limits.h>
#include <sched.h>
#include "common-cpu.h" #include "common-cpu.h"
#include "common-external.h" #include "common-external.h"
@ -434,7 +434,8 @@ int game_mode_unpark_cpu(const GameModeCPUInfo *info)
return 0; return 0;
} }
static void apply_affinity_mask (pid_t pid, size_t cpusetsize, const cpu_set_t *mask, const bool be_silent) static void apply_affinity_mask(pid_t pid, size_t cpusetsize, const cpu_set_t *mask,
const bool be_silent)
{ {
char buffer[PATH_MAX]; char buffer[PATH_MAX];
char *proc_path = NULL; char *proc_path = NULL;
@ -442,20 +443,14 @@ static void apply_affinity_mask (pid_t pid, size_t cpusetsize, const cpu_set_t *
if (!(proc_path = buffered_snprintf(buffer, "/proc/%d/task", pid))) { if (!(proc_path = buffered_snprintf(buffer, "/proc/%d/task", pid))) {
if (!be_silent) { if (!be_silent) {
LOG_ERROR( LOG_ERROR("Unable to find executable for PID %d: %s\n", pid, strerror(errno));
"Unable to find executable for PID %d: %s\n",
pid,
strerror(errno));
} }
return; return;
} }
if (!(proc_dir = opendir(proc_path))) { if (!(proc_dir = opendir(proc_path))) {
if (!be_silent) { if (!be_silent) {
LOG_ERROR( LOG_ERROR("Unable to find executable for PID %d: %s\n", pid, strerror(errno));
"Unable to find executable for PID %d: %s\n",
pid,
strerror(errno));
} }
return; return;
} }
@ -474,7 +469,8 @@ static void apply_affinity_mask (pid_t pid, size_t cpusetsize, const cpu_set_t *
closedir(proc_dir); closedir(proc_dir);
} }
void game_mode_apply_core_pinning(const GameModeCPUInfo *info, const pid_t client, const bool be_silent) void game_mode_apply_core_pinning(const GameModeCPUInfo *info, const pid_t client,
const bool be_silent)
{ {
if (!info || info->park_or_pin == IS_CPU_PARK) if (!info || info->park_or_pin == IS_CPU_PARK)
return; return;

View File

@ -212,7 +212,8 @@ void game_mode_free_cpu(GameModeCPUInfo **info);
void game_mode_reconfig_cpu(GameModeConfig *config, GameModeCPUInfo **info); void game_mode_reconfig_cpu(GameModeConfig *config, GameModeCPUInfo **info);
int game_mode_park_cpu(const GameModeCPUInfo *info); int game_mode_park_cpu(const GameModeCPUInfo *info);
int game_mode_unpark_cpu(const GameModeCPUInfo *info); int game_mode_unpark_cpu(const GameModeCPUInfo *info);
void game_mode_apply_core_pinning(const GameModeCPUInfo *info, const pid_t client, const bool be_silent); void game_mode_apply_core_pinning(const GameModeCPUInfo *info, const pid_t client,
const bool be_silent);
void game_mode_undo_core_pinning(const GameModeCPUInfo *info, const pid_t client); void game_mode_undo_core_pinning(const GameModeCPUInfo *info, const pid_t client);
/** gamemode-dbus.c /** gamemode-dbus.c

View File

@ -31,9 +31,9 @@ POSSIBILITY OF SUCH DAMAGE.
#define _GNU_SOURCE #define _GNU_SOURCE
#include <linux/limits.h>
#include <sched.h> #include <sched.h>
#include <unistd.h> #include <unistd.h>
#include <linux/limits.h>
#include "common-cpu.h" #include "common-cpu.h"
#include "common-logging.h" #include "common-logging.h"