From a05d8372d667437210ea58e9fa6017204bac9944 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 30 Jul 2021 22:36:20 +0800 Subject: [PATCH] Disable the communication socket when UI is disabled The socket is causing building failures and it's never used. Resolves: rhbz1951292 Signed-off-by: Kairui Song --- ...unication-socket-when-UI-is-disabled.patch | 159 ++++++++++++++++++ irqbalance.spec | 2 + 2 files changed, 161 insertions(+) create mode 100644 irqbalance-1.8.0-Disable-the-communication-socket-when-UI-is-disabled.patch diff --git a/irqbalance-1.8.0-Disable-the-communication-socket-when-UI-is-disabled.patch b/irqbalance-1.8.0-Disable-the-communication-socket-when-UI-is-disabled.patch new file mode 100644 index 0000000..07d2545 --- /dev/null +++ b/irqbalance-1.8.0-Disable-the-communication-socket-when-UI-is-disabled.patch @@ -0,0 +1,159 @@ +From 4342acd8d7862e862e0b661135b10671ffeac119 Mon Sep 17 00:00:00 2001 +From: Kairui Song +Date: Thu, 22 Jul 2021 03:05:59 +0800 +Subject: [PATCH] Disable the communication socket when UI is disabled + +The communication socket is added to support the UI, when UI is not +built, also disable the socket. + +Signed-off-by: Kairui Song +--- + configure.ac | 11 +++++++---- + cputree.c | 4 ++++ + irqbalance.c | 23 ++++++++++++++++------- + 3 files changed, 27 insertions(+), 11 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 92a5113..c45b9ce 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -41,10 +41,13 @@ AC_C_INLINE + AM_PROG_CC_C_O + + AC_ARG_WITH([irqbalance-ui], +- [AC_HELP_STRING([--without-irqbalance-ui], +- [Dont build the irqbalance ui component])], +- [with_irqbalanceui=$withval], [with_irqbalanceui=yes]) +- ++ [AS_HELP_STRING([--without-irqbalance-ui], ++ [Dont build the irqbalance ui component])], ++ [with_irqbalanceui=$withval], [with_irqbalanceui=yes]) ++AS_IF( ++ [test "x$with_irqbalanceui" = "xyes"], [ ++ AC_DEFINE([HAVE_IRQBALANCEUI], 1, [Build irqbalance ui component.]) ++]) + AM_CONDITIONAL([IRQBALANCEUI], [test x$with_irqbalanceui = xyes]) + + AC_ARG_WITH([systemd], +diff --git a/cputree.c b/cputree.c +index e4695f2..b716a8f 100644 +--- a/cputree.c ++++ b/cputree.c +@@ -39,7 +39,9 @@ + + #include "irqbalance.h" + ++#ifdef HAVE_IRQBALANCEUI + extern char *banned_cpumask_from_ui; ++#endif + extern char *cpu_ban_string; + + GList *cpus; +@@ -113,12 +115,14 @@ static void setup_banned_cpus(void) + cpumask_t isolated_cpus; + char *env = NULL; + ++#ifdef HAVE_IRQBALANCEUI + /* A manually specified cpumask overrides auto-detection. */ + if (cpu_ban_string != NULL && banned_cpumask_from_ui != NULL) { + cpulist_parse(banned_cpumask_from_ui, + strlen(banned_cpumask_from_ui), banned_cpus); + goto out; + } ++#endif + + /* + * Notes: +diff --git a/irqbalance.c b/irqbalance.c +index 3f94847..07a245f 100644 +--- a/irqbalance.c ++++ b/irqbalance.c +@@ -31,22 +31,21 @@ + #include + #include + #include +-#include +-#include + #include + #include + #ifdef HAVE_GETOPT_LONG + #include + #endif +- + #ifdef HAVE_LIBCAP_NG + #include + #endif ++#ifdef HAVE_IRQBALANCEUI ++#include ++#include ++#endif + #include "irqbalance.h" + + volatile int keep_going = 1; +-int socket_fd; +-char socket_name[64]; + int one_shot_mode; + int debug_mode; + int foreground_mode; +@@ -67,9 +66,14 @@ int last_interval; + GMainLoop *main_loop; + + char *cpu_ban_string = NULL; +-char *banned_cpumask_from_ui = NULL; + unsigned long migrate_ratio = 0; + ++#ifdef HAVE_IRQBALANCEUI ++int socket_fd; ++char socket_name[64]; ++char *banned_cpumask_from_ui = NULL; ++#endif ++ + static void sleep_approx(int seconds) + { + struct timespec ts; +@@ -405,6 +409,7 @@ void get_object_stat(struct topo_obj *object, void *data) + } + } + ++#ifdef HAVE_IRQBALANCEUI + gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attribute__((unused))) + { + char buff[500]; +@@ -585,6 +590,7 @@ int init_socket() + g_unix_fd_add(socket_fd, G_IO_IN, sock_handle, NULL); + return 0; + } ++#endif + + int main(int argc, char** argv) + { +@@ -688,10 +694,12 @@ int main(int argc, char** argv) + parse_proc_interrupts(); + parse_proc_stat(); + ++#ifdef HAVE_IRQBALANCEUI + if (init_socket()) { + ret = EXIT_FAILURE; + goto out; + } ++#endif + main_loop = g_main_loop_new(NULL, FALSE); + last_interval = sleep_interval; + g_timeout_add_seconds(sleep_interval, scan, NULL); +@@ -707,11 +715,12 @@ out: + /* Remove pidfile */ + if (!foreground_mode && pidfile) + unlink(pidfile); ++#ifdef HAVE_IRQBALANCEUI + /* Remove socket */ + if (socket_fd > 0) + close(socket_fd); + if (socket_name[0]) + unlink(socket_name); +- ++#endif + return ret; + } +-- +2.31.1 + diff --git a/irqbalance.spec b/irqbalance.spec index 3140318..b3e14a9 100644 --- a/irqbalance.spec +++ b/irqbalance.spec @@ -24,6 +24,7 @@ Requires: numactl-libs ExcludeArch: s390 s390x Patch1: irqbalance-1.8.0-drop-NoNewPrivs-from-irqbalance-service.patch +Patch2: irqbalance-1.8.0-Disable-the-communication-socket-when-UI-is-disabled.patch %description irqbalance is a daemon that evenly distributes IRQ load across @@ -32,6 +33,7 @@ multiple CPUs for enhanced performance. %prep %setup -q %patch1 -p1 +%patch2 -p1 %build ./autogen.sh