From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161529AbbKFME5 (ORCPT ); Fri, 6 Nov 2015 07:04:57 -0500 Received: from mailout4.w1.samsung.com ([210.118.77.14]:51938 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161389AbbKFMDo (ORCPT ); Fri, 6 Nov 2015 07:03:44 -0500 X-AuditID: cbfec7f4-f79c56d0000012ee-04-563c971ece2d From: Arseniy Krasnov To: linux@arm.linux.org.uk, mingo@redhat.com, peterz@infradead.org Cc: a.krasnov@samsung.com, v.tyrtov@samsung.com, s.rogachev@samsung.com, linux-kernel@vger.kernel.org, Tarek Dakhran , Sergey Dyasly , Dmitriy Safonov , Ilya Maximets Subject: [PATCH 10/13] hperf_hmp: idle pull function. Date: Fri, 06 Nov 2015 15:02:44 +0300 Message-id: <1446811367-23783-11-git-send-email-a.krasnov@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1446811367-23783-1-git-send-email-a.krasnov@samsung.com> References: <1446811367-23783-1-git-send-email-a.krasnov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOLMWRmVeSWpSXmKPExsVy+t/xK7py023CDA7+1LSY91nQ4tPKp2wW V9p/sltc3jWHzeL2ZV6LSwcWMFkc7z3AZDF5tpTFu63XWC3WPz/FaDF1xg92B26PluYeNo/N K7Q8Dr7bw+Txft9VNo++LasYPT5vkgtgi+KySUnNySxLLdK3S+DK2PjiOXPBPbGKBx/2MzUw XhbqYuTkkBAwkVj3agMzhC0mceHeejYQW0hgKaPEgZ4KCLudSeLdCm4Qm01AV+Lnxi1gNSIC ThI9z84ygtjMApOZJDZ8TQOxhQVMJY5P2wlWwyKgKnHxxxp2EJtXwE2i4cUBRohdchInj01m BbE5geIdXbfZIXa5SnScfccygZF3ASPDKkbR1NLkguKk9FxDveLE3OLSvHS95PzcTYyQ4Puy g3HxMatDjAIcjEo8vDeWWIcJsSaWFVfmHmKU4GBWEuGVY7YJE+JNSaysSi3Kjy8qzUktPsQo zcGiJM47d9f7ECGB9MSS1OzU1ILUIpgsEwenVAOjqdztvVuv79iwv25m3Q/2hYvjcxbslu+8 2sqkc7Hvo/W/XwzVk5QVRE+XrsqLEi56VbmZt+TdgY0SUrY1SV/yXT/dcGvTubyQSfn09wWM xl0P7v2xWnHpaqFQEPvx/Y5SwX7Hk8sDXr7NzuXdbfbM9+CG3fv7uHT9+b5aX/vFEbbTYs73 ze7dSizFGYmGWsxFxYkAovl6+zoCAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org HMP idle pull is triggered when CPU becomes idle. It tries to pull task from another cluster when it is overloaded. Also A7 can't pull alone task from A15, but A15 can do that with A7 core. Task for migration is chosen in the same way as for other HMP migration cases - using 'druntime' metric. Only difference is that migration task doesn't need to run 5ms on its cluster before migration. Signed-off-by: Tarek Dakhran Signed-off-by: Sergey Dyasly Signed-off-by: Dmitriy Safonov Signed-off-by: Arseniy Krasnov Signed-off-by: Ilya Maximets --- kernel/sched/fair.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 4fda1ec..fd16729 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7421,6 +7421,72 @@ static unsigned int try_to_move_task(struct task_struct *migrate_task, } /** + * hmp_idle_pull(): Pulls task from opposite domain of this_cpu to this_cpu. + * @sd: Current sched domain. + * @this_cpu: without NO_HZ same as smp_processor_id(). + * + * Returns moved weight. + * + * Chooses task by its druntime. Ignores task's druntime and + * time of last HMP migration. Also A7 can't pulls task from A15 + * if A15 become idle. + */ +static unsigned int hmp_idle_pull(struct sched_domain *sd, int this_cpu) +{ + unsigned int ld_moved = 0; + struct task_struct *task_to_pull; + unsigned long local_flags; + int idle_stopper = 0; + struct rq *local_rq; + struct rq *rq; + + local_irq_save(local_flags); + local_rq = cpu_rq(this_cpu); + rq = get_unfair_rq(sd, this_cpu); + + if (!rq) { + local_irq_restore(local_flags); + return 0; + } + double_lock_balance(rq, local_rq); + + if (rq->active_balance) + goto unlock; + + if (local_rq->active_balance) + goto unlock; + + /* Forbids secondary CPUs to pull alone task from primary CPUs */ + if (!cpu_is_fastest(this_cpu) && rq->cfs.h_nr_running <= 1) + goto unlock; + + /* Get task to pull from opposite domain to this_cpu */ + task_to_pull = get_migration_candidate(sd, rq, 1, this_cpu); + + if (!task_to_pull) + goto unlock; + + ld_moved = try_to_move_task(task_to_pull, this_cpu, &idle_stopper); + + if (idle_stopper) { + rq->push_cpu = this_cpu; + rq->active_balance = 1; + rq->migrate_task = task_to_pull; + } + +unlock: + double_rq_unlock(local_rq, rq); + local_irq_restore(local_flags); + + if (idle_stopper) + stop_one_cpu_nowait(rq->cpu, active_load_balance_cpu_stop, + rq, &rq->active_balance_work); + + return ld_moved; +} + + +/** * swap_tasks(): swaps two tasks from different HMP domains * @sd: Current sched domain * @this_cpu: without NO_HZ same as smp_processor_id(). -- 1.9.1