#include <systemd/sd-daemon.h>
+#include <system/syscommon-plugin-resourced-cpu-boosting.h>
+
#include "module.h"
#include "macro.h"
#include "util.h"
static void free_cpu_boosting_info(gpointer data)
{
- struct cpu_boosting_info *cpu_boosting_info =
- (struct cpu_boosting_info *)data;
+ struct syscommon_resourced_cpu_boosting_info *cpu_boosting_info =
+ (struct syscommon_resourced_cpu_boosting_info *)data;
assert(cpu_boosting_info);
}
static void find_cpu_boosting_info_in_tables(
- struct cpu_boosting_info **cpu_boosting_info, int *tid)
+ struct syscommon_resourced_cpu_boosting_info **cpu_boosting_info, int *tid)
{
assert(cpu_boosting_info);
static void cpu_boosting_destroy_request(gpointer data)
{
- struct cpu_boosting_input *input = (struct cpu_boosting_input *)data;
+ struct syscommon_resourced_cpu_boosting_input *input =
+ (struct syscommon_resourced_cpu_boosting_input *)data;
if (input == NULL)
return;
if (input->gsource_id)
g_free(input->gsource_id);
- g_slice_free(struct cpu_boosting_input, input);
+ g_slice_free(struct syscommon_resourced_cpu_boosting_input, input);
}
-static struct cpu_boosting_input *cpu_boosting_new_request(void)
+static struct syscommon_resourced_cpu_boosting_input *
+cpu_boosting_new_request(void)
{
- struct cpu_boosting_input *input = g_slice_new0(struct cpu_boosting_input);
+ struct syscommon_resourced_cpu_boosting_input *input =
+ g_slice_new0(struct syscommon_resourced_cpu_boosting_input);
if (input == NULL) {
_E("[CPU-BOOSTING] Failed to allocate memory for cpu boosting input");
return NULL;
free(output.level.tid_level);
}
-static int cpu_boosting_enqueue_by_socket(int sock, struct cpu_boosting_input **input_p)
+static int cpu_boosting_enqueue_by_socket(int sock,
+ struct syscommon_resourced_cpu_boosting_input **input_p)
{
int ret = RESOURCED_ERROR_NONE;
int byte;
- struct cpu_boosting_input *input = cpu_boosting_new_request();
+ struct syscommon_resourced_cpu_boosting_input *input =
+ cpu_boosting_new_request();
if (input == NULL) {
ret = RESOURCED_ERROR_OUT_OF_MEMORY;
goto destroy_input;
}
/* Called by resourced main thread */
-static int cpu_boosting_enqueue_by_conf(void *data, struct cpu_boosting_input **input)
+static int cpu_boosting_enqueue_by_conf(void *data,
+ struct syscommon_resourced_cpu_boosting_input **input)
{
assert(data);
static gboolean cpu_boosting_timeout(gpointer data)
{
int ret;
- struct cpu_boosting_input *input = (struct cpu_boosting_input *)data;
+ struct syscommon_resourced_cpu_boosting_input *input =
+ (struct syscommon_resourced_cpu_boosting_input *)data;
if (input == NULL) {
_E("[CPU-BOOSTING] input argument of cpu boosting should not be NULL");
int *tid_list = input->client_input.pid.tid;
for (int i = 0; i < tid_count; i++) {
- struct cpu_boosting_info *cpu_boosting_info = NULL;
+ struct syscommon_resourced_cpu_boosting_info *cpu_boosting_info = NULL;
if (tid_list[i] <= 0) {
_W("[CPU-BOOSTING] Thread (id = %d) should be larger than 0", tid_list[i]);
static void cpu_boosting_find_and_insert_info(pid_t tid,
cpu_boosting_level_e cpu_boosting_level, guint id)
{
- struct cpu_boosting_info *cpu_boosting_info = NULL;
+ struct syscommon_resourced_cpu_boosting_info *cpu_boosting_info = NULL;
switch (cpu_boosting_level) {
case CPU_BOOSTING_LEVEL_STRONG:
find_cpu_boosting_info_in_tables(&cpu_boosting_info, &tid);
if (cpu_boosting_info == NULL) {
- cpu_boosting_info = (struct cpu_boosting_info *)
- calloc(1, sizeof (struct cpu_boosting_info));
+ cpu_boosting_info = (struct syscommon_resourced_cpu_boosting_info *)
+ calloc(1, sizeof (struct syscommon_resourced_cpu_boosting_info));
if (cpu_boosting_info == NULL) {
_E("[CPU-BOOSTING] Failed to allocate memory");
return;
cpu_boosting_info->gsource_id = id;
}
-static void cpu_boosting_set(struct cpu_boosting_input *input)
+static void
+cpu_boosting_set(struct syscommon_resourced_cpu_boosting_input *input)
{
guint id = 0;
int fail_cnt = 0;
cpu_boosting_destroy_request(input);
}
-static void cpu_boosting_clear(struct cpu_boosting_input *input)
+static void cpu_boosting_clear(struct syscommon_resourced_cpu_boosting_input *input)
{
int ret;
int fail_cnt = 0;
cpu_boosting_destroy_request(input);
}
-static void cpu_boosting_get(struct cpu_boosting_input *input)
+static void cpu_boosting_get(struct syscommon_resourced_cpu_boosting_input *input)
{
int fail_cnt = 0;
int success_cnt = 0;
}
for (int i = 0; i < tid_count; i++) {
- struct cpu_boosting_info *cpu_boosting_info = NULL;
+ struct syscommon_resourced_cpu_boosting_info *cpu_boosting_info = NULL;
if (tid_list[i] <= 0) {
fail_cnt++;
cpu_boosting_destroy_request(input);
}
-static void cpu_boosting_set_inheritance(struct cpu_boosting_input *input)
+static void
+cpu_boosting_set_inheritance(struct syscommon_resourced_cpu_boosting_input *input)
{
+ struct syscommon_resourced_cpu_boosting_info *cpu_boosting_info = NULL;
+ struct syscommon_resourced_cpu_boosting_input *input_dest;
pid_t source_tid;
struct sched_attr attr;
cpu_boosting_level_e boosting_level;
- struct cpu_boosting_info *cpu_boosting_info = NULL;
- struct cpu_boosting_input *input_dest;
+
source_tid = input->client_input.pid.pid;
if (source_tid <= 0) {
cpu_boosting_destroy_request(input);
}
-static void cpu_boosting_clear_inheritance(struct cpu_boosting_input *input)
+static void
+cpu_boosting_clear_inheritance(struct syscommon_resourced_cpu_boosting_input *input)
{
- struct cpu_boosting_input *input_dest = g_hash_table_lookup(dest_table, input->client_input.dest);
+ struct syscommon_resourced_cpu_boosting_input *input_dest =
+ g_hash_table_lookup(dest_table, input->client_input.dest);
if (input_dest == NULL) {
_E("[CPU-BOOSTING] %s is not registered before", input->client_input.dest);
goto destroy_input;
cpu_boosting_destroy_request(input);
}
-static void cpu_boosting_register_destination(struct cpu_boosting_input *input)
+static void cpu_boosting_register_destination(
+ struct syscommon_resourced_cpu_boosting_input *input)
{
if (input->client_input.dest == NULL) {
_E("[CPU-BOOSTING] Boosting target name cannot be NULL");
g_hash_table_insert(dest_table, (gpointer)input->client_input.dest, input);
}
-static void cpu_boosting_unregister_destination(struct cpu_boosting_input *input)
+static void cpu_boosting_unregister_destination(
+ struct syscommon_resourced_cpu_boosting_input *input)
{
if (input->client_input.dest == NULL) {
_E("[CPU-BOOSTING] Boosting target name cannot be NULL");
}
#ifdef CONFIG_DEBUG_CPU_BOOSTING
- struct cpu_boosting_input *input_dest = g_hash_table_lookup(dest_table, input->client_input.dest);
+ struct syscommon_resourced_cpu_boosting_input *input_dest =
+ g_hash_table_lookup(dest_table, input->client_input.dest);
if (input_dest == NULL) {
_E("[CPU-BOOSTING] %s does not registered before", input->client_input.dest);
return;
return 0;
}
-static void cpu_boosting_handle_command(struct cpu_boosting_input *input)
+static void
+cpu_boosting_handle_command(struct syscommon_resourced_cpu_boosting_input *input)
{
if (!input) {
_E("[CPU-BOOSTING] Cpu boosting input data structure should not be NULL");
static int cpu_boosting_recv_from_conf(void *data)
{
int ret;
- struct cpu_boosting_input *input = NULL;
+ struct syscommon_resourced_cpu_boosting_input *input = NULL;
if ((ret = cpu_boosting_enqueue_by_conf(data, &input)) < 0 ||
input == NULL)
static bool cpu_boosting_recv_from_client(int fd, void *data)
{
int client_sock = fd;
- struct cpu_boosting_input *input = NULL;
+ struct syscommon_resourced_cpu_boosting_input *input = NULL;
if (client_sock <= 0) {
_E("[CPU-BOOSTING] client socket should be larger than 0");