diff --git a/1610-add-new-rules-for-lower-priority-events-to-preempt.patch b/1610-add-new-rules-for-lower-priority-events-to-preempt.patch deleted file mode 100644 index 8715946f1fc36d41d6ed338bdce9ce4b2765216b..0000000000000000000000000000000000000000 --- a/1610-add-new-rules-for-lower-priority-events-to-preempt.patch +++ /dev/null @@ -1,222 +0,0 @@ -From 49f6a75e648c113fa9985675f47f78a4cd57c084 Mon Sep 17 00:00:00 2001 -From: yangbin -Date: Fri, 26 Jul 2019 10:02:58 +0800 -Subject: [PATCH] systemd-core: Add new rules for lower priority events to - preempt over higher priority events - -1. When a high priority event happenes very frequent, and this event takes long time for execution,systemd will get into busy for handling this event only, and lower priority events will have no any change to dispatch and run. - -2. One example is the event for /proc/self/mountinfo, which have a very high priority with -10. -When there are many mountpoints in mountinfo(for example, there may be many netns mountpoints),this event will take long time to finish. -Then if now there are mountpoints in repeating mounting and unmounting(for example, /run/user/uid mountpoint will be mounted then unmounted when for one su command), -this event will take all time of systemd, and lower priority lower events will not be dispatched anyway. -This will case a very severity problem that zombie process will not be reaped, for the evnet for reaping zombies has a lower priority of -6. - -3. This patch fix this problem by add the following rules to allow lower priority events to preempt over higher priority events. -a) If a higher priority event has already been execute for a certain count in consecutive, it can be preempted by lower priority events. The default value for this count is 10, and can be configured through 'sd_event_source_set_preempt_dispatch_count'. -b) If a lower priority gets into pending for 10 times in consecutive, it can preempt over higher priority events. -c) If a lower priority is in pending, and is not dispatched over 50 iteration, it can preempt over higher priority events. -d) The above rules only works for events with priority equal or higher than 'SD_EVENT_PRIORITY_NORMAL' or evnets with type of SOURCE_DEFER, since SOURCE_DEFER events is used for job running queues. ---- - src/core/mount.c | 4 ++ - src/libsystemd/sd-event/sd-event.c | 87 ++++++++++++++++++++++++++++++ - src/systemd/sd-event.h | 1 + - 3 files changed, 92 insertions(+) - -diff --git a/src/core/mount.c b/src/core/mount.c -index 1b94ab4..78b6e30 100644 ---- a/src/core/mount.c -+++ b/src/core/mount.c -@@ -1742,6 +1742,10 @@ static void mount_enumerate(Manager *m) { - goto fail; - } - -+ r = sd_event_source_set_preempt_dispatch_count(m->mount_event_source, 5); -+ if (r < 0) -+ goto fail; -+ - (void) sd_event_source_set_description(m->mount_event_source, "mount-monitor-dispatch"); - } - -diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c -index d53b9a7..7e33061 100644 ---- a/src/libsystemd/sd-event/sd-event.c -+++ b/src/libsystemd/sd-event/sd-event.c -@@ -26,6 +26,11 @@ - #include "time-util.h" - #include "util.h" - -+#define DEFAULT_PREEMPTED_ITERATION_COUNT (3) -+#define DEFAULT_PREEMPT_DISPATCH_COUNT (10) -+#define DEFAULT_PREEMPT_PENDING_COUNT (10) -+#define DEFAULT_PREEMPT_ITERATION_COUNT (30) -+ - #define DEFAULT_ACCURACY_USEC (250 * USEC_PER_MSEC) - - typedef enum EventSourceType { -@@ -103,6 +108,11 @@ struct sd_event_source { - uint64_t pending_iteration; - uint64_t prepare_iteration; - -+ uint64_t preempted_iteration; /*The iteration that dispatched_count is greater than preempt_dispatch_count*/ -+ unsigned pending_count; /*times of pending not dispatched*/ -+ unsigned dispatched_count; /*consecutive dispatched count*/ -+ unsigned preempt_dispatch_count; /*Will be preempted by lower priority if dispatched count reaches to this*/ -+ - sd_event_destroy_t destroy_callback; - - LIST_FIELDS(sd_event_source, sources); -@@ -301,6 +311,11 @@ struct sd_event { - - LIST_HEAD(sd_event_source, sources); - -+ /*last dispatched source, its type is sd_event_source, -+ * here use void to avoid accessing its members, -+ * for it may have been freed already.*/ -+ void *last_source; -+ - usec_t last_run, last_log; - unsigned delays[sizeof(usec_t) * 8]; - }; -@@ -314,8 +329,42 @@ static sd_event *event_resolve(sd_event *e) { - return e == SD_EVENT_DEFAULT ? default_event : e; - } - -+static int preempt_prioq_compare(const sd_event_source *x, const sd_event_source *y) { -+ if((x->priority > SD_EVENT_PRIORITY_NORMAL && x->type != SOURCE_DEFER) -+ || (y->priority > SD_EVENT_PRIORITY_NORMAL && y->type != SOURCE_DEFER)) { -+ return 0; /*only high priority evnets can preempt*/ -+ } -+ -+ if(x->priority <= y->priority) { -+ if(x->dispatched_count >= x->preempt_dispatch_count) -+ return 1; -+ if(y->type != SOURCE_DEFER) { /*pending state for defer event is always true*/ -+ /*y has lower priority, but its pending count is greater than x, so y wins*/ -+ if(y->pending_count >= (x->pending_count + DEFAULT_PREEMPT_PENDING_COUNT)) -+ return 1; -+ /*y has lower priority, but is in pending longer than x, so y wins*/ -+ if(x->pending_iteration >= (y->pending_iteration + DEFAULT_PREEMPT_ITERATION_COUNT)) -+ return 1; -+ } -+ } else { -+ if(y->dispatched_count >= y->preempt_dispatch_count) -+ return -1; -+ if(x->type != SOURCE_DEFER) { /*pending state for defer event is always true*/ -+ /*x has lower priority, but its pending count is greater than y, so x wins*/ -+ if(x->pending_count >= (y->pending_count + DEFAULT_PREEMPT_PENDING_COUNT)) -+ return -1; -+ /*x has lower priority, but is in pending longer than y, so x wins*/ -+ if(y->pending_iteration >= (x->pending_iteration + DEFAULT_PREEMPT_ITERATION_COUNT)) -+ return -1; -+ } -+ } -+ -+ return 0; -+} -+ - static int pending_prioq_compare(const void *a, const void *b) { - const sd_event_source *x = a, *y = b; -+ int r; - - assert(x->pending); - assert(y->pending); -@@ -326,6 +375,10 @@ static int pending_prioq_compare(const void *a, const void *b) { - if (x->enabled == SD_EVENT_OFF && y->enabled != SD_EVENT_OFF) - return 1; - -+ r = preempt_prioq_compare(a, b); -+ if(r) -+ return r; -+ - /* Lower priority values first */ - if (x->priority < y->priority) - return -1; -@@ -1030,6 +1083,17 @@ static int source_set_pending(sd_event_source *s, bool b) { - assert(s); - assert(s->type != SOURCE_EXIT); - -+ if (b && s->pending == b) -+ s->pending_count++; -+ else -+ s->pending_count = (b ? 1 : 0); -+ if (b && s->preempted_iteration && -+ (s->pending_count >= DEFAULT_PREEMPTED_ITERATION_COUNT || -+ s->event->iteration >= (s->preempted_iteration + DEFAULT_PREEMPTED_ITERATION_COUNT)) ) { -+ s->dispatched_count = 0; -+ s->preempted_iteration = 0; -+ } -+ - if (s->pending == b) - return 0; - -@@ -1097,6 +1161,7 @@ static sd_event_source *source_new(sd_event *e, bool floating, EventSourceType t - .type = type, - .pending_index = PRIOQ_IDX_NULL, - .prepare_index = PRIOQ_IDX_NULL, -+ .preempt_dispatch_count = DEFAULT_PREEMPT_DISPATCH_COUNT, - }; - - if (!floating) -@@ -2263,6 +2328,7 @@ _public_ int sd_event_source_set_enabled(sd_event_source *s, int m) { - return r; - } - -+ s->pending_count = 0; - switch (s->type) { - - case SOURCE_IO: -@@ -3055,6 +3121,19 @@ static int process_inotify(sd_event *e) { - return done; - } - -+static void source_dispatch_pre(sd_event_source *s) { -+ if(s->event->last_source == s) { -+ s->dispatched_count++; -+ if(s->dispatched_count >= s->preempt_dispatch_count) -+ s->preempted_iteration = s->event->iteration; -+ } else { -+ s->preempted_iteration = 0; -+ s->dispatched_count = 0; -+ } -+ s->event->last_source = s; -+ s->pending_count = 0; -+} -+ - static int source_dispatch(sd_event_source *s) { - EventSourceType saved_type; - int r = 0; -@@ -3095,6 +3174,7 @@ static int source_dispatch(sd_event_source *s) { - return r; - } - -+ source_dispatch_pre(s); - s->dispatching = true; - - switch (s->type) { -@@ -3793,3 +3873,10 @@ _public_ int sd_event_source_get_destroy_callback(sd_event_source *s, sd_event_d - - return !!s->destroy_callback; - } -+ -+_public_ int sd_event_source_set_preempt_dispatch_count(sd_event_source *s, unsigned count) { -+ assert_return(s, -EINVAL); -+ -+ s->preempt_dispatch_count = count; -+ return 0; -+} -diff --git a/src/systemd/sd-event.h b/src/systemd/sd-event.h -index 7fcae4a..fdf9108 100644 ---- a/src/systemd/sd-event.h -+++ b/src/systemd/sd-event.h -@@ -143,6 +143,7 @@ int sd_event_source_get_child_pid(sd_event_source *s, pid_t *pid); - int sd_event_source_get_inotify_mask(sd_event_source *s, uint32_t *ret); - int sd_event_source_set_destroy_callback(sd_event_source *s, sd_event_destroy_t callback); - int sd_event_source_get_destroy_callback(sd_event_source *s, sd_event_destroy_t *ret); -+int sd_event_source_set_preempt_dispatch_count(sd_event_source *s, unsigned count); - - /* Define helpers so that __attribute__((cleanup(sd_event_unrefp))) and similar may be used. */ - _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_event, sd_event_unref); --- -2.17.1 - diff --git a/1612-serialize-pids-for-scope-when-not-started.patch b/1612-serialize-pids-for-scope-when-not-started.patch deleted file mode 100644 index 3d51aa655ef056e06273c59ba7cc9876b813160f..0000000000000000000000000000000000000000 --- a/1612-serialize-pids-for-scope-when-not-started.patch +++ /dev/null @@ -1,89 +0,0 @@ -From a5c08598384d44ad3bce24ff63ab320b3b3e5292 Mon Sep 17 00:00:00 2001 -From: huangkaibin -Date: Wed, 31 Jan 2018 22:28:36 +0800 -Subject: [PATCH] systemd-core: Serialize pids for scope unit when it is not - started - -1. when a scope unit is initialized, and daemon-reload is performed before it is started, -pids (generally comes from dbus) belog to this scope will not be attached to the cgroup of this scope, -because these pids are not serialized and are lost during daemon-reload. -2. this patch fix this problem by serializing scope pids when the state of the scope is DEAD(the init state). ---- - src/core/scope.c | 33 +++++++++++++++++++++++++++++++++ - 1 file changed, 33 insertions(+) - -diff --git a/src/core/scope.c b/src/core/scope.c -index ae6614f..8d96ee1 100644 ---- a/src/core/scope.c -+++ b/src/core/scope.c -@@ -194,6 +194,8 @@ static int scope_load(Unit *u) { - - static int scope_coldplug(Unit *u) { - Scope *s = SCOPE(u); -+ Iterator i; -+ void *pidp = NULL; - int r; - - assert(s); -@@ -214,6 +216,12 @@ static int scope_coldplug(Unit *u) { - bus_scope_track_controller(s); - - scope_set_state(s, s->deserialized_state); -+ if (s->state == SCOPE_DEAD && !u->cgroup_path && !set_isempty(u->pids)) { -+ SET_FOREACH(pidp, u->pids, i) { -+ log_unit_info(u, "Rewatch pid from serialized pids. unit: %s, pid: %u", u->id, PTR_TO_UINT32(pidp)); -+ unit_watch_pid(u, PTR_TO_UINT32(pidp)); -+ } -+ } - return 0; - } - -@@ -396,6 +404,8 @@ static int scope_get_timeout(Unit *u, usec_t *timeout) { - } - - static int scope_serialize(Unit *u, FILE *f, FDSet *fds) { -+ Iterator i; -+ void *pidp = NULL; - Scope *s = SCOPE(u); - - assert(s); -@@ -408,6 +418,14 @@ static int scope_serialize(Unit *u, FILE *f, FDSet *fds) { - if (s->controller) - unit_serialize_item(u, f, "controller", s->controller); - -+ /*serialize pids when scope is not started*/ -+ if (s->state == SCOPE_DEAD && !u->cgroup_path && !set_isempty(u->pids)) { -+ SET_FOREACH(pidp, u->pids, i) { -+ log_unit_info(u, "scope is not started yet, pids are serialized. unit: %s, pid: %u", u->id, PTR_TO_UINT32(pidp)); -+ unit_serialize_item_format(u, f, "scope_pids", PID_FMT, PTR_TO_UINT32(pidp)); -+ } -+ } -+ - return 0; - } - -@@ -443,6 +461,21 @@ static int scope_deserialize_item(Unit *u, const char *key, const char *value, F - if (r < 0) - log_oom(); - -+ } else if (streq(key, "scope_pids")) { -+ pid_t pid; -+ -+ if (parse_pid(value, &pid) < 0) -+ log_unit_debug(u, "Failed to parse scope-pid value %s.", value); -+ else { -+ if(!u->pids) { -+ r = set_ensure_allocated(&u->pids, NULL); -+ if (r < 0) -+ return r; -+ } -+ r = set_put(u->pids, pid); -+ if (r < 0) -+ return r; -+ } - } else - log_unit_debug(u, "Unknown serialization key: %s", key); - --- -1.8.3.1 - diff --git a/1615-do-not-finish-job-during-daemon-reload-in-unit_notify.patch b/1615-do-not-finish-job-during-daemon-reload-in-unit_notify.patch deleted file mode 100644 index d29e083491253fe95c06e0b35e564736a1cff97b..0000000000000000000000000000000000000000 --- a/1615-do-not-finish-job-during-daemon-reload-in-unit_notify.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 650352c713aeb3b47807c9699ceeb168f9f880b8 Mon Sep 17 00:00:00 2001 -From: huangkaibin -Date: Tue, 13 Mar 2018 20:51:37 +0800 -Subject: [PATCH] systemd-core: Do not finish job during daemon reloading in - unit_notify. - -1. During daemon reload, a service unit will restore its state from dead to its deserialized state, -and unit_notify will be triggered to notify the state change. -Since JobRemove signal will not be sent during daemon-reload(see details of job_uninstall), -if one job is finished in unit_notify due to the deserialization of a service, the corresponding -job observers(such as systemctl) will not receive any JobRemove signals will hang forever. -2. The above problem will cause a systemctl command to hang forever by using the following steps to reproduce. -a) Ensuere a service(named A)is in running state. -b) execute "systemctl daemon-reload" and "systemctl start A" concurrently -c) the systemctl command will hang for it is in waiting for the JobRemoved signal, but not signals will come from systemd. -3. This patch fix this bug by not finishing job in unit_notify when it is in daemon reload. ---- - src/core/unit.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/src/core/unit.c b/src/core/unit.c -index 9e5f1a8..2da6f61 100644 ---- a/src/core/unit.c -+++ b/src/core/unit.c -@@ -1831,7 +1831,8 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, UnitNotifyFlag - - unit_update_on_console(u); - -- if (u->job) { -+ if (u->job && -+ !(m->n_reloading > 0 && u->job->state != JOB_RUNNING && os == UNIT_INACTIVE)) { /*do not finish job during daemon-reload*/ - unexpected = false; - - if (u->job->state == JOB_WAITING) --- -1.8.3.1 - diff --git a/core-bugfix-call-malloc_trim-to-return-memory-to-OS-immediately.patch b/core-bugfix-call-malloc_trim-to-return-memory-to-OS-immediately.patch deleted file mode 100644 index c9a66d93967a5e3eb91971146a77cc2860afab65..0000000000000000000000000000000000000000 --- a/core-bugfix-call-malloc_trim-to-return-memory-to-OS-immediately.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 95100aa8fa3182f3b066bdc5927b0a78c37550aa Mon Sep 17 00:00:00 2001 -From: huangkaibin -Date: Mon, 23 Jul 2018 17:58:18 +0800 -Subject: [PATCH] systemd-udevd: Call malloc_trim to return memory to OS - immediately in forked children. - -hen there are many events from kernel, memory used to store these events(in event_list) -will be large, may be up to 100M. The forked child process will have a copy of these events and -release them using free. But since glibc will release memory to OS immediately, and if this child process -is stuck due I/O waiting(in D state), these memory will never be released until it is recoveried from D-state. -When there are so many such child processes, it will eat up much memory from system. -This patch fix this problem by invoking glibc's malloc_trim to release memory immediately when the child is forked. ---- - meson.build | 6 ++++++ - src/udev/udevd.c | 12 ++++++++++++ - 2 files changed, 18 insertions(+) - -diff --git a/meson.build b/meson.build -index c14540a..5ee2fa7 100644 ---- a/meson.build -+++ b/meson.build -@@ -518,6 +518,12 @@ else - conf.set10('HAVE_GETRANDOM', have) - endif - -+if cc.has_function('malloc_trim', prefix : '''#include ''') -+ conf.set10('HAVE_MALLOC_TRIM', true) -+else -+ conf.set10('HAVE_MALLOC_TRIM', false) -+endif -+ - ##################################################################### - - sed = find_program('sed') -diff --git a/src/udev/udevd.c b/src/udev/udevd.c -index c1119c3..62f1c44 100644 ---- a/src/udev/udevd.c -+++ b/src/udev/udevd.c -@@ -27,6 +27,9 @@ - #include - #include - #include -+#ifdef HAVE_MALLOC_TRIM -+#include -+#endif - - #include "sd-daemon.h" - #include "sd-event.h" -@@ -233,6 +236,15 @@ static void worker_spawn(Manager *manager, struct event *event) { - - manager->event = sd_event_unref(manager->event); - -+#ifdef HAVE_MALLOC_TRIM -+ /* unused memory inherits from parent has been freed, but it will -+ * not release to OS immediately. We do the optimization by invoking -+ * glibc's malloc_trim to force these unused memory to return to OS immediately. -+ * Otherwise when there are many forked process, it will eat up system's memory, -+ * and will cause OOM problem. -+ */ -+ malloc_trim(0); -+#endif - sigfillset(&mask); - fd_signal = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC); - if (fd_signal < 0) { --- -1.8.3.1 - diff --git a/process-util-log-more-information-when-runnin.patch b/process-util-log-more-information-when-runnin.patch new file mode 100644 index 0000000000000000000000000000000000000000..577d55a637257f65283bdbe7a94fcc6ea0cea23d --- /dev/null +++ b/process-util-log-more-information-when-runnin.patch @@ -0,0 +1,155 @@ +From f5747a70602fa145988a1c4047fe5bd49ebacace Mon Sep 17 00:00:00 2001 +From: licunlong +Date: Tue, 24 Dec 2024 15:44:36 +0800 +Subject: [PATCH] process-util: log more information when running systemctl. + + Print the PID and its cmdline to the system log when a process + runs systemctl command. +--- + src/basic/process-util.c | 31 +++++++++++++++++++++++++++++++ + src/basic/process-util.h | 1 + + src/systemctl/systemctl.c | 12 ++++++++++++ + src/test/test-process-util.c | 22 ++++++++++++++++++++++ + 4 files changed, 66 insertions(+) + +diff --git a/src/basic/process-util.c b/src/basic/process-util.c +index 9e1f1df..c77f509 100644 +--- a/src/basic/process-util.c ++++ b/src/basic/process-util.c +@@ -42,6 +42,7 @@ + #include "stat-util.h" + #include "string-table.h" + #include "string-util.h" ++#include "strv.h" + #include "terminal-util.h" + #include "user-util.h" + #include "utf8.h" +@@ -189,6 +190,36 @@ int get_process_cmdline(pid_t pid, size_t max_columns, ProcessCmdlineFlags flags + return 0; + } + ++int print_process_cmdline_with_arg(pid_t pid, int argc, char *argv[], char *filter[]) { ++ bool is_filtered = false; ++ int r; ++ const char *arg_cmdline = "["; ++ _cleanup_free_ char *cmdline = NULL; ++ ++ r = get_process_cmdline(pid, SIZE_MAX, 0, &cmdline); ++ if (r < 0) { ++ syslog(LOG_INFO, "Failed to get cmdline of PID %d. Ignoring.", pid); ++ return r; ++ } else { ++ for (int i = 0; i < argc; i++ ) { ++ if (filter && strv_find(filter, argv[i])) { ++ is_filtered = true; ++ break; ++ } ++ if (i == 0) { ++ arg_cmdline = strjoina(arg_cmdline, argv[i]); ++ } else { ++ arg_cmdline = strjoina(arg_cmdline, " ", argv[i]); ++ } ++ } ++ if (!is_filtered) { ++ syslog(LOG_INFO, "%s] called by PID %d (%s)", arg_cmdline, pid, cmdline); ++ } ++ return 0; ++ } ++ ++} ++ + int rename_process(const char name[]) { + static size_t mm_size = 0; + static char *mm = NULL; +diff --git a/src/basic/process-util.h b/src/basic/process-util.h +index 41d4759..4d8147e 100644 +--- a/src/basic/process-util.h ++++ b/src/basic/process-util.h +@@ -38,6 +38,7 @@ typedef enum ProcessCmdlineFlags { + + int get_process_comm(pid_t pid, char **name); + int get_process_cmdline(pid_t pid, size_t max_columns, ProcessCmdlineFlags flags, char **line); ++int print_process_cmdline_with_arg(pid_t pid, int argc, char *argv[], char *filter[]); + int get_process_exe(pid_t pid, char **name); + int get_process_uid(pid_t pid, uid_t *uid); + int get_process_gid(pid_t pid, gid_t *gid); +diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c +index 1c01914..edba8e0 100644 +--- a/src/systemctl/systemctl.c ++++ b/src/systemctl/systemctl.c +@@ -4,6 +4,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -9272,6 +9273,14 @@ static int logind_cancel_shutdown(void) { + + static int run(int argc, char *argv[]) { + int r; ++ pid_t ppid; ++ char *filter[] = { ++ "status", "show", "cat", ++ "is-active", "is-failed", "is-enabled", "is-system-running", ++ "list-units", "list-sockets", "list-timers", "list-dependencies", ++ "list-unit-files", "list-machines", "list-jobs", ++ "get-default", "show-environment", NULL ++ }; + + setlocale(LC_ALL, ""); + log_parse_environment(); +@@ -9291,6 +9300,9 @@ static int run(int argc, char *argv[]) { + if (r <= 0) + goto finish; + ++ ppid = getppid(); ++ (void) print_process_cmdline_with_arg(ppid, argc, argv, filter); ++ + if (arg_action != ACTION_SYSTEMCTL && running_in_chroot() > 0) { + if (!arg_quiet) + log_info("Running in chroot, ignoring request."); +diff --git a/src/test/test-process-util.c b/src/test/test-process-util.c +index 8dc9fdd..1cb4ee2 100644 +--- a/src/test/test-process-util.c ++++ b/src/test/test-process-util.c +@@ -601,6 +601,27 @@ static void test_ioprio_class_from_to_string(void) { + test_ioprio_class_from_to_string_one("-1", -1); + } + ++static void test_print_process_cmdline_with_arg(pid_t pid) { ++ char *arg_filter_empty[] = {"", NULL}; ++ char *arg_filter_1_in[] = {"status", NULL}; ++ char *arg_filter_1_no[] = {"stop", NULL}; ++ char *arg_filter_2_in[] = {"restart", "status", NULL}; ++ char *arg_filter_2_no[] = {"restart", "stop", NULL}; ++ char *arg_var_1[1] = {"systemctl"}; ++ char *arg_var_10[10] = {"systemctl", "restart", "1", "2", "3", "4", "5", "6", "7", "8"}; ++ char *arg_var_filter[3] = {"systemctl", "status", "dbus.service"}; ++ assert_se(print_process_cmdline_with_arg(pid, 0, NULL, NULL) >=0); ++ assert_se(print_process_cmdline_with_arg(pid, 1, arg_var_1, NULL) >= 0); ++ assert_se(print_process_cmdline_with_arg(pid, 10, arg_var_10, NULL) >= 0); ++ assert_se(print_process_cmdline_with_arg(897349, 1, arg_var_1, NULL) < 0); ++ assert_se(print_process_cmdline_with_arg(897349, 10, arg_var_10, NULL) < 0); ++ assert_se(print_process_cmdline_with_arg(pid, 3, arg_var_filter, arg_filter_empty) >= 0); ++ assert_se(print_process_cmdline_with_arg(pid, 3, arg_var_filter, arg_filter_1_in) >= 0); ++ assert_se(print_process_cmdline_with_arg(pid, 3, arg_var_filter, arg_filter_1_no) >= 0); ++ assert_se(print_process_cmdline_with_arg(pid, 3, arg_var_filter, arg_filter_2_in) >= 0); ++ assert_se(print_process_cmdline_with_arg(pid, 3, arg_var_filter, arg_filter_2_no) >= 0); ++} ++ + int main(int argc, char *argv[]) { + test_setup_logging(LOG_DEBUG); + +@@ -627,6 +648,7 @@ int main(int argc, char *argv[]) { + test_safe_fork(); + test_pid_to_ptr(); + test_ioprio_class_from_to_string(); ++ test_print_process_cmdline_with_arg(getpid()); + + return 0; + } +-- +2.27.0 + diff --git a/systemd-core-Close-and-free-dbus-when-bus-authentica.patch b/systemd-core-Close-and-free-dbus-when-bus-authentica.patch deleted file mode 100644 index 114f5413a70fdad0afb793d6b2c156557ace87aa..0000000000000000000000000000000000000000 --- a/systemd-core-Close-and-free-dbus-when-bus-authentica.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 1245ae05c6e2ca7a2af055f9c44f19a0db2971a5 Mon Sep 17 00:00:00 2001 -From: yangbin -Date: Thu, 15 Aug 2019 15:24:03 +0800 -Subject: [PATCH 3/3] systemd-core: Close and free dbus when bus authenticating - timedout - -1. when timedout happened on authenticating a private dbus(can be established by systemctl command), -this dbus will never be freed and closed, and will left on systemd permanently even through the client -(for example, systemctl command) has closed the connection. This is because when timedout happend, -the event and also the timer to watch dbus actions is disabled by sd_event_source_set_enabled -from source_dispatch function, and systemd can do nothing on it since this dbus will not be activated again. -2. If a private dbus staying on authenticating state, and when systemd sends a signal message, it will also -add this message to the message write queue of this bus and will never send it out because the dbus is not in running. -systemd does this for it believe that the bus will change from authenticating to running sometime, but actually it will not. -3. When many private dbuses are left as authenticating and many signal messages are sent from dbus, it will eat up our memory -to hold these dbuses and messages, and memory usage of systemd will grow very fast. -4. This patch fix this problem by closing and freeing the dbus when authenticating timedout. ---- - src/libsystemd/sd-bus/sd-bus.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c -index 05cb4c3..65cf449 100644 ---- a/src/libsystemd/sd-bus/sd-bus.c -+++ b/src/libsystemd/sd-bus/sd-bus.c -@@ -2946,6 +2946,11 @@ static int bus_process_internal(sd_bus *bus, bool hint_priority, int64_t priorit - if (IN_SET(r, -ENOTCONN, -ECONNRESET, -EPIPE, -ESHUTDOWN)) { - bus_enter_closing(bus); - r = 1; -+ } else if(r == -ETIMEDOUT && !bus->is_system) { -+ /*close dbus directly when timedout happened and it is a private dbus*/ -+ log_info("Private bus is closed due authentication timedout."); -+ bus_enter_closing(bus); -+ r = 1; - } else if (r < 0) - return r; - --- -2.17.1 - diff --git a/systemd.spec b/systemd.spec index 7548b74c65a38d3b7e8156acd569a7f7225cb449..5f9ad3bcf1717c6252c0b0adcbe8ba63206374f3 100644 --- a/systemd.spec +++ b/systemd.spec @@ -16,7 +16,7 @@ Name: systemd Url: https://www.freedesktop.org/wiki/Software/systemd Version: 243 -Release: 74 +Release: 75 License: MIT and LGPLv2+ and GPLv2+ Summary: System and Service Manager @@ -314,6 +314,7 @@ Patch9010: fix-capsh-drop-but-ping-success.patch Patch9011: 0998-resolved-create-etc-resolv.conf-symlink-at-runtime.patch Patch9012: set-kernel-core_pipe_limit-to-16.patch Patch9013: disable-systemd-timesyncd-networkd-resolved-by-defau.patch +Patch9014: process-util-log-more-information-when-runnin.patch BuildRequires: gcc, gcc-c++ BuildRequires: libcap-devel, libmount-devel, pam-devel, libselinux-devel @@ -1705,6 +1706,16 @@ fi %exclude /usr/share/man/man3/* %changelog +* Fri Feb 7 2025 Han Jinpeng - 243-75 +- 1. Enhance the logging function of the systemctl command + Add process-util-log-more-information-when-runnin.patch + 2. remove redundant patch + del 1610-add-new-rules-for-lower-priority-events-to-preempt.patch + core-bugfix-call-malloc_trim-to-return-memory-to-OS-immediately.patch + 1612-serialize-pids-for-scope-when-not-started.patch + systemd-core-Close-and-free-dbus-when-bus-authentica.patch + 1615-do-not-finish-job-during-daemon-reload-in-unit_notify.patch + * Fri Dec 29 2023 wangyuhang - 243-74 - actually check authenticated flag of SOA transaction in resolved