From patchwork Tue May 12 14:46:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 48394 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6E0B4214A1 for ; Tue, 12 May 2015 14:48:34 +0000 (UTC) Received: by labgx2 with SMTP id gx2sf2673416lab.1 for ; Tue, 12 May 2015 07:48:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=2eTecwWb2uyqvfywfzZo5G6ehh2Sm7f3CeMm9CXNMpQ=; b=XILcgA8TcZ8i1NzaT5iCcx4xBRonVoY+s69WC2qUQy4wYiYyE/UtKUB3oF4K+Hk5iu f244ApWpWHz4O6zyvXHyqQoeTVgWZm0P1ImYPfZsKQLHPvm0nDLoFW6ogxEftVMpNrQa GyJEwY88ImgZlBgRyeURvpwG/7HtHzRWIxc8oXk4G5G41axt45wgJeejEnlh0uCgzkxe ohjq2sWUkJpXYihXOziQ6A4J8oq+I+gctxqPAz6TOvtSKQEEVlzrkIfKKyNzI5PHMItG QmCAHaw8dRF1/VZOMmi6pYm0K7vyOkCShqZ5I7+Pfnst/7+VovhWJsXY7Kl3eguH4vPv 8qMg== X-Gm-Message-State: ALoCoQlw9shLn65861BPHq4I7PygeItCRnPvUaCcBfuYFXLXfsnevPF6MvNh46b+/fRVWKLbRsWH X-Received: by 10.112.171.41 with SMTP id ar9mr10882658lbc.24.1431442112838; Tue, 12 May 2015 07:48:32 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.184.8 with SMTP id eq8ls49874lac.91.gmail; Tue, 12 May 2015 07:48:32 -0700 (PDT) X-Received: by 10.152.207.105 with SMTP id lv9mr12530628lac.10.1431442112665; Tue, 12 May 2015 07:48:32 -0700 (PDT) Received: from mail-la0-x229.google.com (mail-la0-x229.google.com. [2a00:1450:4010:c03::229]) by mx.google.com with ESMTPS id tp6si10500481lbb.97.2015.05.12.07.48.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2015 07:48:32 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::229 as permitted sender) client-ip=2a00:1450:4010:c03::229; Received: by labbd9 with SMTP id bd9so7755483lab.2 for ; Tue, 12 May 2015 07:48:32 -0700 (PDT) X-Received: by 10.152.87.204 with SMTP id ba12mr12594766lab.35.1431442112571; Tue, 12 May 2015 07:48:32 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp2135851lbb; Tue, 12 May 2015 07:48:31 -0700 (PDT) X-Received: by 10.70.43.176 with SMTP id x16mr28454988pdl.83.1431442110761; Tue, 12 May 2015 07:48:30 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ub8si22797172pbc.64.2015.05.12.07.48.29; Tue, 12 May 2015 07:48:30 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933235AbbELOsS (ORCPT + 28 others); 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 Received: from localhost.localdomain (unknown [210.21.223.3]) by smtp6 (Coremail) with SMTP id j9KowAAnVHFdElJVTB0hBw--.1248S3; Tue, 12 May 2015 22:47:01 +0800 (CST) 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 Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: xlpang@126.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::229 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@; dmarc=fail (p=NONE dis=NONE) header.from=126.com Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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; }