diff --git a/0099-lscpu-avoid-EBUSY-on-cpuinfo_max_freq.patch b/0099-lscpu-avoid-EBUSY-on-cpuinfo_max_freq.patch new file mode 100644 index 0000000000000000000000000000000000000000..682712510442f6dc83679e473840f276326bb630 --- /dev/null +++ b/0099-lscpu-avoid-EBUSY-on-cpuinfo_max_freq.patch @@ -0,0 +1,108 @@ +From e561e4740d8dd5419e5fb23ab186ae43fd572736 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 10 Jan 2024 12:08:17 +0100 +Subject: lscpu: avoid EBUSY on cpuinfo_max_freq + +Addresses: https://issues.redhat.com/browse/RHEL-13741 +--- + include/path.h | 4 ++++ + lib/path.c | 20 ++++++++++++++++++++ + sys-utils/lscpu.c | 18 ++++++++++++------ + 3 files changed, 36 insertions(+), 6 deletions(-) + +diff --git a/include/path.h b/include/path.h +index 4be01095c..965bdd047 100644 +--- a/include/path.h ++++ b/include/path.h +@@ -19,8 +19,12 @@ extern void path_read_str(char *result, size_t len, const char *path, ...) + __attribute__ ((__format__ (__printf__, 3, 4))); + extern int path_write_str(const char *str, const char *path, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); ++ ++extern int __path_read_s32(int *result, const char *path, ...) ++ __attribute__ ((__format__ (__printf__, 2, 3))); + extern int path_read_s32(const char *path, ...) + __attribute__ ((__format__ (__printf__, 1, 2))); ++ + extern uint64_t path_read_u64(const char *path, ...) + __attribute__ ((__format__ (__printf__, 1, 2))); + +diff --git a/lib/path.c b/lib/path.c +index e8cfa557a..7217c9089 100644 +--- a/lib/path.c ++++ b/lib/path.c +@@ -145,6 +145,26 @@ path_read_str(char *result, size_t len, const char *path, ...) + result[len - 1] = '\0'; + } + ++/* like path_read_s32() but do not print any error message */ ++int __path_read_s32(int *result, const char *path, ...) ++{ ++ FILE *f; ++ va_list ap; ++ int rc; ++ ++ va_start(ap, path); ++ f = path_vfopen("r" UL_CLOEXECSTR, 0, path, ap); ++ va_end(ap); ++ ++ if (!f) ++ return -1; ++ ++ rc = fscanf(f, "%d", result); ++ fclose(f); ++ ++ return rc == 1 ? 0 : -1; ++} ++ + int + path_read_s32(const char *path, ...) + { +diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c +index 01f8fba35..ed5543901 100644 +--- a/sys-utils/lscpu.c ++++ b/sys-utils/lscpu.c +@@ -1176,28 +1176,34 @@ static void + read_max_mhz(struct lscpu_desc *desc, int idx) + { + int num = real_cpu_num(desc, idx); ++ int mhz = 0; + + if (!path_exist(_PATH_SYS_CPU "/cpu%d/cpufreq/cpuinfo_max_freq", num)) + return; ++ if (__path_read_s32(&mhz, _PATH_SYS_CPU ++ "/cpu%d/cpufreq/cpuinfo_max_freq", num) != 0) ++ return; ++ + if (!desc->maxmhz) + desc->maxmhz = xcalloc(desc->ncpuspos, sizeof(char *)); +- xasprintf(&(desc->maxmhz[idx]), "%.4f", +- (float)path_read_s32(_PATH_SYS_CPU +- "/cpu%d/cpufreq/cpuinfo_max_freq", num) / 1000); ++ xasprintf(&(desc->maxmhz[idx]), "%.4f", (float) mhz / 1000); + } + + static void + read_min_mhz(struct lscpu_desc *desc, int idx) + { + int num = real_cpu_num(desc, idx); ++ int mhz = 0; + + if (!path_exist(_PATH_SYS_CPU "/cpu%d/cpufreq/cpuinfo_min_freq", num)) + return; ++ if (__path_read_s32(&mhz, _PATH_SYS_CPU ++ "/cpu%d/cpufreq/cpuinfo_min_freq", num) != 0) ++ return; ++ + if (!desc->minmhz) + desc->minmhz = xcalloc(desc->ncpuspos, sizeof(char *)); +- xasprintf(&(desc->minmhz[idx]), "%.4f", +- (float)path_read_s32(_PATH_SYS_CPU +- "/cpu%d/cpufreq/cpuinfo_min_freq", num) / 1000); ++ xasprintf(&(desc->minmhz[idx]), "%.4f", (float) mhz / 1000); + } + + static int +-- +2.43.0 + diff --git a/dist b/dist index 5aa45c5bf3f5e5b781981aec176b4910ac39baaf..37a6f9cba7a88cbcf8ab13c9187a23e686af9edd 100644 --- a/dist +++ b/dist @@ -1 +1 @@ -an8_8 +an8_9 diff --git a/util-linux.spec b/util-linux.spec index 2054c029041fa35889f48ccb1a9315044865076a..45f1f040a8cb6e68cc99e54dfa09683f3324b18a 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -1,9 +1,9 @@ -%define anolis_release .0.2 +%define anolis_release .0.1 ### Header Summary: A collection of basic system utilities Name: util-linux Version: 2.32.1 -Release: 43%{anolis_release}%{?dist} +Release: 44%{anolis_release}%{?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 @@ -293,6 +293,11 @@ Patch97: 0097-swapon-man-fix-priority-description.patch # 2227097 - wall(1) fails when trying to use seat0 Patch98: 0098-wall-do-not-error-for-ttys-that-do-not-exist.patch +### RHEL-8.9.Z +### +# RHEL-13741 - lscpu: avoid EBUSY on cpuinfo_max_freq +Patch99: 0099-lscpu-avoid-EBUSY-on-cpuinfo_max_freq.patch + # Begin: Anolis customized patches # hwclock: make glibc 2.31 compatible Patch1001: 1001-hwclock-make-glibc-2.31-compatible.patch @@ -1149,13 +1154,14 @@ fi %{_libdir}/python*/site-packages/libmount/ %changelog -* Thu Mar 21 2024 wxiat 2.32.1-43.0.2 -- cherry-pick `add sw patch #a16dca4d0754a5ae036dc6833523ff37429b3e60`. - -* Mon Dec 11 2023 liuzhilin 2.32.1-43.0.1 +* Wed Apr 17 2024 Weitao Zhou 2.32.1-44.0.1 - [Patch] hwclock: better compatibility for both glibc2.28 and glibc2.31 - [Patch] lscpu: add Neoverse-N2 to ARM identifiers tables (flin@linux.alibaba.com) - [Patch] lscpu: fix lscpu to get cpu frequency from cpuinfo on arm64 (flin@linux.alibaba.com) +- cherry-pick `add sw patch #a16dca4d0754a5ae036dc6833523ff37429b3e60`. (nijie@wxiat.com) + +* Wed Jan 10 2024 Karel Zak 2.32.1-44.el8_9.1 +- fix RHEL-13741 - lscpu: avoid EBUSY on cpuinfo_max_freq * Thu Aug 10 2023 Karel Zak 2.32.1-43 - fix #2117355 - Add additional documentation for fstab