提交 a97a5859 编写于 作者: T Tang Yizhou 提交者: Yang Yingliang

share_pool: Support showing pid of applier process in spa_stat

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

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

/proc/sharepool/spa_stat now can show the pid of applier process, which
helps to debug and check memleak.
Signed-off-by: NTang Yizhou <tangyizhou@huawei.com>
Reviewed-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>
上级 02889964
...@@ -213,6 +213,7 @@ struct sp_area { ...@@ -213,6 +213,7 @@ struct sp_area {
enum spa_type type; /* where spa born from */ enum spa_type type; /* where spa born from */
struct mm_struct *mm; /* owner of k2u(task) */ struct mm_struct *mm; /* owner of k2u(task) */
unsigned long kva; /* shared kva */ unsigned long kva; /* shared kva */
pid_t applier; /* the original applier process */
}; };
static DEFINE_SPINLOCK(sp_area_lock); static DEFINE_SPINLOCK(sp_area_lock);
static struct rb_root sp_area_root = RB_ROOT; static struct rb_root sp_area_root = RB_ROOT;
...@@ -797,7 +798,8 @@ static unsigned long cached_vstart; /* affected by SP_DVPP and sp_config_dvpp_r ...@@ -797,7 +798,8 @@ static unsigned long cached_vstart; /* affected by SP_DVPP and sp_config_dvpp_r
* Return NULL if fail. * Return NULL if fail.
*/ */
static struct sp_area *sp_alloc_area(unsigned long size, unsigned long flags, static struct sp_area *sp_alloc_area(unsigned long size, unsigned long flags,
struct sp_group *spg, enum spa_type type) struct sp_group *spg, enum spa_type type,
pid_t applier)
{ {
struct sp_area *spa, *first, *err; struct sp_area *spa, *first, *err;
struct rb_node *n; struct rb_node *n;
...@@ -914,6 +916,7 @@ static struct sp_area *sp_alloc_area(unsigned long size, unsigned long flags, ...@@ -914,6 +916,7 @@ static struct sp_area *sp_alloc_area(unsigned long size, unsigned long flags,
spa->type = type; spa->type = type;
spa->mm = NULL; spa->mm = NULL;
spa->kva = 0; /* NULL pointer */ spa->kva = 0; /* NULL pointer */
spa->applier = applier;
if (spa_inc_usage(type, size, (flags & SP_DVPP))) { if (spa_inc_usage(type, size, (flags & SP_DVPP))) {
err = ERR_PTR(-EINVAL); err = ERR_PTR(-EINVAL);
...@@ -1350,7 +1353,7 @@ void *sp_alloc(unsigned long size, unsigned long sp_flags, int spg_id) ...@@ -1350,7 +1353,7 @@ void *sp_alloc(unsigned long size, unsigned long sp_flags, int spg_id)
size_aligned = ALIGN(size, PAGE_SIZE); size_aligned = ALIGN(size, PAGE_SIZE);
} }
try_again: try_again:
spa = sp_alloc_area(size_aligned, sp_flags, spg, SPA_TYPE_ALLOC); spa = sp_alloc_area(size_aligned, sp_flags, spg, SPA_TYPE_ALLOC, current->tgid);
if (IS_ERR(spa)) { if (IS_ERR(spa)) {
pr_err_ratelimited("share pool: allocation failed due to alloc spa failure " pr_err_ratelimited("share pool: allocation failed due to alloc spa failure "
"(potential no enough virtual memory when -75): %ld\n", PTR_ERR(spa)); "(potential no enough virtual memory when -75): %ld\n", PTR_ERR(spa));
...@@ -1758,7 +1761,7 @@ void *sp_make_share_k2u(unsigned long kva, unsigned long size, ...@@ -1758,7 +1761,7 @@ void *sp_make_share_k2u(unsigned long kva, unsigned long size,
uva = ERR_PTR(-EINVAL); uva = ERR_PTR(-EINVAL);
goto out_drop_proc_stat; goto out_drop_proc_stat;
} }
spa = sp_alloc_area(size_aligned, sp_flags, NULL, SPA_TYPE_K2TASK); spa = sp_alloc_area(size_aligned, sp_flags, NULL, SPA_TYPE_K2TASK, tsk->tgid);
if (IS_ERR(spa)) { if (IS_ERR(spa)) {
pr_err_ratelimited("share pool: k2u(task) failed due to alloc spa failure " pr_err_ratelimited("share pool: k2u(task) failed due to alloc spa failure "
"(potential no enough virtual memory when -75): %ld\n", PTR_ERR(spa)); "(potential no enough virtual memory when -75): %ld\n", PTR_ERR(spa));
...@@ -1787,9 +1790,9 @@ void *sp_make_share_k2u(unsigned long kva, unsigned long size, ...@@ -1787,9 +1790,9 @@ void *sp_make_share_k2u(unsigned long kva, unsigned long size,
} }
if (enable_share_k2u_spg) if (enable_share_k2u_spg)
spa = sp_alloc_area(size_aligned, sp_flags, spg, SPA_TYPE_K2SPG); spa = sp_alloc_area(size_aligned, sp_flags, spg, SPA_TYPE_K2SPG, tsk->tgid);
else else
spa = sp_alloc_area(size_aligned, sp_flags, NULL, SPA_TYPE_K2TASK); spa = sp_alloc_area(size_aligned, sp_flags, NULL, SPA_TYPE_K2TASK, tsk->tgid);
if (IS_ERR(spa)) { if (IS_ERR(spa)) {
up_read(&spg->rw_lock); up_read(&spg->rw_lock);
...@@ -2577,7 +2580,7 @@ static void rb_spa_stat_show(struct seq_file *seq) ...@@ -2577,7 +2580,7 @@ static void rb_spa_stat_show(struct seq_file *seq)
up_read(&spa->spg->rw_lock); up_read(&spa->spg->rw_lock);
} }
seq_printf(seq, "%2s%-14lx %2s%-14lx %-13ld ", seq_printf(seq, "%2s%-14lx %2s%-14lx %-10ld ",
"0x", spa->va_start, "0x", spa->va_start,
"0x", spa->va_end, "0x", spa->va_end,
byte2kb(spa->real_size)); byte2kb(spa->real_size));
...@@ -2602,7 +2605,8 @@ static void rb_spa_stat_show(struct seq_file *seq) ...@@ -2602,7 +2605,8 @@ static void rb_spa_stat_show(struct seq_file *seq)
else else
seq_printf(seq, "%-5s ", "N"); seq_printf(seq, "%-5s ", "N");
seq_printf(seq, "%-10d\n", atomic_read(&spa->use_count)); seq_printf(seq, "%-8d ", spa->applier);
seq_printf(seq, "%-8d\n", atomic_read(&spa->use_count));
spin_lock(&sp_area_lock); spin_lock(&sp_area_lock);
} }
...@@ -2712,8 +2716,8 @@ static int spa_stat_show(struct seq_file *seq, void *offset) ...@@ -2712,8 +2716,8 @@ static int spa_stat_show(struct seq_file *seq, void *offset)
spg_overview_show(seq); spg_overview_show(seq);
spa_overview_show(seq); spa_overview_show(seq);
/* print the file header */ /* print the file header */
seq_printf(seq, "%-10s %-16s %-16s %-13s %-7s %-5s %-10s\n", seq_printf(seq, "%-10s %-16s %-16s %-10s %-7s %-5s %-8s %-8s\n",
"Group ID", "va_start", "va_end", "Aligned KB", "Type", "Huge", "Ref"); "Group ID", "va_start", "va_end", "Size(KB)", "Type", "Huge", "PID", "Ref");
rb_spa_stat_show(seq); rb_spa_stat_show(seq);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册