CONFIG_FAIR_GROUP_SCHED (which provides task_group.cfs_rq) and
CONFIG_RT_GROUP_SCHED (which provides task_group.rt_rq) need not be both
enabled in a kernel. Let's support runq -g even if only one of them is
enabled.
---
task.c | 46 ++++++++++++++++++++++++++++------------------
1 file changed, 28 insertions(+), 18 deletions(-)
diff --git a/task.c b/task.c
index 3a88d68..3e6aff4 100644
--- a/task.c
+++ b/task.c
@@ -7747,8 +7747,8 @@ cmd_runq(void)
dump_milliseconds_flag = 1;
break;
case 'g':
- if (INVALID_MEMBER(task_group_cfs_rq) ||
- INVALID_MEMBER(task_group_rt_rq) ||
+ if ((INVALID_MEMBER(task_group_cfs_rq) &&
+ INVALID_MEMBER(task_group_rt_rq)) ||
INVALID_MEMBER(task_group_parent))
option_not_supported(c);
dump_task_group_flag = 1;
@@ -9134,8 +9134,8 @@ static void
dump_tasks_by_task_group(void)
{
int cpu, displayed;
- ulong root_task_group, cfs_rq, cfs_rq_p;
- ulong rt_rq, rt_rq_p;
+ ulong root_task_group, cfs_rq = 0, cfs_rq_p;
+ ulong rt_rq = 0, rt_rq_p;
char *buf;
struct task_context *tc;
char *task_group_name;
@@ -9161,8 +9161,10 @@ dump_tasks_by_task_group(void)
buf = GETBUF(SIZE(task_group));
readmem(root_task_group, KVADDR, buf, SIZE(task_group),
"task_group", FAULT_ON_ERROR);
- rt_rq = ULONG(buf + OFFSET(task_group_rt_rq));
- cfs_rq = ULONG(buf + OFFSET(task_group_cfs_rq));
+ if (VALID_MEMBER(task_group_rt_rq))
+ rt_rq = ULONG(buf + OFFSET(task_group_rt_rq));
+ if (VALID_MEMBER(task_group_cfs_rq))
+ cfs_rq = ULONG(buf + OFFSET(task_group_cfs_rq));
fill_task_group_info_array(0, root_task_group, buf, -1);
sort_task_group_info_array();
@@ -9178,10 +9180,14 @@ dump_tasks_by_task_group(void)
if (cpus && !NUM_IN_BITMAP(cpus, cpu))
continue;
- readmem(rt_rq + cpu * sizeof(ulong), KVADDR, &rt_rq_p,
- sizeof(ulong), "task_group rt_rq", FAULT_ON_ERROR);
- readmem(cfs_rq + cpu * sizeof(ulong), KVADDR, &cfs_rq_p,
- sizeof(ulong), "task_group cfs_rq", FAULT_ON_ERROR);
+ if (rt_rq)
+ readmem(rt_rq + cpu * sizeof(ulong), KVADDR,
+ &rt_rq_p, sizeof(ulong), "task_group rt_rq",
+ FAULT_ON_ERROR);
+ if (cfs_rq)
+ readmem(cfs_rq + cpu * sizeof(ulong), KVADDR,
+ &cfs_rq_p, sizeof(ulong), "task_group cfs_rq",
+ FAULT_ON_ERROR);
fprintf(fp, "%sCPU %d", displayed++ ? "\n" : "", cpu);
if (hide_offline_cpu(cpu)) {
@@ -9197,15 +9203,19 @@ dump_tasks_by_task_group(void)
else
fprintf(fp, "%lx\n", tt->active_set[cpu]);
- fprintf(fp, " %s_TASK_GROUP: %lx RT_RQ: %lx\n",
- task_group_name, root_task_group, rt_rq_p);
- reuse_task_group_info_array();
- dump_tasks_in_task_group_rt_rq(0, rt_rq_p, cpu);
+ if (rt_rq) {
+ fprintf(fp, " %s_TASK_GROUP: %lx RT_RQ: %lx\n",
+ task_group_name, root_task_group, rt_rq_p);
+ reuse_task_group_info_array();
+ dump_tasks_in_task_group_rt_rq(0, rt_rq_p, cpu);
+ }
- fprintf(fp, " %s_TASK_GROUP: %lx CFS_RQ: %lx\n",
- task_group_name, root_task_group, cfs_rq_p);
- reuse_task_group_info_array();
- dump_tasks_in_task_group_cfs_rq(0, cfs_rq_p, cpu, tc);
+ if (cfs_rq) {
+ fprintf(fp, " %s_TASK_GROUP: %lx CFS_RQ: %lx\n",
+ task_group_name, root_task_group, cfs_rq_p);
+ reuse_task_group_info_array();
+ dump_tasks_in_task_group_cfs_rq(0, cfs_rq_p, cpu, tc);
+ }
}
FREEBUF(buf);
--
1.7.10.4