import UBI util-linux-2.40.2-13.el10

This commit is contained in:
eabdullin 2025-11-11 21:42:46 +00:00
parent e346269f10
commit bf3a2c1391
7 changed files with 1360 additions and 7 deletions

View File

@ -0,0 +1,37 @@
From bd6c104f931329ce6fbc5a1250c8c80a1d8223ee Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 24 Feb 2025 13:37:04 +0100
Subject: [PATCH] agetty: fix stdin conversion to tty name
Addresses: https://github.com/util-linux/util-linux/issues/3304
Signed-off-by: Karel Zak <kzak@redhat.com>
---
term-utils/agetty.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index aa859c27b..0dfe52c90 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -928,11 +928,15 @@ static void parse_args(int argc, char **argv, struct options *op)
/* resolve the tty path in case it was provided as stdin */
if (strcmp(op->tty, "-") == 0) {
+ int fd;
+ const char *name = op->tty;
+
op->tty_is_stdin = 1;
- int fd = get_terminal_name(NULL, &op->tty, NULL);
- if (fd < 0) {
+ fd = get_terminal_name(NULL, &name, NULL);
+ if (fd >= 0)
+ op->tty = name; /* set real device name */
+ else
log_warn(_("could not get terminal name: %d"), fd);
- }
}
/* On virtual console remember the line which is used for */
--
2.49.0

View File

@ -0,0 +1,806 @@
From 155bf791d2b39fdfae1b6295c8c3d76ba8cb8cf0 Mon Sep 17 00:00:00 2001
From: Thijs Raymakers <thijs@raymakers.nl>
Date: Thu, 25 Apr 2024 18:22:25 +0200
Subject: coresched: Manage core scheduling cookies for tasks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Addresses: https://issues.redhat.com/browse/RHEL-34021
Co-authored-by: Phil Auld <pauld@redhat.com>
Signed-off-by: Phil Auld <pauld@redhat.com>
Signed-off-by: Thijs Raymakers <thijs@raymakers.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
Reviewed-by: Thomas Weißschuh <thomas@t-8ch.de>
Upstream: http://github.com/util-linux/util-linux/commit/b46a82a06f11ddc7a57d8bc892b3154e465f60d4
---
bash-completion/coresched | 0
configure.ac | 12 +-
meson.build | 16 +-
meson_options.txt | 2 +-
schedutils/Makemodule.am | 8 +
schedutils/coresched.1.adoc | 139 +++++++
schedutils/coresched.c | 363 ++++++++++++++++++
tests/commands.sh | 1 +
.../coresched-copy-from-child-to-parent | 1 +
...coresched-copy-from-parent-to-nested-child | 1 +
.../schedutils/coresched-get-cookie-own-pid | 1 +
.../coresched-get-cookie-parent-pid | 1 +
.../coresched-new-child-with-new-cookie | 1 +
.../coresched-set-cookie-parent-pid.err | 1 +
.../expected/schedutils/set-cookie-parent-pid | 1 +
tests/ts/schedutils/coresched | 83 ++++
16 files changed, 625 insertions(+), 6 deletions(-)
create mode 100644 bash-completion/coresched
create mode 100644 schedutils/coresched.1.adoc
create mode 100644 schedutils/coresched.c
create mode 100644 tests/expected/schedutils/coresched-copy-from-child-to-parent
create mode 100644 tests/expected/schedutils/coresched-copy-from-parent-to-nested-child
create mode 100644 tests/expected/schedutils/coresched-get-cookie-own-pid
create mode 100644 tests/expected/schedutils/coresched-get-cookie-parent-pid
create mode 100644 tests/expected/schedutils/coresched-new-child-with-new-cookie
create mode 100644 tests/expected/schedutils/coresched-set-cookie-parent-pid.err
create mode 100644 tests/expected/schedutils/set-cookie-parent-pid
create mode 100755 tests/ts/schedutils/coresched
diff --git a/bash-completion/coresched b/bash-completion/coresched
new file mode 100644
index 000000000..e69de29bb
diff --git a/configure.ac b/configure.ac
index 82d0e4bf9..fb1d8d076 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2495,9 +2495,9 @@ UL_REQUIRES_HAVE([setterm], [ncursesw, ncurses], [ncursesw or ncurses library])
AM_CONDITIONAL([BUILD_SETTERM], [test "x$build_setterm" = xyes])
# build_schedutils= is just configure-only variable to control
-# ionice, taskset and chrt
+# ionice, taskset, coresched and chrt
AC_ARG_ENABLE([schedutils],
- AS_HELP_STRING([--disable-schedutils], [do not build chrt, ionice, taskset]),
+ AS_HELP_STRING([--disable-schedutils], [do not build chrt, ionice, taskset, coresched]),
[], [UL_DEFAULT_ENABLE([schedutils], [check])]
)
@@ -2540,6 +2540,14 @@ UL_REQUIRES_SYSCALL_CHECK([taskset],
AM_CONDITIONAL([BUILD_TASKSET], [test "x$build_taskset" = xyes])
+UL_ENABLE_ALIAS([coresched], [schedutils])
+UL_BUILD_INIT([coresched])
+UL_REQUIRES_SYSCALL_CHECK([coresched],
+ [UL_CHECK_SYSCALL([prctl])],
+ [prctl])
+AM_CONDITIONAL([BUILD_CORESCHED], [test "x$build_coresched" = xyes])
+
+
have_schedsetter=no
AS_IF([test "x$ac_cv_func_sched_setscheduler" = xyes], [have_schedsetter=yes],
[test "x$ac_cv_func_sched_setattr" = xyes], [have_schedsetter=yes])
diff --git a/meson.build b/meson.build
index 6d1f986af..b5b70ab07 100644
--- a/meson.build
+++ b/meson.build
@@ -3194,13 +3194,23 @@ exe4 = executable(
install : opt,
build_by_default : opt)
+exe5 = executable(
+ 'coresched',
+ 'schedutils/coresched.c',
+ include_directories : includes,
+ link_with : lib_common,
+ install_dir : usrbin_exec_dir,
+ install : opt,
+ build_by_default : opt)
+
if opt and not is_disabler(exe)
- exes += [exe, exe2, exe3, exe4]
+ exes += [exe, exe2, exe3, exe4, exe5]
manadocs += ['schedutils/chrt.1.adoc',
'schedutils/ionice.1.adoc',
'schedutils/taskset.1.adoc',
- 'schedutils/uclampset.1.adoc']
- bashcompletions += ['chrt', 'ionice', 'taskset', 'uclampset']
+ 'schedutils/uclampset.1.adoc',
+ 'schedutils/coresched.1.adoc']
+ bashcompletions += ['chrt', 'ionice', 'taskset', 'uclampset', 'coresched']
endif
############################################################
diff --git a/meson_options.txt b/meson_options.txt
index fedda65e5..fac18d826 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -210,7 +210,7 @@ option('build-lsclocks', type : 'feature',
option('build-setterm', type : 'feature',
description : 'build setterm')
option('build-schedutils', type : 'feature',
- description : 'build chrt, ionice, taskset')
+ description : 'build chrt, ionice, taskset, coresched')
option('build-wall', type : 'feature',
description : 'build wall')
option('build-write', type : 'feature',
diff --git a/schedutils/Makemodule.am b/schedutils/Makemodule.am
index 1040da85f..0cb655401 100644
--- a/schedutils/Makemodule.am
+++ b/schedutils/Makemodule.am
@@ -29,3 +29,11 @@ dist_noinst_DATA += schedutils/uclampset.1.adoc
uclampset_SOURCES = schedutils/uclampset.c schedutils/sched_attr.h
uclampset_LDADD = $(LDADD) libcommon.la
endif
+
+if BUILD_CORESCHED
+usrbin_exec_PROGRAMS += coresched
+MANPAGES += schedutils/coresched.1
+dist_noinst_DATA += schedutils/coresched.1.adoc
+coresched_SOURCES = schedutils/coresched.c
+coresched_LDADD = $(LDADD) libcommon.la
+endif
diff --git a/schedutils/coresched.1.adoc b/schedutils/coresched.1.adoc
new file mode 100644
index 000000000..8a9c28846
--- /dev/null
+++ b/schedutils/coresched.1.adoc
@@ -0,0 +1,139 @@
+//po4a: entry man manual
+////
+coresched(1) manpage
+////
+= coresched(1)
+:doctype: manpage
+:man manual: User Commands
+:man source: util-linux {release-version}
+:page-layout: base
+:command: coresched
+:colon: :
+:copyright: ©
+
+== NAME
+
+coresched - manage core scheduling cookies for tasks
+
+== SYNOPSIS
+
+*{command}* [*get*] [*-s* _pid_]
+
+*{command}* *new* [*-t* _type_] *-d* _pid_
+
+*{command}* *new* [*-t* _type_] \-- _command_ [_argument_...]
+
+*{command}* *copy* [*-s* _pid_] [*-t* _type_] *-d* _pid_
+
+*{command}* *copy* [*-s* _pid_] [*-t* _type_] \-- _command_ [_argument_...]
+
+== DESCRIPTION
+The *{command}* command is used to retrieve or modify the core scheduling cookies of a running process given its _pid_, or to spawn a new _command_ with core scheduling cookies.
+
+Core scheduling permits the definition of groups of tasks that are allowed to share a physical core.
+This is done by assigning a cookie to each task.
+Only tasks have the same cookie are allowed to be scheduled on the same physical core.
+
+It is possible to either assign a new random cookie to a task, or copy a cookie from another task. It is not possible to choose the value of the cookie.
+
+== FUNCTIONS
+*get*::
+Retrieve the core scheduling cookie of the PID specified in *-s*.
+If *-s* is omitted, it will get the cookie of the current *{command}* process.
+
+*new*::
+Assign a new cookie to an existing PID specified in *-d*, or execute _command_ with a new cookie.
+
+*copy*::
+Copy the cookie from an existing PID (*-s*) to another PID (*-d*), or execute _command_ with that cookie.
+If *-s* is omitted, it will get the cookie of the current *{command}* process.
+
+If no function is specified, it will run the *get* function.
+
+== OPTIONS
+*-s*, *--source* _PID_::
+Which _PID_ to get the cookie from.
+If this option is omitted, it will get the cookie from the current *{command}* process.
+
+*-d*, *--dest* _PID_::
+Which _PID_ to modify the cookie of.
+
+*-t*, *--dest-type* _TYPE_::
+The type of the PID whose cookie will be modified. This can be one of three values:
+- *pid*, or process ID
+- *tgid*, or thread group ID (default value)
+- *pgid*, or process group ID
+
+*-v*, *--verbose*::
+Show extra information when modifying cookies of tasks.
+
+*-h*, *--help*::
+Display help text and exit.
+
+*-V*, *--version*::
+Print version and exit.
+
+== EXAMPLES
+Get the core scheduling cookie of the {command} task itself, usually inherited from its parent{colon}::
+*{command} get*
+
+Get the core scheduling cookie of a task with PID _123_{colon}::
+*{command} get -s* _123_
+
+Give a task with PID _123_ a new core scheduling cookie{colon}::
+*{command} new -d* _123_
+
+Spawn a new task with a new core scheduling cookie{colon}::
+*{command} new* \-- _command_ [_argument_...]
+
+Copy the cookie from the current {command} process another task with pid _456_{colon}::
+*{command} copy -d* _456_
+
+Copy the cookie from a task with pid _123_ to another task with pid _456_{colon}::
+*{command} copy -s* _123_ *-d* _456_
+
+Copy the cookie from a task with pid _123_ to a new task _command_{colon}::
+*{command} copy -s* _123_ \-- _command_ [_argument_...]
+
+Copy the cookie from a task with pid _123_ to the process group ID _456_{colon}::
+*{command} copy -s* _123_ *-t* _pgid_ *-d* _456_
+
+== PERMISSIONS
+Retrieving or modifying the core scheduling cookie of a process requires *PTRACE_MODE_READ_REALCREDS* ptrace access to that process.
+See the section "Ptrace access mode checking" in *ptrace*(2) for more information.
+
+== RETURN VALUE
+On success, *{command}* returns 0.
+If *{command}* fails, it will print an error and return 1.
+
+If a _command_ is being executed, the return value of *{command}* will be the return value of _command_.
+
+== NOTES
+*{command}* requires core scheduling support in the kernel.
+This can be enabled via the *CONFIG_SCHED_CORE* kernel config option.
+
+== AUTHORS
+mailto:thijs@raymakers.nl[Thijs Raymakers],
+mailto:pauld@redhat.com[Phil Auld]
+
+== COPYRIGHT
+
+Copyright {copyright} 2024 Thijs Raymakers and Phil Auld. This is free software licensed under the EUPL.
+
+== SEE ALSO
+*chrt*(1),
+*nice*(1),
+*renice*(1),
+*taskset*(1),
+*ptrace*(2),
+*sched*(7)
+
+The Linux kernel source files _Documentation/admin-guide/hw-vuln/core-scheduling.rst_
+
+include::man-common/bugreports.adoc[]
+
+include::man-common/footer.adoc[]
+
+ifdef::translation[]
+include::man-common/translation.adoc[]
+endif::[]
diff --git a/schedutils/coresched.c b/schedutils/coresched.c
new file mode 100644
index 000000000..9d8be3e12
--- /dev/null
+++ b/schedutils/coresched.c
@@ -0,0 +1,363 @@
+/**
+ * SPDX-License-Identifier: EUPL-1.2
+ *
+ * coresched.c - manage core scheduling cookies for tasks
+ *
+ * Copyright (C) 2024 Thijs Raymakers, Phil Auld
+ * Licensed under the EUPL v1.2
+ */
+
+#include <getopt.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <sys/prctl.h>
+#include <unistd.h>
+
+#include "c.h"
+#include "closestream.h"
+#include "nls.h"
+#include "strutils.h"
+
+// These definitions might not be defined in the header files, even if the
+// prctl interface in the kernel accepts them as valid.
+#ifndef PR_SCHED_CORE
+ #define PR_SCHED_CORE 62
+#endif
+#ifndef PR_SCHED_CORE_GET
+ #define PR_SCHED_CORE_GET 0
+#endif
+#ifndef PR_SCHED_CORE_CREATE
+ #define PR_SCHED_CORE_CREATE 1
+#endif
+#ifndef PR_SCHED_CORE_SHARE_TO
+ #define PR_SCHED_CORE_SHARE_TO 2
+#endif
+#ifndef PR_SCHED_CORE_SHARE_FROM
+ #define PR_SCHED_CORE_SHARE_FROM 3
+#endif
+#ifndef PR_SCHED_CORE_SCOPE_THREAD
+ #define PR_SCHED_CORE_SCOPE_THREAD 0
+#endif
+#ifndef PR_SCHED_CORE_SCOPE_THREAD_GROUP
+ #define PR_SCHED_CORE_SCOPE_THREAD_GROUP 1
+#endif
+#ifndef PR_SCHED_CORE_SCOPE_PROCESS_GROUP
+ #define PR_SCHED_CORE_SCOPE_PROCESS_GROUP 2
+#endif
+
+typedef int sched_core_scope;
+typedef unsigned long long sched_core_cookie;
+typedef enum {
+ SCHED_CORE_CMD_GET,
+ SCHED_CORE_CMD_NEW,
+ SCHED_CORE_CMD_COPY,
+} sched_core_cmd;
+
+struct args {
+ pid_t src;
+ pid_t dest;
+ sched_core_scope type;
+ sched_core_cmd cmd;
+ int exec_argv_offset;
+};
+
+static bool sched_core_verbose = false;
+
+static void __attribute__((__noreturn__)) usage(void)
+{
+ fputs(USAGE_HEADER, stdout);
+ fprintf(stdout, _(" %s [get] [--source <PID>]\n"),
+ program_invocation_short_name);
+ fprintf(stdout, _(" %s new [-t <TYPE>] --dest <PID>\n"),
+ program_invocation_short_name);
+ fprintf(stdout, _(" %s new [-t <TYPE>] -- PROGRAM [ARGS...]\n"),
+ program_invocation_short_name);
+ fprintf(stdout,
+ _(" %s copy [--source <PID>] [-t <TYPE>] --dest <PID>\n"),
+ program_invocation_short_name);
+ fprintf(stdout,
+ _(" %s copy [--source <PID>] [-t <TYPE>] -- PROGRAM [ARGS...]\n"),
+ program_invocation_short_name);
+
+ fputs(USAGE_SEPARATOR, stdout);
+ fputsln(_("Manage core scheduling cookies for tasks."), stdout);
+
+ fputs(USAGE_FUNCTIONS, stdout);
+ fputsln(_(" get retrieve the core scheduling cookie of a PID"),
+ stdout);
+ fputsln(_(" new assign a new core scheduling cookie to an existing\n"
+ " PID or execute a program with a new cookie"),
+ stdout);
+ fputsln(_(" copy copy the core scheduling cookie from an existing PID\n"
+ " to another PID, or execute a program with that\n"
+ " copied cookie"),
+ stdout);
+
+ fputs(USAGE_OPTIONS, stdout);
+ fprintf(stdout,
+ _(" -s, --source <PID> which PID to get the cookie from\n"
+ " If omitted, it is the PID of %s itself\n"),
+ program_invocation_short_name);
+ fputsln(_(" -d, --dest <PID> which PID to modify the cookie of\n"),
+ stdout);
+ fputsln(_(" -t, --dest-type <TYPE> type of the destination PID, or the type of the PID\n"
+ " when a new core scheduling cookie is created.\n"
+ " Can be one of the following: pid, tgid or pgid.\n"
+ " The default is tgid."),
+ stdout);
+ fputs(USAGE_SEPARATOR, stdout);
+ fputsln(_(" -v, --verbose verbose"), stdout);
+ fprintf(stdout, USAGE_HELP_OPTIONS(20));
+ fprintf(stdout, USAGE_MAN_TAIL("coresched(1)"));
+ exit(EXIT_SUCCESS);
+}
+
+#define bad_usage(FMT...) \
+ do { \
+ warnx(FMT); \
+ errtryhelp(EXIT_FAILURE); \
+ } while (0)
+
+static sched_core_cookie core_sched_get_cookie(pid_t pid)
+{
+ sched_core_cookie cookie = 0;
+ if (prctl(PR_SCHED_CORE, PR_SCHED_CORE_GET, pid,
+ PR_SCHED_CORE_SCOPE_THREAD, &cookie))
+ err(EXIT_FAILURE, _("Failed to get cookie from PID %d"), pid);
+ return cookie;
+}
+
+static void core_sched_create_cookie(pid_t pid, sched_core_scope type)
+{
+ if (prctl(PR_SCHED_CORE, PR_SCHED_CORE_CREATE, pid, type, 0))
+ err(EXIT_FAILURE, _("Failed to create cookie for PID %d"), pid);
+}
+
+static void core_sched_pull_cookie(pid_t from)
+{
+ if (prctl(PR_SCHED_CORE, PR_SCHED_CORE_SHARE_FROM, from,
+ PR_SCHED_CORE_SCOPE_THREAD, 0))
+ err(EXIT_FAILURE, _("Failed to pull cookie from PID %d"), from);
+}
+
+static void core_sched_push_cookie(pid_t to, sched_core_scope type)
+{
+ if (prctl(PR_SCHED_CORE, PR_SCHED_CORE_SHARE_TO, to, type, 0))
+ err(EXIT_FAILURE, _("Failed to push cookie to PID %d"), to);
+}
+
+static void core_sched_copy_cookie(pid_t from, pid_t to,
+ sched_core_scope to_type)
+{
+ core_sched_pull_cookie(from);
+ core_sched_push_cookie(to, to_type);
+
+ if (sched_core_verbose) {
+ sched_core_cookie before = core_sched_get_cookie(from);
+ warnx(_("copied cookie 0x%llx from PID %d to PID %d"), before,
+ from, to);
+ }
+}
+
+static void core_sched_get_and_print_cookie(pid_t pid)
+{
+ if (sched_core_verbose) {
+ sched_core_cookie after = core_sched_get_cookie(pid);
+ warnx(_("set cookie of PID %d to 0x%llx"), pid, after);
+ }
+}
+
+static void core_sched_exec_with_cookie(struct args *args, char **argv)
+{
+ // Move the argument list to the first argument of the program
+ argv = &argv[args->exec_argv_offset];
+
+ // If a source PID is provided, try to copy the cookie from
+ // that PID. Otherwise, create a brand new cookie with the
+ // provided type.
+ if (args->src) {
+ core_sched_pull_cookie(args->src);
+ core_sched_get_and_print_cookie(args->src);
+ } else {
+ pid_t pid = getpid();
+ core_sched_create_cookie(pid, args->type);
+ core_sched_get_and_print_cookie(pid);
+ }
+
+ if (execvp(argv[0], argv))
+ errexec(argv[0]);
+}
+
+// There are two failure conditions for the core scheduling prctl calls
+// that rely on the environment in which coresched is running.
+// 1. If PR_SCHED_CORE is not recognized, or not supported on this system,
+// then prctl will set errno to EINVAL. Assuming all other operands of
+// prctl are valid, we can use errno==EINVAL as a check to see whether
+// core scheduling is available on this system.
+// 2. prctl sets errno to ENODEV if SMT is not available on this system,
+// either because SMT support has been disabled in the kernel, or because
+// the hardware doesn't support it.
+static bool is_core_sched_supported(void)
+{
+ sched_core_cookie cookie = 0;
+ if (prctl(PR_SCHED_CORE, PR_SCHED_CORE_GET, getpid(),
+ PR_SCHED_CORE_SCOPE_THREAD, &cookie))
+ if (errno == EINVAL || errno == ENODEV)
+ return false;
+
+ return true;
+}
+
+static sched_core_scope parse_core_sched_type(char *str)
+{
+ if (!strcmp(str, "pid"))
+ return PR_SCHED_CORE_SCOPE_THREAD;
+ else if (!strcmp(str, "tgid"))
+ return PR_SCHED_CORE_SCOPE_THREAD_GROUP;
+ else if (!strcmp(str, "pgid"))
+ return PR_SCHED_CORE_SCOPE_PROCESS_GROUP;
+
+ bad_usage(_("'%s' is an invalid option. Must be one of pid/tgid/pgid"),
+ str);
+}
+
+static void parse_and_verify_arguments(int argc, char **argv, struct args *args)
+{
+ int c;
+
+ static const struct option longopts[] = {
+ { "source", required_argument, NULL, 's' },
+ { "dest", required_argument, NULL, 'd' },
+ { "dest-type", required_argument, NULL, 't' },
+ { "verbose", no_argument, NULL, 'v' },
+ { "version", no_argument, NULL, 'V' },
+ { "help", no_argument, NULL, 'h' },
+ { NULL, 0, NULL, 0 }
+ };
+
+ while ((c = getopt_long(argc, argv, "s:d:t:vVh", longopts, NULL)) != -1)
+ switch (c) {
+ case 's':
+ args->src = strtopid_or_err(
+ optarg,
+ _("Failed to parse PID for -s/--source"));
+ break;
+ case 'd':
+ args->dest = strtopid_or_err(
+ optarg, _("Failed to parse PID for -d/--dest"));
+ break;
+ case 't':
+ args->type = parse_core_sched_type(optarg);
+ break;
+ case 'v':
+ sched_core_verbose = true;
+ break;
+ case 'V':
+ print_version(EXIT_SUCCESS);
+ case 'h':
+ usage();
+ default:
+ errtryhelp(EXIT_FAILURE);
+ }
+
+ if (argc <= optind) {
+ args->cmd = SCHED_CORE_CMD_GET;
+ } else {
+ if (!strcmp(argv[optind], "get"))
+ args->cmd = SCHED_CORE_CMD_GET;
+ else if (!strcmp(argv[optind], "new"))
+ args->cmd = SCHED_CORE_CMD_NEW;
+ else if (!strcmp(argv[optind], "copy"))
+ args->cmd = SCHED_CORE_CMD_COPY;
+ else
+ bad_usage(_("Unknown function"));
+
+ // Since we parsed an extra "option" outside of getopt_long, we have to
+ // increment optind manually.
+ ++optind;
+ }
+
+ if (args->cmd == SCHED_CORE_CMD_GET && args->dest)
+ bad_usage(_("get does not accept the --dest option"));
+
+ if (args->cmd == SCHED_CORE_CMD_NEW && args->src)
+ bad_usage(_("new does not accept the --source option"));
+
+ // If the -s/--source option is not specified, it defaults to the PID
+ // of the current coresched process
+ if (args->cmd != SCHED_CORE_CMD_NEW && !args->src)
+ args->src = getpid();
+
+ // More arguments have been passed, which means that the user wants to run
+ // another program with a core scheduling cookie.
+ if (argc > optind) {
+ switch (args->cmd) {
+ case SCHED_CORE_CMD_GET:
+ bad_usage(_("bad usage of the get function"));
+ break;
+ case SCHED_CORE_CMD_NEW:
+ if (args->dest)
+ bad_usage(_(
+ "new requires either a -d/--dest or a command"));
+ else
+ args->exec_argv_offset = optind;
+ break;
+ case SCHED_CORE_CMD_COPY:
+ if (args->dest)
+ bad_usage(_(
+ "copy requires either a -d/--dest or a command"));
+ else
+ args->exec_argv_offset = optind;
+ break;
+ }
+ } else {
+ if (args->cmd == SCHED_CORE_CMD_NEW && !args->dest)
+ bad_usage(_(
+ "new requires either a -d/--dest or a command"));
+ if (args->cmd == SCHED_CORE_CMD_COPY && !args->dest)
+ bad_usage(_(
+ "copy requires either a -d/--dest or a command"));
+ }
+}
+
+int main(int argc, char **argv)
+{
+ struct args args = { .type = PR_SCHED_CORE_SCOPE_THREAD_GROUP };
+
+ setlocale(LC_ALL, "");
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+ close_stdout_atexit();
+
+ parse_and_verify_arguments(argc, argv, &args);
+
+ if (!is_core_sched_supported())
+ errx(EXIT_FAILURE,
+ _("Core scheduling is not supported on this system. Either SMT "
+ "is unavailable or your kernel does not support CONFIG_SCHED_CORE."));
+
+ sched_core_cookie cookie;
+
+ switch (args.cmd) {
+ case SCHED_CORE_CMD_GET:
+ cookie = core_sched_get_cookie(args.src);
+ printf(_("cookie of pid %d is 0x%llx\n"), args.src, cookie);
+ break;
+ case SCHED_CORE_CMD_NEW:
+ if (args.exec_argv_offset) {
+ core_sched_exec_with_cookie(&args, argv);
+ } else {
+ core_sched_create_cookie(args.dest, args.type);
+ core_sched_get_and_print_cookie(args.dest);
+ }
+ break;
+ case SCHED_CORE_CMD_COPY:
+ if (args.exec_argv_offset)
+ core_sched_exec_with_cookie(&args, argv);
+ else
+ core_sched_copy_cookie(args.src, args.dest, args.type);
+ break;
+ default:
+ usage();
+ }
+}
diff --git a/tests/commands.sh b/tests/commands.sh
index cb8013ef4..69d941a02 100644
--- a/tests/commands.sh
+++ b/tests/commands.sh
@@ -71,6 +71,7 @@ TS_CMD_COLCRT=${TS_CMD_COLCRT:-"${ts_commandsdir}colcrt"}
TS_CMD_COLRM=${TS_CMD_COLRM:-"${ts_commandsdir}colrm"}
TS_CMD_COL=${TS_CMD_COL:-"${ts_commandsdir}col"}
TS_CMD_COLUMN=${TS_CMD_COLUMN:-"${ts_commandsdir}column"}
+TS_CMD_CORESCHED=${TS_CMD_CORESCHED:-"${ts_commandsdir}coresched"}
TS_CMD_ENOSYS=${TS_CMD_ENOSYS-"${ts_commandsdir}enosys"}
TS_CMD_EJECT=${TS_CMD_EJECT-"${ts_commandsdir}eject"}
TS_CMD_EXCH=${TS_CMD_EXCH-"${ts_commandsdir}exch"}
diff --git a/tests/expected/schedutils/coresched-copy-from-child-to-parent b/tests/expected/schedutils/coresched-copy-from-child-to-parent
new file mode 100644
index 000000000..5b9c40052
--- /dev/null
+++ b/tests/expected/schedutils/coresched-copy-from-child-to-parent
@@ -0,0 +1 @@
+DIFFERENT_COOKIE
diff --git a/tests/expected/schedutils/coresched-copy-from-parent-to-nested-child b/tests/expected/schedutils/coresched-copy-from-parent-to-nested-child
new file mode 100644
index 000000000..ecfc41142
--- /dev/null
+++ b/tests/expected/schedutils/coresched-copy-from-parent-to-nested-child
@@ -0,0 +1 @@
+SAME_COOKIE
diff --git a/tests/expected/schedutils/coresched-get-cookie-own-pid b/tests/expected/schedutils/coresched-get-cookie-own-pid
new file mode 100644
index 000000000..84f182cbe
--- /dev/null
+++ b/tests/expected/schedutils/coresched-get-cookie-own-pid
@@ -0,0 +1 @@
+cookie of pid OWN_PID is PARENT_COOKIE
diff --git a/tests/expected/schedutils/coresched-get-cookie-parent-pid b/tests/expected/schedutils/coresched-get-cookie-parent-pid
new file mode 100644
index 000000000..e183e0402
--- /dev/null
+++ b/tests/expected/schedutils/coresched-get-cookie-parent-pid
@@ -0,0 +1 @@
+cookie of pid PARENT_PID is PARENT_COOKIE
diff --git a/tests/expected/schedutils/coresched-new-child-with-new-cookie b/tests/expected/schedutils/coresched-new-child-with-new-cookie
new file mode 100644
index 000000000..5b9c40052
--- /dev/null
+++ b/tests/expected/schedutils/coresched-new-child-with-new-cookie
@@ -0,0 +1 @@
+DIFFERENT_COOKIE
diff --git a/tests/expected/schedutils/coresched-set-cookie-parent-pid.err b/tests/expected/schedutils/coresched-set-cookie-parent-pid.err
new file mode 100644
index 000000000..e7318ffc2
--- /dev/null
+++ b/tests/expected/schedutils/coresched-set-cookie-parent-pid.err
@@ -0,0 +1 @@
+coresched: set cookie of PID PARENT_PID to PARENT_COOKIE
diff --git a/tests/expected/schedutils/set-cookie-parent-pid b/tests/expected/schedutils/set-cookie-parent-pid
new file mode 100644
index 000000000..e7318ffc2
--- /dev/null
+++ b/tests/expected/schedutils/set-cookie-parent-pid
@@ -0,0 +1 @@
+coresched: set cookie of PID PARENT_PID to PARENT_COOKIE
diff --git a/tests/ts/schedutils/coresched b/tests/ts/schedutils/coresched
new file mode 100755
index 000000000..2ab0803bd
--- /dev/null
+++ b/tests/ts/schedutils/coresched
@@ -0,0 +1,83 @@
+#!/bin/bash
+# SPDX-License-Identifier: EUPL-1.2
+#
+# This file is part of util-linux
+#
+# Copyright (C) 2024 Thijs Raymakers
+# Licensed under the EUPL v1.2
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="coresched"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_CORESCHED"
+ts_check_prog "tee"
+ts_check_prog "sed"
+
+# If coresched cannot succesfully run, skip the test suite
+CORESCHED_TEST_KERNEL_SUPPORT_CMD=$($TS_CMD_CORESCHED 2>&1)
+if [[ $CORESCHED_TEST_KERNEL_SUPPORT_CMD == *"CONFIG_SCHED_CORE"* ]]; then
+ ts_skip "Kernel has no CONFIG_SCHED_CORE support or SMT is not available"
+fi
+
+# The output of coresched contains PIDs and core scheduling cookies, both of which should be
+# assumed to be random values as we have no control over them. The tests replace these values
+# with sed before writing them to the output file, so it can match the expected output file.
+# - The PID of this bash script is replaced with the placeholder `OWN_PID`
+# - The core scheduling cookie of this bash script is replaced by `COOKIE`
+# - Any other cookie is replaced by `DIFFERENT_COOKIE`
+# The behavior of coresched does not depend on the exact values of these cookies, so using
+# placeholder values does not change the behavior tests.
+ts_init_subtest "set-cookie-parent-pid"
+CORESCHED_OUTPUT=$( ($TS_CMD_CORESCHED -v new -d $$ \
+ | tee -a "$TS_OUTPUT") 3>&1 1>&2 2>&3 \
+ | sed "s/$$/PARENT_PID/g")
+CORESCHED_PARENT_COOKIE=$(echo "$CORESCHED_OUTPUT" | sed 's/^.*\(0x.*$\)/\1/g')
+if [ -z "$CORESCHED_PARENT_COOKIE" ]; then
+ ts_failed "empty value for CORESCHED_PARENT_COOKIE"
+fi
+CORESCHED_OUTPUT=$(echo "$CORESCHED_OUTPUT" \
+ | sed "s/$CORESCHED_PARENT_COOKIE/PARENT_COOKIE/g")
+echo "$CORESCHED_OUTPUT" >> "$TS_ERRLOG"
+ts_finalize_subtest
+
+ts_init_subtest "get-cookie-parent-pid"
+$TS_CMD_CORESCHED get -s $$ 2>> "$TS_ERRLOG" \
+ | sed -e "s/$$/PARENT_PID/g" \
+ -e "s/$CORESCHED_PARENT_COOKIE/PARENT_COOKIE/g" >> "$TS_OUTPUT"
+ts_finalize_subtest
+
+ts_init_subtest "get-cookie-own-pid"
+$TS_CMD_CORESCHED get 2>> "$TS_ERRLOG" \
+ | sed -e "s/pid [0-9]\+/pid OWN_PID/g" \
+ -e "s/$CORESCHED_PARENT_COOKIE/PARENT_COOKIE/g" >> "$TS_OUTPUT"
+ts_finalize_subtest
+
+ts_init_subtest "new-child-with-new-cookie"
+$TS_CMD_CORESCHED new -- "$TS_CMD_CORESCHED" get 2>> "$TS_ERRLOG" \
+ | sed -e 's/^.*\(0x.*$\)/\1/g' \
+ -e "s/$CORESCHED_PARENT_COOKIE/SAME_COOKIE/g" \
+ -e "s/0x.*$/DIFFERENT_COOKIE/g" >> "$TS_OUTPUT"
+ts_finalize_subtest
+
+ts_init_subtest "copy-from-parent-to-nested-child"
+$TS_CMD_CORESCHED new -- /bin/bash -c \
+ "$TS_CMD_CORESCHED copy -s $$ -- $TS_CMD_CORESCHED get" \
+2>> "$TS_ERRLOG" \
+ | sed -e 's/^.*\(0x.*$\)/\1/g' \
+ -e "s/$CORESCHED_PARENT_COOKIE/SAME_COOKIE/g" \
+ -e "s/0x.*$/DIFFERENT_COOKIE/g" >> "$TS_OUTPUT"
+ts_finalize_subtest
+
+ts_init_subtest "copy-from-child-to-parent"
+$TS_CMD_CORESCHED new -- /bin/bash -c \
+ "$TS_CMD_CORESCHED copy -s \$\$ -d $$"
+$TS_CMD_CORESCHED get 2>> "$TS_ERRLOG" \
+ | sed -e 's/^.*\(0x.*$\)/\1/g' \
+ -e "s/$CORESCHED_PARENT_COOKIE/SAME_COOKIE/g" \
+ -e "s/0x.*$/DIFFERENT_COOKIE/g" >> "$TS_OUTPUT"
+ts_finalize_subtest
+
+ts_finalize
--
2.50.1

View File

@ -0,0 +1,87 @@
From eeb51a72ee10b89b7a13af7f3623cf1ef9a2a7ba Mon Sep 17 00:00:00 2001
From: Thijs Raymakers <thijs@raymakers.nl>
Date: Wed, 22 May 2024 16:24:01 +0200
Subject: coresched: add bash completions
Addresses: https://issues.redhat.com/browse/RHEL-34021
Signed-off-by: Thijs Raymakers <thijs@raymakers.nl>
Upstream: http://github.com/util-linux/util-linux/commit/f9d28c8e234503d5c6b4a91a2475df94ab599bbd)
Signed-off-by: Karel Zak <kzak@redhat.com>
---
bash-completion/Makemodule.am | 3 +++
bash-completion/coresched | 51 +++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+)
diff --git a/bash-completion/Makemodule.am b/bash-completion/Makemodule.am
index 034f9434a..f7aa99fcf 100644
--- a/bash-completion/Makemodule.am
+++ b/bash-completion/Makemodule.am
@@ -18,6 +18,9 @@ endif
if BUILD_COLUMN
dist_bashcompletion_DATA += bash-completion/column
endif
+if BUILD_CORESCHED
+dist_bashcompletion_DATA += bash-completion/coresched
+endif
if BUILD_EXCH
dist_bashcompletion_DATA += bash-completion/exch
endif
diff --git a/bash-completion/coresched b/bash-completion/coresched
index e69de29bb..3a14c5080 100644
--- a/bash-completion/coresched
+++ b/bash-completion/coresched
@@ -0,0 +1,51 @@
+_coresched_module()
+{
+ compopt -o nosort
+
+ COMPREPLY=()
+
+ # If the previous argument equals the program name
+ if [[ "$1" == "$3" ]]; then
+ COMPREPLY=( $(compgen -W "get new copy --help --version" -- "$2") )
+ return 0
+ fi
+
+ case $3 in
+ "-s"|"--source"|"-d"|"--dest")
+ local pids sorted_pids
+ pids=$(cd /proc && echo [0-9]*)
+ sorted_pids=$(echo "${pids[@]}" | tr ' ' '\n' | sort -nr | tr '\n' ' ')
+ COMPREPLY=( $(compgen -W "$sorted_pids" -- "$2") )
+ return 0
+ ;;
+ "-t"|"--dest-type")
+ COMPREPLY=( $(compgen -W "pid tgid pgid" -- "$2") )
+ return 0
+ ;;
+ "--")
+ COMPREPLY=( $(compgen -c "$2") )
+ return 0
+ ;;
+ esac
+
+ local function="${COMP_WORDS[1]}"
+ case $function in
+ 'get')
+ COMPREPLY=( $(compgen -W "--source" -- "$2") )
+ return 0
+ ;;
+ 'new')
+ COMPREPLY=( $(compgen -W "--dest -- --dest-type --verbose" -- "$2") )
+ return 0
+ ;;
+ 'copy')
+ COMPREPLY=( $(compgen -W "--source --dest -- --dest-type --verbose" -- "$2") )
+ return 0
+ ;;
+ '-h'|'--help'|'-V'|'--version')
+ return 0
+ ;;
+ esac
+ return 0
+}
+complete -F _coresched_module coresched
--
2.50.1

View File

@ -0,0 +1,325 @@
From 5a57307b707a0f329c32ee97a14de16a8db3b7a8 Mon Sep 17 00:00:00 2001
From: Thijs Raymakers <thijs@raymakers.nl>
Date: Wed, 22 May 2024 13:38:18 +0200
Subject: docs: add European Public License v1.2
schedutils/coresched is licensed under the EUPL 1.2.
Addresses: https://issues.redhat.com/browse/RHEL-34021
Signed-off-by: Thijs Raymakers <thijs@raymakers.nl>
Upstream: http://github.com/util-linux/util-linux/commit/74f3265b9a079f9f60ad6e606d77deae0029a43a)
---
Documentation/licenses/COPYING.EUPL-1.2 | 287 ++++++++++++++++++++++++
README.licensing | 2 +
2 files changed, 289 insertions(+)
create mode 100644 Documentation/licenses/COPYING.EUPL-1.2
diff --git a/Documentation/licenses/COPYING.EUPL-1.2 b/Documentation/licenses/COPYING.EUPL-1.2
new file mode 100644
index 000000000..4153cd377
--- /dev/null
+++ b/Documentation/licenses/COPYING.EUPL-1.2
@@ -0,0 +1,287 @@
+ EUROPEAN UNION PUBLIC LICENCE v. 1.2
+ EUPL © the European Union 2007, 2016
+
+This European Union Public Licence (the EUPL) applies to the Work (as defined
+below) which is provided under the terms of this Licence. Any use of the Work,
+other than as authorised under this Licence is prohibited (to the extent such
+use is covered by a right of the copyright holder of the Work).
+
+The Work is provided under the terms of this Licence when the Licensor (as
+defined below) has placed the following notice immediately following the
+copyright notice for the Work:
+
+ Licensed under the EUPL
+
+or has expressed by any other means his willingness to license under the EUPL.
+
+1. Definitions
+
+In this Licence, the following terms have the following meaning:
+
+- The Licence: this Licence.
+
+- The Original Work: the work or software distributed or communicated by the
+ Licensor under this Licence, available as Source Code and also as Executable
+ Code as the case may be.
+
+- Derivative Works: the works or software that could be created by the
+ Licensee, based upon the Original Work or modifications thereof. This Licence
+ does not define the extent of modification or dependence on the Original Work
+ required in order to classify a work as a Derivative Work; this extent is
+ determined by copyright law applicable in the country mentioned in Article 15.
+
+- The Work: the Original Work or its Derivative Works.
+
+- The Source Code: the human-readable form of the Work which is the most
+ convenient for people to study and modify.
+
+- The Executable Code: any code which has generally been compiled and which is
+ meant to be interpreted by a computer as a program.
+
+- The Licensor: the natural or legal person that distributes or communicates
+ the Work under the Licence.
+
+- Contributor(s): any natural or legal person who modifies the Work under the
+ Licence, or otherwise contributes to the creation of a Derivative Work.
+
+- The Licensee or You: any natural or legal person who makes any usage of
+ the Work under the terms of the Licence.
+
+- Distribution or Communication: any act of selling, giving, lending,
+ renting, distributing, communicating, transmitting, or otherwise making
+ available, online or offline, copies of the Work or providing access to its
+ essential functionalities at the disposal of any other natural or legal
+ person.
+
+2. Scope of the rights granted by the Licence
+
+The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
+sublicensable licence to do the following, for the duration of copyright vested
+in the Original Work:
+
+- use the Work in any circumstance and for all usage,
+- reproduce the Work,
+- modify the Work, and make Derivative Works based upon the Work,
+- communicate to the public, including the right to make available or display
+ the Work or copies thereof to the public and perform publicly, as the case may
+ be, the Work,
+- distribute the Work or copies thereof,
+- lend and rent the Work or copies thereof,
+- sublicense rights in the Work or copies thereof.
+
+Those rights can be exercised on any media, supports and formats, whether now
+known or later invented, as far as the applicable law permits so.
+
+In the countries where moral rights apply, the Licensor waives his right to
+exercise his moral right to the extent allowed by law in order to make effective
+the licence of the economic rights here above listed.
+
+The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to
+any patents held by the Licensor, to the extent necessary to make use of the
+rights granted on the Work under this Licence.
+
+3. Communication of the Source Code
+
+The Licensor may provide the Work either in its Source Code form, or as
+Executable Code. If the Work is provided as Executable Code, the Licensor
+provides in addition a machine-readable copy of the Source Code of the Work
+along with each copy of the Work that the Licensor distributes or indicates, in
+a notice following the copyright notice attached to the Work, a repository where
+the Source Code is easily and freely accessible for as long as the Licensor
+continues to distribute or communicate the Work.
+
+4. Limitations on copyright
+
+Nothing in this Licence is intended to deprive the Licensee of the benefits from
+any exception or limitation to the exclusive rights of the rights owners in the
+Work, of the exhaustion of those rights or of other applicable limitations
+thereto.
+
+5. Obligations of the Licensee
+
+The grant of the rights mentioned above is subject to some restrictions and
+obligations imposed on the Licensee. Those obligations are the following:
+
+Attribution right: The Licensee shall keep intact all copyright, patent or
+trademarks notices and all notices that refer to the Licence and to the
+disclaimer of warranties. The Licensee must include a copy of such notices and a
+copy of the Licence with every copy of the Work he/she distributes or
+communicates. The Licensee must cause any Derivative Work to carry prominent
+notices stating that the Work has been modified and the date of modification.
+
+Copyleft clause: If the Licensee distributes or communicates copies of the
+Original Works or Derivative Works, this Distribution or Communication will be
+done under the terms of this Licence or of a later version of this Licence
+unless the Original Work is expressly distributed only under this version of the
+Licence — for example by communicating EUPL v. 1.2 only. The Licensee
+(becoming Licensor) cannot offer or impose any additional terms or conditions on
+the Work or Derivative Work that alter or restrict the terms of the Licence.
+
+Compatibility clause: If the Licensee Distributes or Communicates Derivative
+Works or copies thereof based upon both the Work and another work licensed under
+a Compatible Licence, this Distribution or Communication can be done under the
+terms of this Compatible Licence. For the sake of this clause, Compatible
+Licence refers to the licences listed in the appendix attached to this Licence.
+Should the Licensee's obligations under the Compatible Licence conflict with
+his/her obligations under this Licence, the obligations of the Compatible
+Licence shall prevail.
+
+Provision of Source Code: When distributing or communicating copies of the Work,
+the Licensee will provide a machine-readable copy of the Source Code or indicate
+a repository where this Source will be easily and freely available for as long
+as the Licensee continues to distribute or communicate the Work.
+
+Legal Protection: This Licence does not grant permission to use the trade names,
+trademarks, service marks, or names of the Licensor, except as required for
+reasonable and customary use in describing the origin of the Work and
+reproducing the content of the copyright notice.
+
+6. Chain of Authorship
+
+The original Licensor warrants that the copyright in the Original Work granted
+hereunder is owned by him/her or licensed to him/her and that he/she has the
+power and authority to grant the Licence.
+
+Each Contributor warrants that the copyright in the modifications he/she brings
+to the Work are owned by him/her or licensed to him/her and that he/she has the
+power and authority to grant the Licence.
+
+Each time You accept the Licence, the original Licensor and subsequent
+Contributors grant You a licence to their contributions to the Work, under the
+terms of this Licence.
+
+7. Disclaimer of Warranty
+
+The Work is a work in progress, which is continuously improved by numerous
+Contributors. It is not a finished work and may therefore contain defects or
+bugs inherent to this type of development.
+
+For the above reason, the Work is provided under the Licence on an as is basis
+and without warranties of any kind concerning the Work, including without
+limitation merchantability, fitness for a particular purpose, absence of defects
+or errors, accuracy, non-infringement of intellectual property rights other than
+copyright as stated in Article 6 of this Licence.
+
+This disclaimer of warranty is an essential part of the Licence and a condition
+for the grant of any rights to the Work.
+
+8. Disclaimer of Liability
+
+Except in the cases of wilful misconduct or damages directly caused to natural
+persons, the Licensor will in no event be liable for any direct or indirect,
+material or moral, damages of any kind, arising out of the Licence or of the use
+of the Work, including without limitation, damages for loss of goodwill, work
+stoppage, computer failure or malfunction, loss of data or any commercial
+damage, even if the Licensor has been advised of the possibility of such damage.
+However, the Licensor will be liable under statutory product liability laws as
+far such laws apply to the Work.
+
+9. Additional agreements
+
+While distributing the Work, You may choose to conclude an additional agreement,
+defining obligations or services consistent with this Licence. However, if
+accepting obligations, You may act only on your own behalf and on your sole
+responsibility, not on behalf of the original Licensor or any other Contributor,
+and only if You agree to indemnify, defend, and hold each Contributor harmless
+for any liability incurred by, or claims asserted against such Contributor by
+the fact You have accepted any warranty or additional liability.
+
+10. Acceptance of the Licence
+
+The provisions of this Licence can be accepted by clicking on an icon I agree
+placed under the bottom of a window displaying the text of this Licence or by
+affirming consent in any other similar way, in accordance with the rules of
+applicable law. Clicking on that icon indicates your clear and irrevocable
+acceptance of this Licence and all of its terms and conditions.
+
+Similarly, you irrevocably accept this Licence and all of its terms and
+conditions by exercising any rights granted to You by Article 2 of this Licence,
+such as the use of the Work, the creation by You of a Derivative Work or the
+Distribution or Communication by You of the Work or copies thereof.
+
+11. Information to the public
+
+In case of any Distribution or Communication of the Work by means of electronic
+communication by You (for example, by offering to download the Work from a
+remote location) the distribution channel or media (for example, a website) must
+at least provide to the public the information requested by the applicable law
+regarding the Licensor, the Licence and the way it may be accessible, concluded,
+stored and reproduced by the Licensee.
+
+12. Termination of the Licence
+
+The Licence and the rights granted hereunder will terminate automatically upon
+any breach by the Licensee of the terms of the Licence.
+
+Such a termination will not terminate the licences of any person who has
+received the Work from the Licensee under the Licence, provided such persons
+remain in full compliance with the Licence.
+
+13. Miscellaneous
+
+Without prejudice of Article 9 above, the Licence represents the complete
+agreement between the Parties as to the Work.
+
+If any provision of the Licence is invalid or unenforceable under applicable
+law, this will not affect the validity or enforceability of the Licence as a
+whole. Such provision will be construed or reformed so as necessary to make it
+valid and enforceable.
+
+The European Commission may publish other linguistic versions or new versions of
+this Licence or updated versions of the Appendix, so far this is required and
+reasonable, without reducing the scope of the rights granted by the Licence. New
+versions of the Licence will be published with a unique version number.
+
+All linguistic versions of this Licence, approved by the European Commission,
+have identical value. Parties can take advantage of the linguistic version of
+their choice.
+
+14. Jurisdiction
+
+Without prejudice to specific agreement between parties,
+
+- any litigation resulting from the interpretation of this License, arising
+ between the European Union institutions, bodies, offices or agencies, as a
+ Licensor, and any Licensee, will be subject to the jurisdiction of the Court
+ of Justice of the European Union, as laid down in article 272 of the Treaty on
+ the Functioning of the European Union,
+
+- any litigation arising between other parties and resulting from the
+ interpretation of this License, will be subject to the exclusive jurisdiction
+ of the competent court where the Licensor resides or conducts its primary
+ business.
+
+15. Applicable Law
+
+Without prejudice to specific agreement between parties,
+
+- this Licence shall be governed by the law of the European Union Member State
+ where the Licensor has his seat, resides or has his registered office,
+
+- this licence shall be governed by Belgian law if the Licensor has no seat,
+ residence or registered office inside a European Union Member State.
+
+Appendix
+
+Compatible Licences according to Article 5 EUPL are:
+
+- GNU General Public License (GPL) v. 2, v. 3
+- GNU Affero General Public License (AGPL) v. 3
+- Open Software License (OSL) v. 2.1, v. 3.0
+- Eclipse Public License (EPL) v. 1.0
+- CeCILL v. 2.0, v. 2.1
+- Mozilla Public Licence (MPL) v. 2
+- GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
+- Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
+ works other than software
+- European Union Public Licence (EUPL) v. 1.1, v. 1.2
+- Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong
+ Reciprocity (LiLiQ-R+).
+
+The European Commission may update this Appendix to later versions of the above
+licences without producing a new version of the EUPL, as long as they provide
+the rights granted in Article 2 of this Licence and protect the covered Source
+Code from exclusive appropriation.
+
+All other changes or additions to this Appendix require the production of a new
+EUPL version.
diff --git a/README.licensing b/README.licensing
index 535ad3481..0d06b73fd 100644
--- a/README.licensing
+++ b/README.licensing
@@ -20,6 +20,8 @@ There is code under:
* BSD-4-Clause-UC - BSD 4-Clause University of California-Specific
+ * EUPL-1.2 - European Union Public Licence version 1.2
+
* Public Domain
Please, check the source code for more details. A license is usually at the start
--
2.50.1

View File

@ -0,0 +1,29 @@
From 07c5d3c21b17b1dc0517ff4fe5bdd925c145c145 Mon Sep 17 00:00:00 2001
From: "Emi, Kisanuki" <fj0570is@fujitsu.com>
Date: Tue, 24 Dec 2024 06:27:51 +0000
Subject: lscpu: Add FUJITSU aarch64 MONAKA cpupart
Add an entry for FUJITSU aarch64 part MONAKA.
Signed-off-by: Emi, Kisanuki <fj0570is@fujitsu.com>
Upstream: http://github.com/util-linux/util-linux/commit/9156b69f05bc1519230d823c735cc69be9823de5
Addresses: https://issues.redhat.com/browse/RHEL-82216
---
sys-utils/lscpu-arm.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/sys-utils/lscpu-arm.c b/sys-utils/lscpu-arm.c
index 997ae88ff..949b31e71 100644
--- a/sys-utils/lscpu-arm.c
+++ b/sys-utils/lscpu-arm.c
@@ -249,6 +249,7 @@ static const struct id_part intel_part[] = {
static const struct id_part fujitsu_part[] = {
{ 0x001, "A64FX" },
+ { 0x003, "MONAKA" },
{ -1, "unknown" },
};
--
2.50.1

View File

@ -0,0 +1,46 @@
From 3863c5bac1a4ea75e1917878ec711c085f09a0d0 Mon Sep 17 00:00:00 2001
From: Jeremy Linton <jeremy.linton@arm.com>
Date: Thu, 6 Mar 2025 12:17:30 -0600
Subject: lscpu: New Arm part numbers
Arm has announced the Cortex-A320 and published the TRM here:
https://developer.arm.com/documentation/109551
The Cortex-A520AE with a TRM here:
https://developer.arm.com/documentation/107726
The Cortex-A720AE with a TRM here:
https://developer.arm.com/documentation/102828
The Neoverse-V3AE with a TRM here:
https://developer.arm.com/documentation/101595
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Upstream: http://github.com/util-linux/util-linux/commit/be77fa82ad491f38537030c329c2a8e0612506a5
Addresses: https://issues.redhat.com/browse/RHEL-82216
---
sys-utils/lscpu-arm.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sys-utils/lscpu-arm.c b/sys-utils/lscpu-arm.c
index 949b31e71..682868550 100644
--- a/sys-utils/lscpu-arm.c
+++ b/sys-utils/lscpu-arm.c
@@ -93,10 +93,14 @@ static const struct id_part arm_part[] = {
{ 0xd80, "Cortex-A520" },
{ 0xd81, "Cortex-A720" },
{ 0xd82, "Cortex-X4" },
+ { 0xd83, "Neoverse-V3AE" },
{ 0xd84, "Neoverse-V3" },
{ 0xd85, "Cortex-X925" },
{ 0xd87, "Cortex-A725" },
+ { 0xd88, "Cortex-A520AE" },
+ { 0xd89, "Cortex-A720AE" },
{ 0xd8e, "Neoverse-N3" },
+ { 0xd8f, "Cortex-A320" },
{ -1, "unknown" },
};
--
2.50.1

View File

@ -2,7 +2,7 @@
## (rpmautospec version 0.6.5)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
release_number = 10;
release_number = 13;
base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
@ -14,7 +14,7 @@ Name: util-linux
Version: 2.40.2
# -p -e rc1
Release: %autorelease
License: GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-2.1-or-later AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC AND LicenseRef-Fedora-Public-Domain
License: GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-2.1-or-later AND EUPL-1.2 AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC AND LicenseRef-Fedora-Public-Domain
URL: https://en.wikipedia.org/wiki/Util-linux
### Macros
@ -49,10 +49,11 @@ BuildRequires: librtas-devel
%endif
# enable if make changes to build-system
#BuildRequires: autoconf
#BuildRequires: automake
#BuildRequires: libtool
#BuildRequires: bison
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: libtool
BuildRequires: bison
BuildRequires: flex
### Sources
Source0: https://www.kernel.org/pub/linux/utils/util-linux/v%{upstream_major}/util-linux-%{upstream_version}.tar.xz
@ -116,6 +117,16 @@ Patch3: 0003-uuidd-fix-typo-in-tmpfiles.conf.patch
Patch4: 0004-more-make-sure-we-have-data-on-stderr.patch
# RHEL-76070 - blkid: allow up to 64k erofs block sizes
Patch5: 0005-blkid-allow-up-to-64k-erofs-block-sizes.patch
# RHEL-79770 - agetty: fix stdin conversion to tty name
Patch6: 0006-agetty-fix-stdin-conversion-to-tty-name.patch
# RHEL-34021 - coresched: Manage core scheduling cookies for tasks
Patch7: 0007-coresched-Manage-core-scheduling-cookies-for-tasks.patch
Patch8: 0008-coresched-add-bash-completions.patch
Patch9: 0009-docs-add-European-Public-License-v1.2.patch
# RHEL-82216 - lscpu: Add FUJITSU aarch64 MONAKA cpupart
Patch10: 0010-lscpu-Add-FUJITSU-aarch64-MONAKA-cpupart.patch
Patch11: 0011-lscpu-New-Arm-part-numbers.patch
%description
The util-linux package contains a large variety of low-level system
@ -314,7 +325,7 @@ util-linux commands.
unset LINGUAS || :
# enable only when make a change to the build-system
#./autogen.sh
./autogen.sh
export CFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 $RPM_OPT_FLAGS"
@ -526,6 +537,7 @@ fi
%{_bindir}/colcrt
%{_bindir}/colrm
%{_bindir}/column
%{_bindir}/coresched
%{_bindir}/eject
%{_bindir}/enosys
%{_bindir}/exch
@ -580,6 +592,7 @@ fi
%{_mandir}/man1/colcrt.1*
%{_mandir}/man1/colrm.1*
%{_mandir}/man1/column.1*
%{_mandir}/man1/coresched.1.*
%{_mandir}/man1/eject.1*
%{_mandir}/man1/enosys.1*
%{_mandir}/man1/exch.1*
@ -700,6 +713,7 @@ fi
%{compldir}/colcrt
%{compldir}/colrm
%{compldir}/column
%{compldir}/coresched
%{compldir}/ctrlaltdel
%{compldir}/delpart
%{compldir}/eject
@ -974,6 +988,15 @@ fi
%changelog
## START: Generated by rpmautospec
* Wed Jul 30 2025 Karel Zak <kzak@redhat.com> - 2.40.2-13
- lscpu: update table with ARM IDs
* Tue Jul 29 2025 Karel Zak <kzak@redhat.com> - 2.40.2-12
- coresched: backport new tool to RHEL-10
* Sat Apr 19 2025 Frank Liang <xiliang@redhat.com> - 2.40.2-11
- agetty: fix stdin conversion to tty name
* Thu Feb 13 2025 Karel Zak <kzak@redhat.com> - 2.40.2-10
- blkid: allow up to 64k erofs block sizes