[PATCH 08/15] task_diag: Only add VMAs for thread_group leader

From: Andrey Vagin
Date: Mon Apr 11 2016 - 19:36:57 EST


From: David Ahern <dsahern@xxxxxxxxx>

threads of a process share the same VMAs, so when dumping all threads
for all processes only push vma data for group leader.

Signed-off-by: David Ahern <dsahern@xxxxxxxxx>
Signed-off-by: Andrey Vagin <avagin@xxxxxxxxxx>
---
fs/proc/task_diag.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/fs/proc/task_diag.c b/fs/proc/task_diag.c
index e0f0b03..00db32d 100644
--- a/fs/proc/task_diag.c
+++ b/fs/proc/task_diag.c
@@ -433,7 +433,17 @@ static int task_diag_fill(struct task_struct *tsk, struct sk_buff *skb,
}

if (show_flags & TASK_DIAG_SHOW_VMA) {
- if (i >= n)
+ bool dump_vma = true;
+
+ /* if the request is to dump all threads of all processes
+ * only show VMAs for group leader.
+ */
+ if ((req->dump_strategy == TASK_DIAG_DUMP_ALL_THREAD ||
+ req->dump_strategy == TASK_DIAG_DUMP_THREAD) &&
+ !thread_group_leader(tsk))
+ dump_vma = false;
+
+ if (dump_vma && i >= n)
err = fill_vma(tsk, skb, cb, &progress, show_flags);
if (err)
goto err;
--
2.5.5