Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp922040ybi; Tue, 16 Jul 2019 07:08:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQMGv806iho2bIe8uz5NaOUbKKu3VFf4RwQO+RYQVjN9BY88Sx/9SMf8es0kv+kzKG+e8D X-Received: by 2002:a17:902:2a29:: with SMTP id i38mr36057599plb.46.1563286104077; Tue, 16 Jul 2019 07:08:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563286104; cv=none; d=google.com; s=arc-20160816; b=NHahi1I7nCLODVSlqb4iI/LHSjnZzi6bLHNxAs237GyLztk4ST5nl6Fbk5nml+eFBq +AcbmewW3NRYoMQfeUggFWvQ1ILaPJzJae+LQMeTgK1BEOYei4VIvaiYnDzOdQ7nOZqQ XTdJQTGVcOni4b1ntxFg1T0lazFf4b9xwp09WTSNUGBeJWywuC43kZUGJTCrSD+fMzLD 68dUWafmWKoT0lNxLYob1AvcjBgKm72Kn2f/2uMkVZVCrpGIFP/L1ozWzqC30LMMuu26 6Sdu5GmATwVqV7WW+VEUJpocGAaxkjTXuSlmXNaHsWJj7UJ5INW/33CuaGCtLk+WbxFO Oz5w== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=qAujFwMGwE6ahRj5epLmE3AxHP/Opkob9Zs3qWjMAsM=; b=BAduHkgRbmUGR3+G1FsNr6SaGGGzKeNKXtvIws37rUFf5HydcGaOjni7Wfrl6NW25m 4gmG1B94468cUWXTgD8G9MUcCOjhNjWjHPOr+miYMt0vRvNVIgnE4L/eeUAawgRibsHl YCFwnoUoAFzOCvdJVMzqMIuBfMvNZWVF/l99I1yeCufvWruBgi8V5+K9pqjN2lN46hKh XTEbwOTva6wqzWMgc5j6hly9Zdz/Qhs6ufu2Qb/DCVKICuUeEewp+glBZiFgZR6MPIvJ FTbhSmKBHWBBqHVOY/vETat7+pRx3dKak10jt3CKJMi37FHWtZZY+oFr8LsHSVIMJH44 tJqA== 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 f32si19058972pje.70.2019.07.16.07.08.06; Tue, 16 Jul 2019 07:08:24 -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 S2387445AbfGPOHM (ORCPT + 99 others); Tue, 16 Jul 2019 10:07:12 -0400 Received: from foss.arm.com ([217.140.110.172]:35434 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727796AbfGPOHL (ORCPT ); Tue, 16 Jul 2019 10:07:11 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 343A6344; Tue, 16 Jul 2019 07:07:11 -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 D33A63F59C; Tue, 16 Jul 2019 07:07:08 -0700 (PDT) Date: Tue, 16 Jul 2019 15:07:06 +0100 From: Patrick Bellasi To: Michal =?utf-8?Q?Koutn=C3=BD?= Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Ingo Molnar , Peter Zijlstra , 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 , Alessio Balsini Subject: Re: [PATCH v11 2/5] sched/core: uclamp: Propagate parent clamps Message-ID: <20190716140706.vuggfigjlys44lkp@e110439-lin> References: <20190708084357.12944-1-patrick.bellasi@arm.com> <20190708084357.12944-3-patrick.bellasi@arm.com> <20190715164200.GA30862@blackbody.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190715164200.GA30862@blackbody.suse.cz> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Michal, On 15-Jul 18:42, Michal Koutn? wrote: > On Mon, Jul 08, 2019 at 09:43:54AM +0100, Patrick Bellasi wrote: > > Since it's possible for a cpu.uclamp.min value to be bigger than the > > cpu.uclamp.max value, ensure local consistency by restricting each > > "protection" > > (i.e. min utilization) with the corresponding "limit" (i.e. max > > utilization). > I think this constraint should be mentioned in the Documentation/.... That note comes from the previous review cycle and it's based on a request from Tejun to align uclamp behaviors with the way the delegation model is supposed to work. I guess this part of the documentation: https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html?highlight=protections#resource-distribution-models should already cover the expected uclamp min/max behaviors. However, I guess "repetita iuvant" in this case. I'll call this out explicitly in the description of cpu.uclamp.min. > > +static void cpu_util_update_eff(struct cgroup_subsys_state *css) > > +{ > > + struct cgroup_subsys_state *top_css = css; > > + struct uclamp_se *uc_se = NULL; > > + unsigned int eff[UCLAMP_CNT]; > > + unsigned int clamp_id; > > + unsigned int clamps; > > + > > + css_for_each_descendant_pre(css, top_css) { > > + uc_se = css_tg(css)->parent > > + ? css_tg(css)->parent->uclamp : NULL; > > + > > + for_each_clamp_id(clamp_id) { > > + /* Assume effective clamps matches requested clamps */ > > + eff[clamp_id] = css_tg(css)->uclamp_req[clamp_id].value; > > + /* Cap effective clamps with parent's effective clamps */ > > + if (uc_se && > > + eff[clamp_id] > uc_se[clamp_id].value) { > > + eff[clamp_id] = uc_se[clamp_id].value; > > + } > > + } > > + /* Ensure protection is always capped by limit */ > > + eff[UCLAMP_MIN] = min(eff[UCLAMP_MIN], eff[UCLAMP_MAX]); > > + > > + /* Propagate most restrictive effective clamps */ > > + clamps = 0x0; > > + uc_se = css_tg(css)->uclamp; > (Nitpick only, reassigning child where was parent before decreases > readibility. IMO) Did not checked but I think the compiler will figure out it can still use a single pointer for both assignments. I'll let's the compiler to its job and add in a dedicated stack var for the parent pointer. > > + for_each_clamp_id(clamp_id) { > > + if (eff[clamp_id] == uc_se[clamp_id].value) > > + continue; > > + uc_se[clamp_id].value = eff[clamp_id]; > > + uc_se[clamp_id].bucket_id = uclamp_bucket_id(eff[clamp_id]); > Shouldn't these writes be synchronized with writes from > __setscheduler_uclamp()? You right, the synchronization is introduced by a later patch: sched/core: uclamp: Update CPU's refcount on TG's clamp changes Cheers, Patrick -- #include Patrick Bellasi