Received: by 10.223.176.5 with SMTP id f5csp373669wra; Fri, 9 Feb 2018 00:03:47 -0800 (PST) X-Google-Smtp-Source: AH8x227PXsbk6rPF5TZLyWp66TP5BtSdniMc6GBUzQJ07Mpf8K2hnI7Rz/HI7lxpPVmK91YVuZZw X-Received: by 10.101.78.1 with SMTP id r1mr1691096pgt.322.1518163427819; Fri, 09 Feb 2018 00:03:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518163427; cv=none; d=google.com; s=arc-20160816; b=PO1LS4Psf5nOk7srl3Kl12Pphweu1YOisAoybtO/MQvKRyh417s8e6Cw/qOa+iE33R PljxMpcP+3vVa9D+tKglQHvg294x0PT0cyx0aKoTlAym+xahC4RcNf+jL8y/aZBYS1iR Z/EduRYG9OFLFaOAc8SppaELJiUzF/jh2nZ8pUXVFBkqFaGvLRey118YmR2pxxOCbTkC JDhgqV1cTXjoOtQbxfz9SDv8dvKMb//TFyXVeGAUQK2GJI6WoZtsoxuiAqSENLiuY8Nw 00YckWcqnBYRVPiSyBCZav09PC3TjT6P8v/tQgYMwp/OlWoEtXIOKkyO0cYmuBcAjoW6 yr1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=VFrg4rKl/uBPxkfJTJZA+Gc8o5K8Wi03vB77rLaU2bE=; b=GDo0RCFCIuiYIMCOkDD8LI7KSn3b/S7+XoWNHm0yyCzV1UJEYtpnfcg6sbtKF70z1v +fdq30JnMJHRX1i8LBijci/xoXr08fY3RPjSZFjyse+Ec3clPv8qypCz3f8NWVj6Peyu PJAU0Gn6zB1aZUVdy1UnReJpRA6tJCFy8vvhKMgKejeZAYjsBqWoHUULW7tGDlakFFnp 0SNkmz8yclPo26IfbBzU4uYFkD8PzBZ9dUQ5UHTt/uxVEwTE2Z1cYpFOjQNOoP7CfQ4R edkaYKDHtbxoxC0DyJ1Kl5vbvNtKY9RblXjs01zRsMBshoMh1/VamQHja3vi/Wbpf5D+ 61Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@evidence-eu-com.20150623.gappssmtp.com header.s=20150623 header.b=Q1nxRuHJ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4si1077508pgo.136.2018.02.09.00.03.33; Fri, 09 Feb 2018 00:03:47 -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; dkim=pass header.i=@evidence-eu-com.20150623.gappssmtp.com header.s=20150623 header.b=Q1nxRuHJ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751060AbeBIICi (ORCPT + 99 others); Fri, 9 Feb 2018 03:02:38 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:39349 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750942AbeBIICg (ORCPT ); Fri, 9 Feb 2018 03:02:36 -0500 Received: by mail-wr0-f194.google.com with SMTP id f6so7252271wra.6 for ; Fri, 09 Feb 2018 00:02:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=evidence-eu-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=VFrg4rKl/uBPxkfJTJZA+Gc8o5K8Wi03vB77rLaU2bE=; b=Q1nxRuHJ7N2ciRCBdsNBT5dJGLjyWlvs1jWOu9sYU46fEgLNGGwRC6UrXP7PKnhQLx SmRztWZAGgF0bivqHqDQ/qPvexCjIrU2s9+86YFVHiE7WR0/CJXU497rRDOrFkaq/67v OTZyX1L2tusQfvPP4spSQH6jPamg/pEhKXwqdlOjrg6CNey2MI4iUUNW68MUWK5V/yHq +weTD3/HnlPS31E5BuJ9R1Da/So2hlFLxFq2rhfsJFnz+k3uU2BO4zAdoMqK+e3Fsovb d9iMyqBmbnbv8e2ivRBOuRPBOKqOh8z1lytjbf0a+8x5D7BEmzozKwvEGSORXMVXF7cL DOog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=VFrg4rKl/uBPxkfJTJZA+Gc8o5K8Wi03vB77rLaU2bE=; b=OB+QZmIao+9bSunXBNsXujZKedv7lVr6X+hmQ8hDLrBXH9EQsHudhrCV50idWmbR4A XuRhoyqI8Ge4KZL1qY/ZFlLHW7eCN9+RxRgU+Y9aQMRoLY5RZyn4EPLYgMmx1FBRZAfC fZiLnwhHGrQtcLwO+JpZAQXlE2iQG5etlgv9WAT5EOa3vCpXWYQQeu83ZwqRO1NC+/X4 ru+9cM2JCo11qQHo6TyY1AuxGdyiuwExa83wvs63inngkG8+RKFbBlIOex7Vzt6RyZBw cqWTVXLrBPi5drrAbeIxTn+WCF2CMVWf0nJog9YjS8f/Dh5bhTrbDJ4+P6N91Ujfgt38 dFIw== X-Gm-Message-State: APf1xPBxtiZXjMODGi7B3TR65E25+FmVx/0SoGlT6aqQwrj8Uz40hgZX PRTrJwWbY79immu2SUzDFefYhGIy X-Received: by 10.223.186.5 with SMTP id o5mr1699446wrg.267.1518163355082; Fri, 09 Feb 2018 00:02:35 -0800 (PST) Received: from [192.168.10.160] (host92-93-static.8-79-b.business.telecomitalia.it. [79.8.93.92]) by smtp.gmail.com with ESMTPSA id i33sm1400610wri.70.2018.02.09.00.02.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Feb 2018 00:02:34 -0800 (PST) Subject: Re: [PATCH] cpufreq: schedutil: rate limits for SCHED_DEADLINE To: Viresh Kumar Cc: Peter Zijlstra , Ingo Molnar , "Rafael J . Wysocki" , Patrick Bellasi , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Vincent Guittot , Todd Kjos , Joel Fernandes , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org References: <1518109302-8239-1-git-send-email-claudio@evidence.eu.com> <20180209035143.GX28462@vireshk-i7> From: Claudio Scordino Message-ID: <197c26ba-c2a6-2de7-dffa-5b884079f746@evidence.eu.com> Date: Fri, 9 Feb 2018 09:02:34 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180209035143.GX28462@vireshk-i7> Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Viresh, Il 09/02/2018 04:51, Viresh Kumar ha scritto: > On 08-02-18, 18:01, Claudio Scordino wrote: >> When the SCHED_DEADLINE scheduling class increases the CPU utilization, >> we should not wait for the rate limit, otherwise we may miss some deadline. >> >> Tests using rt-app on Exynos5422 have shown reductions of about 10% of deadline >> misses for tasks with low RT periods. >> >> The patch applies on top of the one recently proposed by Peter to drop the >> SCHED_CPUFREQ_* flags. >> >> Signed-off-by: Claudio Scordino >> CC: Rafael J . Wysocki >> CC: Patrick Bellasi >> CC: Dietmar Eggemann >> CC: Morten Rasmussen >> CC: Juri Lelli >> CC: Viresh Kumar >> CC: Vincent Guittot >> CC: Todd Kjos >> CC: Joel Fernandes >> CC: linux-pm@vger.kernel.org >> CC: linux-kernel@vger.kernel.org >> --- >> kernel/sched/cpufreq_schedutil.c | 15 ++++++++++++--- >> 1 file changed, 12 insertions(+), 3 deletions(-) > > So the previous commit was surely incorrect as it relied on comparing > frequencies instead of dl-util, and freq requirements could have even > changed due to CFS. You're right. The very original patch (not posted) added a specific SCHED_CPUFREQ flag to let the scheduling class ask for ignoring the rate limit. However, polluting the API with further flags is not such a good approach. The next patches didn't introduce such flag, but were incorrect. > >> diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c >> index b0bd77d..d8dcba2 100644 >> --- a/kernel/sched/cpufreq_schedutil.c >> +++ b/kernel/sched/cpufreq_schedutil.c >> @@ -74,7 +74,10 @@ static DEFINE_PER_CPU(struct sugov_cpu, sugov_cpu); >> >> /************************ Governor internals ***********************/ >> >> -static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time) >> +static bool sugov_should_update_freq(struct sugov_policy *sg_policy, >> + u64 time, >> + struct sugov_cpu *sg_cpu_old, >> + struct sugov_cpu *sg_cpu_new) >> { >> s64 delta_ns; >> >> @@ -111,6 +114,10 @@ static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time) >> return true; >> } >> >> + /* Ignore rate limit when DL increased utilization. */ >> + if (sg_cpu_new->util_dl > sg_cpu_old->util_dl) >> + return true; >> + > > Changing the frequency has a penalty, specially in the ARM world (and > that's where you are testing your stuff). I am worried that we will > have (corner) cases where we will waste a lot of time changing the > frequencies. For example (I may be wrong here), what if 10 small DL > tasks are queued one after the other? The util will keep on changing > and so will the frequency ? There may be more similar cases ? I forgot to say that I've not observed any relevant increase of the energy consumption (measured through a Baylibre Cape). However, the tests had a very small number of RT tasks. If I'm not wrong, at the hardware level we do have a physical rate limit (as we cannot trigger a frequency update when there is one already on-going). Don't know if this could somehow mitigate such effect. Anyway, I'll repeat the tests with a considerable amount of RT tasks to check if I can reproduce such "ramp up" situation. Depending on the energy results, we may have to choose between meeting more RT deadlines and consuming less energy. > > Is it possible to (somehow) check here if the DL tasks will miss > deadline if we continue to run at current frequency? And only ignore > rate-limit if that is the case ? I need to think further about it. > >> delta_ns = time - sg_policy->last_freq_update_time; >> return delta_ns >= sg_policy->freq_update_delay_ns; >> } >> @@ -271,6 +278,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, >> unsigned int flags) >> { >> struct sugov_cpu *sg_cpu = container_of(hook, struct sugov_cpu, update_util); >> + struct sugov_cpu sg_cpu_old = *sg_cpu; > > Not really a big deal, but this structure is 80 bytes on ARM64, why > copy everything when what we need is just 8 bytes ? I didn't want to add deadline-specific code into the sugov_should_update_freq() signature as it should remain independent from the scheduling classes. In my opinion, the best approach would be to group util_cfs and util_dl in a struct within sugov_cpu and pass that struct to sugov_should_update_freq(). Thanks for your comments. Claudio