From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933215AbbELOsS (ORCPT ); Tue, 12 May 2015 10:48:18 -0400 Received: from m50-112.126.com ([123.125.50.112]:57825 "EHLO m50-112.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932375AbbELOsP (ORCPT ); Tue, 12 May 2015 10:48:15 -0400 From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Steven Rostedt , Juri Lelli , Ingo Molnar , Xunlei Pang Subject: [PATCH v3 2/4] sched/deadline: Check to push the task away after its affinity was changed Date: Tue, 12 May 2015 22:46:42 +0800 Message-Id: <1431442004-18716-2-git-send-email-xlpang@126.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431442004-18716-1-git-send-email-xlpang@126.com> References: <1431442004-18716-1-git-send-email-xlpang@126.com> X-CM-TRANSID: j9KowAAnVHFdElJVTB0hBw--.1248S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7ZFyxuFyrCryfCr1fZryfCrg_yoW8tFW7pr s2ka45WF4UJayIg343Zws5AFyrW3s7t342y3W3KFW8CFZ5XF4jvF90vFW3XrZIgr1I9F42 qF1vqF92k3Wjy3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jlc_3UUUUU= X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbi7wb3v1Uwxlu5GgAAs6 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xunlei Pang (Sync up the same behaviour as that of RT.) We may suffer from extra dl overload rq due to the affinity, so when the affinity of any runnable dl task is changed, we should check to trigger balancing, otherwise it will cause some unnecessary delayed real-time response. Unfortunately, current DL global scheduler does nothing about this. This patch modified set_cpus_allowed_dl(), if the target task is runnable but not running and not throttled, it tries to push it away once it got migratable. The patch also solves a problem about move_queued_task() called in set_cpus_allowed_ptr(): When a smaller deadline value dl task got migrated due to its curr cpu isn't in the new affinity mask, after move_queued_task() it will miss the chance of pushing away, because check_preempt_curr() called by move_queued_task() doens't set the "need resched flag" for smaller deadline value tasks. Signed-off-by: Xunlei Pang --- kernel/sched/deadline.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 3baffb2..968612b 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1615,11 +1615,12 @@ static bool set_cpus_allowed_dl(struct task_struct *p, weight = cpumask_weight(new_mask); /* - * Only update if the process changes its state from whether it - * can migrate or not. + * Skip updating the migration stuff if the process doesn't change + * its migrate state, but still need to check if it can be pushed + * away due to its new affinity. */ if ((p->nr_cpus_allowed > 1) == (weight > 1)) - return false; + goto check_push; /* * The process used to be able to migrate OR it can now migrate @@ -1637,6 +1638,18 @@ static bool set_cpus_allowed_dl(struct task_struct *p, update_dl_migration(&rq->dl); +check_push: + if (weight > 1 && + !task_running(rq, p) && + !test_tsk_need_resched(rq->curr) && + !cpumask_subset(new_mask, &p->cpus_allowed)) { + /* Update new affinity and try to push. */ + cpumask_copy(&p->cpus_allowed, new_mask); + p->nr_cpus_allowed = weight; + push_dl_tasks(rq); + return true; + } + return false; } -- 1.9.1