Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758485AbbLBOIr (ORCPT ); Wed, 2 Dec 2015 09:08:47 -0500 Received: from mail-wm0-f45.google.com ([74.125.82.45]:34538 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752097AbbLBOIp (ORCPT ); Wed, 2 Dec 2015 09:08:45 -0500 Subject: Re: [PATCH v5] sched/deadline: fix earliest_dl.next logic To: Wanpeng Li , Juri Lelli , Wanpeng Li References: <1449056847-17190-1-git-send-email-wanpeng.li@hotmail.com> <20151202120454.GZ20439@e106622-lin> Cc: Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org From: Luca Abeni Message-ID: <565EFB6A.10607@unitn.it> Date: Wed, 2 Dec 2015 15:08:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2633 Lines: 75 Hi, On 12/02/2015 02:33 PM, Wanpeng Li wrote: [...] >> We updated leftmost above, can't we simply use that path for this thing >> below? > > Do you mean something like below? > > @@ -195,6 +195,9 @@ static void dequeue_pushable_dl_task(struct rq *rq, struct task_struct *p) > > next_node = rb_next(&p->pushable_dl_tasks); > dl_rq->pushable_dl_tasks_leftmost = next_node; > + if (has_pushable_dl_tasks(rq)) I do not know the rb trees code, but... Are you sre you can call has_pushable_tasks() here? (I suspect pushable_dl_tasks_root is not updated yet, so maybe has_pushable_dl_tasks() risks to return a wrong value?) > + dl_rq->earliest_dl.next = rb_entry(rq->dl.pushable_dl_tasks_leftmost, > + struct task_struct, pushable_dl_task)->dl.deadline; I am not sure if this is what Juri meant, but maybe something like this? diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 087d090..26d3279 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -185,11 +185,6 @@ static void enqueue_pushable_dl_task(struct rq *rq, struct task_struct *p) rb_insert_color(&p->pushable_dl_tasks, &dl_rq->pushable_dl_tasks_root); } -static inline int has_pushable_dl_tasks(struct rq *rq) -{ - return !RB_EMPTY_ROOT(&rq->dl.pushable_dl_tasks_root); -} - static void dequeue_pushable_dl_task(struct rq *rq, struct task_struct *p) { struct dl_rq *dl_rq = &rq->dl; @@ -202,16 +197,18 @@ static void dequeue_pushable_dl_task(struct rq *rq, struct task_struct *p) next_node = rb_next(&p->pushable_dl_tasks); dl_rq->pushable_dl_tasks_leftmost = next_node; + if (next_node) + dl_rq->earliest_dl.next = rb_entry(next_node, + struct task_struct, pushable_dl_tasks)->dl.deadline; } rb_erase(&p->pushable_dl_tasks, &dl_rq->pushable_dl_tasks_root); RB_CLEAR_NODE(&p->pushable_dl_tasks); +} - if (has_pushable_dl_tasks(rq)) { - p = rb_entry(rq->dl.pushable_dl_tasks_leftmost, - struct task_struct, pushable_dl_tasks); - dl_rq->earliest_dl.next = p->dl.deadline; - } +static inline int has_pushable_dl_tasks(struct rq *rq) +{ + return !RB_EMPTY_ROOT(&rq->dl.pushable_dl_tasks_root); } static int push_dl_task(struct rq *rq); I do not know if it is correct, but I ran some quick tests and seem to work without problems. Luca -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/