Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4776189imm; Wed, 30 May 2018 11:46:19 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKuCP8b7pwu9pUPgeByWbarCwLEjOebF9OTtVPDLbSAtFQZsy78FGu2qsUfD5RnYQehrXsh X-Received: by 2002:a65:4e85:: with SMTP id b5-v6mr3114261pgs.155.1527705979532; Wed, 30 May 2018 11:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527705979; cv=none; d=google.com; s=arc-20160816; b=flsjnrz8QteYtIZN/V2iVGXWVo0DIbCV1J/Gpi1t5lRInZWekVzaMAbLU5f8TpR0Os f5pokzU74qKR4lb4I/08YxPNxEm23bGBRpf5iUtc2hqW5E6hu25Pn9uUDRv9ZGsg9XoD Pl5el54AlrPKHlEWi3nZ4G7C02dVx0X/9eFSrzhPYoqVFiwa2oJER2R62+BJrQK0pC2Y 0jnw1uXe+JiE6ouIJtYmhqRIoSE0bHqoNxM75n5TAgKTH9+lk8XKzFb01+wR3O+70q9d 8vbDtKLOWYfR1Qod142uMxeuyT1skZ9OqxPSk5GEFa4whXbLeF6+mIXT4HWjo0OSCTYD XUEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=SWIpKy4GxQwiIz4A0TxLVZWPc1qiCtjCJjC8/irpf1s=; b=XDBK/dYpMx6VjmX27azGcprtEeQpG1ztyBQ9n1C1wmFnCmMnSCU1rcb2wFXe5UXRdv U0Rn10ooDRQ3baIZrHAhx8YHwObA4tCC+RcVt9oF11VQ/Ue3wunLAIDCpbwdb39VDEbo yBjV65QKo9O++t/Gd2MUea0p7omJtgLbGuG1Af/LN4j9+ZIwNvGyMQW+N653HX4fJBYY UuUWxMF3MTtumA2QXdoMBuONf4+K3u4MCZbQGQsSOpooB4Un9MsbmD1hDmZLJ4JC0qud byHrCSZRKms2ezeBxO0Dlig1tXjvnYYKjiMpyq6KHmrRdbXtlXdEuFkmCrzIsLJTDLxq 4wWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h1pKaGF/; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33-v6si2590436ply.344.2018.05.30.11.46.05; Wed, 30 May 2018 11:46:19 -0700 (PDT) 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=@linaro.org header.s=google header.b=h1pKaGF/; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932127AbeE3Spi (ORCPT + 99 others); Wed, 30 May 2018 14:45:38 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:34483 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932077AbeE3Spg (ORCPT ); Wed, 30 May 2018 14:45:36 -0400 Received: by mail-io0-f194.google.com with SMTP id e15-v6so14455253iog.1 for ; Wed, 30 May 2018 11:45:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=SWIpKy4GxQwiIz4A0TxLVZWPc1qiCtjCJjC8/irpf1s=; b=h1pKaGF/zfLdNLo6+Pdf7ISms6boHmL0br7Ye21yEJnolssBJw5xJwHRCspT9PFsiN VOQq3oyJXLxuIR2QzP/z/YczJFiXb9gpxu5jGwB5l/XRqN6MPQkhhOxGzYOUnDKsUkpy Iw51toKdEqvQbSjCuQ1TgxldE3EP+iUA9GHJg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=SWIpKy4GxQwiIz4A0TxLVZWPc1qiCtjCJjC8/irpf1s=; b=WhJHa4GVkIwMea0gqezOZiJcf/O404nIRT4fpK4mO7FvpXccjuT3ugvz9lopJPTbn6 l2H+YttF8LERPIyQSk4ux3NJU82d07RUPhpUFVQZ0XT8HXE4UEN1llTAR6wCbGOW+eiM TcucvXDYxcchua1XEwhrFujPPSlHKolEnYwlUz5Z55dUCKNFBw9kEbpKueAr9Mq1Kdmi /BNkvG4RU4t47BI3hwZN3s1DhZdeHgTFsAVj4Nb4VwxJkoeHt3rL5IlaulC7Px1wIMmP /7BmvCy/pN2pSRU83iGq1OG/BtWKIWYwivOCEn0/n8CKAMX+dC1eTmF6XogRaLNIWOD6 yElQ== X-Gm-Message-State: ALKqPweynS/g3KKuBy/5pFfz540eWx9kuspwWdIRROKeGuzkaMbws2zc Svmky6diLq0xOzYhpMf9Bn2/Na6/SYjQTB9IO5yUow== X-Received: by 2002:a6b:1502:: with SMTP id 2-v6mr3502969iov.18.1527705935765; Wed, 30 May 2018 11:45:35 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:4cc:0:0:0:0:0 with HTTP; Wed, 30 May 2018 11:45:15 -0700 (PDT) In-Reply-To: <72473e6f-8ade-8e26-3282-276fcae4c4c7@arm.com> References: <1527253951-22709-1-git-send-email-vincent.guittot@linaro.org> <1527253951-22709-8-git-send-email-vincent.guittot@linaro.org> <72473e6f-8ade-8e26-3282-276fcae4c4c7@arm.com> From: Vincent Guittot Date: Wed, 30 May 2018 20:45:15 +0200 Message-ID: Subject: Re: [PATCH v5 07/10] sched/irq: add irq utilization tracking To: Dietmar Eggemann Cc: Peter Zijlstra , Ingo Molnar , linux-kernel , "Rafael J. Wysocki" , Juri Lelli , Morten Rasmussen , viresh kumar , Valentin Schneider , Quentin Perret Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dietmar, On 30 May 2018 at 17:55, Dietmar Eggemann wrote: > On 05/25/2018 03:12 PM, Vincent Guittot wrote: >> >> interrupt and steal time are the only remaining activities tracked by >> rt_avg. Like for sched classes, we can use PELT to track their average >> utilization of the CPU. But unlike sched class, we don't track when >> entering/leaving interrupt; Instead, we take into account the time spent >> under interrupt context when we update rqs' clock (rq_clock_task). >> This also means that we have to decay the normal context time and account >> for interrupt time during the update. >> >> That's also important to note that because >> rq_clock == rq_clock_task + interrupt time >> and rq_clock_task is used by a sched class to compute its utilization, the >> util_avg of a sched class only reflects the utilization of the time spent >> in normal context and not of the whole time of the CPU. The utilization of >> interrupt gives an more accurate level of utilization of CPU. >> The CPU utilization is : >> avg_irq + (1 - avg_irq / max capacity) * /Sum avg_rq >> >> Most of the time, avg_irq is small and neglictible so the use of the >> approximation CPU utilization = /Sum avg_rq was enough > > > [...] > >> @@ -7362,6 +7363,7 @@ static void update_blocked_averages(int cpu) >> } >> update_rt_rq_load_avg(rq_clock_task(rq), rq, 0); >> update_dl_rq_load_avg(rq_clock_task(rq), rq, 0); >> + update_irq_load_avg(rq, 0); > > > So this one decays the signals only in case the update_rq_clock_task() > didn't call update_irq_load_avg() because 'irq_delta + steal' is 0, right? yes > > [...] > > >> diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c >> index 3d5bd3a..d2e4f21 100644 >> --- a/kernel/sched/pelt.c >> +++ b/kernel/sched/pelt.c >> @@ -355,3 +355,41 @@ int update_dl_rq_load_avg(u64 now, struct rq *rq, int >> running) >> return 0; >> } >> + >> +/* >> + * irq: >> + * >> + * util_sum = \Sum se->avg.util_sum but se->avg.util_sum is not tracked >> + * util_sum = cpu_scale * load_sum >> + * runnable_load_sum = load_sum >> + * >> + */ >> + >> +int update_irq_load_avg(struct rq *rq, u64 running) >> +{ >> + int ret = 0; >> + /* >> + * We know the time that has been used by interrupt since last >> update >> + * but we don't when. Let be pessimistic and assume that interrupt >> has >> + * happened just before the update. This is not so far from >> reality >> + * because interrupt will most probably wake up task and trig an >> update >> + * of rq clock during which the metric si updated. >> + * We start to decay with normal context time and then we add the >> + * interrupt context time. >> + * We can safely remove running from rq->clock because >> + * rq->clock += delta with delta >= running > > > This is true as long update_irq_load_avg() with a 'running != 0' is called > only after rq->clock moved forward (rq->clock += delta) (which is true for > update_rq_clock()->update_rq_clock_task()). yes > >> + */ >> + ret = ___update_load_sum(rq->clock - running, rq->cpu, >> &rq->avg_irq, >> + 0, >> + 0, >> + 0); >> + ret += ___update_load_sum(rq->clock, rq->cpu, &rq->avg_irq, >> + 1, >> + 1, >> + 1); > > > So you decay the signal in [sa->lut, rq->clock - running] (assumed to be the > portion of delta used by the task scheduler) and you increase it in > [rq->clock - running, rq->clock] (irq and virt portion of delta). > > That means that this signal is updated on rq->clock whereas the others are > on rq->clock_task. > > What about the ever growing clock diff between them? I see e.g ~6s after > 20min uptime and up to 1.5ms 'running'. > > It should be still safe to sum the sched class and irq signal in > sugov_aggregate_util() because they are independent, I guess. yes. the formula is explained in patch "cpufreq/schedutil: take into account interrupt" > > [...]