All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched: skip autogroup when looking for all rt sched groups
@ 2011-06-22  5:22 Yong Zhang
  2011-06-23 11:21 ` Cheng Xu
  0 siblings, 1 reply; 6+ messages in thread
From: Yong Zhang @ 2011-06-22  5:22 UTC (permalink / raw)
  To: linux-kernel; +Cc: Peter Zijlstra, Ingo Molnar, Mike Galbraith, Cheng Xu

[-- Attachment #1: Type: text/plain, Size: 2632 bytes --]

From: Yong Zhang <yong.zhang0@gmail.com>
Subject: [PATCH] sched: skip autogroup when looking for all rt sched groups

Since [commit ec514c48: sched: Fix rt_rq runtime leakage bug],
'cat /proc/sched_debug' will print data of root_task_group.rt_rq
multi times, this is due to autogroup has no its own rt group,
instead rt group of autogroup is linked to root_task_group.

So skip it when we are looking for all rt sched groups, and it
will also save some noop operation against root_task_group when
__disable_runtime()/__enable_runtime().

Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mike Galbraith <efault@gmx.de>
---

Since webmail may mangle the patch, attach it too.

 kernel/sched_autogroup.h |    1 +
 kernel/sched_rt.c        |   29 ++++++++++++++++++++++++-----
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/kernel/sched_autogroup.h b/kernel/sched_autogroup.h
index 0557705..c2f0e72 100644
--- a/kernel/sched_autogroup.h
+++ b/kernel/sched_autogroup.h
@@ -13,6 +13,7 @@ struct autogroup {
 	int			nice;
 };

+static inline bool task_group_is_autogroup(struct task_group *tg);
 static inline struct task_group *
 autogroup_task_group(struct task_struct *p, struct task_group *tg);

diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
index 10d0182..8edf487 100644
--- a/kernel/sched_rt.c
+++ b/kernel/sched_rt.c
@@ -185,11 +185,30 @@ static inline u64 sched_rt_period(struct rt_rq *rt_rq)

 typedef struct task_group *rt_rq_iter_t;

-#define for_each_rt_rq(rt_rq, iter, rq) \
-	for (iter = list_entry_rcu(task_groups.next, typeof(*iter), list); \
-	     (&iter->list != &task_groups) && \
-	     (rt_rq = iter->rt_rq[cpu_of(rq)]); \
-	     iter = list_entry_rcu(iter->list.next, typeof(*iter), list))
+/* autogroup is not related to rt group, skip it */
+#define find_first_valid_task_group(iter)				\
+	({								\
+		list_for_each_entry_rcu(iter, &task_groups, list)	\
+			if (!task_group_is_autogroup(iter))		\
+				break;					\
+		iter;							\
+	})
+
+#define find_next_valid_task_group(iter)				\
+	({								\
+		do {							\
+			iter = list_entry_rcu(iter->list.next,		\
+					typeof(*iter),	list);		\
+		} while (&iter->list != &task_groups &&			\
+			task_group_is_autogroup(iter));			\
+		iter;							\
+	})
+
+#define for_each_rt_rq(rt_rq, iter, rq)					\
+	for (find_first_valid_task_group(iter);				\
+	     (&iter->list != &task_groups) &&				\
+	     (rt_rq = iter->rt_rq[cpu_of(rq)]);				\
+	     find_next_valid_task_group(iter))

 static inline void list_add_leaf_rt_rq(struct rt_rq *rt_rq)
 {
-- 
1.7.4.1

[-- Attachment #2: 0001-sched-skip-autogroup-when-looking-for-all-rt-sched-g.patch --]
[-- Type: text/x-patch, Size: 2747 bytes --]

From 40117635a8f22a05a4eed98c40fcaf67ad90f738 Mon Sep 17 00:00:00 2001
From: Yong Zhang <yong.zhang0@gmail.com>
Date: Wed, 22 Jun 2011 12:52:40 +0800
Subject: [PATCH] sched: skip autogroup when looking for all rt sched groups

Since [commit ec514c48: sched: Fix rt_rq runtime leakage bug],
'cat /proc/sched_debug' will print data of root_task_group.rt_rq
multi times, this is due to autogroup has no its own rt group,
instead rt group of autogroup is linked to root_task_group.

So skip it when we are looking for all rt sched groups, and it
will also save some noop operation against root_task_group when
__disable_runtime()/__enable_runtime().

Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mike Galbraith <efault@gmx.de>
---

Since webmail may mangle the patch, attach it too.

 kernel/sched_autogroup.h |    1 +
 kernel/sched_rt.c        |   29 ++++++++++++++++++++++++-----
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/kernel/sched_autogroup.h b/kernel/sched_autogroup.h
index 0557705..c2f0e72 100644
--- a/kernel/sched_autogroup.h
+++ b/kernel/sched_autogroup.h
@@ -13,6 +13,7 @@ struct autogroup {
 	int			nice;
 };
 
+static inline bool task_group_is_autogroup(struct task_group *tg);
 static inline struct task_group *
 autogroup_task_group(struct task_struct *p, struct task_group *tg);
 
diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
index 10d0182..8edf487 100644
--- a/kernel/sched_rt.c
+++ b/kernel/sched_rt.c
@@ -185,11 +185,30 @@ static inline u64 sched_rt_period(struct rt_rq *rt_rq)
 
 typedef struct task_group *rt_rq_iter_t;
 
-#define for_each_rt_rq(rt_rq, iter, rq) \
-	for (iter = list_entry_rcu(task_groups.next, typeof(*iter), list); \
-	     (&iter->list != &task_groups) && \
-	     (rt_rq = iter->rt_rq[cpu_of(rq)]); \
-	     iter = list_entry_rcu(iter->list.next, typeof(*iter), list))
+/* autogroup is not related to rt group, skip it */
+#define find_first_valid_task_group(iter)				\
+	({								\
+		list_for_each_entry_rcu(iter, &task_groups, list)	\
+			if (!task_group_is_autogroup(iter))		\
+				break;					\
+		iter;							\
+	})
+
+#define find_next_valid_task_group(iter)				\
+	({								\
+		do {							\
+			iter = list_entry_rcu(iter->list.next,		\
+					typeof(*iter),	list);		\
+		} while (&iter->list != &task_groups &&			\
+			task_group_is_autogroup(iter));			\
+		iter;							\
+	})
+
+#define for_each_rt_rq(rt_rq, iter, rq)					\
+	for (find_first_valid_task_group(iter);				\
+	     (&iter->list != &task_groups) &&				\
+	     (rt_rq = iter->rt_rq[cpu_of(rq)]);				\
+	     find_next_valid_task_group(iter))
 
 static inline void list_add_leaf_rt_rq(struct rt_rq *rt_rq)
 {
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] sched: skip autogroup when looking for all rt sched groups
  2011-06-22  5:22 [PATCH] sched: skip autogroup when looking for all rt sched groups Yong Zhang
@ 2011-06-23 11:21 ` Cheng Xu
  2011-06-28  2:40   ` Yong Zhang
  0 siblings, 1 reply; 6+ messages in thread
From: Cheng Xu @ 2011-06-23 11:21 UTC (permalink / raw)
  To: Yong Zhang; +Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, Mike Galbraith

On 06/22/2011 01:22 PM, Yong Zhang wrote:
> From: Yong Zhang <yong.zhang0@gmail.com>
> Subject: [PATCH] sched: skip autogroup when looking for all rt sched groups
> 
> Since [commit ec514c48: sched: Fix rt_rq runtime leakage bug],
> 'cat /proc/sched_debug' will print data of root_task_group.rt_rq
> multi times, this is due to autogroup has no its own rt group,
> instead rt group of autogroup is linked to root_task_group.
> 
> So skip it when we are looking for all rt sched groups, and it
> will also save some noop operation against root_task_group when
> __disable_runtime()/__enable_runtime().
> 
> Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Mike Galbraith <efault@gmx.de>
> ---
> 
> Since webmail may mangle the patch, attach it too.
> 
>  kernel/sched_autogroup.h |    1 +
>  kernel/sched_rt.c        |   29 ++++++++++++++++++++++++-----
>  2 files changed, 25 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/sched_autogroup.h b/kernel/sched_autogroup.h
> index 0557705..c2f0e72 100644
> --- a/kernel/sched_autogroup.h
> +++ b/kernel/sched_autogroup.h
> @@ -13,6 +13,7 @@ struct autogroup {
>  	int			nice;
>  };
> 
> +static inline bool task_group_is_autogroup(struct task_group *tg);
>  static inline struct task_group *
>  autogroup_task_group(struct task_struct *p, struct task_group *tg);
> 
> diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
> index 10d0182..8edf487 100644
> --- a/kernel/sched_rt.c
> +++ b/kernel/sched_rt.c
> @@ -185,11 +185,30 @@ static inline u64 sched_rt_period(struct rt_rq *rt_rq)
> 
>  typedef struct task_group *rt_rq_iter_t;
> 
> -#define for_each_rt_rq(rt_rq, iter, rq) \
> -	for (iter = list_entry_rcu(task_groups.next, typeof(*iter), list); \
> -	     (&iter->list != &task_groups) && \
> -	     (rt_rq = iter->rt_rq[cpu_of(rq)]); \
> -	     iter = list_entry_rcu(iter->list.next, typeof(*iter), list))
> +/* autogroup is not related to rt group, skip it */
> +#define find_first_valid_task_group(iter)				\
> +	({								\
> +		list_for_each_entry_rcu(iter, &task_groups, list)	\
> +			if (!task_group_is_autogroup(iter))		\
> +				break;					\
> +		iter;							\
> +	})
> +
> +#define find_next_valid_task_group(iter)				\
> +	({								\
> +		do {							\
> +			iter = list_entry_rcu(iter->list.next,		\
> +					typeof(*iter),	list);		\
> +		} while (&iter->list != &task_groups &&			\
> +			task_group_is_autogroup(iter));			\
> +		iter;							\
> +	})
> +
> +#define for_each_rt_rq(rt_rq, iter, rq)					\
> +	for (find_first_valid_task_group(iter);				\
> +	     (&iter->list != &task_groups) &&				\
> +	     (rt_rq = iter->rt_rq[cpu_of(rq)]);				\
> +	     find_next_valid_task_group(iter))
> 
>  static inline void list_add_leaf_rt_rq(struct rt_rq *rt_rq)
>  {

This looks like it works, but seems we might be able to do that with less code... 

static inline struct task_group *next_task_group(struct task_group *tg)
{
	do {
		tg = list_entry_rcu(tg->list.next,
		                    typeof(struct task_group), list);
	} while ((&tg->list != &task_groups) && (task_group_is_autogroup(tg)));
	if (&tg->list == &task_groups)
		tg = NULL;
	return tg;
}

#define for_each_rt_rq(rt_rq, iter, rq) \
	for (iter = container_of(&task_groups, typeof(*iter), list); \
	     (iter = next_task_group(iter)) && \
	     (rt_rq = iter->rt_rq[cpu_of(rq)]);)


Thanks,
Cheng

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] sched: skip autogroup when looking for all rt sched groups
  2011-06-23 11:21 ` Cheng Xu
@ 2011-06-28  2:40   ` Yong Zhang
  2011-06-28  2:51     ` [PATCH V2] " Yong Zhang
  0 siblings, 1 reply; 6+ messages in thread
From: Yong Zhang @ 2011-06-28  2:40 UTC (permalink / raw)
  To: Cheng Xu; +Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, Mike Galbraith

Sorry for my late response and comments below.

On Thu, Jun 23, 2011 at 7:21 PM, Cheng Xu <chengxu@linux.vnet.ibm.com> wrote:
>
> This looks like it works, but seems we might be able to do that with less code...
>
> static inline struct task_group *next_task_group(struct task_group *tg)
> {
>        do {
>                tg = list_entry_rcu(tg->list.next,
>                                    typeof(struct task_group), list);
>        } while ((&tg->list != &task_groups) && (task_group_is_autogroup(tg)));
>        if (&tg->list == &task_groups)
>                tg = NULL;
>        return tg;
> }
>
> #define for_each_rt_rq(rt_rq, iter, rq) \
>        for (iter = container_of(&task_groups, typeof(*iter), list); \
>             (iter = next_task_group(iter)) && \
>             (rt_rq = iter->rt_rq[cpu_of(rq)]);)

Yeah, this works too, and it save some code.

Will update the patch based on it.

Thanks,
Yong



-- 
Only stand for myself

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH V2] sched: skip autogroup when looking for all rt sched groups
  2011-06-28  2:40   ` Yong Zhang
@ 2011-06-28  2:51     ` Yong Zhang
  2011-06-30  3:33       ` Cheng Xu
  2011-07-01 15:17       ` [tip:sched/core] sched: Skip " tip-bot for Yong Zhang
  0 siblings, 2 replies; 6+ messages in thread
From: Yong Zhang @ 2011-06-28  2:51 UTC (permalink / raw)
  To: Cheng Xu; +Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, Mike Galbraith

[-- Attachment #1: Type: text/plain, Size: 2467 bytes --]

From: Yong Zhang <yong.zhang0@gmail.com>
Subject: [PATCH V2] sched: skip autogroup when looking for all rt sched groups

Since [commit ec514c48: sched: Fix rt_rq runtime leakage bug],
'cat /proc/sched_debug' will print data of root_task_group.rt_rq
multi times, this is due to autogroup has no its own rt group,
instead rt group of autogroup is linked to root_task_group.

So skip it when we are looking for all rt sched groups, and it
will also save some noop operation against root_task_group when
__disable_runtime()/__enable_runtime().

V2: Based on Cheng Xu's idea which uses less code.

Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Cheng Xu <chengxu@linux.vnet.ibm.com>
---

Attach it too in case webmail will mangle the patch.

 kernel/sched_autogroup.h |    1 +
 kernel/sched_rt.c        |   22 +++++++++++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/kernel/sched_autogroup.h b/kernel/sched_autogroup.h
index 0557705..c2f0e72 100644
--- a/kernel/sched_autogroup.h
+++ b/kernel/sched_autogroup.h
@@ -13,6 +13,7 @@ struct autogroup {
 	int			nice;
 };

+static inline bool task_group_is_autogroup(struct task_group *tg);
 static inline struct task_group *
 autogroup_task_group(struct task_struct *p, struct task_group *tg);

diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
index 10d0182..8c04cb2 100644
--- a/kernel/sched_rt.c
+++ b/kernel/sched_rt.c
@@ -185,11 +185,23 @@ static inline u64 sched_rt_period(struct rt_rq *rt_rq)

 typedef struct task_group *rt_rq_iter_t;

-#define for_each_rt_rq(rt_rq, iter, rq) \
-	for (iter = list_entry_rcu(task_groups.next, typeof(*iter), list); \
-	     (&iter->list != &task_groups) && \
-	     (rt_rq = iter->rt_rq[cpu_of(rq)]); \
-	     iter = list_entry_rcu(iter->list.next, typeof(*iter), list))
+static inline struct task_group *next_task_group(struct task_group *tg)
+{
+	do {
+		tg = list_entry_rcu(tg->list.next,
+			typeof(struct task_group), list);
+	} while (&tg->list != &task_groups && task_group_is_autogroup(tg));
+
+	if (&tg->list == &task_groups)
+		tg = NULL;
+
+	return tg;
+}
+
+#define for_each_rt_rq(rt_rq, iter, rq)					\
+	for (iter = container_of(&task_groups, typeof(*iter), list);	\
+		(iter = next_task_group(iter)) &&			\
+		(rt_rq = iter->rt_rq[cpu_of(rq)]);)

 static inline void list_add_leaf_rt_rq(struct rt_rq *rt_rq)
 {
-- 
1.7.4.1

[-- Attachment #2: 0001-sched-skip-autogroup-when-looking-for-all-rt-sched-g.patch --]
[-- Type: text/x-patch, Size: 2582 bytes --]

From e8ffcca971815ba50d6a83e0acd692aee874e106 Mon Sep 17 00:00:00 2001
From: Yong Zhang <yong.zhang0@gmail.com>
Date: Wed, 22 Jun 2011 12:52:40 +0800
Subject: [PATCH V2] sched: skip autogroup when looking for all rt sched groups

Since [commit ec514c48: sched: Fix rt_rq runtime leakage bug],
'cat /proc/sched_debug' will print data of root_task_group.rt_rq
multi times, this is due to autogroup has no its own rt group,
instead rt group of autogroup is linked to root_task_group.

So skip it when we are looking for all rt sched groups, and it
will also save some noop operation against root_task_group when
__disable_runtime()/__enable_runtime().

V2: Based on Cheng Xu's idea which uses less code.

Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Cheng Xu <chengxu@linux.vnet.ibm.com>
---

Attach it too in case webmail will mangle the patch.

 kernel/sched_autogroup.h |    1 +
 kernel/sched_rt.c        |   22 +++++++++++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/kernel/sched_autogroup.h b/kernel/sched_autogroup.h
index 0557705..c2f0e72 100644
--- a/kernel/sched_autogroup.h
+++ b/kernel/sched_autogroup.h
@@ -13,6 +13,7 @@ struct autogroup {
 	int			nice;
 };
 
+static inline bool task_group_is_autogroup(struct task_group *tg);
 static inline struct task_group *
 autogroup_task_group(struct task_struct *p, struct task_group *tg);
 
diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
index 10d0182..8c04cb2 100644
--- a/kernel/sched_rt.c
+++ b/kernel/sched_rt.c
@@ -185,11 +185,23 @@ static inline u64 sched_rt_period(struct rt_rq *rt_rq)
 
 typedef struct task_group *rt_rq_iter_t;
 
-#define for_each_rt_rq(rt_rq, iter, rq) \
-	for (iter = list_entry_rcu(task_groups.next, typeof(*iter), list); \
-	     (&iter->list != &task_groups) && \
-	     (rt_rq = iter->rt_rq[cpu_of(rq)]); \
-	     iter = list_entry_rcu(iter->list.next, typeof(*iter), list))
+static inline struct task_group *next_task_group(struct task_group *tg)
+{
+	do {
+		tg = list_entry_rcu(tg->list.next,
+			typeof(struct task_group), list);
+	} while (&tg->list != &task_groups && task_group_is_autogroup(tg));
+
+	if (&tg->list == &task_groups)
+		tg = NULL;
+
+	return tg;
+}
+
+#define for_each_rt_rq(rt_rq, iter, rq)					\
+	for (iter = container_of(&task_groups, typeof(*iter), list);	\
+		(iter = next_task_group(iter)) &&			\
+		(rt_rq = iter->rt_rq[cpu_of(rq)]);)
 
 static inline void list_add_leaf_rt_rq(struct rt_rq *rt_rq)
 {
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH V2] sched: skip autogroup when looking for all rt sched groups
  2011-06-28  2:51     ` [PATCH V2] " Yong Zhang
@ 2011-06-30  3:33       ` Cheng Xu
  2011-07-01 15:17       ` [tip:sched/core] sched: Skip " tip-bot for Yong Zhang
  1 sibling, 0 replies; 6+ messages in thread
From: Cheng Xu @ 2011-06-30  3:33 UTC (permalink / raw)
  To: Yong Zhang; +Cc: linux-kernel, Peter Zijlstra, Ingo Molnar, Mike Galbraith

On 06/28/2011 10:51 AM, Yong Zhang wrote:
> From: Yong Zhang <yong.zhang0@gmail.com>
> Subject: [PATCH V2] sched: skip autogroup when looking for all rt sched groups
> 
> Since [commit ec514c48: sched: Fix rt_rq runtime leakage bug],
> 'cat /proc/sched_debug' will print data of root_task_group.rt_rq
> multi times, this is due to autogroup has no its own rt group,
> instead rt group of autogroup is linked to root_task_group.
> 
> So skip it when we are looking for all rt sched groups, and it
> will also save some noop operation against root_task_group when
> __disable_runtime()/__enable_runtime().
> 
> V2: Based on Cheng Xu's idea which uses less code.
> 
> Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Mike Galbraith <efault@gmx.de>
> Cc: Cheng Xu <chengxu@linux.vnet.ibm.com>

The code looks fine, and works for me. 

Reviewed-by: Cheng Xu <chengxu@linux.vnet.ibm.com>

> ---
> 
> Attach it too in case webmail will mangle the patch.
> 
>  kernel/sched_autogroup.h |    1 +
>  kernel/sched_rt.c        |   22 +++++++++++++++++-----
>  2 files changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/sched_autogroup.h b/kernel/sched_autogroup.h
> index 0557705..c2f0e72 100644
> --- a/kernel/sched_autogroup.h
> +++ b/kernel/sched_autogroup.h
> @@ -13,6 +13,7 @@ struct autogroup {
>  	int			nice;
>  };
> 
> +static inline bool task_group_is_autogroup(struct task_group *tg);
>  static inline struct task_group *
>  autogroup_task_group(struct task_struct *p, struct task_group *tg);
> 
> diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
> index 10d0182..8c04cb2 100644
> --- a/kernel/sched_rt.c
> +++ b/kernel/sched_rt.c
> @@ -185,11 +185,23 @@ static inline u64 sched_rt_period(struct rt_rq *rt_rq)
> 
>  typedef struct task_group *rt_rq_iter_t;
> 
> -#define for_each_rt_rq(rt_rq, iter, rq) \
> -	for (iter = list_entry_rcu(task_groups.next, typeof(*iter), list); \
> -	     (&iter->list != &task_groups) && \
> -	     (rt_rq = iter->rt_rq[cpu_of(rq)]); \
> -	     iter = list_entry_rcu(iter->list.next, typeof(*iter), list))
> +static inline struct task_group *next_task_group(struct task_group *tg)
> +{
> +	do {
> +		tg = list_entry_rcu(tg->list.next,
> +			typeof(struct task_group), list);
> +	} while (&tg->list != &task_groups && task_group_is_autogroup(tg));
> +
> +	if (&tg->list == &task_groups)
> +		tg = NULL;
> +
> +	return tg;
> +}
> +
> +#define for_each_rt_rq(rt_rq, iter, rq)					\
> +	for (iter = container_of(&task_groups, typeof(*iter), list);	\
> +		(iter = next_task_group(iter)) &&			\
> +		(rt_rq = iter->rt_rq[cpu_of(rq)]);)
> 
>  static inline void list_add_leaf_rt_rq(struct rt_rq *rt_rq)
>  {


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip:sched/core] sched: Skip autogroup when looking for all rt sched groups
  2011-06-28  2:51     ` [PATCH V2] " Yong Zhang
  2011-06-30  3:33       ` Cheng Xu
@ 2011-07-01 15:17       ` tip-bot for Yong Zhang
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot for Yong Zhang @ 2011-07-01 15:17 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, a.p.zijlstra, efault, tglx,
	yong.zhang0, chengxu, mingo

Commit-ID:  1c09ab0d257317f97e8629a3d0c8713d6dd9de4c
Gitweb:     http://git.kernel.org/tip/1c09ab0d257317f97e8629a3d0c8713d6dd9de4c
Author:     Yong Zhang <yong.zhang0@gmail.com>
AuthorDate: Tue, 28 Jun 2011 10:51:31 +0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Fri, 1 Jul 2011 10:39:08 +0200

sched: Skip autogroup when looking for all rt sched groups

Since commit ec514c48 ("sched: Fix rt_rq runtime leakage bug")
'cat /proc/sched_debug' will print data of root_task_group.rt_rq
multiple times.

This is because autogroup does not have its own rt group, instead
rt group of autogroup is linked to root_task_group.

So skip it when we are looking for all rt sched groups, and it
will also save some noop operation against root_task_group when
__disable_runtime()/__enable_runtime().

-v2: Based on Cheng Xu's idea which uses less code.

Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Cheng Xu <chengxu@linux.vnet.ibm.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/BANLkTi=87P3RoTF_UEtamNfc_XGxQXE__Q@mail.gmail.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/sched_autogroup.h |    1 +
 kernel/sched_rt.c        |   22 +++++++++++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/kernel/sched_autogroup.h b/kernel/sched_autogroup.h
index 0557705..c2f0e72 100644
--- a/kernel/sched_autogroup.h
+++ b/kernel/sched_autogroup.h
@@ -13,6 +13,7 @@ struct autogroup {
 	int			nice;
 };
 
+static inline bool task_group_is_autogroup(struct task_group *tg);
 static inline struct task_group *
 autogroup_task_group(struct task_struct *p, struct task_group *tg);
 
diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
index b03cd89..97540f0 100644
--- a/kernel/sched_rt.c
+++ b/kernel/sched_rt.c
@@ -185,11 +185,23 @@ static inline u64 sched_rt_period(struct rt_rq *rt_rq)
 
 typedef struct task_group *rt_rq_iter_t;
 
-#define for_each_rt_rq(rt_rq, iter, rq) \
-	for (iter = list_entry_rcu(task_groups.next, typeof(*iter), list); \
-	     (&iter->list != &task_groups) && \
-	     (rt_rq = iter->rt_rq[cpu_of(rq)]); \
-	     iter = list_entry_rcu(iter->list.next, typeof(*iter), list))
+static inline struct task_group *next_task_group(struct task_group *tg)
+{
+	do {
+		tg = list_entry_rcu(tg->list.next,
+			typeof(struct task_group), list);
+	} while (&tg->list != &task_groups && task_group_is_autogroup(tg));
+
+	if (&tg->list == &task_groups)
+		tg = NULL;
+
+	return tg;
+}
+
+#define for_each_rt_rq(rt_rq, iter, rq)					\
+	for (iter = container_of(&task_groups, typeof(*iter), list);	\
+		(iter = next_task_group(iter)) &&			\
+		(rt_rq = iter->rt_rq[cpu_of(rq)]);)
 
 static inline void list_add_leaf_rt_rq(struct rt_rq *rt_rq)
 {

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-07-01 15:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-22  5:22 [PATCH] sched: skip autogroup when looking for all rt sched groups Yong Zhang
2011-06-23 11:21 ` Cheng Xu
2011-06-28  2:40   ` Yong Zhang
2011-06-28  2:51     ` [PATCH V2] " Yong Zhang
2011-06-30  3:33       ` Cheng Xu
2011-07-01 15:17       ` [tip:sched/core] sched: Skip " tip-bot for Yong Zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.