Package init
This commit is contained in:
parent
deb8249f89
commit
72868d0397
@ -332,10 +332,10 @@ index eb84a1c..d384860 100644
|
||||
struct irq_info *info;
|
||||
char *c;
|
||||
char *savedline = NULL;
|
||||
@@ -186,45 +220,13 @@ GList* collect_full_irq_list()
|
||||
continue;
|
||||
|
||||
@@ -188,45 +222,13 @@ GList* collect_full_irq_list()
|
||||
savedline = strdup(line);
|
||||
if (!savedline)
|
||||
break;
|
||||
- irq_name = strtok_r(savedline, " ", &savedptr);
|
||||
- if (strstr(irq_name, "xen-dyn") != NULL)
|
||||
- is_xen_dyn = 1;
|
||||
@ -374,7 +374,7 @@ index eb84a1c..d384860 100644
|
||||
- info->class = IRQ_OTHER;
|
||||
-#endif
|
||||
- }
|
||||
- info->name = strdupa(irq_mod);
|
||||
- info->name = strdup(irq_mod);
|
||||
+ init_irq_class_and_type(savedline, info, number);
|
||||
tmp_list = g_list_append(tmp_list, info);
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ index 40ec65c..27cf2eb 100644
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
struct sigaction action, hupaction;
|
||||
@@ -676,17 +747,11 @@ int main(int argc, char** argv)
|
||||
@@ -709,17 +782,12 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
if (!foreground_mode) {
|
||||
@ -114,7 +114,8 @@ index 40ec65c..27cf2eb 100644
|
||||
- write(pidfd, str, strlen(str));
|
||||
- close(pidfd);
|
||||
+ if (pidfile && create_lock_pidfile(pidfile) < 0) {
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ ret = EXIT_FAILURE;
|
||||
+ goto out;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,9 +7,9 @@ Subject: [PATCH] irqbalance: make the return value of getline() handled correct
|
||||
|
||||
---
|
||||
activate.c | 2 +-
|
||||
cputree.c | 8 ++++----
|
||||
cputree.c | 6 +++---
|
||||
procinterrupts.c | 12 ++++++------
|
||||
3 files changed, 11 insertions(+), 11 deletions(-)
|
||||
3 files changed, 10 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/activate.c b/activate.c
|
||||
index ad60fde..87336f4 100644
|
||||
@ -28,15 +28,6 @@ diff --git a/cputree.c b/cputree.c
|
||||
index 0dbb5c8..51ef357 100644
|
||||
--- a/cputree.c
|
||||
+++ b/cputree.c
|
||||
@@ -279,7 +279,7 @@ static void do_one_cpu(char *path)
|
||||
if (file) {
|
||||
char *line = NULL;
|
||||
size_t size = 0;
|
||||
- if (getline(&line, &size, file)==0)
|
||||
+ if (getline(&line, &size, file)<=0)
|
||||
return;
|
||||
fclose(file);
|
||||
if (line && line[0]=='0') {
|
||||
@@ -324,7 +324,7 @@ static void do_one_cpu(char *path)
|
||||
if (file) {
|
||||
char *line = NULL;
|
||||
|
||||
@ -112,7 +112,7 @@ index 65aeae2..7c97d47 100644
|
||||
+
|
||||
}
|
||||
|
||||
|
||||
static void free_tmp_irqs(gpointer data)
|
||||
diff --git a/irqbalance.c b/irqbalance.c
|
||||
index 21d578a..d41753c 100644
|
||||
--- a/irqbalance.c
|
||||
@ -153,16 +153,19 @@ index 21d578a..d41753c 100644
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -586,6 +590,19 @@ int main(int argc, char** argv)
|
||||
@@ -586,6 +590,22 @@ int main(int argc, char** argv)
|
||||
HZ = 100;
|
||||
}
|
||||
|
||||
+ if (!foreground_mode) {
|
||||
+ if (daemon(0,0))
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ if (daemon(0,0)) {
|
||||
+ ret = EXIT_FAILURE;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ /* Write pidfile */
|
||||
+ if (pidfile && create_lock_pidfile(pidfile) < 0) {
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ ret = EXIT_FAILURE;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@ -173,8 +176,8 @@ index 21d578a..d41753c 100644
|
||||
build_object_tree();
|
||||
if (debug_mode)
|
||||
dump_object_tree();
|
||||
@@ -600,14 +617,6 @@ int main(int argc, char** argv)
|
||||
exit(EXIT_SUCCESS);
|
||||
@@ -600,15 +617,6 @@ int main(int argc, char** argv)
|
||||
goto out;
|
||||
}
|
||||
|
||||
- if (!foreground_mode) {
|
||||
@ -182,15 +185,16 @@ index 21d578a..d41753c 100644
|
||||
- exit(EXIT_FAILURE);
|
||||
- /* Write pidfile */
|
||||
- if (pidfile && create_lock_pidfile(pidfile) < 0) {
|
||||
- exit(EXIT_FAILURE);
|
||||
- ret = EXIT_FAILURE;
|
||||
- goto out;
|
||||
- }
|
||||
- }
|
||||
|
||||
action.sa_handler = handler;
|
||||
sigemptyset(&action.sa_mask);
|
||||
@@ -640,7 +649,7 @@ int main(int argc, char** argv)
|
||||
log(TO_CONSOLE, LOG_WARNING, "WARNING: Failed to create irqbalance socket thread, return %d.\n", err);
|
||||
return EXIT_FAILURE;
|
||||
ret = EXIT_FAILURE;
|
||||
goto out;
|
||||
}
|
||||
-
|
||||
+ log(TO_ALL, LOG_INFO, "irqbalance start scan.\n");
|
||||
|
||||
@ -314,8 +314,8 @@ index e375a1a..bf9a2e4 100644
|
||||
{
|
||||
+ struct sigaction action, hupaction;
|
||||
sigset_t sigset, old_sigset;
|
||||
int ret = EXIT_SUCCESS;
|
||||
|
||||
sigemptyset(&sigset);
|
||||
@@ -600,11 +658,19 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
@ -341,9 +341,9 @@ index e375a1a..bf9a2e4 100644
|
||||
sigprocmask(SIG_SETMASK, &old_sigset, NULL);
|
||||
|
||||
#ifdef HAVE_LIBCAP_NG
|
||||
@@ -624,12 +690,23 @@ int main(int argc, char** argv)
|
||||
if (init_socket()) {
|
||||
return EXIT_FAILURE;
|
||||
@@ -625,12 +691,23 @@ int main(int argc, char** argv)
|
||||
ret = EXIT_FAILURE;
|
||||
goto out;
|
||||
}
|
||||
- main_loop = g_main_loop_new(NULL, FALSE);
|
||||
- int *last_interval = &sleep_interval;
|
||||
@ -368,8 +368,8 @@ index e375a1a..bf9a2e4 100644
|
||||
+ }
|
||||
+ }
|
||||
|
||||
out:
|
||||
free_object_tree();
|
||||
free_cl_opts();
|
||||
diff --git a/irqbalance.h b/irqbalance.h
|
||||
index 73737ed..b8141aa 100644
|
||||
--- a/irqbalance.h
|
||||
|
||||
@ -175,7 +175,7 @@ index 27cf2eb..6e9de88 100644
|
||||
|
||||
volatile int keep_going = 1;
|
||||
volatile int ban_pci_assigned_irq = 1;
|
||||
@@ -430,160 +432,6 @@ void get_object_stat(struct topo_obj *object, void *data)
|
||||
@@ -430,178 +432,6 @@ void get_object_stat(struct topo_obj *object, void *data)
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,6 +206,10 @@ index 27cf2eb..6e9de88 100644
|
||||
- goto out_close;
|
||||
- }
|
||||
- cmsg = CMSG_FIRSTHDR(&msg);
|
||||
- if (!cmsg) {
|
||||
- log(TO_ALL, LOG_WARNING, "Connection no memory.\n");
|
||||
- goto out_close;
|
||||
- }
|
||||
- if ((cmsg->cmsg_level == SOL_SOCKET) &&
|
||||
- (cmsg->cmsg_type == SCM_CREDENTIALS)) {
|
||||
- struct ucred *credentials = (struct ucred *) CMSG_DATA(cmsg);
|
||||
@ -229,6 +233,8 @@ index 27cf2eb..6e9de88 100644
|
||||
- strlen("sleep ")))) {
|
||||
- char *sleep_string = malloc(
|
||||
- sizeof(char) * (recv_size - strlen("settings sleep ")));
|
||||
- if (!sleep_string)
|
||||
- goto out_close;
|
||||
- strncpy(sleep_string, buff + strlen("settings sleep "),
|
||||
- recv_size - strlen("settings sleep "));
|
||||
- int new_iterval = strtoul(sleep_string, NULL, 10);
|
||||
@ -241,6 +247,8 @@ index 27cf2eb..6e9de88 100644
|
||||
- char *end;
|
||||
- char *irq_string = malloc(
|
||||
- sizeof(char) * (recv_size - strlen("settings ban irqs ")));
|
||||
- if (!irq_string)
|
||||
- goto out_close;
|
||||
- strncpy(irq_string, buff + strlen("settings ban irqs "),
|
||||
- recv_size - strlen("settings ban irqs "));
|
||||
- g_list_free_full(cl_banned_irqs, free);
|
||||
@ -259,6 +267,8 @@ index 27cf2eb..6e9de88 100644
|
||||
- strlen("cpus")))) {
|
||||
- char *cpu_ban_string = malloc(
|
||||
- sizeof(char) * (recv_size - strlen("settings cpus ")));
|
||||
- if (!cpu_ban_string)
|
||||
- goto out_close;
|
||||
- strncpy(cpu_ban_string, buff + strlen("settings cpus "),
|
||||
- recv_size - strlen("settings cpus "));
|
||||
- banned_cpumask_from_ui = strtok(cpu_ban_string, " ");
|
||||
@ -272,15 +282,23 @@ index 27cf2eb..6e9de88 100644
|
||||
- if (!strncmp(buff, "setup", strlen("setup"))) {
|
||||
- char banned[512];
|
||||
- char *setup = calloc(strlen("SLEEP ") + 11 + 1, 1);
|
||||
- char *newptr = NULL;
|
||||
- if (!setup)
|
||||
- goto out_close;
|
||||
- snprintf(setup, strlen("SLEEP ") + 11 + 1, "SLEEP %d ", sleep_interval);
|
||||
- if(g_list_length(cl_banned_irqs) > 0) {
|
||||
- for_each_irq(cl_banned_irqs, get_irq_data, setup);
|
||||
- for_each_irq(cl_banned_irqs, get_irq_data, &setup);
|
||||
- }
|
||||
- cpumask_scnprintf(banned, 512, banned_cpus);
|
||||
- setup = realloc(setup, strlen(setup) + strlen(banned) + 7 + 1);
|
||||
- newptr = realloc(setup, strlen(setup) + strlen(banned) + 7 + 1);
|
||||
- if (!newptr)
|
||||
- goto out_free_setup;
|
||||
-
|
||||
- setup = newptr;
|
||||
- snprintf(setup + strlen(setup), strlen(banned) + 7 + 1,
|
||||
- "BANNED %s", banned);
|
||||
- send(sock, setup, strlen(setup), 0);
|
||||
-out_free_setup:
|
||||
- free(setup);
|
||||
- }
|
||||
-
|
||||
@ -336,7 +354,7 @@ index 27cf2eb..6e9de88 100644
|
||||
static int create_lock_pidfile(const char *lockfile)
|
||||
{
|
||||
struct flock lock = { 0 };
|
||||
@@ -657,7 +505,9 @@ error_close:
|
||||
@@ -691,7 +519,9 @@ error_close:
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
@ -345,8 +363,8 @@ index 27cf2eb..6e9de88 100644
|
||||
+ pthread_t socket_tid;
|
||||
+ struct sigaction action, hupaction;
|
||||
sigset_t sigset, old_sigset;
|
||||
int ret = EXIT_SUCCESS;
|
||||
|
||||
sigemptyset(&sigset);
|
||||
@@ -781,7 +631,9 @@ int main(int argc, char** argv)
|
||||
parse_proc_interrupts();
|
||||
parse_proc_stat();
|
||||
@ -355,9 +373,9 @@ index 27cf2eb..6e9de88 100644
|
||||
+ err = pthread_create(&socket_tid, NULL, &handle_socket_api_event, NULL);
|
||||
+ if (0 != err) {
|
||||
+ log(TO_CONSOLE, LOG_WARNING, "WARNING: Failed to create irqbalance socket thread, return %d.\n", err);
|
||||
return EXIT_FAILURE;
|
||||
ret = EXIT_FAILURE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
diff --git a/irqbalance.h b/irqbalance.h
|
||||
index 339e2a3..f9b554e 100644
|
||||
--- a/irqbalance.h
|
||||
@ -376,7 +394,7 @@ new file mode 100644
|
||||
index 0000000..4a0e683
|
||||
--- /dev/null
|
||||
+++ b/sockapi.c
|
||||
@@ -0,0 +1,410 @@
|
||||
@@ -0,0 +1,415 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2019. Huawei Technologies Co., Ltd. All rights reserved.
|
||||
+ *
|
||||
@ -729,6 +747,11 @@ index 0000000..4a0e683
|
||||
+ memset((void*)events, 0, sizeof(struct epoll_event) * MAX_EVENTS);
|
||||
+
|
||||
+ banned_cpumask_from_ui = (char*)malloc(NR_CPUS + 1);
|
||||
+ banned_cpumask_from_ui = (char*)malloc(NR_CPUS + 1);
|
||||
+ if (!banned_cpumask_from_ui) {
|
||||
+ log(TO_ALL, LOG_WARNING, "Daemon faild to malloc banned_cpumask_from_ui space.\n");
|
||||
+ exit(-1);
|
||||
+ }
|
||||
+ memset((void*)banned_cpumask_from_ui, 0, NR_CPUS + 1);
|
||||
+
|
||||
+ while (keep_going) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
Summary: A dynamic adaptive IRQ balancing daemon
|
||||
Name: irqbalance
|
||||
Version: 1.4.0
|
||||
Release: 8
|
||||
Release: 11
|
||||
Epoch: 3
|
||||
|
||||
License: GPLv2
|
||||
@ -38,6 +38,15 @@ Patch11:Don-t-leak-socket-fd-on-connection-error.patch
|
||||
Patch12:Fix-string-truncation-issues-detected-by-GCC-8.patch
|
||||
Patch13:fix-balancing-when-numa-information-isn-t-available.patch
|
||||
|
||||
Patch6000: Checking-return-value-of-strdup-in-collect_full_irq_.patch
|
||||
Patch6001: getline-clean-up-freeing-of-lines-from-getline.patch
|
||||
Patch6002: free-the-memory-when-getline-fail-in-add_one_node.patch
|
||||
Patch6003: prevent-NULL-pointer-dereference-when-memory-allocat.patch
|
||||
Patch6004: fix-resource-leak-for-not-invoking-closedir-after-op.patch
|
||||
Patch6005: correct-to-use-realloc-function.patch
|
||||
Patch6006: fix-the-problem-of-banmod-that-memory-is-freed-befor.patch
|
||||
Patch6007: fix-resource-leak-on-the-error-paths-in-main.patch
|
||||
|
||||
Patch9000: irqbalance-1.0.4-env-file-path.patch
|
||||
Patch9001: bugfix-fix-a-hole-that-flees-hotplug-event.patch
|
||||
Patch9002: bugfix-use-policy-prior-to-the-default-values.patch
|
||||
@ -56,6 +65,7 @@ Patch9014: bugfix-guess_arm_irq_hints.patch
|
||||
Patch9015: feature-add-new-user-irq-policy-config-rule.patch
|
||||
Patch9016: bugfix-make-the-return-value-of-getline-handled-correct.patch
|
||||
Patch9017: bugfix-change-irq-ban-check-path-to-devpath.patch
|
||||
Patch9018: bugfix-fix-strcat-may-cause-buffer-overrun.patch
|
||||
|
||||
%description
|
||||
Irqbalance is a daemon to help balance the cpu load generated by
|
||||
@ -116,6 +126,24 @@ fi
|
||||
/sbin/chkconfig --del %{name} >/dev/null 2>&1 || :
|
||||
|
||||
%changelog
|
||||
* Wed Nov 13 2019 liuchao<liuchao173@huawei.com> - 3:1.4.0-11
|
||||
- Type:other
|
||||
- ID:NA
|
||||
- SUG:restart
|
||||
- DESC:remove backport prefix of community patches
|
||||
|
||||
* Mon Nov 11 2019 liuchao<liuchao173@huawei.com> - 3:1.4.0-10
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:restart
|
||||
- DESC:add patches from community
|
||||
|
||||
* Fri Nov 8 2019 liuchao<liuchao173@huawei.com> - 3:1.4.0-9
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC: fix strcat may cause buffer overrun
|
||||
|
||||
* Thu Oct 17 2019 caomeng<caomeng5@huawei.com> - 3:1.4.0-8
|
||||
- Type:other
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user