[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1436172445-6979-18-git-send-email-avagin@openvz.org>
Date: Mon, 6 Jul 2015 11:47:18 +0300
From: Andrey Vagin <avagin@...nvz.org>
To: linux-kernel@...r.kernel.org
Cc: linux-api@...r.kernel.org, Andrey Vagin <avagin@...nvz.org>,
Oleg Nesterov <oleg@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Cyrill Gorcunov <gorcunov@...nvz.org>,
Pavel Emelyanov <xemul@...allels.com>,
Roger Luethi <rl@...lgate.ch>, Arnd Bergmann <arnd@...db.de>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
David Ahern <dsahern@...il.com>,
Andy Lutomirski <luto@...capital.net>,
Pavel Odintsov <pavel.odintsov@...il.com>
Subject: [PATCH 17/24] task_diag: add ability to dump theads
Signed-off-by: Andrey Vagin <avagin@...nvz.org>
---
include/uapi/linux/task_diag.h | 1 +
kernel/taskdiag.c | 15 ++++++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/task_diag.h b/include/uapi/linux/task_diag.h
index 9e4c3c4..e1d09e6 100644
--- a/include/uapi/linux/task_diag.h
+++ b/include/uapi/linux/task_diag.h
@@ -150,6 +150,7 @@ static inline struct task_diag_vma_stat *task_diag_vma_stat(struct task_diag_vma
#define TASK_DIAG_DUMP_ALL 0
#define TASK_DIAG_DUMP_CHILDREN 1
+#define TASK_DIAG_DUMP_THREAD 2
struct task_diag_pid {
__u64 show_flags;
diff --git a/kernel/taskdiag.c b/kernel/taskdiag.c
index 8e00c3e..dc319bf 100644
--- a/kernel/taskdiag.c
+++ b/kernel/taskdiag.c
@@ -559,8 +559,15 @@ static struct task_struct *iter_start(struct task_iter *iter)
}
switch (iter->req.dump_strategy) {
- case TASK_DIAG_DUMP_CHILDREN:
+ case TASK_DIAG_DUMP_THREAD:
+ if (iter->parent == NULL)
+ return ERR_PTR(-ESRCH);
+
+ iter->pos = iter->cb->args[0];
+ iter->task = task_first_tid(iter->parent, 0, iter->pos, iter->ns);
+ return iter->task;
+ case TASK_DIAG_DUMP_CHILDREN:
if (iter->parent == NULL)
return ERR_PTR(-ESRCH);
@@ -581,6 +588,12 @@ static struct task_struct *iter_start(struct task_iter *iter)
static struct task_struct *iter_next(struct task_iter *iter)
{
switch (iter->req.dump_strategy) {
+ case TASK_DIAG_DUMP_THREAD:
+ iter->pos++;
+ iter->task = task_next_tid(iter->task);
+ iter->cb->args[0] = iter->pos;
+ iter->cb->args[1] = task_pid_nr_ns(iter->task, iter->ns);
+ return iter->task;
case TASK_DIAG_DUMP_CHILDREN:
iter->pos++;
iter->task = task_next_child(iter->parent, iter->task, iter->pos);
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists