Skip to contentSkip to conversation

sched: add uid information to sched_debug for CONFIG_USER_SCHED

PATCH Applied Arun R Bharadwaj 3 participants 6 messages Dec 1, 2008 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched: add uid information to sched_debug for CONFIG_USER_SCHED

Hi,

This patch adds uid information in sched_debug for CONFIG_USER_SCHED

---
 include/linux/sched.h |    1 +
 kernel/sched.c        |   10 ++++++++++
 kernel/sched_debug.c  |    5 +++++
 kernel/user.c         |    2 ++
 4 files changed, 18 insertions(+)
kernel/sched_debug.c +5 -0
Index: git-2.6/kernel/sched_debug.c
===================================================================
@@ -131,6 +131,11 @@ void print_cfs_rq(struct seq_file *m, in
 		cgroup_path(cgroup, path, sizeof(path));
 
 	SEQ_printf(m, "\ncfs_rq[%d]:%s\n", cpu, path);
+#elif defined(CONFIG_USER_SCHED)
+	{
+		uid_t uid = cfs_rq->tg->uid;
+		SEQ_printf(m, "\ncfs_rq[%d] for UID: %u\n", cpu, uid);
+	}
 #else
 	SEQ_printf(m, "\ncfs_rq[%d]:\n", cpu);
 #endif
kernel/sched.c +10 -0
Index: git-2.6/kernel/sched.c
===================================================================
@@ -261,6 +261,10 @@ struct task_group {
 	struct cgroup_subsys_state css;
 #endif
 
+#ifdef CONFIG_USER_SCHED
+	uid_t uid;
+#endif
+
 #ifdef CONFIG_FAIR_GROUP_SCHED
 	/* schedulable entities of this group on each cpu */
 	struct sched_entity **se;
@@ -286,6 +290,12 @@ struct task_group {
 
 #ifdef CONFIG_USER_SCHED
 
+/* Helper function to pass uid information to create_sched_user() */
+void set_tg_uid(struct user_struct *user)
+{
+	user->tg->uid = user->uid;
+}
+
 /*
  * Root task group.
  * 	Every UID task group (including init_task_group aka UID-0) will
kernel/user.c +2 -0
Index: git-2.6/kernel/user.c
===================================================================
@@ -101,6 +101,8 @@ static int sched_create_user(struct user
 	if (IS_ERR(up->tg))
 		rc = -ENOMEM;
 
+	set_tg_uid(up);
+
 	return rc;
 }
 
include/linux/sched.h +1 -0
Index: git-2.6/include/linux/sched.h
===================================================================
@@ -2220,6 +2220,7 @@ extern void normalize_rt_tasks(void);
 extern struct task_group init_task_group;
 #ifdef CONFIG_USER_SCHED
 extern struct task_group root_task_group;
+extern void set_tg_uid(struct user_struct *user);
 #endif
 
 extern struct task_group *sched_create_group(struct task_group *parent);
#1 lore raw
Quoted 3 lines · Arun R Bharadwaj

Hi,

This patch adds uid information in sched_debug for CONFIG_USER_SCHED

I'd much rather have people working at removing USER_SCHED,. but sure, the patch looks sane..

#2 lore raw
Quoted 7 lines · Peter Zijlstra
Quoted 3 lines · Arun R Bharadwaj

Hi,

This patch adds uid information in sched_debug for CONFIG_USER_SCHED

I'd much rather have people working at removing USER_SCHED,. but sure, the patch looks sane..

ok, i have applied it to tip/sched/core.

Thanks,

Ingo

#3 lore raw
Quoted 4 lines · Ingo Molnar
Quoted 1 line · Peter Zijlstra

On Mon, 2008-12-01 at 16:59 +0530, Arun R Bharadwaj wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Hi,

This patch adds uid information in sched_debug for CONFIG_USER_SCHED

I'd much rather have people working at removing USER_SCHED,. but sure, the patch looks sane..

ok, i have applied it to tip/sched/core.

it doesnt build:

kernel/sched_debug.c: In function 'print_cfs_rq':
kernel/sched_debug.c:165: error: 'struct cfs_rq' has no member named 'tg'

please send v2 patch.

Ingo

#4 lore raw
Quoted 16 lines · Ingo Molnar
Quoted 4 lines · Ingo Molnar
Quoted 1 line · Peter Zijlstra

On Mon, 2008-12-01 at 16:59 +0530, Arun R Bharadwaj wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Hi,

This patch adds uid information in sched_debug for CONFIG_USER_SCHED

I'd much rather have people working at removing USER_SCHED,. but sure, the patch looks sane..

ok, i have applied it to tip/sched/core.

Quoted 8 lines

it doesnt build:

kernel/sched_debug.c: In function 'print_cfs_rq':
kernel/sched_debug.c:165: error: 'struct cfs_rq' has no member named 'tg'

please send v2 patch.

Ingo

Hi Ingo,

I've posted v2 of the patch.
Had missed an '&& #if defined(CONFIG_FAIR_GROUP_SCHED)' last time around.

--arun

This patch adds uid information in sched_debug for CONFIG_USER_SCHED

---
 include/linux/sched.h |    1 +
 kernel/sched.c        |   10 ++++++++++
 kernel/sched_debug.c  |    6 +++++-
 kernel/user.c         |    2 ++
 4 files changed, 18 insertions(+), 1 deletion(-)
kernel/sched_debug.c +5 -1
Index: git-2.6/kernel/sched_debug.c
===================================================================
@@ -131,10 +131,14 @@ void print_cfs_rq(struct seq_file *m, in
 		cgroup_path(cgroup, path, sizeof(path));
 
 	SEQ_printf(m, "\ncfs_rq[%d]:%s\n", cpu, path);
+#elif defined(CONFIG_USER_SCHED) && defined(CONFIG_FAIR_GROUP_SCHED)
+	{
+		uid_t uid = cfs_rq->tg->uid;
+		SEQ_printf(m, "\ncfs_rq[%d] for UID: %u\n", cpu, uid);
+	}
 #else
 	SEQ_printf(m, "\ncfs_rq[%d]:\n", cpu);
 #endif
-
 	SEQ_printf(m, "  .%-30s: %Ld.%06ld\n", "exec_clock",
 			SPLIT_NS(cfs_rq->exec_clock));
 
kernel/sched.c +10 -0
Index: git-2.6/kernel/sched.c
===================================================================
@@ -261,6 +261,10 @@ struct task_group {
 	struct cgroup_subsys_state css;
 #endif
 
+#ifdef CONFIG_USER_SCHED
+	uid_t uid;
+#endif
+
 #ifdef CONFIG_FAIR_GROUP_SCHED
 	/* schedulable entities of this group on each cpu */
 	struct sched_entity **se;
@@ -286,6 +290,12 @@ struct task_group {
 
 #ifdef CONFIG_USER_SCHED
 
+/* Helper function to pass uid information to create_sched_user() */
+void set_tg_uid(struct user_struct *user)
+{
+	user->tg->uid = user->uid;
+}
+
 /*
  * Root task group.
  * 	Every UID task group (including init_task_group aka UID-0) will
kernel/user.c +2 -0
Index: git-2.6/kernel/user.c
===================================================================
@@ -101,6 +101,8 @@ static int sched_create_user(struct user
 	if (IS_ERR(up->tg))
 		rc = -ENOMEM;
 
+	set_tg_uid(up);
+
 	return rc;
 }
 
include/linux/sched.h +1 -0
Index: git-2.6/include/linux/sched.h
===================================================================
@@ -2220,6 +2220,7 @@ extern void normalize_rt_tasks(void);
 extern struct task_group init_task_group;
 #ifdef CONFIG_USER_SCHED
 extern struct task_group root_task_group;
+extern void set_tg_uid(struct user_struct *user);
 #endif
 
 extern struct task_group *sched_create_group(struct task_group *parent);
Applied
#5 lore raw
Quoted 25 lines · Arun R Bharadwaj
Quoted 23 lines · Ingo Molnar
Quoted 4 lines · Ingo Molnar
Quoted 1 line · Peter Zijlstra

On Mon, 2008-12-01 at 16:59 +0530, Arun R Bharadwaj wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Hi,

This patch adds uid information in sched_debug for CONFIG_USER_SCHED

I'd much rather have people working at removing USER_SCHED,. but sure, the patch looks sane..

ok, i have applied it to tip/sched/core.

it doesnt build:

kernel/sched_debug.c: In function 'print_cfs_rq':
kernel/sched_debug.c:165: error: 'struct cfs_rq' has no member named 'tg'

please send v2 patch.

Quoted 7 lines
Quoted 1 line

Ingo

Hi Ingo,

I've posted v2 of the patch.
Had missed an '&& #if defined(CONFIG_FAIR_GROUP_SCHED)' last time around.

applied, thanks!

Ingo