diff --git a/SOURCES/bz1896311-1-Fix-log_perror.patch b/SOURCES/bz1896311-1-Fix-log_perror.patch new file mode 100644 index 0000000..712e12b --- /dev/null +++ b/SOURCES/bz1896311-1-Fix-log_perror.patch @@ -0,0 +1,54 @@ +From cbb46dccb2804be3db142f5eb37acf2c0fa7e2b8 Mon Sep 17 00:00:00 2001 +From: Jan Friesse +Date: Tue, 10 Nov 2020 09:51:33 +0100 +Subject: [PATCH 1/2] Fix log_perror + +Also add definitions of log_printf and log_vprintf with format attribute +so compiler have information about problems in printf strings. + +Signed-off-by: Jan Friesse +--- + spausedd.c | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +diff --git a/spausedd.c b/spausedd.c +index d453e39..0a6fe65 100644 +--- a/spausedd.c ++++ b/spausedd.c +@@ -91,6 +91,15 @@ static int use_vmguestlib_stealtime = 0; + static VMGuestLibHandle guestlib_handle; + #endif + ++/* ++ * Definitions (for attributes) ++ */ ++static void log_printf(int priority, const char *format, ...) ++ __attribute__((__format__(__printf__, 2, 3))); ++ ++static void log_vprintf(int priority, const char *format, va_list ap) ++ __attribute__((__format__(__printf__, 2, 0))); ++ + /* + * Logging functions + */ +@@ -155,7 +164,7 @@ log_perror(int priority, const char *s) + + stored_errno = errno; + +- log_printf(priority, "%s (%u): %s", stored_errno, strerror(stored_errno)); ++ log_printf(priority, "%s (%u): %s", s, stored_errno, strerror(stored_errno)); + } + + static int +@@ -577,7 +586,7 @@ poll_run(uint64_t timeout) + steal_perc); + + if (steal_perc > max_steal_threshold) { +- log_printf(LOG_WARNING, "Steal time is > %0.1f%, this is usually because " ++ log_printf(LOG_WARNING, "Steal time is > %0.1f%%, this is usually because " + "of overloaded host machine", max_steal_threshold); + } + times_not_scheduled++; +-- +2.18.2 + diff --git a/SOURCES/bz1897087-1-Add-ability-to-move-process-into-root-cgroup.patch b/SOURCES/bz1897087-1-Add-ability-to-move-process-into-root-cgroup.patch new file mode 100644 index 0000000..6a3a281 --- /dev/null +++ b/SOURCES/bz1897087-1-Add-ability-to-move-process-into-root-cgroup.patch @@ -0,0 +1,147 @@ +From 261d784c7b0e8c2b33ae8701b12397f2cc6e695b Mon Sep 17 00:00:00 2001 +From: Jan Friesse +Date: Mon, 16 Mar 2020 16:57:09 +0100 +Subject: [PATCH 2/2] Add ability to move process into root cgroup + +Signed-off-by: Jan Friesse +--- + spausedd.8 | 8 +++++--- + spausedd.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- + 2 files changed, 53 insertions(+), 5 deletions(-) + +diff --git a/spausedd.8 b/spausedd.8 +index 6c35666..b23e590 100644 +--- a/spausedd.8 ++++ b/spausedd.8 +@@ -1,5 +1,5 @@ + .\" +-.\" Copyright (c) 2018-2019, Red Hat, Inc. ++.\" Copyright (c) 2018-2020, Red Hat, Inc. + .\" + .\" Permission to use, copy, modify, and/or distribute this software for any + .\" purpose with or without fee is hereby granted, provided that the above +@@ -15,7 +15,7 @@ + .\" + .\" Author: Jan Friesse + .\" +-.Dd Mar 21, 2018 ++.Dd Nov 11, 2020 + .Dt SPAUSEDD 8 + .Os + .Sh NAME +@@ -66,7 +66,9 @@ Run on foreground (do not demonize - default). + Show help. + .It Fl p + Do not set RR scheduler. +-.It Fl t Ar steal_threshold ++.It Fl P ++Do not move process to root cgroup. ++.It Fl m Ar steal_threshold + Set steal threshold percent. (default is 10 if kernel information is used and + 100 if VMGuestLib is used). + .It Fl t Ar timeout +diff --git a/spausedd.c b/spausedd.c +index 0a6fe65..6a194cd 100644 +--- a/spausedd.c ++++ b/spausedd.c +@@ -273,6 +273,42 @@ utils_set_rr_scheduler(void) + #endif + } + ++static void ++utils_move_to_root_cgroup(void) ++{ ++ FILE *f; ++ ++ /* ++ * /sys/fs/cgroup is hardcoded, because most of Linux distributions are now ++ * using systemd and systemd uses hardcoded path of cgroup mount point. ++ * ++ * This feature is expected to be removed as soon as systemd gets support ++ * for managing RT configuration. ++ */ ++ f = fopen("/sys/fs/cgroup/cpu/cpu.rt_runtime_us", "rt"); ++ if (f == NULL) { ++ log_printf(LOG_DEBUG, "cpu.rt_runtime_us doesn't exists -> " ++ "system without cgroup or with disabled CONFIG_RT_GROUP_SCHED"); ++ return ; ++ } ++ (void)fclose(f); ++ ++ f = fopen("/sys/fs/cgroup/cpu/tasks", "w"); ++ if (f == NULL) { ++ log_printf(LOG_WARNING, "Can't open cgroups tasks file for writing"); ++ return ; ++ } ++ ++ if (fprintf(f, "%jd\n", (intmax_t)getpid()) <= 0) { ++ log_printf(LOG_WARNING, "Can't write spausedd pid into cgroups tasks file"); ++ } ++ ++ if (fclose(f) != 0) { ++ log_printf(LOG_WARNING, "Can't close cgroups tasks file"); ++ return ; ++ } ++} ++ + /* + * Signal handlers + */ +@@ -603,13 +639,14 @@ poll_run(uint64_t timeout) + static void + usage(void) + { +- printf("usage: %s [-dDfhp] [-m steal_th] [-t timeout]\n", PROGRAM_NAME); ++ printf("usage: %s [-dDfhpP] [-m steal_th] [-t timeout]\n", PROGRAM_NAME); + printf("\n"); + printf(" -d Display debug messages\n"); + printf(" -D Run on background - daemonize\n"); + printf(" -f Run foreground - do not daemonize (default)\n"); + printf(" -h Show help\n"); + printf(" -p Do not set RR scheduler\n"); ++ printf(" -P Do not move process to root cgroup\n"); + printf(" -m steal_th Steal percent threshold\n"); + printf(" -t timeout Set timeout value (default: %u)\n", DEFAULT_TIMEOUT); + } +@@ -622,14 +659,16 @@ main(int argc, char **argv) + long long int tmpll; + uint64_t timeout; + int set_prio; ++ int move_to_root_cgroup; + + foreground = 1; + timeout = DEFAULT_TIMEOUT; + set_prio = 1; ++ move_to_root_cgroup = 1; + max_steal_threshold = DEFAULT_MAX_STEAL_THRESHOLD; + max_steal_threshold_user_set = 0; + +- while ((ch = getopt(argc, argv, "dDfhpm:t:")) != -1) { ++ while ((ch = getopt(argc, argv, "dDfhpPm:t:")) != -1) { + switch (ch) { + case 'D': + foreground = 0; +@@ -659,6 +698,9 @@ main(int argc, char **argv) + usage(); + exit(1); + break; ++ case 'P': ++ move_to_root_cgroup = 0; ++ break; + case 'p': + set_prio = 0; + break; +@@ -677,6 +719,10 @@ main(int argc, char **argv) + + utils_mlockall(); + ++ if (move_to_root_cgroup) { ++ utils_move_to_root_cgroup(); ++ } ++ + if (set_prio) { + utils_set_rr_scheduler(); + } +-- +2.18.2 + diff --git a/SPECS/corosync.spec b/SPECS/corosync.spec index 1ef1947..35b31e4 100644 --- a/SPECS/corosync.spec +++ b/SPECS/corosync.spec @@ -29,7 +29,7 @@ Name: corosync Summary: The Corosync Cluster Engine and Application Programming Interfaces Version: 2.4.5 -Release: 7%{?gitver}%{?dist} +Release: 7%{?gitver}%{?dist}.1 License: BSD Group: System Environment/Base URL: http://corosync.github.io/corosync/ @@ -49,9 +49,11 @@ Patch3: bz1679792-1-votequorum-set-wfa-status-only-on-startup.patch Patch4: bz1835885-1-stats-Add-basic-schedule-miss-stats-to-needle.patch Patch5: bz1835885-2-main-Add-schedmiss-timestamp-into-message.patch Patch6: bz1835885-3-main-Make-schedmiss-in-cmap-and-log-equal.patch +Patch7: bz1896311-1-Fix-log_perror.patch +Patch8: bz1897087-1-Add-ability-to-move-process-into-root-cgroup.patch %if 0%{?rhel} -ExclusiveArch: i686 x86_64 s390x ppc64le aarch64 %{arm} +ExclusiveArch: i686 x86_64 s390x ppc64le aarch64 %endif # Runtime bits @@ -123,6 +125,8 @@ BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) %patch4 -p1 -b .bz1835885-1 %patch5 -p1 -b .bz1835885-2 %patch6 -p1 -b .bz1835885-3 +%patch7 -p1 -d spausedd-%{spausedd_version} +%patch8 -p1 -d spausedd-%{spausedd_version} %build %if %{with runautogen} @@ -631,6 +635,13 @@ fi %endif %changelog +* Fri Jan 15 2021 Jan Friesse 2.4.5-7.1 +- Resolves: rhbz#1896311 +- Resolves: rhbz#1897087 + +- spausedd: Fix log_perror (rhbz#1896311) +- spausedd: Add ability to move process into root cgroup (rhbz#1897087) + * Fri Jun 5 2020 Jan Friesse 2.4.5-7 - Related: rhbz#1835885