From patchwork Tue Feb 23 01:22:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Muckle X-Patchwork-Id: 8385871 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1596FC0553 for ; Tue, 23 Feb 2016 01:24:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2F0132047C for ; Tue, 23 Feb 2016 01:24:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3975C204D8 for ; Tue, 23 Feb 2016 01:24:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756858AbcBWBYS (ORCPT ); Mon, 22 Feb 2016 20:24:18 -0500 Received: from mail-pa0-f49.google.com ([209.85.220.49]:36150 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932256AbcBWBW7 (ORCPT ); Mon, 22 Feb 2016 20:22:59 -0500 Received: by mail-pa0-f49.google.com with SMTP id yy13so100321480pab.3 for ; Mon, 22 Feb 2016 17:22:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OSxYM/FG3EHeuvjRwQMJ+nV3NxbbMEGOIXgq1hWE2wE=; b=JBbZ/Rwy0LQBIn9XiOFmb1vVGmzVC5oonw5PYXNcxqm81okpUsxjIeDo6E6pcpbYwa vZTFDNAOUqOiI4/58ye7vxSwoz5AvaogQVmRQp/iaA0EgDWIf8V8M7dnI390LxsI9jkV eVyfiVyKcXkjhxjjOKtq+QiyG6gaDZGIxRL00= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OSxYM/FG3EHeuvjRwQMJ+nV3NxbbMEGOIXgq1hWE2wE=; b=BKAVu3I4r5qJ2tmD3StA8Iu6rVKH5jXQd/uAn52OyVSMrzhvytnNpT1BjZPUUv9oMZ M9kQvW4PbCp2XOo2pZaAwadQ6SlU0Us0+ZjV3Eviq9Ms2LeacPKlVj0VLFnxdWJj7QeI sLJdThQXDVAFSnTuiqA9lp/4Va/m81ITPp0cfCIxQMOeRRhrpGdnSVTUl4qE8U73uqIg ieOdX1ZFZA9nfk2dNXVWmZ9vMYK2lHaaDKkoe/mi9hPRSipkYzEkRGgAU5KZt5M4xVTI tdkAOs3WoX/vVFUt4W4bkPpU03T4noHwY4Hq2RnHo5nTfNmckDTTwFyU1EHvlgMIXTaL nHyg== X-Gm-Message-State: AG10YOTtKC5Y03gKNU3/QhQCiYfWQwIWRTouF29PMPeOARnVG3koVZIsC00eBQrn+lGP6Egb X-Received: by 10.66.236.132 with SMTP id uu4mr42373925pac.95.1456190578618; Mon, 22 Feb 2016 17:22:58 -0800 (PST) Received: from graphite.smuckle.net (cpe-75-80-155-7.san.res.rr.com. [75.80.155.7]) by smtp.gmail.com with ESMTPSA id t29sm39626789pfi.8.2016.02.22.17.22.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Feb 2016 17:22:58 -0800 (PST) From: Steve Muckle X-Google-Original-From: Steve Muckle To: Peter Zijlstra , Ingo Molnar , "Rafael J. Wysocki" Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Vincent Guittot , Morten Rasmussen , Dietmar Eggemann , Juri Lelli , Patrick Bellasi , Michael Turquette , Juri Lelli Subject: [RFCv7 PATCH 04/10] sched/fair: add triggers for OPP change requests Date: Mon, 22 Feb 2016 17:22:44 -0800 Message-Id: <1456190570-4475-5-git-send-email-smuckle@linaro.org> X-Mailer: git-send-email 2.4.10 In-Reply-To: <1456190570-4475-1-git-send-email-smuckle@linaro.org> References: <1456190570-4475-1-git-send-email-smuckle@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Juri Lelli Each time a task is {en,de}queued we might need to adapt the current frequency to the new usage. Add triggers on {en,de}queue_task_fair() for this purpose. Only trigger a freq request if we are effectively waking up or going to sleep. Filter out load balancing related calls to reduce the number of triggers. [smuckle@linaro.org: resolve merge conflicts, define task_new, use renamed static key sched_freq] cc: Ingo Molnar cc: Peter Zijlstra Signed-off-by: Juri Lelli Signed-off-by: Steve Muckle --- kernel/sched/fair.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 3437e01..f1f00a4 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4283,6 +4283,21 @@ static inline void hrtick_update(struct rq *rq) } #endif +static unsigned long capacity_orig_of(int cpu); +static int cpu_util(int cpu); + +static void update_capacity_of(int cpu) +{ + unsigned long req_cap; + + if (!sched_freq()) + return; + + /* Convert scale-invariant capacity to cpu. */ + req_cap = cpu_util(cpu) * SCHED_CAPACITY_SCALE / capacity_orig_of(cpu); + set_cfs_cpu_capacity(cpu, true, req_cap); +} + /* * The enqueue_task method is called before nr_running is * increased. Here we update the fair scheduling stats and @@ -4293,6 +4308,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) { struct cfs_rq *cfs_rq; struct sched_entity *se = &p->se; + int task_new = !(flags & ENQUEUE_WAKEUP); for_each_sched_entity(se) { if (se->on_rq) @@ -4324,9 +4340,23 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) update_cfs_shares(cfs_rq); } - if (!se) + if (!se) { add_nr_running(rq, 1); + /* + * We want to potentially trigger a freq switch + * request only for tasks that are waking up; this is + * because we get here also during load balancing, but + * in these cases it seems wise to trigger as single + * request after load balancing is done. + * + * XXX: how about fork()? Do we need a special + * flag/something to tell if we are here after a + * fork() (wakeup_task_new)? + */ + if (!task_new) + update_capacity_of(cpu_of(rq)); + } hrtick_update(rq); } @@ -4384,9 +4414,24 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) update_cfs_shares(cfs_rq); } - if (!se) + if (!se) { sub_nr_running(rq, 1); + /* + * We want to potentially trigger a freq switch + * request only for tasks that are going to sleep; + * this is because we get here also during load + * balancing, but in these cases it seems wise to + * trigger as single request after load balancing is + * done. + */ + if (task_sleep) { + if (rq->cfs.nr_running) + update_capacity_of(cpu_of(rq)); + else if (sched_freq()) + set_cfs_cpu_capacity(cpu_of(rq), false, 0); + } + } hrtick_update(rq); }