You need to sign in or sign up before continuing.
提交 90880c55 编写于 作者: W Weilong Chen 提交者: Yang Yingliang

arm64/ascend: Add mmap hook when alloc hugepage

ascend inclusion
category: feature
bugzilla: NA
CVE: NA

-------------------------------------------------

Use block notify chain to notify user that mmap event.
Signed-off-by: NWeilong Chen <chenweilong@huawei.com>
Reviewed-by: NDing Tianhong <dingtianhong@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 46f6486b
......@@ -1349,6 +1349,30 @@ static inline bool file_mmap_ok(struct file *file, struct inode *inode,
return true;
}
#ifdef CONFIG_ASCEND_AUTO_TUNING_HUGEPAGE
int mmap_notifier_enable = 0;
EXPORT_SYMBOL_GPL(mmap_notifier_enable);
static BLOCKING_NOTIFIER_HEAD(mmap_notify_list);
int register_mmap_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_register(&mmap_notify_list, nb);
}
EXPORT_SYMBOL_GPL(register_mmap_notifier);
int mmap_notifier_call(unsigned long val, void *v)
{
return blocking_notifier_call_chain(&mmap_notify_list, val, v);
}
int unregister_mmap_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_unregister(&mmap_notify_list, nb);
}
EXPORT_SYMBOL_GPL(unregister_mmap_notifier);
#endif
/*
* The caller must hold down_write(&current->mm->mmap_sem).
*/
......@@ -1396,6 +1420,12 @@ unsigned long do_mmap(struct file *file, unsigned long addr,
if (mm->map_count > sysctl_max_map_count)
return -ENOMEM;
#ifdef CONFIG_ASCEND_AUTO_TUNING_HUGEPAGE
/* only notify flags with MAP_HUGETLB */
if (flags & MAP_HUGETLB && mmap_notifier_enable)
mmap_notifier_call(len, NULL);
#endif
/* Obtain the address to map to. we verify (or select) it and ensure
* that it represents a valid section of the address space.
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册