提交 5ad541e3 编写于 作者: D Ding Tianhong 提交者: Yang Yingliang

ascend: share_pool: support debug mode and refactor some functions

ascend inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I4EUVI
CVE: NA

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

The share pool is used widely for several accelerator, and it is
difficult to debug the user problem, so add debug mode to analyse
the problem, this mode is enabled by the sysctl_sp_debug_mode flag.

Some functions have been refactored to protect the critical area
correctly, and output message more clearly.
Signed-off-by: NTang Yizhou <tangyizhou@huawei.com>
Signed-off-by: NZhou Guanghui <zhouguanghui1@huawei.com>
Signed-off-by: NWu Peng <wupeng58@huawei.com>
Signed-off-by: NDing Tianhong <dingtianhong@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 4a280fac
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <linux/mm_types.h> #include <linux/mm_types.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/printk.h>
#define SP_HUGEPAGE (1 << 0) #define SP_HUGEPAGE (1 << 0)
#define SP_HUGEPAGE_ONLY (1 << 1) #define SP_HUGEPAGE_ONLY (1 << 1)
...@@ -35,6 +36,8 @@ extern int sysctl_share_pool_hugepage_enable; ...@@ -35,6 +36,8 @@ extern int sysctl_share_pool_hugepage_enable;
extern int sysctl_ac_mode; extern int sysctl_ac_mode;
extern int sysctl_sp_debug_mode;
extern int enable_ascend_share_pool; extern int enable_ascend_share_pool;
/* Processes in the same sp_group can share memory. /* Processes in the same sp_group can share memory.
...@@ -70,7 +73,7 @@ struct sp_group { ...@@ -70,7 +73,7 @@ struct sp_group {
/* number of sp_area */ /* number of sp_area */
atomic_t spa_num; atomic_t spa_num;
/* total size of all sp_area from sp_alloc and k2u(spg) */ /* total size of all sp_area from sp_alloc and k2u(spg) */
atomic_t size; atomic64_t size;
/* record the number of hugepage allocation failures */ /* record the number of hugepage allocation failures */
int hugepage_failures; int hugepage_failures;
/* is_alive == false means it's being destroyed */ /* is_alive == false means it's being destroyed */
...@@ -211,6 +214,12 @@ static inline bool sp_mmap_check(unsigned long flags) ...@@ -211,6 +214,12 @@ static inline bool sp_mmap_check(unsigned long flags)
return false; return false;
} }
static inline void sp_dump_stack(void)
{
if (sysctl_sp_debug_mode)
dump_stack();
}
#else #else
static inline int sp_group_add_task(int pid, int spg_id) static inline int sp_group_add_task(int pid, int spg_id)
...@@ -349,6 +358,10 @@ static inline bool sp_mmap_check(unsigned long flags) ...@@ -349,6 +358,10 @@ static inline bool sp_mmap_check(unsigned long flags)
{ {
return false; return false;
} }
static inline void sp_dump_stack(void)
{
}
#endif #endif
#endif /* LINUX_SHARE_POOL_H */ #endif /* LINUX_SHARE_POOL_H */
...@@ -1782,6 +1782,15 @@ static struct ctl_table vm_table[] = { ...@@ -1782,6 +1782,15 @@ static struct ctl_table vm_table[] = {
.extra1 = &zero, .extra1 = &zero,
.extra2 = &one, .extra2 = &one,
}, },
{
.procname = "sharepool_debug_mode",
.data = &sysctl_sp_debug_mode,
.maxlen = sizeof(sysctl_sp_debug_mode),
.mode = 0600,
.proc_handler = proc_dointvec_minmax,
.extra1 = &zero,
.extra2 = &one,
},
#endif #endif
{ } { }
}; };
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册