Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1655980 > unrolled thread

[PATCH 2/2] sched/deadline: Don't return invalid cpu in cpudl_maximum_cpu()

Started byByungchul Park <byungchul.park@lge.com>
First post2017-06-02 09:40 +0200
Last post2017-06-07 02:20 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/2] sched/deadline: Don't return invalid cpu in cpudl_maximum_cpu() Byungchul Park <byungchul.park@lge.com> - 2017-06-02 09:40 +0200
    Re: [PATCH 2/2] sched/deadline: Don't return invalid cpu in  cpudl_maximum_cpu() Juri Lelli <juri.lelli@arm.com> - 2017-06-06 17:20 +0200
      Re: [PATCH 2/2] sched/deadline: Don't return invalid cpu in  cpudl_maximum_cpu() Byungchul Park <byungchul.park@lge.com> - 2017-06-07 01:50 +0200
        Re: [PATCH 2/2] sched/deadline: Don't return invalid cpu in  cpudl_maximum_cpu() Byungchul Park <byungchul.park@lge.com> - 2017-06-07 02:20 +0200

#1655980 — [PATCH 2/2] sched/deadline: Don't return invalid cpu in cpudl_maximum_cpu()

FromByungchul Park <byungchul.park@lge.com>
Date2017-06-02 09:40 +0200
Subject[PATCH 2/2] sched/deadline: Don't return invalid cpu in cpudl_maximum_cpu()
Message-ID<tNPlE-6o8-29@gated-at.bofh.it>
When the heap tree is empty, cp->elements[0].cpu has meaningless value.
We need to consider the case.

Signed-off-by: Byungchul Park <byungchul.park@lge.com>
---
 kernel/sched/cpudeadline.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
index d4a6963..9b314a9 100644
--- a/kernel/sched/cpudeadline.c
+++ b/kernel/sched/cpudeadline.c
@@ -110,7 +110,8 @@ static void cpudl_heapify(struct cpudl *cp, int idx)
 
 static inline int cpudl_maximum_cpu(struct cpudl *cp)
 {
-	return cp->elements[0].cpu;
+	int cpu = cp->elements[0].cpu;
+	return cp->elements[cpu].idx == IDX_INVALID ? -1 : cpu;
 }
 
 static inline u64 cpudl_maximum_dl(struct cpudl *cp)
-- 
1.9.1

[toc] | [next] | [standalone]


#1658860 — Re: [PATCH 2/2] sched/deadline: Don't return invalid cpu in cpudl_maximum_cpu()

FromJuri Lelli <juri.lelli@arm.com>
Date2017-06-06 17:20 +0200
SubjectRe: [PATCH 2/2] sched/deadline: Don't return invalid cpu in cpudl_maximum_cpu()
Message-ID<tPor0-24q-15@gated-at.bofh.it>
In reply to#1655980
Hi,

On 02/06/17 16:31, Byungchul Park wrote:
> When the heap tree is empty, cp->elements[0].cpu has meaningless value.
> We need to consider the case.
> 
> Signed-off-by: Byungchul Park <byungchul.park@lge.com>
> ---
>  kernel/sched/cpudeadline.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
> index d4a6963..9b314a9 100644
> --- a/kernel/sched/cpudeadline.c
> +++ b/kernel/sched/cpudeadline.c
> @@ -110,7 +110,8 @@ static void cpudl_heapify(struct cpudl *cp, int idx)
>  
>  static inline int cpudl_maximum_cpu(struct cpudl *cp)
>  {
> -	return cp->elements[0].cpu;
> +	int cpu = cp->elements[0].cpu;
> +	return cp->elements[cpu].idx == IDX_INVALID ? -1 : cpu;

Mmm, don't we get a WARN from cpumask_check() if we return -1 here?

Thanks,

- Juri

[toc] | [prev] | [next] | [standalone]


#1659301 — Re: [PATCH 2/2] sched/deadline: Don't return invalid cpu in cpudl_maximum_cpu()

FromByungchul Park <byungchul.park@lge.com>
Date2017-06-07 01:50 +0200
SubjectRe: [PATCH 2/2] sched/deadline: Don't return invalid cpu in cpudl_maximum_cpu()
Message-ID<tPwox-7a2-3@gated-at.bofh.it>
In reply to#1658860
On Tue, Jun 06, 2017 at 04:12:25PM +0100, Juri Lelli wrote:
> Hi,
> 
> On 02/06/17 16:31, Byungchul Park wrote:
> > When the heap tree is empty, cp->elements[0].cpu has meaningless value.

Hi,

The meaningless value is 0.

> > We need to consider the case.
> > 
> > Signed-off-by: Byungchul Park <byungchul.park@lge.com>
> > ---
> >  kernel/sched/cpudeadline.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
> > index d4a6963..9b314a9 100644
> > --- a/kernel/sched/cpudeadline.c
> > +++ b/kernel/sched/cpudeadline.c
> > @@ -110,7 +110,8 @@ static void cpudl_heapify(struct cpudl *cp, int idx)
> >  
> >  static inline int cpudl_maximum_cpu(struct cpudl *cp)
> >  {
> > -	return cp->elements[0].cpu;
> > +	int cpu = cp->elements[0].cpu;
> > +	return cp->elements[cpu].idx == IDX_INVALID ? -1 : cpu;
> 
> Mmm, don't we get a WARN from cpumask_check() if we return -1 here?

The function does not return -1 without my patch.

Right?

> 
> Thanks,
> 
> - Juri

[toc] | [prev] | [next] | [standalone]


#1659310 — Re: [PATCH 2/2] sched/deadline: Don't return invalid cpu in cpudl_maximum_cpu()

FromByungchul Park <byungchul.park@lge.com>
Date2017-06-07 02:20 +0200
SubjectRe: [PATCH 2/2] sched/deadline: Don't return invalid cpu in cpudl_maximum_cpu()
Message-ID<tPwRz-7z5-3@gated-at.bofh.it>
In reply to#1659301
On Wed, Jun 07, 2017 at 08:42:24AM +0900, Byungchul Park wrote:
> On Tue, Jun 06, 2017 at 04:12:25PM +0100, Juri Lelli wrote:
> > Hi,
> > 
> > On 02/06/17 16:31, Byungchul Park wrote:
> > > When the heap tree is empty, cp->elements[0].cpu has meaningless value.
> 
> Hi,
> 
> The meaningless value is 0.
> 
> > > We need to consider the case.
> > > 
> > > Signed-off-by: Byungchul Park <byungchul.park@lge.com>
> > > ---
> > >  kernel/sched/cpudeadline.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
> > > index d4a6963..9b314a9 100644
> > > --- a/kernel/sched/cpudeadline.c
> > > +++ b/kernel/sched/cpudeadline.c
> > > @@ -110,7 +110,8 @@ static void cpudl_heapify(struct cpudl *cp, int idx)
> > >  
> > >  static inline int cpudl_maximum_cpu(struct cpudl *cp)
> > >  {
> > > -	return cp->elements[0].cpu;
> > > +	int cpu = cp->elements[0].cpu;
> > > +	return cp->elements[cpu].idx == IDX_INVALID ? -1 : cpu;
> > 
> > Mmm, don't we get a WARN from cpumask_check() if we return -1 here?
> 
> The function does not return -1 without my patch.
> 
> Right?

Or the following patch would be needed, instead.

----->8-----

From cada1345bf0ff8e6b5743999509d2abcacd79a9e Mon Sep 17 00:00:00 2001
From: Byungchul Park <byungchul.park@lge.com>
Date: Wed, 7 Jun 2017 09:05:34 +0900
Subject: [PATCH 2/2] sched/deadline: Initialize cp->elements[].cpu to an
 invalid value

Currently, when the heap tree is empty, cpudl_maximum_cpu() returns 0,
which causes unnecessary migration. It has to return an invalid value
e.g. -1 to prevent that.

Signed-off-by: Byungchul Park <byungchul.park@lge.com>
---
 kernel/sched/cpudeadline.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
index d4a6963..0f67cea 100644
--- a/kernel/sched/cpudeadline.c
+++ b/kernel/sched/cpudeadline.c
@@ -266,8 +266,10 @@ int cpudl_init(struct cpudl *cp)
 		return -ENOMEM;
 	}
 
-	for_each_possible_cpu(i)
+	for_each_possible_cpu(i) {
+		cp->elements[i].cpu = -1;
 		cp->elements[i].idx = IDX_INVALID;
+	}
 
 	return 0;
 }
-- 
1.9.1

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web