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

Commit 90ec8176 authored by Patrick Daly's avatar Patrick Daly Committed by Chris Goldsworthy
Browse files

mm/oom-kill: Add option to panic when killing foreground app



This setting is useful to debug memory intensive test scenarios,
which are close to the limit of what the device supports.

Change-Id: Id09f43736bd3c9586b4dac4fae570e78089f5bb3
Signed-off-by: default avatarPatrick Daly <pdaly@codeaurora.org>
[cgoldswo@codeaurora.org: Add macro introduced in obsolete patch]
Signed-off-by: default avatarChris Goldsworthy <cgoldswo@codeaurora.org>
parent 83d2497e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -130,4 +130,6 @@ extern int sysctl_reap_mem_on_sigkill;

/* calls for LMK reaper */
extern void add_to_oom_reaper(struct task_struct *p);
extern void check_panic_on_foreground_kill(struct task_struct *p);
#define ULMK_MAGIC "lmkd"
#endif /* _INCLUDE_LINUX_OOM_H */
+1 −0
Original line number Diff line number Diff line
@@ -1406,6 +1406,7 @@ int group_send_sig_info(int sig, struct kernel_siginfo *info,
	rcu_read_unlock();

	if (!ret && sig) {
		check_panic_on_foreground_kill(p);
		ret = do_send_sig_info(sig, info, p, type);
		if (capable(CAP_KILL) && sig == SIGKILL)
			add_to_oom_reaper(p);
+18 −0
Original line number Diff line number Diff line
@@ -58,6 +58,9 @@ int sysctl_oom_kill_allocating_task;
int sysctl_oom_dump_tasks = 1;
int sysctl_reap_mem_on_sigkill = 1;

static int panic_on_adj_zero;
module_param(panic_on_adj_zero, int, 0644);

/*
 * Serializes oom killer invocations (out_of_memory()) from all contexts to
 * prevent from over eager oom killing (e.g. when the oom killer is invoked
@@ -1197,3 +1200,18 @@ void add_to_oom_reaper(struct task_struct *p)

	put_task_struct(p);
}

/*
 * Should be called prior to sending sigkill. To guarantee that the
 * process to-be-killed is still untouched.
 */
void check_panic_on_foreground_kill(struct task_struct *p)
{
	if (unlikely(!strcmp(current->comm, ULMK_MAGIC)
			&& p->signal->oom_score_adj == 0
			&& panic_on_adj_zero)) {
		show_mem(SHOW_MEM_FILTER_NODES, NULL);
		show_mem_call_notifiers();
		panic("Attempt to kill foreground task: %s", p->comm);
	}
}