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


Groups > linux.kernel > #1579471 > unrolled thread

[PATCH v2 8/9] sched: Don't reinvent the wheel but use existing llist API

Started byByungchul Park <byungchul.park@lge.com>
First post2017-02-13 08:30 +0100
Last post2017-02-13 17:00 +0100
Articles 3 — 3 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 v2 8/9] sched: Don't reinvent the wheel but use existing llist API Byungchul Park <byungchul.park@lge.com> - 2017-02-13 08:30 +0100
    Re: [PATCH v2 8/9] sched: Don't reinvent the wheel but use existing  llist API Peter Zijlstra <peterz@infradead.org> - 2017-02-13 11:10 +0100
      Re: [PATCH v2 8/9] sched: Don't reinvent the wheel but use existing  llist API Oleg Nesterov <oleg@redhat.com> - 2017-02-13 17:00 +0100

#1579471 — [PATCH v2 8/9] sched: Don't reinvent the wheel but use existing llist API

FromByungchul Park <byungchul.park@lge.com>
Date2017-02-13 08:30 +0100
Subject[PATCH v2 8/9] sched: Don't reinvent the wheel but use existing llist API
Message-ID<tajfc-zU-5@gated-at.bofh.it>
Although llist provides proper APIs, they are not used. Make them used.

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

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index d01f9d0..417060b 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1783,17 +1783,8 @@ void sched_ttwu_pending(void)
 	raw_spin_lock_irqsave(&rq->lock, flags);
 	rq_pin_lock(rq, &rf);
 
-	while (llist) {
-		int wake_flags = 0;
-
-		p = llist_entry(llist, struct task_struct, wake_entry);
-		llist = llist_next(llist);
-
-		if (p->sched_remote_wakeup)
-			wake_flags = WF_MIGRATED;
-
-		ttwu_do_activate(rq, p, wake_flags, &rf);
-	}
+	llist_for_each_entry(p, llist, wake_entry)
+		ttwu_do_activate(rq, p, p->sched_remote_wakeup ? WF_MIGRATED : 0, &rf);
 
 	rq_unpin_lock(rq, &rf);
 	raw_spin_unlock_irqrestore(&rq->lock, flags);
-- 
1.9.1

[toc] | [next] | [standalone]


#1579570 — Re: [PATCH v2 8/9] sched: Don't reinvent the wheel but use existing llist API

FromPeter Zijlstra <peterz@infradead.org>
Date2017-02-13 11:10 +0100
SubjectRe: [PATCH v2 8/9] sched: Don't reinvent the wheel but use existing llist API
Message-ID<talK2-2iF-13@gated-at.bofh.it>
In reply to#1579471
On Mon, Feb 13, 2017 at 04:21:08PM +0900, Byungchul Park wrote:
> Although llist provides proper APIs, they are not used. Make them used.
> 
> Signed-off-by: Byungchul Park <byungchul.park@lge.com>
> ---
>  kernel/sched/core.c | 13 ++-----------
>  1 file changed, 2 insertions(+), 11 deletions(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index d01f9d0..417060b 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -1783,17 +1783,8 @@ void sched_ttwu_pending(void)
>  	raw_spin_lock_irqsave(&rq->lock, flags);
>  	rq_pin_lock(rq, &rf);
>  
> -	while (llist) {
> -		int wake_flags = 0;
> -
> -		p = llist_entry(llist, struct task_struct, wake_entry);
> -		llist = llist_next(llist);
> -
> -		if (p->sched_remote_wakeup)
> -			wake_flags = WF_MIGRATED;
> -
> -		ttwu_do_activate(rq, p, wake_flags, &rf);
> -	}
> +	llist_for_each_entry(p, llist, wake_entry)
> +		ttwu_do_activate(rq, p, p->sched_remote_wakeup ? WF_MIGRATED : 0, &rf);

I think this suffers the exact same problem the others did. After
ttwu_do_activate() the llist entry can be reused, so doing list_next()
after it is flaky.

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


#1579904 — Re: [PATCH v2 8/9] sched: Don't reinvent the wheel but use existing llist API

FromOleg Nesterov <oleg@redhat.com>
Date2017-02-13 17:00 +0100
SubjectRe: [PATCH v2 8/9] sched: Don't reinvent the wheel but use existing llist API
Message-ID<tarcJ-5Fx-1@gated-at.bofh.it>
In reply to#1579570
On 02/13, Peter Zijlstra wrote:
>
> On Mon, Feb 13, 2017 at 04:21:08PM +0900, Byungchul Park wrote:
> > +	llist_for_each_entry(p, llist, wake_entry)
> > +		ttwu_do_activate(rq, p, p->sched_remote_wakeup ? WF_MIGRATED : 0, &rf);
>
> I think this suffers the exact same problem the others did. After
> ttwu_do_activate() the llist entry can be reused, so doing list_next()
> after it is flaky.

llist_for_each_entry_safe() should work, I guess.

Oleg.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web