Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1130071imm; Fri, 29 Jun 2018 11:56:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfTzevJuP31ahCI9qn/IQoOZRG5prThVByqtTxtcqD1KUQWWXXrRBams0Blk17AZyWXXJat X-Received: by 2002:a62:4141:: with SMTP id o62-v6mr15576938pfa.111.1530298587671; Fri, 29 Jun 2018 11:56:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530298587; cv=none; d=google.com; s=arc-20160816; b=SDgB6++1NfqrZDV0KBsAHHTN+QfUybdqU1MylZKi6kz3hadEfwEMMJw7Wg70DbR7e0 7t6LM4AmJqi8gZU4ifSPMMQw1WhLUKEQNDuGZaTeE1MhOw9+KgHBB3aHg5VdMTcze8Ee LOqvM7jIhIJLd4t2LLPc22Jm+1F7hHfJ7a2DhDL+cQY1O3zRMPCmLyWn2qxI5dUb9cTD zzeeyREnch7bjmvwUWVFNet3ztuFjRjs4CFNIBv5usYcr3A+vwdBDg4Rydcec5XyqoIG iSTHwvd0wOTzMaw0lWBZnG4xu0Ia3YwSUr/VK/fgkjmtPRCMOnu8qZJxgJYa5KpSDM+W WuQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=9r9AtNZBHhD/fMjv5S8hLTePDvy7n7A1dRpluu9sKXg=; b=JTjvlKv1Ydgdy1wB05TgvK+sJGRxk9GwdH65Ruewgg/ldFcUfczBFvvp7v4oCTKYGn WI9qNS4oAadWIXXRdL1duDez+C7tazSswyRuYcs/H1w9XB+aTQmYOfitoxSxKLunAPC5 zcHK9UoEl2Dd6VajZVHfledxY+ou/EbebpByW1MXSQ6UB21JbpwFFEJb8o+reGS/NXpt OCWeLI8LLGVJ3zBaFJn1AVpKCPFIV2TQ8vEIInwqJSVWs8tuZWj6DcGGa0gN9bsAWxZO ZxbcN0yXRikNBgmSqfKYXZLVy62I3mj7WBQjH+3TjJuu6+ITlGfRl53o5NG3S2eZlYxE XsBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b="pGZA/Nci"; 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 z1-v6si9771578plo.516.2018.06.29.11.56.13; Fri, 29 Jun 2018 11:56:27 -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=@joelfernandes.org header.s=google header.b="pGZA/Nci"; 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 S936320AbeF2Sp3 (ORCPT + 99 others); Fri, 29 Jun 2018 14:45:29 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:39151 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932375AbeF2Sp1 (ORCPT ); Fri, 29 Jun 2018 14:45:27 -0400 Received: by mail-pl0-f65.google.com with SMTP id s24-v6so4861804plq.6 for ; Fri, 29 Jun 2018 11:45:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=9r9AtNZBHhD/fMjv5S8hLTePDvy7n7A1dRpluu9sKXg=; b=pGZA/NciLOAA6IPh7Won8fhTy56FA6Tb66E37gmYyk70GnM5vjKgsamO3Yqlmqgltg u4H82uQkEBpifuRIvTQ3+kIpPjGsTJPBnuYzj2bq9Ldz8ZRXXEzD11ooqm4R7xT2ajJ7 EDqckZ15Xn60/jJKv6OxVA0ofcrLqESt66Rrc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=9r9AtNZBHhD/fMjv5S8hLTePDvy7n7A1dRpluu9sKXg=; b=TFpsf0fu9vdOA7YPiCOqJhxfM7jeH3rQ5wCpcjCSfH1oqscn2Hg9sZ326iP+GC7QkN WLF1wmiFf7NO5LhVGEaoOFYt/HWbq4qG51MnQ4CIGd3Jv0SiDNIXw4d+0PNjaYRl1D8a zt8pdVs0kXPMYKBPAo6ZrJsFjrcS8qnhWAmf72/lTQ72rXibJxul3PXZhzP33557SQVh W8VeBfl93k3TEkYRQHVM0FBSo/gnFr+3WyQkEJxD0I+pDBSVW/cWbxD9Px9pyLgHFcVB QYFHDsEVqR85sCS3kWHuKfMWyRamS7asEAzQqtsa6w/ZSaAr1inlhAfGLmZb5EiRSoGU jTkQ== X-Gm-Message-State: APt69E1UdeNPM0ahnvzpeALWz8ymQBjn0Bq9m8ioCF9BO2aS+b6GL9a1 tw+ZGNaD2PGtENLiuVOaOLlNWQ== X-Received: by 2002:a17:902:b589:: with SMTP id a9-v6mr16205063pls.140.1530297926750; Fri, 29 Jun 2018 11:45:26 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id e81-v6sm29551747pfb.62.2018.06.29.11.45.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Jun 2018 11:45:26 -0700 (PDT) Date: Fri, 29 Jun 2018 11:45:25 -0700 From: Joel Fernandes To: Alessio Balsini Cc: linux-kernel@vger.kernel.org, Juri Lelli , Tommaso Cucinotta , Luca Abeni , Claudio Scordino , Daniel Bristot de Oliveira , Patrick Bellasi , Ingo Molnar , Peter Zijlstra Subject: Re: [RFC PATCH] sched/deadline: sched_getattr() returns absolute dl-task information Message-ID: <20180629184525.GA261771@joelaf.mtv.corp.google.com> References: <20180629120947.14579-1-alessio.balsini@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180629120947.14579-1-alessio.balsini@gmail.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 29, 2018 at 02:09:47PM +0200, Alessio Balsini wrote: > If the task calls sched_getattr() with SCHED_GETATTR_FLAGS_DL_ABSOLUTE > flag set, the returned runtime and deadline parameters are, accordingly, > the remaining runtime and the absolute deadline. > > To return consistent data, the scheduler and rq times, as well as the > task statistics, are updated. The commit log should typically also explain the "why" not just the "how". Think about someone doing a git log later and trying to find out why this was added. > Cc: Juri Lelli > Cc: Tommaso Cucinotta > Cc: Luca Abeni > Cc: Claudio Scordino > Cc: Daniel Bristot de Oliveira > Cc: Patrick Bellasi > Cc: Ingo Molnar > Cc: Peter Zijlstra > Tested-by: Joel Fernandes (Google) > Reviewed-by: Joel Fernandes (Google) > Signed-off-by: Alessio Balsini > --- > Having a precise means for measuring the execution time of a task at > each activation is critical for real-time application design, > development, and deployment. This allows for estimating the > computational demand of the task at run-time, constituting the > fundamental information over which the runtime parameter can be set when > using the SCHED_DEADLINE policy. For example, one could set the runtime > equal to the maximum observed execution time, or a proper percentile of > its observed distribution (while a discussion of more complex WCET > estimation techniques is out of scope here). Moreover, in dynamic > workload scenarios, one needs to track the execution time changes, in > order to possibly adapt the runtime parameter as needed. All this should be in the commit log? > However, on platforms with frequency switching capabilities, the typical > way to perform execution time measurements for a task, based on sampling > the CLOCK_THREAD_CPUTIME_ID clock, produces unreliable results due to > the sporadic frequency switches that may happen between two > measurements, and locking down the frequency is rarely a viable > solution, anyway only acceptable during design/development, not for > dynamic adaptations while the task is running. > > Execution time measurements can be done by using the remaining runtime > and absolute deadline instead, for SCHED_DEADLINE tasks. This is a > better option because (i) it only accounts for the actual runtime of the > task, and (ii) the runtime accounting is automatically normalized > (scaled) with the CPU frequency (and capacity, for heterogeneous > platforms). > > > This solution preserves the ability to query for the absolute "The solution presented in this patch" > sched_{runtime, deadline} values of tasks other than itself, simplifying > the development of a task hierarchy where a manager process can allocate > the bandwidths of other deadline tasks in the system. You didn't mention here you are attempting to fetch the remaining runtime of the DL task. It almost sounds like you are saying here that the new flag will fetch the configured runtime which it doesn't. > > > The simplest way to measure the normalized duration C_ns of a piece of "The simples way this can be used" > deadline task that does not use bandwidth reclaiming is the following: > > struct sched_attr s, e; > uint64_t dl_misses; > struct sched_attr curr_attr = { > [...] > sched_policy = SCHED_DEADLINE, > [...] > }; > > sched_setattr(0, &curr_attr, 0); > > sched_getattr(0, &s, ..., SCHED_GETATTR_FLAGS_DL_ABSOLUTE); > /* calculations to be measured */ > sched_getattr(0, &e, ..., SCHED_GETATTR_FLAGS_DL_ABSOLUTE); > > /* SCHED_DL periods within measurement, usually 0 */ > n_periods = (e.sched_deadline - s.sched_deadline) / s.sched_period; > C_ns = s.sched_runtime - e.sched_runtime + n_periods * t.sched_runtime; Overall I feel the description can be improved and made clear in conveying the need for the patch in calculating the execution time. Also you didn't even mention the usecase of low-latency audio. :-( thanks! - Joel