linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] sched/deadline: reduce overhead if there are no scheduling parameters changed
@ 2014-11-19  8:35 Wanpeng Li
  2014-11-19  8:35 ` [PATCH 2/2] sched/deadline: fix pull if dl task who's prio changed is not on queue Wanpeng Li
  2014-11-25 17:49 ` [PATCH 1/2] sched/deadline: reduce overhead if there are no scheduling parameters changed Juri Lelli
  0 siblings, 2 replies; 7+ messages in thread
From: Wanpeng Li @ 2014-11-19  8:35 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra
  Cc: Juri Lelli, Kirill Tkhai, linux-kernel, Wanpeng Li

There is no need to dequeue/enqueue and push/pull if there are
no scheduling parameters changed for dl class, actually both 
fair and rt class have already check if parameters changed for 
them to avoid unnecessary overhead. This patch add the parameters 
changed verify for dl class in order to reduce overhead.

Signed-off-by: Wanpeng Li <wanpeng.li@linux.intel.com>
---
 kernel/sched/core.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 603c462..f361867 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3402,6 +3402,21 @@ static bool check_same_owner(struct task_struct *p)
 	return match;
 }
 
+static bool dl_param_changed(struct task_struct *p,
+			const struct sched_attr *attr)
+{
+	struct sched_dl_entity *dl_se = &p->dl;
+
+	if (dl_se->dl_runtime != attr->sched_runtime ||
+		dl_se->dl_deadline != attr->sched_deadline ||
+		dl_se->dl_period != attr->sched_period ||
+		dl_se->flags != attr->sched_flags ||
+		p->rt_priority != attr->sched_priority)
+		return true;
+
+	return false;
+}
+
 static int __sched_setscheduler(struct task_struct *p,
 				const struct sched_attr *attr,
 				bool user)
@@ -3530,7 +3545,7 @@ recheck:
 			goto change;
 		if (rt_policy(policy) && attr->sched_priority != p->rt_priority)
 			goto change;
-		if (dl_policy(policy))
+		if (dl_policy(policy) && dl_param_changed(p, attr))
 			goto change;
 
 		p->sched_reset_on_fork = reset_on_fork;
-- 
1.9.1


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

* [PATCH 2/2] sched/deadline: fix pull if dl task who's prio changed is not on queue
  2014-11-19  8:35 [PATCH 1/2] sched/deadline: reduce overhead if there are no scheduling parameters changed Wanpeng Li
@ 2014-11-19  8:35 ` Wanpeng Li
  2014-11-25 17:54   ` Juri Lelli
  2014-11-25 17:49 ` [PATCH 1/2] sched/deadline: reduce overhead if there are no scheduling parameters changed Juri Lelli
  1 sibling, 1 reply; 7+ messages in thread
From: Wanpeng Li @ 2014-11-19  8:35 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra
  Cc: Juri Lelli, Kirill Tkhai, linux-kernel, Wanpeng Li

Dl task who is not on queue and it is also the curr task simultaneously 
can not happen. In addition, pull since the priority of a not on queue 
dl task doesn't make any sense.

This patch fix it by don't pull if dl task who's prio changed is not on 
queue.

Signed-off-by: Wanpeng Li <wanpeng.li@linux.intel.com>
---
 kernel/sched/deadline.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index b9e44ae..4eaf55c 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1678,7 +1678,10 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
 static void prio_changed_dl(struct rq *rq, struct task_struct *p,
 			    int oldprio)
 {
-	if (task_on_rq_queued(p) || rq->curr == p) {
+	if (!task_on_rq_queued(p))
+		return;
+
+	if (rq->curr == p) {
 #ifdef CONFIG_SMP
 		/*
 		 * This might be too much, but unfortunately
-- 
1.9.1


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

* Re: [PATCH 1/2] sched/deadline: reduce overhead if there are no scheduling parameters changed
  2014-11-19  8:35 [PATCH 1/2] sched/deadline: reduce overhead if there are no scheduling parameters changed Wanpeng Li
  2014-11-19  8:35 ` [PATCH 2/2] sched/deadline: fix pull if dl task who's prio changed is not on queue Wanpeng Li
@ 2014-11-25 17:49 ` Juri Lelli
  1 sibling, 0 replies; 7+ messages in thread
From: Juri Lelli @ 2014-11-25 17:49 UTC (permalink / raw)
  To: Wanpeng Li, Ingo Molnar, Peter Zijlstra; +Cc: Kirill Tkhai, linux-kernel

Hi,

On 19/11/14 08:35, Wanpeng Li wrote:
> There is no need to dequeue/enqueue and push/pull if there are
> no scheduling parameters changed for dl class, actually both 
> fair and rt class have already check if parameters changed for 
> them to avoid unnecessary overhead. This patch add the parameters 
> changed verify for dl class in order to reduce overhead.
> 
> Signed-off-by: Wanpeng Li <wanpeng.li@linux.intel.com>
> ---
>  kernel/sched/core.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 603c462..f361867 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -3402,6 +3402,21 @@ static bool check_same_owner(struct task_struct *p)
>  	return match;
>  }
>  
> +static bool dl_param_changed(struct task_struct *p,
> +			const struct sched_attr *attr)

Please check alignment.

> +{
> +	struct sched_dl_entity *dl_se = &p->dl;
> +
> +	if (dl_se->dl_runtime != attr->sched_runtime ||
> +		dl_se->dl_deadline != attr->sched_deadline ||
> +		dl_se->dl_period != attr->sched_period ||
> +		dl_se->flags != attr->sched_flags ||
> +		p->rt_priority != attr->sched_priority)

This last one is useless, as we fail above if
attr->sched_priority != 0 when task has !rt_policy.

Thanks,

- Juri

> +		return true;
> +
> +	return false;
> +}
> +
>  static int __sched_setscheduler(struct task_struct *p,
>  				const struct sched_attr *attr,
>  				bool user)
> @@ -3530,7 +3545,7 @@ recheck:
>  			goto change;
>  		if (rt_policy(policy) && attr->sched_priority != p->rt_priority)
>  			goto change;
> -		if (dl_policy(policy))
> +		if (dl_policy(policy) && dl_param_changed(p, attr))
>  			goto change;
>  
>  		p->sched_reset_on_fork = reset_on_fork;
> 


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

* Re: [PATCH 2/2] sched/deadline: fix pull if dl task who's prio changed is not on queue
  2014-11-19  8:35 ` [PATCH 2/2] sched/deadline: fix pull if dl task who's prio changed is not on queue Wanpeng Li
@ 2014-11-25 17:54   ` Juri Lelli
  2014-11-25 22:55     ` Wanpeng Li
  0 siblings, 1 reply; 7+ messages in thread
From: Juri Lelli @ 2014-11-25 17:54 UTC (permalink / raw)
  To: Wanpeng Li, Ingo Molnar, Peter Zijlstra; +Cc: Kirill Tkhai, linux-kernel

Hi,

On 19/11/14 08:35, Wanpeng Li wrote:
> Dl task who is not on queue and it is also the curr task simultaneously 
> can not happen. In addition, pull since the priority of a not on queue 
> dl task doesn't make any sense.
> 
> This patch fix it by don't pull if dl task who's prio changed is not on 
> queue.
> 
> Signed-off-by: Wanpeng Li <wanpeng.li@linux.intel.com>
> ---
>  kernel/sched/deadline.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index b9e44ae..4eaf55c 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -1678,7 +1678,10 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
>  static void prio_changed_dl(struct rq *rq, struct task_struct *p,
>  			    int oldprio)
>  {
> -	if (task_on_rq_queued(p) || rq->curr == p) {
> +	if (!task_on_rq_queued(p))
> +		return;
> +
> +	if (rq->curr == p) {

Yeah. I already posted a patches for this, that I forgot to properly
post again :/. I'll do it soon.

Thanks,

- Juri

>  #ifdef CONFIG_SMP
>  		/*
>  		 * This might be too much, but unfortunately
> 


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

* Re: [PATCH 2/2] sched/deadline: fix pull if dl task who's prio changed is not on queue
  2014-11-25 17:54   ` Juri Lelli
@ 2014-11-25 22:55     ` Wanpeng Li
  0 siblings, 0 replies; 7+ messages in thread
From: Wanpeng Li @ 2014-11-25 22:55 UTC (permalink / raw)
  To: Juri Lelli
  Cc: Wanpeng Li, Ingo Molnar, Peter Zijlstra, Kirill Tkhai, linux-kernel

Hi Juri,
On Tue, Nov 25, 2014 at 05:54:29PM +0000, Juri Lelli wrote:
>Hi,
>
>On 19/11/14 08:35, Wanpeng Li wrote:
>> Dl task who is not on queue and it is also the curr task simultaneously 
>> can not happen. In addition, pull since the priority of a not on queue 
>> dl task doesn't make any sense.
>> 
>> This patch fix it by don't pull if dl task who's prio changed is not on 
>> queue.
>> 
>> Signed-off-by: Wanpeng Li <wanpeng.li@linux.intel.com>
>> ---
>>  kernel/sched/deadline.c | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>> 
>> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
>> index b9e44ae..4eaf55c 100644
>> --- a/kernel/sched/deadline.c
>> +++ b/kernel/sched/deadline.c
>> @@ -1678,7 +1678,10 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
>>  static void prio_changed_dl(struct rq *rq, struct task_struct *p,
>>  			    int oldprio)
>>  {
>> -	if (task_on_rq_queued(p) || rq->curr == p) {
>> +	if (!task_on_rq_queued(p))
>> +		return;
>> +
>> +	if (rq->curr == p) {
>
>Yeah. I already posted a patches for this, that I forgot to properly
>post again :/. I'll do it soon.

Cool, so we can ignore this patch from me, and you can move forward. ;-)
I will resend the recent posted patches in one patchset so you can
review them easily.

Regards,
Wanpeng Li 

>
>Thanks,
>
>- Juri
>
>>  #ifdef CONFIG_SMP
>>  		/*
>>  		 * This might be too much, but unfortunately
>> 

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

* Re: [PATCH 1/2] sched/deadline: reduce overhead if there are no scheduling parameters changed
  2014-11-19 10:01 Wanpeng Li
@ 2014-11-19 12:28 ` Wanpeng Li
  0 siblings, 0 replies; 7+ messages in thread
From: Wanpeng Li @ 2014-11-19 12:28 UTC (permalink / raw)
  To: Wanpeng Li, Ingo Molnar, Peter Zijlstra
  Cc: Juri Lelli, Kirill Tkhai, linux-kernel

Sorry to send out a duplicated patchset, please ignore this one.
On 11/19/14, 6:01 PM, Wanpeng Li wrote:
> There is no need to dequeue/enqueue and push/pull if there are
> no scheduling parameters changed for dl class, actually both
> fair and rt class have already check if parameters changed for
> them to avoid unnecessary overhead. This patch add the parameters
> changed verify for dl class in order to reduce overhead.
>
> Signed-off-by: Wanpeng Li <wanpeng.li@linux.intel.com>
> ---
>   kernel/sched/core.c | 17 ++++++++++++++++-
>   1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 603c462..f361867 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -3402,6 +3402,21 @@ static bool check_same_owner(struct task_struct *p)
>   	return match;
>   }
>   
> +static bool dl_param_changed(struct task_struct *p,
> +			const struct sched_attr *attr)
> +{
> +	struct sched_dl_entity *dl_se = &p->dl;
> +
> +	if (dl_se->dl_runtime != attr->sched_runtime ||
> +		dl_se->dl_deadline != attr->sched_deadline ||
> +		dl_se->dl_period != attr->sched_period ||
> +		dl_se->flags != attr->sched_flags ||
> +		p->rt_priority != attr->sched_priority)
> +		return true;
> +
> +	return false;
> +}
> +
>   static int __sched_setscheduler(struct task_struct *p,
>   				const struct sched_attr *attr,
>   				bool user)
> @@ -3530,7 +3545,7 @@ recheck:
>   			goto change;
>   		if (rt_policy(policy) && attr->sched_priority != p->rt_priority)
>   			goto change;
> -		if (dl_policy(policy))
> +		if (dl_policy(policy) && dl_param_changed(p, attr))
>   			goto change;
>   
>   		p->sched_reset_on_fork = reset_on_fork;


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

* [PATCH 1/2] sched/deadline: reduce overhead if there are no scheduling parameters changed
@ 2014-11-19 10:01 Wanpeng Li
  2014-11-19 12:28 ` Wanpeng Li
  0 siblings, 1 reply; 7+ messages in thread
From: Wanpeng Li @ 2014-11-19 10:01 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra
  Cc: Juri Lelli, Kirill Tkhai, linux-kernel, Wanpeng Li

There is no need to dequeue/enqueue and push/pull if there are
no scheduling parameters changed for dl class, actually both 
fair and rt class have already check if parameters changed for 
them to avoid unnecessary overhead. This patch add the parameters 
changed verify for dl class in order to reduce overhead.

Signed-off-by: Wanpeng Li <wanpeng.li@linux.intel.com>
---
 kernel/sched/core.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 603c462..f361867 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3402,6 +3402,21 @@ static bool check_same_owner(struct task_struct *p)
 	return match;
 }
 
+static bool dl_param_changed(struct task_struct *p,
+			const struct sched_attr *attr)
+{
+	struct sched_dl_entity *dl_se = &p->dl;
+
+	if (dl_se->dl_runtime != attr->sched_runtime ||
+		dl_se->dl_deadline != attr->sched_deadline ||
+		dl_se->dl_period != attr->sched_period ||
+		dl_se->flags != attr->sched_flags ||
+		p->rt_priority != attr->sched_priority)
+		return true;
+
+	return false;
+}
+
 static int __sched_setscheduler(struct task_struct *p,
 				const struct sched_attr *attr,
 				bool user)
@@ -3530,7 +3545,7 @@ recheck:
 			goto change;
 		if (rt_policy(policy) && attr->sched_priority != p->rt_priority)
 			goto change;
-		if (dl_policy(policy))
+		if (dl_policy(policy) && dl_param_changed(p, attr))
 			goto change;
 
 		p->sched_reset_on_fork = reset_on_fork;
-- 
1.9.1


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

end of thread, other threads:[~2014-11-25 23:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-19  8:35 [PATCH 1/2] sched/deadline: reduce overhead if there are no scheduling parameters changed Wanpeng Li
2014-11-19  8:35 ` [PATCH 2/2] sched/deadline: fix pull if dl task who's prio changed is not on queue Wanpeng Li
2014-11-25 17:54   ` Juri Lelli
2014-11-25 22:55     ` Wanpeng Li
2014-11-25 17:49 ` [PATCH 1/2] sched/deadline: reduce overhead if there are no scheduling parameters changed Juri Lelli
2014-11-19 10:01 Wanpeng Li
2014-11-19 12:28 ` Wanpeng Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).