1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00
Commit Graph

50522 Commits

Author SHA1 Message Date
Frantisek Sumsal
34fde9f898 test: check if the unit file fuzzer corpora is up to date
This follows a similar pattern we already have in place for
networkd-related directives.
2021-04-05 14:41:05 +01:00
Anita Zhang
685b0985f0 oomd: threshold swap kill candidates to usages of more than 5%
In some instances, particularly with swap on zram, swap used will be high
while there is still a lot of memory available. FB OOMD handles this by
thresholding kills to X% of total swap usage. Let's do the same thing here.

Anecdotally with these thresholds and my laptop which is exclusively swap
on zram I can sit at 0K / 4G swap free with most of memory free and
systemd-oomd doesn't kill anything.

Partially addresses aggressive kill behavior from
https://bugzilla.redhat.com/show_bug.cgi?id=1941170
2021-04-05 02:04:49 -07:00
Anita Zhang
cb13961ada oomd: don't get pressure candidates on every interval
Only start collecting candidates for a memory pressure kill when we're
hitting the limit (but before the duration hitting that limit is
exceeded). This brings CPU util from ~1% to 0.3%.

Addresses CPU util from
https://bugzilla.redhat.com/show_bug.cgi?id=1941340
and
https://bugzilla.redhat.com/show_bug.cgi?id=1944646
2021-04-05 02:01:32 -07:00
Frantisek Sumsal
080a602771 fuzzer: add a test case for #19178 2021-04-03 10:38:06 +01:00
Luca Boccassi
1270e56526
Merge pull request #19179 from anitazha/buildandtest
test-oomd-util: fix running in mkosi
2021-04-02 17:56:13 +01:00
Viktor Mihajlovski
a496a238e8 udev: fix slot based network names on s390
The s390 PCI driver assigns the hotplug slot name from the
function_id attribute of the PCI device using a 8 char hexadecimal
format to match the underlying firmware/hypervisor notation.

Further, there's always a one-to-one mapping between a PCI
function and a hotplug slot, as individual functions can
hot plugged even for multi-function devices.

As the generic matching code will always try to parse the slot
name in /sys/bus/pci/slots as a positive decimal number, either
a wrong value might be produced for ID_NET_NAME_SLOT if
the slot name consists of decimal numbers only, or none at all
if a character in the range from 'a' to 'f' is encountered.

Additionally, the generic code assumes that two interfaces
share a hotplug slot, if they differ only in the function part
of the PCI address. E.g., for an interface with the PCI address
dddd:bb:aa.f, it will match the device to the first slot with
an address dddd:bb:aa. As more than one slot may have this address
for the s390 PCI driver, the wrong slot may be selected.

To resolve this we're adding a new naming schema version with the
flag NAMING_SLOT_FUNCTION_ID, which enables the correct matching
of hotplug slots if the device has an attribute named function_id.
The ID_NET_NAME_SLOT property will only be produced if there's
a file /sys/bus/pci/slots/<slotname> where <slotname> matches
the value of /sys/bus/pci/devices/.../function_id in 8 char
hex notation.

Fixes #19016
See also #19078
2021-04-02 18:08:23 +02:00
Zbigniew Jędrzejewski-Szmek
bd6ea22920
Merge pull request #18717 from yuwata/sd-device-monitor-introduce-more-filters
sd-device-monitor: introduce two new filters and use them in dissect-image.c
2021-04-02 15:53:16 +02:00
Carlo Teubner
6d3831cee5 docs: use current spelling "macOS" not "OS X" etc. 2021-04-02 10:53:26 +01:00
Yu Watanabe
0a8f9bc6bb dissect-image: move parent device check into device_is_partition()
Checking parent for enumerated devices is mostly redundant. Just for
safety.
2021-04-02 15:10:09 +09:00
Yu Watanabe
11368b694e dissect-image: also check devtype in device_is_partition()
This should be mostly redundant. Just for safety.
2021-04-02 15:10:09 +09:00
Yu Watanabe
210e1cd6e6 dissect-image: filter out enumerated or triggered devices without "partition" sysattr
This also adds more filters for device enumerator and monitor.
These newly added filters should be mostly redundant. But this hides
spurious error in sd_device_get_sysattr_value(). See,
https://github.com/systemd/systemd/pull/18684#discussion_r579700977
2021-04-02 15:10:09 +09:00
Yu Watanabe
def366933c test: add tests for filters of sd-device-monitor 2021-04-02 15:10:09 +09:00
Yu Watanabe
b8a0edbb2a sd-device-monitor: introduce sd_device_monitor_filter_add_match_parent() 2021-04-02 15:10:09 +09:00
Yu Watanabe
bcfe746ba7 sd-device-enumerator: also move match_parent() to device-util.[ch] 2021-04-02 15:10:09 +09:00
Yu Watanabe
d9b030b673 sd-device-monitor: introduce sd_device_monitor_filter_add_match_sysattr() 2021-04-02 15:10:09 +09:00
Yu Watanabe
ac790e8bfc sd-device-enumerator: move match_sysattr() to device-util.[ch]
It will be used by sd-device-monitor in later commits.
2021-04-02 15:10:07 +09:00
Yu Watanabe
112e6dd106 sd-device-monitor: split passes_filter() into two parts 2021-04-02 15:09:03 +09:00
Anita Zhang
080ca0d830 test-oomd-util: fix running in mkosi
When this test is run in mkosi, the previously tested cgroup that we write
xattrs into and the root cgroup are the same.

Since the root cgroup is a live cgroup anyways (vs. the test cgroups which are
remade each time) let's generate the expected preference values from reading
the xattrs instead of assuming it will be NONE.
2021-04-01 21:23:24 -07:00
Anita Zhang
a858355e4a oomd: force DefaultMemoryPressureDurationSec= to be greater than or equal 1 sec 2021-04-01 19:53:42 -07:00
Anita Zhang
14140b3544 oomd: delete unused variables 2021-04-01 19:53:13 -07:00
Anita Zhang
69c8f0255a oomd: rename last_hit_mem_pressure_limit -> mem_pressure_limit_hit_start
Since this is only changed the first time the limit is hit (and remains
set as long as the pressure remains over), I changed the name to better
reflect that.

Keeps consistent with "last_had_mem_reclaim" which is actually updated
every time there is reclaim activity.
2021-04-01 19:52:49 -07:00
Anita Zhang
df637ede7b oomd: rework memory reclaim detection logic
systemd-oomd only monitors and kills within a selected cgroup subtree
For memory pressure kills, this means it's unnecessary to get the
pgscan rate across all the monitored memory pressure cgroups.
The increase will show up whether we do a total sum or not, but since
we only care about the increase in the subtree we're about to target
for a kill, we can simplify the code a bit by not doing this total sum.
2021-04-01 19:51:54 -07:00
Anita Zhang
37d8020ccc oomd: refactor pgscan_rate calculation into helper 2021-04-01 19:45:24 -07:00
Anita Zhang
81d66fab34 oomd: split swap and mem pressure event timers
One thing that came out of the test week is that systoomd needs to poll
more frequently so as not to race with the kernel oom killer in
situations where memory is eaten quickly. Memory pressure counters are
lagging so it isn't worthwhile to change the current read rate; however swap
is not lagging and can be checked more frequently.

So let's split these into 2 different timer events. As a result, swap
now also doesn't have to be subject to the post-action (post-kill) delay
that we need for memory pressure events.

Addresses some of slowness to kill discussed in
https://bugzilla.redhat.com/show_bug.cgi?id=1941340
2021-04-01 19:44:14 -07:00
Anita Zhang
ea460d7964 meson: link with libm for math functions
Fixes this error I got building on F33:
  /usr/bin/ld: test-random-util.p/src_test_test-random-util.c.o: undefined
  reference to symbol 'sqrt@@GLIBC_2.2.5'
  /usr/bin/ld: /usr/lib64/libm.so.6: error adding symbols: DSO missing
  from command line
2021-04-01 18:45:48 -07:00
Joerg Behrmann
8ab34a49db systemd-notify: Fix return value of --booted 2021-04-01 20:42:22 +01:00
Luca Boccassi
28a9744673
Merge pull request #19175 from keszybz/maybe-unitialized-warning-2
Third batch of fixes and suppressions for maybe-unitialized warnings
2021-04-01 19:45:08 +01:00
Luca Boccassi
677ba9d062 resolved: use _cleanup_(gcry_md_closep) in one more place
Documentation says gcry_md_close will ignore a NULL input so should be safe:

https://gnupg.org/documentation/manuals/gcrypt/Working-with-hash-algorithms.html

Makes Coverity happy, follow-up for 248b1e0aa4

CID #1451555
2021-04-01 15:00:51 +01:00
Zbigniew Jędrzejewski-Szmek
0f4b6e59bd libudev: fix return of udev_monitor_filter_add_match_subsystem_devtype()
Follow-up for 7117842657.

sd_device_monitor_filter_add_match_subsystem_devtype() now returns 1 to signify
that something was done, and 0 to signify that nothing was done, but
udev_monitor_filter_add_match_subsystem_devtype() needs to return 0 as documented.

udev_monitor_filter_add_match_tag() is adjusted to match.

This makes gdm start successfully here again.
Before, it would just not boot, with nothing very obvious in the logs:
gdm[1756]: Gdm: GdmDisplay: Session never registered, failing

Replaces #19171.
2021-04-01 14:59:58 +01:00
Zbigniew Jędrzejewski-Szmek
e7d48709ed resolved: avoid passing unitialized variable
The issue was introduced in the refactoring in 775ae35403.
We would pass an initialized value to a helper function. We would only *use*
it if it was initialized. But the mere passing of an unitialized variable is
UB, so let's not do that. This silences a gcc warning.
2021-04-01 12:02:25 +02:00
Zbigniew Jędrzejewski-Szmek
aff81b1851 various: silence gcc warnings
AFAICT, gcc is just being stupid in all those cases.
2021-04-01 12:02:25 +02:00
Zbigniew Jędrzejewski-Szmek
1f8fb21c42 shared/dissect-image: silence gcc warning 2021-04-01 12:02:25 +02:00
Zbigniew Jędrzejewski-Szmek
04ab97a829 sd-netlink: drop unnecessary forward declaration 2021-04-01 12:02:25 +02:00
Zbigniew Jędrzejewski-Szmek
c03916164d backlight: refactor get_max_brightness() to appease gcc
The old code was just fine, but gcc doesn't understand that max_brightness is
initialized. Let's rework it a bit to move some logic to the main function. Now
get_max_brightness() just retrieves and parses the attribute, and the main
function decides what to do with it.
2021-04-01 12:01:58 +02:00
Zbigniew Jędrzejewski-Szmek
0246f42980 test-device-util: let's verify that we return proper error from log_device_* 2021-04-01 11:44:42 +02:00
Zbigniew Jędrzejewski-Szmek
023e75df4c sd-device: header needs an include because it uses sd_device type 2021-04-01 11:30:25 +02:00
Luca Boccassi
4cf1b41568
Merge pull request #19168 from keszybz/nss-resolve-unfoobar
Fix nss-resolve reverse alias lookups
2021-04-01 10:07:46 +01:00
Luca Boccassi
bd506dfb5e
Merge pull request #19169 from keszybz/reenable-maybe-unitialized-warning
Fix a bunch of maybe-unitialized warnings but don't enable the warning yet
2021-04-01 09:36:46 +01:00
Deepak Rawat
1d8a16f1f4 logind: Rename kexec reboot flag
Also change error message to be more meanigful. No change in
functionality.

Fixes: 0d96caa5c0
2021-03-31 21:43:45 +02:00
Zbigniew Jędrzejewski-Szmek
1dbd0bdb3a basic/env-util: silence two gcc warnings 2021-03-31 18:24:54 +02:00
Zbigniew Jędrzejewski-Szmek
c26f7dd9f0 cryptsetup: silence gcc maybe-unused warning
Simplify one debug stmt while at it.
2021-03-31 18:24:54 +02:00
Zbigniew Jędrzejewski-Szmek
703e2870b1 systemctl: silence gcc maybe-unused warning 2021-03-31 18:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
1c93632ead shared/pretty-print: silence gcc warning
gcc was very unhappy for some reason:

[988/1664] Compiling C object systemd-oomd.p/src_oom_oomd.c.o
In file included from ../src/basic/path-util.h:10,
                 from ../src/shared/pretty-print.c:14,
                 from ../src/oom/oomd.c:15:
../src/shared/pretty-print.c: In function ‘conf_files_cat’:
../src/basic/strv.h:123:32: warning: ‘prefixes’ may be used uninitialized [-Wmaybe-uninitialized]
  123 |         for ((s) = (l); (s) && *(s); (s)++)
      |                                ^
In file included from ../src/oom/oomd.c:15:
../src/shared/pretty-print.c:283:16: note: ‘prefixes’ was declared here
  283 |         char **prefixes, **prefix;
      |                ^~~~~~~~
../src/shared/pretty-print.c:305:12: warning: ‘is_collection’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  305 |         if (!is_collection) {
      |            ^
../src/shared/pretty-print.c:301:13: warning: ‘extension’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  301 |         r = conf_files_list_strv(&files, extension, root, 0, (const char* const*) dirs);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Maybe this is caused by the statis char** variables?
2021-03-31 18:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
1a2948fece core: silence gcc warning 2021-03-31 18:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
487c123a32 shared/bus-message-util: silence gcc warning
[1/429] Compiling C object src/shared/libsystemd-shared-248.a.p/bus-message-util.c.o
../src/shared/bus-message-util.c: In function ‘bus_message_read_dns_servers’:
../src/shared/bus-message-util.c:165:21: warning: ‘family’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  165 |                 r = in_addr_full_new(family, &a, port, 0, server_name, dns + n);
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/shared/bus-message-util.c:165:21: warning: ‘port’ may be used uninitialized in this function [-Wmaybe-uninitialized]
../src/shared/bus-message-util.c:165:21: warning: ‘server_name’ may be used uninitialized in this function [-Wmaybe-uninitialized]

The warning would be there despite all the asserts in bus_error_setfv() and
sd_bus_error_set(). So let's add an explicit assert.
2021-03-31 18:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
9fd8d678ba shared/conf-parser: fix unitialized variable
Introduced in 4f9ff96a55.
2021-03-31 18:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
0a94e77ed4 test-capability: silence gcc warning
[2/3] Compiling C object test-capability.p/src_test_test-capability.c.o
../src/test/test-capability.c: In function ‘main’:
../src/test/test-capability.c:270:12: warning: ‘run_ambient’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  270 |         if (run_ambient)
      |            ^

gcc-11.0.1-0.3.fc34.x86_64
2021-03-31 18:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
bc20c31bbc basic/cgroup-util: silence gcc warning about unitialized variable 2021-03-31 18:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
bfd9bfccce sd-event: silence gcc's maybe-unitialized warning
[91/180] Compiling C object libsystemd.a.p/src_libsystemd_sd-event_sd-event.c.o
In file included from ../src/basic/macro.h:12,
                 from ../src/basic/alloc-util.h:9,
                 from ../src/libsystemd/sd-event/sd-event.c:11:
../src/libsystemd/sd-event/sd-event.c: In function ‘sd_event_wait’:
../src/fundamental/macro-fundamental.h:86:63: warning: ‘child_min_priority’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   86 |                 UNIQ_T(A, aq) < UNIQ_T(B, bq) ? UNIQ_T(A, aq) : UNIQ_T(B, bq); \
      |                                                               ^
../src/libsystemd/sd-event/sd-event.c:3983:45: note: ‘child_min_priority’ was declared here
 3983 |                 int64_t epoll_min_priority, child_min_priority;
      |                                             ^~~~~~~~~~~~~~~~~~

Alternative to #19159.
2021-03-31 18:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
4990d4b8ff varlink: use two local flag variables to silence gcc warning
[59/655] Compiling C object src/shared/libsystemd-shared-248.a.p/varlink.c.o
../src/shared/varlink.c: In function ‘varlink_write’:
../src/shared/varlink.c:459:12: warning: ‘n’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  459 |         if (n < 0) {
      |            ^
../src/shared/varlink.c: In function ‘varlink_process’:
../src/shared/varlink.c:541:12: warning: ‘n’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  541 |         if (n < 0) {
      |            ^
../src/shared/varlink.c:486:17: note: ‘n’ was declared here
  486 |         ssize_t n;
      |                 ^
2021-03-31 18:24:53 +02:00