Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1778921imm; Sat, 9 Jun 2018 01:15:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ6JuppduKtpXFXAv0BGo39ySWUFxRuc9cWR0HupUkY+4nqGViewXhvBlyGTxDD24CEWCYN X-Received: by 2002:a62:3101:: with SMTP id x1-v6mr9189850pfx.246.1528532113348; Sat, 09 Jun 2018 01:15:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528532113; cv=none; d=google.com; s=arc-20160816; b=Er8TUT5BbiVPKP/Ox+E0CtApfYT7WFN4WM3SYMUOBwoai83UPFa7VC593e+Y0l6NGL nyP5hEhgf4X9gAzG0n9bP6zX/q+UkKOrJn6MA26Ex/AXd4m7F7aM5tsrJ3WRbM0cZR8w zm4Ws/bcRBN+2LAjKSbw/bh/tTjsliv8Tc9fh9dNUyE7qe7P/jBmnG5nIdR93CrznS9X SuPUJsPu3x6Rwqgo9ImrJgOnupEN6t9in5MlRX/x+agUMH+yBnADiGhdM9Iw/0qCRr4U /iu5HBwK3f1ImtjIZ/PxKEgjYgJqIThzZ29LMVOYJKJjXk9GZLZHR5/8fIE4ugVU6cBl SeLA== 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=YuomcKTeqmTpd9H6dPHgxZUSzs1HuVnZsV9schEjAaE=; b=f/UNxaKN/pOj/YTg3V6Y7D0ftcX34XJk9/Abyz5Va3quoRE1CD5OPX/zqPIB0/IhFw Z6DieCp04KUMr6weAzIvLJpjAvW5D89zWjuBhWZb/gXMPAxFetAcxkJaaoljISjl9Ml0 VdmWVparantxekSh1venk6fmWqcJDvtl/Y3sB/de6qSY1wJi90F0h7dmlpVzQOHaFhDQ WCUVskPZBb6QF0blxP3XozvUH8IAKVLp6l+AjnNbhAnLG7ykm38XvjaVj1VPvWMsQzCc HMwcR64Iyj+ojPRn0SFig1L28XMUAVnz2O37RnmlNSV0tzbKyJcSMTActuwwbAFjEMC7 tm5g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s136-v6si20317877pfc.222.2018.06.09.01.14.45; Sat, 09 Jun 2018 01:15:13 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753225AbeFIIOF (ORCPT + 99 others); Sat, 9 Jun 2018 04:14:05 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:39857 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753156AbeFIIOC (ORCPT ); Sat, 9 Jun 2018 04:14:02 -0400 Received: by mail-wr0-f194.google.com with SMTP id w7-v6so15451115wrn.6; Sat, 09 Jun 2018 01:14:01 -0700 (PDT) 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=YuomcKTeqmTpd9H6dPHgxZUSzs1HuVnZsV9schEjAaE=; b=MGjurQGdYl11MTS43HzF9f54ERmxdkQWt697H2wwGK2SmMNDGK/8XH1kcI6btToxLt cjYP0QA/6g4lZ91py9OYL9dUfFwzd4OpbE2GVv2bm+XixeI8Ga//w4NPHd+AoCdbefMJ 1qJBMxznkBb9OzDPn2mQe9IMTBQ7plU9XXERXb2OI1XjJYBHFS655cHoQDmog5uj8hP3 r0oFGpd7hPn3wocb92pyyqyJg4MZtOHy0ojp//pxc2CEdzd/oPpTPiu9bKu93xpb9SiC BxkRfEXn/gXPaB2gyVwh38GHUf+ig3eyvP+5o+yqntiHMOcTxixcTfUU0EVsf9zy7ifX /0uQ== X-Gm-Message-State: APt69E2UpjgAtzeL6LkenzmRIfgEWLpz27dOO4+fxPD4dOIbuUR4WsG3 RAPbYk0CCjgYkqJgr2KW3w== X-Received: by 2002:adf:ba8f:: with SMTP id p15-v6mr7816669wrg.139.1528532040933; Sat, 09 Jun 2018 01:14:00 -0700 (PDT) Received: from tesla (2.154.108.25.dyn.user.ono.com. [2.154.108.25]) by smtp.googlemail.com with ESMTPSA id q81-v6sm5604856wmd.14.2018.06.09.01.13.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 01:13:59 -0700 (PDT) Received: from javi by tesla with local (Exim 4.91) (envelope-from ) id 1fRZ0X-0006CO-Um; Sat, 09 Jun 2018 10:13:57 +0200 Date: Sat, 9 Jun 2018 10:13:57 +0200 From: Javi Merino To: Juri Lelli Cc: Quentin Perret , peterz@infradead.org, rjw@rjwysocki.net, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, mingo@redhat.com, dietmar.eggemann@arm.com, morten.rasmussen@arm.com, chris.redpath@arm.com, patrick.bellasi@arm.com, valentin.schneider@arm.com, vincent.guittot@linaro.org, thara.gopinath@linaro.org, viresh.kumar@linaro.org, tkjos@google.com, joelaf@google.com, smuckle@google.com, adharmap@quicinc.com, skannan@quicinc.com, pkondeti@codeaurora.org, edubezval@gmail.com, srinivas.pandruvada@linux.intel.com, currojerez@riseup.net Subject: Re: [RFC PATCH v3 03/10] PM: Introduce an Energy Model management framework Message-ID: <20180609081357.GC4359@tesla> References: <20180521142505.6522-1-quentin.perret@arm.com> <20180521142505.6522-4-quentin.perret@arm.com> <20180607144409.GB3311@localhost.localdomain> <20180607151954.GA3597@e108498-lin.cambridge.arm.com> <20180607160419.GD3311@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180607160419.GD3311@localhost.localdomain> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 07, 2018 at 06:04:19PM +0200, Juri Lelli wrote: > On 07/06/18 16:19, Quentin Perret wrote: > > Hi Juri, > > > > On Thursday 07 Jun 2018 at 16:44:09 (+0200), Juri Lelli wrote: > > > On 21/05/18 15:24, Quentin Perret wrote: > > [...] > > > > > +static void fd_update_cs_table(struct em_cs_table *cs_table, int cpu) > > > > +{ > > > > + unsigned long cmax = arch_scale_cpu_capacity(NULL, cpu); > > > > + int max_cap_state = cs_table->nr_cap_states - 1; > > > ^ > > > You don't need this on the stack, right? > > > > Oh, why not ? > > > > Because you use it only once here below? Anyway, more a (debatable) > nitpick than anything. The compiler optimizes that for you because it knows that it is used only once. It doesn't put it in the stack, it uses a register. As it is, it's more readable so I'd rather keep it. For reference, this is the code gcc 7.3 generates for arm64 for fd_update_cstable() (which is inlined in em_rescale_cpu_capacity(): x27 holds the address to cs_table 1ac: b9400b63 ldr w3, [x27, #8] ; w3 = cs_table->nr_cap_states 1b0: b9406fa4 ldr w4, [x29, #108] ; w4 = 0x18 (sizeof(struct em_cap_state)) 1b4: f9400362 ldr x2, [x27] ; x2 = &cs_table[state] 1b8: 51000461 sub w1, w3, #0x1 ; w1 max_cap_state = cs_table->nr_cap_states - 1 [...] 1cc: 9b240821 smaddl x1, w1, w4, x2 ; x1 = &cs_table->state[max_cap_state] [...] 1d4: f9400427 ldr x7, [x1, #8] ; x7 fmax = cs_table->state[max_cap_state].frequency [...] ; calculates cmax * cs_table->state[i].frequency in x0 200: 9ac70800 udiv x0, x0, x7 ; x0 = x0 / fmax ; x0 is then stored to cs_table->state[i].capacity