Received: by 10.192.165.156 with SMTP id m28csp575204imm; Fri, 13 Apr 2018 04:21:43 -0700 (PDT) X-Google-Smtp-Source: AIpwx49qV8KgfKgiFcgJ3avoOUghtE2iH1nEiVrK6RKnJr/yvGqcnDQew/I1XsRbA80y4K8jvjiu X-Received: by 10.98.15.92 with SMTP id x89mr11171767pfi.7.1523618503589; Fri, 13 Apr 2018 04:21:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523618503; cv=none; d=google.com; s=arc-20160816; b=KXaVjzYSEeL+b95QXa+pQemLQ4nvSEoynkHKe3nrDoEJ7pNbT1h1NH7qT1E/LNyA99 6ef5RW7wyNRyFosZIG9oSqtw4WRslQzLmB9g3Vic5FYuxdJNGfUICAZHTDeMcPBTD6jM 29c2NUyrzE7WlwgE2qiGe39HA5reYGTRsMPZ8KQ6VNf3LUsF2hJ+zjTWTNI/U2/1zgEb e1pSGYoPJYkTSjRHFJujnw0f6iynJU6q08ux3eV5F7zW+wr7WHLnJREJ6DIwgIB+CZmd CYZyte6DMu4YPmm+WBb5Zs8DARsp33wgTQmzOWgtrvs4w24d3pjO7NSei8IPxFr/1UBo KOaw== 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=H2kVPJgYYtPvoIlijZG2N6VTgKI6UVGtvrPqaFdDODY=; b=mHDgo2mHTzonVb2ROwHDgYWHGu/MkhduojbZEmTdoZRBIHE7rKsJtyqS4kWvSL0qyU pzhmiJWkrXY9fNN9x40ZWaJHyUUJfhx1YL851nI0iHVqlx6KTIbo8dmBcNpHXAXXUT3z ITpZG/0czqnHyRQeQIkhvjzrhlXx+ruQ642H15wkZPY2twrHhvW5F3Qomj0KtQ20snJU wXXKZ2Y6cGWG/CTic3yb049E3yPyrOVn1koBbiM3oeqJ2IPa8LF+5CgTzAJ9c1/YO4rg 19eT59yB9L0NpxFjUnI5TkMk5FFPw/Ki7oHTa1uPiQtTlIdJf/Tw39HTgsIaVKJWPZFb uXwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=C4oBp1f9; 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 q1-v6si5211263plb.349.2018.04.13.04.21.29; Fri, 13 Apr 2018 04:21:43 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=C4oBp1f9; 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 S1754027AbeDMLTG (ORCPT + 99 others); Fri, 13 Apr 2018 07:19:06 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:46154 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751847AbeDMLTF (ORCPT ); Fri, 13 Apr 2018 07:19:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=H2kVPJgYYtPvoIlijZG2N6VTgKI6UVGtvrPqaFdDODY=; b=C4oBp1f969NGkKyB2M4H46N/w 6cco7e31usRCja7yrv+1KsoYwAdSg73qKF6+PumTPBA2IBxiUP2rDIuZiDOz6znoRlXiaau+Fx7to pO/khKMtsyjJvnglpXinKL9Na18YRyt9dN8+o0bi2GomcRiaq2/a58xgs2C58qtFf+MCrpcj+/Q4G RkVoa5TrQUTpUSZNNP2cVqUiTAIQ4HvwTQOT5DFsWlRFSbcRBL8UFd0GrJo3uHHFwRYQ4bfkiWRxc QGIl3hFtFmMa5tEnCKJd0ewF66zQlKUAh/nRbJEJQ+egRs2pqLzBkWlsQxPTBYTcKWRDyD21ZjCbN aW0IF2c8g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1f6wjO-0000sK-Gt; Fri, 13 Apr 2018 11:19:02 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D926D2029F86F; Fri, 13 Apr 2018 13:19:00 +0200 (CEST) Date: Fri, 13 Apr 2018 13:19:00 +0200 From: Peter Zijlstra To: Patrick Bellasi 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: <20180413111900.GF4082@hirez.programming.kicks-ass.net> References: <20180409165615.2326-1-patrick.bellasi@arm.com> <20180409165615.2326-2-patrick.bellasi@arm.com> <20180413094615.GT4043@hirez.programming.kicks-ass.net> <20180413110848.GR14248@e110439-lin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180413110848.GR14248@e110439-lin> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 13, 2018 at 12:08:48PM +0100, Patrick Bellasi wrote: > 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. I'm not following; the only possible reason for having this second copy of group_id is when your original value (p->uclamp[clamp_id].group_id) can change between enqueue and dequeue. Why can this happen? > 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. But that check is _completely_ redundant, because you already _know_ from being in the en/de-queue path. So having that single callback is actively harmfull (and confusing).