From patchwork Wed Dec 9 06:19:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Muckle X-Patchwork-Id: 57928 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp480128lbb; Tue, 8 Dec 2015 22:20:54 -0800 (PST) X-Received: by 10.98.71.157 with SMTP id p29mr10633291pfi.152.1449642054523; Tue, 08 Dec 2015 22:20:54 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 73si10348937pfq.207.2015.12.08.22.20.54; Tue, 08 Dec 2015 22:20:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro-org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753453AbbLIGUw (ORCPT + 28 others); Wed, 9 Dec 2015 01:20:52 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:36105 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752474AbbLIGTv (ORCPT ); Wed, 9 Dec 2015 01:19:51 -0500 Received: by pacdm15 with SMTP id dm15so24608509pac.3 for ; Tue, 08 Dec 2015 22:19:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4Yj4d7NEZ7DOkMomQAc6DlBeSBBRbPlISg8LxyJKwLY=; b=WXI89uaq/Snwdn9r3fPkha8LVPlt8ZOh38GY+fO9BhsRbkWTsuqYMv6VomfcmFt5R5 jJNQodbeYjQUtPh7WBYrDmyKKhZSUKO6DRfV5U1jmiTlBH362IsItN5sLYmdE2qBiHC7 VyKXMBAIauF2hxltqLCSh5V7Y15xRji5OU/L53S8vQjGX9/HkiLRN/U6K7CNjpZf/4Qg QtibhGOEr1LADSax0KeuEqCx7w1G91svU4pQlKka09e0E8FG2eEkMr7k8vkXroObDlEy 7Tjc6UcXYJ0lce0sFCLgVZp8mat84pD77lanF2U2MdiyIxUrup3OWJ9dnAyTdZAE3ivO acHg== 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=4Yj4d7NEZ7DOkMomQAc6DlBeSBBRbPlISg8LxyJKwLY=; b=jL91j31igUV8GEafaD98GyECFQYViu4PP5MtZHxp+c0mz4LD5SrXF0HrEv1yqpsPC7 2i3ntw4LiowbWB08ot6l0q2i42CVAE/+zn2TqlPcRds9GJM5+B5MRBYnQH3S5vNNHcwe /StpbZaEk4GbMelqXpH7R4SoLvd59hwNMkUC/6AjYg4VAsUYZpKuuHbj1BmRlGVjmEqE aHHboO3qdjdnNZ5ZuGQOzYF1rswbO0tBL3kOopXrN/MNGSYRtgTBOx7ZjrE+VKQGvVwM jTHRAGUN95Av95wWazzaJMu4J1Ovq+hvRUdxxgQtQPwMKWGRFVSwhVlNBiMcrsdrYjxj aa8A== X-Gm-Message-State: ALoCoQmNbM+b6c2I9Aji59b+JyZY9Demz0RHn5E2ynSk1xU7GIHvo46OlOs1bfHh86wBd6GjBpTJc11XIGzOYh5DACB5SIx1kA== X-Received: by 10.66.139.72 with SMTP id qw8mr4919253pab.130.1449641990679; Tue, 08 Dec 2015 22:19:50 -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 l84sm8643078pfb.15.2015.12.08.22.19.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Dec 2015 22:19:50 -0800 (PST) From: Steve Muckle X-Google-Original-From: Steve Muckle To: Peter Zijlstra , Ingo Molnar Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Vincent Guittot , Morten Rasmussen , Dietmar Eggemann , Juri Lelli , Patrick Bellasi , Michael Turquette Subject: [RFCv6 PATCH 10/10] sched: rt scheduler sets capacity requirement Date: Tue, 8 Dec 2015 22:19:31 -0800 Message-Id: <1449641971-20827-11-git-send-email-smuckle@linaro.org> X-Mailer: git-send-email 2.4.10 In-Reply-To: <1449641971-20827-1-git-send-email-smuckle@linaro.org> References: <1449641971-20827-1-git-send-email-smuckle@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vincent Guittot RT tasks don't provide any running constraints like deadline ones except their running priority. The only current usable input to estimate the capacity needed by RT tasks is the rt_avg metric. We use it to estimate the CPU capacity needed for the RT scheduler class. In order to monitor the evolution for RT task load, we must peridiocally check it during the tick. Then, we use the estimated capacity of the last activity to estimate the next one which can not be that accurate but is a good starting point without any impact on the wake up path of RT tasks. Signed-off-by: Vincent Guittot Signed-off-by: Steve Muckle --- kernel/sched/rt.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) -- 2.4.10 -- 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/ diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 8ec86ab..9694204 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1426,6 +1426,41 @@ static void check_preempt_curr_rt(struct rq *rq, struct task_struct *p, int flag #endif } +#ifdef CONFIG_SMP +static void sched_rt_update_capacity_req(struct rq *rq) +{ + u64 total, used, age_stamp, avg; + s64 delta; + + if (!sched_freq()) + return; + + sched_avg_update(rq); + /* + * Since we're reading these variables without serialization make sure + * we read them once before doing sanity checks on them. + */ + age_stamp = READ_ONCE(rq->age_stamp); + avg = READ_ONCE(rq->rt_avg); + delta = rq_clock(rq) - age_stamp; + + if (unlikely(delta < 0)) + delta = 0; + + total = sched_avg_period() + delta; + + used = div_u64(avg, total); + if (unlikely(used > SCHED_CAPACITY_SCALE)) + used = SCHED_CAPACITY_SCALE; + + set_rt_cpu_capacity(rq->cpu, 1, (unsigned long)(used)); +} +#else +static inline void sched_rt_update_capacity_req(struct rq *rq) +{ } + +#endif + static struct sched_rt_entity *pick_next_rt_entity(struct rq *rq, struct rt_rq *rt_rq) { @@ -1494,8 +1529,17 @@ pick_next_task_rt(struct rq *rq, struct task_struct *prev) if (prev->sched_class == &rt_sched_class) update_curr_rt(rq); - if (!rt_rq->rt_queued) + if (!rt_rq->rt_queued) { + /* + * The next task to be picked on this rq will have a lower + * priority than rt tasks so we can spend some time to update + * the capacity used by rt tasks based on the last activity. + * This value will be the used as an estimation of the next + * activity. + */ + sched_rt_update_capacity_req(rq); return NULL; + } put_prev_task(rq, prev); @@ -2212,6 +2256,9 @@ static void task_tick_rt(struct rq *rq, struct task_struct *p, int queued) update_curr_rt(rq); + if (rq->rt.rt_nr_running) + sched_rt_update_capacity_req(rq); + watchdog(rq, p); /*