Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp554102yba; Thu, 9 May 2019 02:13:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxw3mj0XxFzwyAMxnhkJvYcn/OGbvbII6oswkOOeiMpwxKp3lab77WPnskwMtQNB4/v0GaJ X-Received: by 2002:aa7:8251:: with SMTP id e17mr3512062pfn.147.1557393196996; Thu, 09 May 2019 02:13:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557393196; cv=none; d=google.com; s=arc-20160816; b=EYLXlg1LBkIl9V8/IyJ1A1Vfhb3mKhdu/wcnllPa4LOE9tBcN58OLSz/kJz/faX0ST 165noGxiZXUrejbnYLdjphzMCup5/2mqSK0NfP9jHaKSAoT0f6apbaPV/HnoOIH7Gm1X zQxQRQrjq/Bb7bS5oYfbcmKVLlbelxau/kzDh/Du3opD3xIHHwKj8uEDZU0o2jCvQrxq qAD/RHx7NDWhjiqDM6R4Q4PV8FA6YTGJ1nF3ejd9c2HAzXcP63mH/rt2Gwr9vOR6gprT TbBirf6eNMlbxNuXBL5liGDJmRMvPRvetdE3MqHE/okyPzhpo1Y6ln/BnjwodTQLG3O8 8Ocw== 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; bh=+PTeuwLSt+ZmBdY74uDhd8aW5UIBURbuVI/7FupuK0Y=; b=BKYB4eFu+yHHbrattM5EVvd1y2L3mlC+vIzMxJeD898M+J8AZCYEGsdoeE5VwCiWGS 4R8oOIlawI3uqimX9sFOHKobnrbp+H78EMW4zLPJSN9TSdGdFM4rHIvu0w/1NHJfUvfH 899u8xlyW4sMGFzu9UV2h58DPyZ9UxX7+eSAzPRMqGrgxY4DTZ78ZVpuWEQbpnOuDoSc nci2XHrd/TpQX2x+wSoPTg8rnxO/rERqTvHm3otmoxaHTkTM7qHprSBFas3zKhF5vaem RR+nhCsu9GkmkFH/GTTsGbJ3PnxrLxl3qOXKPBf3ZYHeRixfbkT+Qu0LveUnOSH4gPvO kmSA== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v20si2109505pgn.266.2019.05.09.02.13.00; Thu, 09 May 2019 02:13:16 -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; 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 S1726576AbfEIJLE (ORCPT + 99 others); Thu, 9 May 2019 05:11:04 -0400 Received: from foss.arm.com ([217.140.101.70]:35286 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725963AbfEIJLE (ORCPT ); Thu, 9 May 2019 05:11:04 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2BF4B374; Thu, 9 May 2019 02:11:03 -0700 (PDT) Received: from e110439-lin (e110439-lin.cambridge.arm.com [10.1.194.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2D13F3F575; Thu, 9 May 2019 02:11:00 -0700 (PDT) Date: Thu, 9 May 2019 10:10:57 +0100 From: Patrick Bellasi To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-api@vger.kernel.org, Ingo Molnar , Tejun Heo , "Rafael J . Wysocki" , Vincent Guittot , Viresh Kumar , Paul Turner , Quentin Perret , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Todd Kjos , Joel Fernandes , Steve Muckle , Suren Baghdasaryan Subject: Re: [PATCH v8 04/16] sched/core: uclamp: Add system default clamps Message-ID: <20190509091057.ckef2ley4eswyzds@e110439-lin> References: <20190402104153.25404-1-patrick.bellasi@arm.com> <20190402104153.25404-5-patrick.bellasi@arm.com> <20190508190733.GC32547@worktop.programming.kicks-ass.net> <20190508191529.GA26813@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190508191529.GA26813@worktop.programming.kicks-ass.net> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08-May 21:15, Peter Zijlstra wrote: > On Wed, May 08, 2019 at 09:07:33PM +0200, Peter Zijlstra wrote: > > On Tue, Apr 02, 2019 at 11:41:40AM +0100, Patrick Bellasi wrote: > > > +static inline struct uclamp_se > > > +uclamp_eff_get(struct task_struct *p, unsigned int clamp_id) > > > +{ > > > + struct uclamp_se uc_req = p->uclamp_req[clamp_id]; > > > + struct uclamp_se uc_max = uclamp_default[clamp_id]; > > > + > > > + /* System default restrictions always apply */ > > > + if (unlikely(uc_req.value > uc_max.value)) > > > + return uc_max; > > > + > > > + return uc_req; > > > +} > > > + > > > +static inline unsigned int > > > +uclamp_eff_bucket_id(struct task_struct *p, unsigned int clamp_id) > > > +{ > > > + struct uclamp_se uc_eff; > > > + > > > + /* Task currently refcounted: use back-annotated (effective) bucket */ > > > + if (p->uclamp[clamp_id].active) > > > + return p->uclamp[clamp_id].bucket_id; > > > + > > > + uc_eff = uclamp_eff_get(p, clamp_id); > > > + > > > + return uc_eff.bucket_id; > > > +} > > > + > > > +unsigned int uclamp_eff_value(struct task_struct *p, unsigned int clamp_id) > > > +{ > > > + struct uclamp_se uc_eff; > > > + > > > + /* Task currently refcounted: use back-annotated (effective) value */ > > > + if (p->uclamp[clamp_id].active) > > > + return p->uclamp[clamp_id].value; > > > + > > > + uc_eff = uclamp_eff_get(p, clamp_id); > > > + > > > + return uc_eff.value; > > > +} > > > > This is 'wrong' because: > > > > uclamp_eff_value(p,id) := uclamp_eff(p,id).value > > Clearly I means to say the above does not hold with the given > implementation, while the naming would suggest it does. Not sure to completely get your point... AFAIU, what you call uclamp_eff(p, id).value is the "value" member of the struct returned by uclamp_eff_get(p,id), which is back annotate by uclamp_rq_inc_id(p, rq, id) in: p->uclamp[clamp_id].value when a task becomes RUNNABLE. > > Which seems to suggest the uclamp_eff_*() functions want another name. That function returns the effective value of a task, which is either: 1. the back annotated value for a RUNNABLE task or 2. the aggregation of task-specific, system-default and cgroup values for a non RUNNABLE task. > > Also, suppose the above would be true; does GCC really generate better > > code for the LHS compared to the RHS? It generate "sane" code which implements the above logic and allows to know that whenever we call uclamp_eff_value(p,id) we get the most updated effective value for a task, independently from its {!}RUNNABLE state. I would keep the function but, since Suren also complained also about the name... perhaps I should come up with a better name? Proposals? -- #include Patrick Bellasi