Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cc635da2 authored by Colin Cross's avatar Colin Cross Committed by Greg Kroah-Hartman
Browse files

staging: lowmemorykiller: Make default lowmemorykiller debug message useful



lowmemorykiller debug messages are inscrutable and mostly useful
for debugging the lowmemorykiller, not explaining why a process
was killed.  Make the messages more useful by prefixing them
with "lowmemorykiller: " and explaining in more readable terms
what was killed, who it was killed for, and why it was killed.

The messages now look like:
[   76.997631] lowmemorykiller: Killing 'droid.gallery3d' (2172), adj 1000,
[   76.997635]    to free 27436kB on behalf of 'kswapd0' (29) because
[   76.997638]    cache 122624kB is below limit 122880kB for oom_score_adj 1000
[   76.997641]    Free memory is -53356kB above reserved

A negative number for free memory above reserved means some of the
reserved memory has been used and is being regenerated by kswapd,
which is likely what called the shrinkers.

Cc: Android Kernel Team <kernel-team@android.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: default avatarColin Cross <ccross@android.com>
[jstultz: Minor checkpatch tweaks]
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 90a2f171
Loading
Loading
Loading
Loading
+17 −7
Original line number Original line Diff line number Diff line
@@ -84,6 +84,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
	int tasksize;
	int tasksize;
	int i;
	int i;
	short min_score_adj = OOM_SCORE_ADJ_MAX + 1;
	short min_score_adj = OOM_SCORE_ADJ_MAX + 1;
	int minfree = 0;
	int selected_tasksize = 0;
	int selected_tasksize = 0;
	short selected_oom_score_adj;
	short selected_oom_score_adj;
	int array_size = ARRAY_SIZE(lowmem_adj);
	int array_size = ARRAY_SIZE(lowmem_adj);
@@ -97,8 +98,8 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
	if (lowmem_minfree_size < array_size)
	if (lowmem_minfree_size < array_size)
		array_size = lowmem_minfree_size;
		array_size = lowmem_minfree_size;
	for (i = 0; i < array_size; i++) {
	for (i = 0; i < array_size; i++) {
		if (other_free < lowmem_minfree[i] &&
		minfree = lowmem_minfree[i];
		    other_file < lowmem_minfree[i]) {
		if (other_free < minfree && other_file < minfree) {
			min_score_adj = lowmem_adj[i];
			min_score_adj = lowmem_adj[i];
			break;
			break;
		}
		}
@@ -153,8 +154,8 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
		selected = p;
		selected = p;
		selected_tasksize = tasksize;
		selected_tasksize = tasksize;
		selected_oom_score_adj = oom_score_adj;
		selected_oom_score_adj = oom_score_adj;
		lowmem_print(2, "select %d (%s), adj %hd, size %d, to kill\n",
		lowmem_print(2, "select '%s' (%d), adj %hd, size %d, to kill\n",
			     p->pid, p->comm, oom_score_adj, tasksize);
			     p->comm, p->pid, oom_score_adj, tasksize);
	}
	}
	if (selected) {
	if (selected) {
		task_lock(selected);
		task_lock(selected);
@@ -167,9 +168,18 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
		if (selected->mm)
		if (selected->mm)
			mark_oom_victim(selected);
			mark_oom_victim(selected);
		task_unlock(selected);
		task_unlock(selected);
		lowmem_print(1, "send sigkill to %d (%s), adj %hd, size %d\n",
		lowmem_print(1, "Killing '%s' (%d), adj %hd,\n"
			     selected->pid, selected->comm,
				 "   to free %ldkB on behalf of '%s' (%d) because\n"
			     selected_oom_score_adj, selected_tasksize);
				 "   cache %ldkB is below limit %ldkB for oom_score_adj %hd\n"
				 "   Free memory is %ldkB above reserved\n",
			     selected->comm, selected->pid,
			     selected_oom_score_adj,
			     selected_tasksize * (long)(PAGE_SIZE / 1024),
			     current->comm, current->pid,
			     other_file * (long)(PAGE_SIZE / 1024),
			     minfree * (long)(PAGE_SIZE / 1024),
			     min_score_adj,
			     other_free * (long)(PAGE_SIZE / 1024));
		lowmem_deathpending_timeout = jiffies + HZ;
		lowmem_deathpending_timeout = jiffies + HZ;
		rem += selected_tasksize;
		rem += selected_tasksize;
	}
	}