android_kernel_xiaomi_sm8350/mm/showmem.c
Vinayak Menon 5ba88f8522 mm: showmem: make the notifiers atomic
There are places in kernel like the lowmemorykiller which
invokes show_mem_call_notifiers from an atomic context.
So move from a blocking notifier to atomic. At present
the notifier callbacks does not call sleeping functions,
but it should be made sure, it does not happen in future also.

Change-Id: I9668e67463ab8a6a60be55dbc86b88f45be8b041
Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
[swatsrid@codeaurora.org: Fix merge conflicts]
Signed-off-by: Swathi Sridhar <swatsrid@codeaurora.org>
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
2019-10-10 12:39:04 -07:00

48 lines
1.1 KiB
C

// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
*/
#include <linux/kernel.h>
#include <linux/notifier.h>
#include <linux/debugfs.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/show_mem_notifier.h>
static ATOMIC_NOTIFIER_HEAD(show_mem_notifier);
int show_mem_notifier_register(struct notifier_block *nb)
{
return atomic_notifier_chain_register(&show_mem_notifier, nb);
}
int show_mem_notifier_unregister(struct notifier_block *nb)
{
return atomic_notifier_chain_unregister(&show_mem_notifier, nb);
}
void show_mem_call_notifiers(void)
{
atomic_notifier_call_chain(&show_mem_notifier, 0, NULL);
}
static int show_mem_notifier_get(void *dat, u64 *val)
{
show_mem_call_notifiers();
*val = 0;
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(show_mem_notifier_debug_ops, show_mem_notifier_get,
NULL, "%llu\n");
static int show_mem_notifier_debugfs_register(void)
{
debugfs_create_file("show_mem_notifier", 0664, NULL, NULL,
&show_mem_notifier_debug_ops);
return 0;
}
late_initcall(show_mem_notifier_debugfs_register);