summaryrefslogtreecommitdiffstats
path: root/src/core/swap.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-11-11 14:11:02 +0100
committerGitHub <noreply@github.com>2020-11-11 14:11:02 +0100
commit23dce98e89616092007005692a4574ab908db5a6 (patch)
tree829c00842440ba9fb8c42d765b25b341860ba45c /src/core/swap.c
parentNEWS,man: tweak the description of FixedRandomDelay= (diff)
parentuser: move "extrinsic" units to their root slice (diff)
downloadsystemd-23dce98e89616092007005692a4574ab908db5a6.tar.xz
systemd-23dce98e89616092007005692a4574ab908db5a6.zip
Merge pull request #16603 from benzea/benzea/special-app-slice
Use app.slice by default in user manager (and define special user slices)
Diffstat (limited to 'src/core/swap.c')
-rw-r--r--src/core/swap.c59
1 files changed, 34 insertions, 25 deletions
diff --git a/src/core/swap.c b/src/core/swap.c
index d984ac0f2d..76e491ad94 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -56,6 +56,35 @@ static bool SWAP_STATE_WITH_PROCESS(SwapState state) {
SWAP_CLEANING);
}
+_pure_ static UnitActiveState swap_active_state(Unit *u) {
+ assert(u);
+
+ return state_translation_table[SWAP(u)->state];
+}
+
+_pure_ static const char *swap_sub_state_to_string(Unit *u) {
+ assert(u);
+
+ return swap_state_to_string(SWAP(u)->state);
+}
+
+_pure_ static bool swap_may_gc(Unit *u) {
+ Swap *s = SWAP(u);
+
+ assert(s);
+
+ if (s->from_proc_swaps)
+ return false;
+
+ return true;
+}
+
+_pure_ static bool swap_is_extrinsic(Unit *u) {
+ assert(SWAP(u));
+
+ return MANAGER_IS_USER(u->manager);
+}
+
static void swap_unset_proc_swaps(Swap *s) {
assert(s);
@@ -610,13 +639,15 @@ static void swap_dump(Unit *u, FILE *f, const char *prefix) {
"%sClean Result: %s\n"
"%sWhat: %s\n"
"%sFrom /proc/swaps: %s\n"
- "%sFrom fragment: %s\n",
+ "%sFrom fragment: %s\n"
+ "%sExtrinsic: %s\n",
prefix, swap_state_to_string(s->state),
prefix, swap_result_to_string(s->result),
prefix, swap_result_to_string(s->clean_result),
prefix, s->what,
prefix, yes_no(s->from_proc_swaps),
- prefix, yes_no(s->from_fragment));
+ prefix, yes_no(s->from_fragment),
+ prefix, yes_no(swap_is_extrinsic(u)));
if (s->devnode)
fprintf(f, "%sDevice Node: %s\n", prefix, s->devnode);
@@ -1028,29 +1059,6 @@ static int swap_deserialize_item(Unit *u, const char *key, const char *value, FD
return 0;
}
-_pure_ static UnitActiveState swap_active_state(Unit *u) {
- assert(u);
-
- return state_translation_table[SWAP(u)->state];
-}
-
-_pure_ static const char *swap_sub_state_to_string(Unit *u) {
- assert(u);
-
- return swap_state_to_string(SWAP(u)->state);
-}
-
-_pure_ static bool swap_may_gc(Unit *u) {
- Swap *s = SWAP(u);
-
- assert(s);
-
- if (s->from_proc_swaps)
- return false;
-
- return true;
-}
-
static void swap_sigchld_event(Unit *u, pid_t pid, int code, int status) {
Swap *s = SWAP(u);
SwapResult f;
@@ -1649,6 +1657,7 @@ const UnitVTable swap_vtable = {
.will_restart = unit_will_restart_default,
.may_gc = swap_may_gc,
+ .is_extrinsic = swap_is_extrinsic,
.sigchld_event = swap_sigchld_event,