From: Xu Qiang xuqiang36@huawei.com
Offering: HULK hulk inclusion category: other bugzilla: https://gitee.com/openeuler/kernel/issues/I6ET9W
----------------------------------------------
The tgid information is also stored in sp_group_master.
Signed-off-by: Xu Qiang xuqiang36@huawei.com --- mm/share_pool.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/mm/share_pool.c b/mm/share_pool.c index 2ba05eb7d1ca..e11dc2769de5 100644 --- a/mm/share_pool.c +++ b/mm/share_pool.c @@ -123,7 +123,6 @@ struct sp_meminfo { #ifndef __GENKSYMS__ /* per process memory usage statistics indexed by tgid */ struct sp_proc_stat { - int tgid; char comm[TASK_COMM_LEN]; /* * alloc amount minus free amount, may be negative when freed by @@ -312,13 +311,12 @@ static void meminfo_dec_k2u(unsigned long size, struct sp_meminfo *meminfo) }
/* The caller should hold mmap_sem to protect master (TBD) */ -static void sp_init_group_master_stat(int tgid, struct mm_struct *mm, +static void sp_init_group_master_stat(struct mm_struct *mm, struct sp_proc_stat *stat) { atomic64_set(&stat->alloc_nsize, 0); atomic64_set(&stat->alloc_hsize, 0); atomic64_set(&stat->k2u_size, 0); - stat->tgid = tgid; get_task_comm(stat->comm, current); }
@@ -586,7 +584,7 @@ static int sp_init_group_master_locked(struct task_struct *tsk, struct mm_struct master->count = 0; master->mm = mm; master->tgid = tsk->tgid; - sp_init_group_master_stat(tsk->tgid, mm, &master->instat); + sp_init_group_master_stat(mm, &master->instat); mm->sp_group_master = master; sp_add_group_master(master);
@@ -3771,7 +3769,7 @@ int proc_sp_group_state(struct seq_file *m, struct pid_namespace *ns, "PID", "COMM", "SP_ALLOC", "SP_K2U", "SP_RES", "Non-SP_RES", "Non-SP_Shm", "VIRT"); seq_printf(m, "%-8d %-16s %-9ld %-9ld %-9ld %-10ld %-10ld %-8ld\n", - proc_stat->tgid, proc_stat->comm, + master->tgid, proc_stat->comm, get_proc_alloc(proc_stat), get_proc_k2u(proc_stat), sp_res, non_sp_res, non_sp_shm, @@ -3985,7 +3983,7 @@ static int proc_usage_by_group(int id, void *p, void *data) list_for_each_entry(spg_node, &spg->procs, proc_node) { master = spg_node->master; mm = master->mm; - tgid = master->instat.tgid; + tgid = master->tgid;
get_mm_rss_info(mm, &anon, &file, &shmem, &total_rss);
@@ -4054,7 +4052,7 @@ static int proc_usage_show(struct seq_file *seq, void *offset) get_process_non_sp_res(total_rss, shmem, sp_res_nsize, &non_sp_res, &non_sp_shm); seq_printf(seq, "%-8d %-16s %-9ld %-9ld %-9ld %-10ld %-10ld %-8ld\n", - proc_stat->tgid, proc_stat->comm, + master->tgid, proc_stat->comm, get_proc_alloc(proc_stat), get_proc_k2u(proc_stat), sp_res, non_sp_res, non_sp_shm, @@ -4285,7 +4283,7 @@ void sp_group_post_exit(struct mm_struct *mm)
if (alloc_size != 0 || k2u_size != 0) pr_info("process %s(%d) exits. It applied %ld aligned KB, k2u shared %ld aligned KB\n", - stat->comm, stat->tgid, + stat->comm, master->tgid, byte2kb(alloc_size), byte2kb(k2u_size)); }