summaryrefstree
path: root/kernel/mm/sec_mm/panic_handler.c
blob: 3cf302fa843937335d70d1f30a92611694b9e66b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// SPDX-License-Identifier: GPL-2.0
/*
 * sec_mm/
 *
 * Copyright (C) 2020 Samsung Electronics
 *
 */

#include <linux/module.h>
#include <linux/mm.h>
#include "sec_mm.h"

static int sec_mm_panic_handler(struct notifier_block *nb, unsigned long action,
				void *str_buf)
{
	/* not to print duplicate information */
	if (strstr(str_buf, "System is deadlocked on memory"))
		return NOTIFY_DONE;

#ifdef CONFIG_SEC_MM
	show_mem(0, NULL);
#else
	mm_debug_show_free_areas();
#endif
	mm_debug_dump_tasks();

	return NOTIFY_DONE;
}

static struct notifier_block panic_block = {
	.notifier_call = sec_mm_panic_handler,
};

void init_panic_hander(void)
{
	atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
}

void exit_panic_hander(void)
{
	atomic_notifier_chain_unregister(&panic_notifier_list, &panic_block);
}

MODULE_LICENSE("GPL");