summaryrefslogtreecommitdiffstats
path: root/src/basic/procfs-util.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Rename def.h to constants.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+1
| | | | | | The name "def.h" originates from before the rule of "no needless abbreviations" was established. Let's rename the file to clarify that it contains a collection of various semi-related constants.
* oomd: calculate 'used' memory with MemAvailable instead of MemFreeNick Rosbrook2022-04-051-6/+6
| | | | | | | | | | | | | | The calculation for used memory in oomd_system_context_acquire is given by MemTotal - MemFree from /proc/meminfo. This is too strict of a calculation because it does not consider memory that is still available for starting new applictions without swapping (MemAvailable). As a result, systemd-oomd can start to kill processes before it is necessary. This is more apparent on systems with low swap space. Instead, compute 'used' memory as MemTotal - MemAvailable in oomd_system_context_acquire and procfs_memory_get (which is used by oomd_cgroup_context_acquire). And, rename oomd_mem_free_below to oomd_mem_available_below for clarity.
* procfs-util: fix confusion wrt. quantity limit and maximum valueZbigniew Jędrzejewski-Szmek2021-11-031-40/+13
| | | | | | | | | | | | | | | | | | | From packit/rawhide-arm64 logs: Assertion 'limit >= INT_MAX || get_process_ppid(limit+1, NULL) == -ESRCH' failed at src/test/test-process-util.c:855, function test_get_process_ppid(). Aborting. ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― The kernel has a few different limits. In particular kernel.threads-max can be set to some lower value, and kernel.pid_max can be set to a higher value. This is nice because it reduces PID reuse, even if the number of threads that is allowed is limited. But the tests assumed that we cannot have a thread with PID above MIN(kernel.threads-max, kernel.pid_max-1), which is not valid. So let's rework the whole thing: let's expose the helpers to read kernel.threads-max and kernel.pid_max, and print what they return in tests. procfs_tasks_get_limit() was something that is only used in tests, and wasn't very well defined, so let's drop it. Fixes #21193.
* alloc-util: add strdupa_safe() + strndupa_safe() and use it everywhereLennart Poettering2021-10-141-1/+1
| | | | | | | | | | | | | Let's define two helpers strdupa_safe() + strndupa_safe() which do the same as their non-safe counterparts, except that they abort if called with allocations larger than ALLOCA_MAX. This should ensure that all our alloca() based allocations are subject to this limit. afaics glibc offers three alloca() based APIs: alloca() itself, strndupa() + strdupa(). With this we have now replacements for all of them, that take the limit into account.
* variuos: add missing includesZbigniew Jędrzejewski-Szmek2021-09-221-0/+1
|
* oomd: review follow ups to #20020Anita Zhang2021-07-021-3/+11
|
* oomd: switch system context parsing to use /proc/meminfoAnita Zhang2021-06-301-21/+39
| | | | | Makes it easier in the next commits to unify on one way to read swap and memory info.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* Replace gendered pronouns with gender neutral ones. (#16844)PhoenixDiscord2020-08-271-1/+1
|
* procfs-util: expose functionality to query total memoryZbigniew Jędrzejewski-Szmek2019-01-221-4/+5
| | | | | | | | procfs_memory_get_current is renamed to procfs_memory_get_used, because "current" can mean anything, including total memory, used memory, and free memory, as long as the value is up to date. No functional change.
* procfs-util: drop unnecessary zero initializations (#8321)Lennart Poettering2018-03-011-2/+1
| | | Follow-up for #8149.
* procfs-util: add APIs to get consumed CPU time and used memory from /procLennart Poettering2018-02-091-0/+130
| | | | | | This is preparation for emulating the "usage_usec" keyed attribute of the "cpu.stat" property of the root cgroup from data in /proc. Similar, for emulating the "memory.current" attribute.
* util-lib: add new procfs-util.[ch] API for dealing with tasks limitsLennart Poettering2018-01-221-0/+138
As it turns out the limit on concurrent tasks on Linux nasty to determine, hence let's appropriate helpers for this.