Received: by 10.192.165.156 with SMTP id m28csp564572imm; Fri, 13 Apr 2018 04:10:18 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/o0ZltQo7MC7AvZARkk2w7HtMvMGTs6chkrCCFJrJSKJoqMNC8E07kY+u2ASlcJCJUr64E X-Received: by 10.101.70.132 with SMTP id h4mr3765792pgr.155.1523617818377; Fri, 13 Apr 2018 04:10:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523617818; cv=none; d=google.com; s=arc-20160816; b=UA992Eh5DCfpomoX7swNST2rCrlB5UrKk39MfsqvJtsYKqRmwsfpF1CtcLAhutIZu/ BvWQ0ajb2i3MRnCkFKcZlkJd8xH7bF0K9cGK6jk++9Zn/3wFByi3d4qVZ3bICcQhhU1v hFNB0PaWQ8FRkA8rnwA3trgFR+/LIpK6/z+egU1jmwjSTdJsC36QDfyGb2IQmTBP9/0B K9WTjXL0mwUHBJ2lUtdQm2CUeHKY868sNYS8m7U7eq5cvBYgccOvg23+MH2L5RY26X2g js5GT9IY5i0TtnoFD/j0S9Dgg3imW1Q9DQ05XKVE1JFLlNuUlgeS09BhDuoPIOL9Tymy 70dA== 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:arc-authentication-results; bh=PI/ySsVTJOiYLcC3FW5k56V3h/qvQrd7ScRaBClXiBE=; b=lxhgI0J9urIWeXks+4KIab2/irSoc+BlEJdAB2nA0ci28/2erPxAgMKvI/wN27uoiA GZJbYTgfnT8PgEXFYiFRXik97dweTE6Nmac+aKK3uF645T3J/sMIDRwhk+pTEz1xbqrj I1kNjHFaTt7MPRERsJDeFfgu3OAwjU70ZIoRHXtyCpNMLxd/Wbjivg8QlhG8i6LiRx9r q33Cj+0Gnabgs7Sx0D+46WelQQRmAJqR4fFViztOC0NbMjt/fo9QEu7glU16Nv1THvif 8vf7ucloJyHE/0MLlwJ2IjX0mfmS6u3DJWQVnpW6eNQMh3N2ezGT5g0ojFUsSO2O4D8c Hveg== 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 f3-v6si5298248plr.453.2018.04.13.04.10.04; Fri, 13 Apr 2018 04:10:18 -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 S1754219AbeDMLIz (ORCPT + 99 others); Fri, 13 Apr 2018 07:08:55 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:41342 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751827AbeDMLIx (ORCPT ); Fri, 13 Apr 2018 07:08:53 -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 8BBF51435; Fri, 13 Apr 2018 04:08:53 -0700 (PDT) Received: from e110439-lin (e110439-lin.cambridge.arm.com [10.1.210.68]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 339583F24A; Fri, 13 Apr 2018 04:08:51 -0700 (PDT) Date: Fri, 13 Apr 2018 12:08:48 +0100 From: Patrick Bellasi To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Ingo Molnar , Tejun Heo , "Rafael J . Wysocki" , Viresh Kumar , Vincent Guittot , Paul Turner , Dietmar Eggemann , Morten Rasmussen , Juri Lelli , Joel Fernandes , Steve Muckle Subject: Re: [PATCH 1/7] sched/core: uclamp: add CPU clamp groups accounting Message-ID: <20180413110848.GR14248@e110439-lin> References: <20180409165615.2326-1-patrick.bellasi@arm.com> <20180409165615.2326-2-patrick.bellasi@arm.com> <20180413094615.GT4043@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180413094615.GT4043@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13-Apr 11:46, Peter Zijlstra wrote: > On Mon, Apr 09, 2018 at 05:56:09PM +0100, Patrick Bellasi wrote: > > +static inline void uclamp_cpu_get(struct task_struct *p, int cpu, int clamp_id) > > +{ > > + struct uclamp_cpu *uc_cpu = &cpu_rq(cpu)->uclamp[clamp_id]; > > + int clamp_value; > > + int group_id; > > + > > + /* Get task's specific clamp value */ > > + clamp_value = p->uclamp[clamp_id].value; > > + group_id = p->uclamp[clamp_id].group_id; > > + > > + /* No task specific clamp values: nothing to do */ > > + if (group_id == UCLAMP_NONE) > > + return; > > + > > + /* Increment the current group_id */ > > That I think qualifies being called a bad comment. my bad :/ > > + uc_cpu->group[group_id].tasks += 1; > > + > > + /* Mark task as enqueued for this clamp index */ > > + p->uclamp_group_id[clamp_id] = group_id; > > Why exactly do we need this? we got group_id from @p in the first place. The idea is to back-annotate on the task the group in which it has been refcounted. That allows a much simpler and less racy refcount decrements at dequeue/migration time. That's also why we have a single call-back, uclamp_task_update(), for both enqueue/dequeue. Depending on the check performed by uclamp_task_affects() we know if we have to get or put the refcounter. > I suspect this is because when we update p->uclamp[], we don't update > this active value (when needed), is that worth it? What you mean by "we don't update this active value"? > > + /* > > + * If this is the new max utilization clamp value, then we can update > > + * straight away the CPU clamp value. Otherwise, the current CPU clamp > > + * value is still valid and we are done. > > + */ > > + if (uc_cpu->value < clamp_value) > > + uc_cpu->value = clamp_value; > > +} -- #include Patrick Bellasi