1
0
mirror of https://github.com/systemd/systemd synced 2025-11-20 09:14:46 +01:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Luca Boccassi
3b11139c0d ci: re-enable bpf-framework option for build and unit test jobs
Use the same trickery we do in the package build and search for
the actual bpftool binary. For the CI job any one we find is
good enough.
When we switch all jobs to 26.04 we can drop all of this.

This reverts commit cc814110af7a453db898ea2990a0281616d5ceff.
2025-10-17 15:08:54 +01:00
Frantisek Sumsal
1ec5d43a0e test: let kernel OOM-kill a child process instead of the main one
This test occasionally fails due to a race where systemd processes
kernel's SIGKILL before the OOM notification, so the test service dies
with Result=signal instead of the expected Result=oom-kill:

[   51.008765] TEST-55-OOMD.sh[906]: + systemd-run --wait --unit oom-kill -p OOMPolicy=kill -p Delegate=yes -p DelegateSubgroup=init.scope /tmp/script.sh
[   51.048747] TEST-55-OOMD.sh[907]: Running as unit: oom-kill.service; invocation ID: 456645347d554ea2878463404b181bd8
[   51.066296] sysrq: Manual OOM execution
[   51.066596] kworker/1:0 invoked oom-killer: gfp_mask=0xcc0(GFP_KERNEL), order=-1, oom_score_adj=0
[   51.066915] CPU: 1 UID: 0 PID: 27 Comm: kworker/1:0 Not tainted 6.17.1-arch1-1 #1 PREEMPT(full)  d2b229857b2eb4001337041f41d3c4f131433540
[   51.066919] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS Arch Linux 1.17.0-2-2 04/01/2014
[   51.066921] Workqueue: events moom_callback
[   51.066928] Call Trace:
[   51.066931]  <TASK>
[   51.066936]  dump_stack_lvl+0x5d/0x80
[   51.066942]  dump_header+0x43/0x1aa
<...snip...>
[   51.087814] 47583 pages reserved
[   51.087969] 0 pages cma reserved
[   51.088208] 0 pages hwpoisoned
[   51.088519] Out of memory: Killed process 908 (sleep) total-vm:3264kB, anon-rss:256kB, file-rss:1916kB, shmem-rss:0kB, UID:0 pgtables:44kB oom_score_adj:1000
[   51.090263] TEST-55-OOMD.sh[907]:           Finished with result: signal
[   51.094416] TEST-55-OOMD.sh[907]: Main processes terminated with: code=killed, status=9/KILL
[   51.094898] TEST-55-OOMD.sh[907]:                Service runtime: 58ms
[   51.095436] TEST-55-OOMD.sh[907]:              CPU time consumed: 22ms
[   51.095854] TEST-55-OOMD.sh[907]:                    Memory peak: 1.6M (swap: 0B)
[   51.096722] TEST-55-OOMD.sh[912]: ++ systemctl show oom-kill -P Result
[   51.106549] TEST-55-OOMD.sh[879]: + assert_eq signal oom-kill
[   51.107394] TEST-55-OOMD.sh[913]: + set +ex
[   51.108256] TEST-55-OOMD.sh[913]: FAIL: expected: 'oom-kill' actual: 'signal'
[FAILED] Failed to start TEST-55-OOMD.service.

To mitigate this, let's spawn a child process and move it to the
subcgroup to get killed instead of the main process, so systemd has more
time to react to the OOM notification and terminate the service with the
expected oom-kill result.
2025-10-17 15:19:16 +02:00
Daan De Meyer
b8ee7c2206 tree-wide: Various forward header cleanups
- Make sure forward headers have the iwyu pragma to always keep them
- Make sure we always include the daemon specific forward header
  instead of shared-forward.h
- Remove shared-forward.h include where the daemon specific forward
  header is already included
2025-10-17 21:11:23 +09:00
Daan De Meyer
cc814110af ci: Disable bpf-framework option for build and unit test jobs
/usr/sbin/bpftool is completely broken inside containers on
Ubuntu which makes meson blow up so disable the bpf-framework
stuff to avoid the issue.

TODO: Drop when we move off Ubuntu Noble as this will be fixed
in the next Ubuntu LTS release.
2025-10-17 21:11:23 +09:00
46 changed files with 81 additions and 34 deletions

View File

@ -47,6 +47,7 @@ PACKAGES=(
libxkbcommon-dev
libxtables-dev
libzstd-dev
linux-tools-generic
mold
mount
net-tools
@ -143,6 +144,12 @@ sudo apt-get -y install "${PACKAGES[@]}"
pip3 install --user -r .github/workflows/requirements.txt --require-hashes --break-system-packages
export PATH="$HOME/.local/bin:$PATH"
# TODO: drop after we switch to ubuntu 26.04
bpftool_dir=$(dirname "$(find /usr/lib/linux-tools/ /usr/lib/linux-tools-* -name 'bpftool' -perm /u=x 2>/dev/null | sort -r | head -n1)")
if [ -n "$bpftool_dir" ]; then
export PATH="$bpftool_dir:$PATH"
fi
if [[ -n "$CUSTOM_PYTHON" ]]; then
# If CUSTOM_PYTHON is set we need to pull jinja2 from pip, as a local interpreter is used
pip3 install --user --break-system-packages jinja2

View File

@ -18,6 +18,7 @@ ADDITIONAL_DEPS=(
libtss2-dev
libxkbcommon-dev
libzstd-dev
linux-tools-generic
python3-libevdev
python3-pip
python3-pyelftools
@ -74,6 +75,12 @@ for phase in "${PHASES[@]}"; do
capsh --drop=all -- -c "stat $PWD/meson.build"
;;
RUN|RUN_GCC|RUN_CLANG|RUN_CLANG_RELEASE)
# TODO: drop after we switch to ubuntu 26.04
bpftool_dir=$(dirname "$(find /usr/lib/linux-tools/ /usr/lib/linux-tools-* -name 'bpftool' -perm /u=x 2>/dev/null | sort -r | head -n1)")
if [ -n "$bpftool_dir" ]; then
export PATH="$bpftool_dir:$PATH"
fi
if [[ "$phase" =~ ^RUN_CLANG ]]; then
export CC=clang
export CXX=clang++
@ -105,6 +112,12 @@ for phase in "${PHASES[@]}"; do
TZ=GMT+12 meson test "${MESON_TEST_ARGS[@]}" -C build --print-errorlogs
;;
RUN_ASAN_UBSAN|RUN_GCC_ASAN_UBSAN|RUN_CLANG_ASAN_UBSAN|RUN_CLANG_ASAN_UBSAN_NO_DEPS)
# TODO: drop after we switch to ubuntu 26.04
bpftool_dir=$(dirname "$(find /usr/lib/linux-tools/ /usr/lib/linux-tools-* -name 'bpftool' -perm /u=x 2>/dev/null | sort -r | head -n1)")
if [ -n "$bpftool_dir" ]; then
export PATH="$bpftool_dir:$PATH"
fi
MESON_ARGS=(--optimization=1)
if [[ "$phase" =~ ^RUN_CLANG_ASAN_UBSAN ]]; then

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
#include "core-forward.h"
int get_core_audit_fd(void);
void close_core_audit_fd(void);

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
#include "core-forward.h"
int clock_reset_timewarp(void);
void clock_apply_epoch(bool allow_backwards);

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
/* IWYU pragma: always_keep */
#include "conf-parser-forward.h" /* IWYU pragma: export */
#include "shared-forward.h" /* IWYU pragma: export */
#include "unit-def.h" /* IWYU pragma: export */

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
#include "core-forward.h"
typedef enum CrashAction {
CRASH_FREEZE,

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
#include "core-forward.h"
typedef enum KillMode {
/* The kill mode is a property of a unit. */

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
#include "core-forward.h"
#include "crash-handler.h"
extern bool arg_dump_core;

View File

@ -6,7 +6,7 @@
#include "cgroup.h"
#include "common-signal.h"
#include "execute.h"
#include "shared-forward.h"
#include "core-forward.h"
#include "log.h"
#include "path-lookup.h"
#include "show-status.h"

View File

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
#include "core-forward.h"
int mac_selinux_setup(bool *loaded_policy);

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
#include "core-forward.h"
/* Manager status */

View File

@ -7,6 +7,6 @@
Nathaniel Chen <nathaniel.chen@intel.com>
***/
#include "shared-forward.h"
#include "core-forward.h"
int mac_smack_setup(bool *loaded_policy);

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
#include "core-forward.h"
/* Flags that identify the various "atomic" behaviours a specific dependency type implies. Each dependency is
* a combination of one or more of these flags that define what they actually entail. */

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
#include "core-forward.h"
int unit_cgroup_context_build_json(sd_json_variant **ret, const char *name, void *userdata);
int unit_cgroup_runtime_build_json(sd_json_variant **ret, const char *name, void *userdata);

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
#include "core-forward.h"
int rlimit_build_json(sd_json_variant **ret, const char *name, void *userdata);
int rlimit_table_build_json(sd_json_variant **ret, const char *name, void *userdata);

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
#include "core-forward.h"
int vl_method_get_user_record(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata);
int vl_method_get_group_record(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata);

View File

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
#include "core-forward.h"
int vl_method_describe_manager(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata);

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
#include "core-forward.h"
#define VARLINK_ERROR_UNIT_NO_SUCH_UNIT "io.systemd.Unit.NoSuchUnit"

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
/* IWYU pragma: always_keep */
#include "conf-parser-forward.h" /* IWYU pragma: export */
#include "shared-forward.h" /* IWYU pragma: export */

View File

@ -1,7 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
#include "homed-forward.h"
#include "pidref.h"
#include "stat-util.h"

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
/* IWYU pragma: always_keep */
#include "shared-forward.h" /* IWYU pragma: export */
typedef enum HomeSetupFlags HomeSetupFlags;

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
/* IWYU pragma: always_keep */
#include "conf-parser-forward.h" /* IWYU pragma: export */
#include "shared-forward.h" /* IWYU pragma: export */

View File

@ -1,7 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "sd-forward.h"
/* IWYU pragma: always_keep */
#include "sd-forward.h" /* IWYU pragma: export */
typedef enum BusAuth BusAuth;
typedef enum BusSlotType BusSlotType;

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
/* IWYU pragma: always_keep */
#include "conf-parser-forward.h" /* IWYU pragma: export */
#include "shared-forward.h" /* IWYU pragma: export */

View File

@ -1,7 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
#include "list.h"
#include "logind-forward.h"
#include "time-util.h"

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
/* IWYU pragma: always_keep */
#include "shared-forward.h" /* IWYU pragma: export */
typedef struct Machine Machine;

View File

@ -2,7 +2,6 @@
#pragma once
#include "firewall-util.h"
#include "shared-forward.h"
#include "in-addr-util.h"
#include "networkd-forward.h"
#include "networkd-util.h"

View File

@ -8,7 +8,6 @@
#include <linux/neighbour.h>
#include <net/ethernet.h>
#include "shared-forward.h"
#include "in-addr-util.h"
#include "networkd-forward.h"

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
/* IWYU pragma: always_keep */
#include "conf-parser-forward.h" /* IWYU pragma: export */
#include "shared-forward.h" /* IWYU pragma: export */

View File

@ -4,7 +4,6 @@
#include <linux/nl80211.h>
#include "ether-addr-util.h"
#include "shared-forward.h"
#include "network-util.h"
#include "networkd-bridge-vlan.h"
#include "networkd-forward.h"

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
/* IWYU pragma: always_keep */
#include "shared-forward.h" /* IWYU pragma: export */
typedef struct Manager Manager;

View File

@ -2,7 +2,6 @@
#pragma once
#include "dns-def.h"
#include "shared-forward.h"
#include "list.h"
#include "ratelimit.h"
#include "resolve-util.h"

View File

@ -1,7 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
#include "in-addr-util.h"
#include "list.h"
#include "resolved-conf.h"

View File

@ -1,7 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
#include "list.h"
#include "resolved-dns-packet.h"
#include "resolved-dnstls.h"

View File

@ -2,7 +2,7 @@
#pragma once
#include "shared-forward.h"
#include "resolved-forward.h"
extern const BusObjectImplementation dnssd_object;

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
/* IWYU pragma: always_keep */
#include "conf-parser-forward.h" /* IWYU pragma: export */
#include "shared-forward.h" /* IWYU pragma: export */

View File

@ -4,7 +4,6 @@
#include <sys/stat.h>
#include "common-signal.h"
#include "shared-forward.h"
#include "list.h"
#include "resolve-util.h"
#include "resolved-dns-browse-services.h"

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
/* IWYU pragma: always_keep */
#include "shared-forward.h" /* IWYU pragma: export */
typedef struct Context Context;

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
/* IWYU pragma: always_keep */
#include "conf-parser-forward.h" /* IWYU pragma: export */
#include "shared-forward.h" /* IWYU pragma: export */

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include "shared-forward.h"
#include "udev-forward.h"
#include "udev-event.h"
typedef struct UdevBuiltin {

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include "shared-forward.h"
#include "udev-forward.h"
int device_add_errno(sd_device *dev, int error);
int device_add_exit_status(sd_device *dev, int status);

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
/* IWYU pragma: always_keep */
#include "shared-forward.h" /* IWYU pragma: export */
typedef struct UdevCtrl UdevCtrl;

View File

@ -3,7 +3,6 @@
#include "sd-event.h"
#include "shared-forward.h"
#include "list.h"
#include "udev-config.h"
#include "udev-forward.h"

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include "shared-forward.h"
#include "udev-forward.h"
int udev_node_apply_permissions(
sd_device *dev,

View File

@ -8,7 +8,7 @@
#include "device-private.h"
#include "device-util.h"
#include "errno-util.h"
#include "shared-forward.h"
#include "udev-forward.h"
/* Each trace point can have different number of additional arguments. Note that when the macro is used only
* additional arguments are listed in the macro invocation!

View File

@ -301,6 +301,7 @@ testcase_reload() {
testcase_kernel_oom() {
cat >/tmp/script.sh <<"EOF"
#!/usr/bin/env bash
set -x
choom --adjust '+1000' -- bash -c 'echo f >/proc/sysrq-trigger && exec sleep infinity'
choom --adjust '+1000' -p $$
echo f >/proc/sysrq-trigger
@ -324,12 +325,22 @@ EOF
cat >/tmp/script.sh <<"EOF"
#!/usr/bin/env bash
set -x
echo '+memory' >/sys/fs/cgroup/system.slice/oom-kill.service/cgroup.subtree_control
mkdir /sys/fs/cgroup/system.slice/oom-kill.service/sub
echo 1 >/sys/fs/cgroup/system.slice/oom-kill.service/sub/memory.oom.group
echo $$ >/sys/fs/cgroup/system.slice/oom-kill.service/sub/cgroup.procs
choom --adjust '+1000' -p $$
echo f >/proc/sysrq-trigger
# Start a child process in the subcgroup that will trigger OOM and be killed but keep the main process
# outside the subcgroup to avoid a race condition where the kernel SIGKILLs the main process before systemd
# can process the OOM notification. With the main process still alive, systemd should have time to receive
# the OOM event and enter the 'oom-kill' state before the service exits.
(
echo $BASHPID >/sys/fs/cgroup/system.slice/oom-kill.service/sub/cgroup.procs
choom --adjust '+1000' -p $BASHPID
echo f >/proc/sysrq-trigger
exec sleep infinity
) &
wait $! || :
exec sleep infinity
EOF
chmod +x /tmp/script.sh