From 1fb9fbe74e89b72e62ce9d4cf64efe1315757260 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Feb 02 2021 09:31:35 +0000 Subject: import util-linux-2.23.2-65.el7_9.1 --- diff --git a/SOURCES/0199-chrt-follow-nice-setting-prefer-sched_setscheduler.patch b/SOURCES/0199-chrt-follow-nice-setting-prefer-sched_setscheduler.patch new file mode 100644 index 0000000..239f537 --- /dev/null +++ b/SOURCES/0199-chrt-follow-nice-setting-prefer-sched_setscheduler.patch @@ -0,0 +1,93 @@ +From 3bf68910c3425dc4563ba74c671a9b0e311873e2 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 3 Oct 2016 11:02:35 +0200 +Subject: [PATCH 199/201] chrt: follow nice setting, prefer + sched_setscheduler() + +* do not reset 'nice' setting by sched_setattr(), if 'nice' setting + is not zero then chrt ends with EPERM for non-root users: + + $ renice -n 5 -p $$; chrt -v -b 0 date + 12475 (process ID) old priority 0, new priority 5 + chrt: failed to set pid 0's policy: Operation not permitted + +* it seems more elegant to always use old sched_setscheduler() API for + non-deadline policies; in this case we do not need getpriority() + to keep 'nice' unchanged. + +Addresses: https://github.com/karelzak/util-linux/issues/359 +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1905956 +Signed-off-by: Karel Zak +--- + schedutils/chrt.c | 34 ++++++++++++++++++---------------- + 1 file changed, 18 insertions(+), 16 deletions(-) + +diff --git a/schedutils/chrt.c b/schedutils/chrt.c +index edae0d9f4..0a51c1088 100644 +--- a/schedutils/chrt.c ++++ b/schedutils/chrt.c +@@ -26,6 +26,8 @@ + #include + #include + #include ++#include ++#include + + #include "c.h" + #include "nls.h" +@@ -340,6 +342,7 @@ static int set_sched_one_by_setscheduler(struct chrt_ctl *ctl, pid_t pid) + struct sched_param sp = { .sched_priority = ctl->priority }; + int policy = ctl->policy; + ++ errno = 0; + # ifdef SCHED_RESET_ON_FORK + if (ctl->reset_on_fork) + policy |= SCHED_RESET_ON_FORK; +@@ -357,29 +360,28 @@ static int set_sched_one(struct chrt_ctl *ctl, pid_t pid) + #else /* !HAVE_SCHED_SETATTR */ + static int set_sched_one(struct chrt_ctl *ctl, pid_t pid) + { ++ struct sched_attr sa = { .size = sizeof(struct sched_attr) }; ++ ++ /* old API is good enough for non-deadline */ ++ if (ctl->policy != SCHED_DEADLINE) ++ return set_sched_one_by_setscheduler(ctl, pid); ++ ++ /* no changeed by chrt, follow the current setting */ ++ sa.sched_nice = getpriority(PRIO_PROCESS, pid); ++ + /* use main() to check if the setting makes sense */ +- struct sched_attr sa = { +- .size = sizeof(struct sched_attr), +- .sched_policy = ctl->policy, +- .sched_priority = ctl->priority, +- .sched_runtime = ctl->runtime, +- .sched_period = ctl->period, +- .sched_deadline = ctl->deadline +- }; +- int rc; ++ sa.sched_policy = ctl->policy; ++ sa.sched_priority = ctl->priority; ++ sa.sched_runtime = ctl->runtime; ++ sa.sched_period = ctl->period; ++ sa.sched_deadline = ctl->deadline; + + # ifdef SCHED_RESET_ON_FORK + if (ctl->reset_on_fork) + sa.sched_flags |= SCHED_RESET_ON_FORK; + # endif + errno = 0; +- rc = sched_setattr(pid, &sa, 0); +- +- if (rc != 0 && errno == ENOSYS && ctl->policy != SCHED_DEADLINE) +- /* fallback -- build with new kernel/libc, but executed on old kernels */ +- rc = set_sched_one_by_setscheduler(ctl, pid); +- +- return rc; ++ return sched_setattr(pid, &sa, 0); + } + #endif /* HAVE_SCHED_SETATTR */ + +-- +2.28.0 + diff --git a/SOURCES/0200-chrt-default-to-SCHED_RR-policy.patch b/SOURCES/0200-chrt-default-to-SCHED_RR-policy.patch new file mode 100644 index 0000000..5b757d8 --- /dev/null +++ b/SOURCES/0200-chrt-default-to-SCHED_RR-policy.patch @@ -0,0 +1,40 @@ +From 7c9a240af89ba8025ee86e7ec1ab22708924fc4b Mon Sep 17 00:00:00 2001 +From: Andreas Henriksson +Date: Fri, 2 Dec 2016 15:10:18 +0100 +Subject: [PATCH 200/201] chrt: default to SCHED_RR policy + +This fixes a regression introduced in: + +commit 7a4ea5664edba98bff28adec3a9c3cfb5763a495 +"chrt: add control struct" + +Previously (and as documented in the manpage) the default policy +was SCHED_RR. Now it's implicitly SCHED_OTHER (0) as the value +is not initialized explicitly anymore. + +Test-command: chrt 90 echo hello + +Reported-by: Patrick Pelissier +Addresses: http://bugs.debian.org/846572 +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1905954 +Signed-off-by: Andreas Henriksson +--- + schedutils/chrt.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/schedutils/chrt.c b/schedutils/chrt.c +index 0a51c1088..4cceff2d7 100644 +--- a/schedutils/chrt.c ++++ b/schedutils/chrt.c +@@ -408,7 +408,7 @@ static void set_sched(struct chrt_ctl *ctl) + + int main(int argc, char **argv) + { +- struct chrt_ctl _ctl = { .pid = -1 }, *ctl = &_ctl; ++ struct chrt_ctl _ctl = { .pid = -1, .policy = SCHED_RR }, *ctl = &_ctl; + int c; + + static const struct option longopts[] = { +-- +2.28.0 + diff --git a/SOURCES/0201-chrt-use-SCHED_FLAG_RESET_ON_FORK-for-sched_setattr.patch b/SOURCES/0201-chrt-use-SCHED_FLAG_RESET_ON_FORK-for-sched_setattr.patch new file mode 100644 index 0000000..a35c278 --- /dev/null +++ b/SOURCES/0201-chrt-use-SCHED_FLAG_RESET_ON_FORK-for-sched_setattr.patch @@ -0,0 +1,47 @@ +From d35e578ac2d9b154c967967ae9593093d903c0e8 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 1 Oct 2020 10:40:27 +0200 +Subject: [PATCH 201/201] chrt: use SCHED_FLAG_RESET_ON_FORK for + sched_setattr() + +Reviewed by many people, used for years (but probably nobody uses +SCHED_DEADLINE with reset-on-fork), but we all missed: + +- sched_setscheduler() uses SCHED_RESET_ON_FORK (0x40000000) +- sched_setattr() uses SCHED_FLAG_RESET_ON_FORK (0x01) + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1883013 +Signed-off-by: Karel Zak +--- + schedutils/chrt.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/schedutils/chrt.c b/schedutils/chrt.c +index 4cceff2d7..84e76f17b 100644 +--- a/schedutils/chrt.c ++++ b/schedutils/chrt.c +@@ -123,7 +123,7 @@ struct chrt_ctl { + uint64_t period; + + unsigned int all_tasks : 1, /* all threads of the PID */ +- reset_on_fork : 1, /* SCHED_RESET_ON_FORK */ ++ reset_on_fork : 1, /* SCHED_RESET_ON_FORK or SCHED_FLAG_RESET_ON_FORK */ + altered : 1, /* sched_set**() used */ + verbose : 1; /* verbose output */ + }; +@@ -376,9 +376,10 @@ static int set_sched_one(struct chrt_ctl *ctl, pid_t pid) + sa.sched_period = ctl->period; + sa.sched_deadline = ctl->deadline; + +-# ifdef SCHED_RESET_ON_FORK ++# ifdef SCHED_FLAG_RESET_ON_FORK ++ /* Don't use SCHED_RESET_ON_FORK for sched_setattr()! */ + if (ctl->reset_on_fork) +- sa.sched_flags |= SCHED_RESET_ON_FORK; ++ sa.sched_flags |= SCHED_FLAG_RESET_ON_FORK; + # endif + errno = 0; + return sched_setattr(pid, &sa, 0); +-- +2.28.0 + diff --git a/SPECS/util-linux.spec b/SPECS/util-linux.spec index 6342969..d292e5f 100644 --- a/SPECS/util-linux.spec +++ b/SPECS/util-linux.spec @@ -2,7 +2,7 @@ Summary: A collection of basic system utilities Name: util-linux Version: 2.23.2 -Release: 65%{?dist} +Release: 65%{?dist}.1 License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain Group: System Environment/Base URL: http://en.wikipedia.org/wiki/Util-linux @@ -487,6 +487,16 @@ Patch197: 0197-col-make-flush_line-a-little-bit-robust.patch # 1826719 - mount -a tries to mount already mounted cifs shares when we cannot query up to root dir Patch198: 0198-libmount-fix-mount-a-EBUSY-for-cifs.patch +# RHEL-7.9.Z +# +# 1905956 - RHEL-7: chrt regression: unwanted 'nice' value reset on sched_setattr() [rhel-7.9.z] +Patch199: 0199-chrt-follow-nice-setting-prefer-sched_setscheduler.patch +# 1905954 - RHEL-7: chrt regression: unexpected default scheduler [rhel-7.9.z] +Patch200: 0200-chrt-default-to-SCHED_RR-policy.patch +# 1883013 - RHEL-7: chrt command does not support the -R option [rhel-7.9.z] +Patch201: 0201-chrt-use-SCHED_FLAG_RESET_ON_FORK-for-sched_setattr.patch + + %description The util-linux package contains a large variety of low-level system utilities that are necessary for a Linux system to function. Among @@ -1266,6 +1276,11 @@ fi %{_libdir}/pkgconfig/uuid.pc %changelog +* Wed Dec 09 2020 Karel Zak 2.23.2-65.el7_9.1 +- fix #1905956 - RHEL-7: chrt regression: unwanted 'nice' value reset on sched_setattr() [rhel-7.9.z] +- fix #1905954 - RHEL-7: chrt regression: unexpected default scheduler [rhel-7.9.z] +- fix #1883013 - RHEL-7: chrt command does not support the -R option [rhel-7.9.z] + * Mon Apr 27 2020 Karel Zak 2.23.2-65 - fix #1826719 - mount -a tries to mount already mounted cifs shares when we cannot query up to root dir - fix #1745657 - mismatch between spec file and uuidd runtime directory