From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FSL_HELO_FAKE,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AEDAC2D0CE for ; Tue, 21 Jan 2020 10:09:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E494320882 for ; Tue, 21 Jan 2020 10:09:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="iNHLk9So" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729372AbgAUKJB (ORCPT ); Tue, 21 Jan 2020 05:09:01 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36288 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729291AbgAUKJA (ORCPT ); Tue, 21 Jan 2020 05:09:00 -0500 Received: by mail-wr1-f65.google.com with SMTP id z3so2484583wru.3 for ; Tue, 21 Jan 2020 02:08:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=8os47Jh+iH/mWhGJOKaN0Ikowvgw7Dsg6piAesimf+8=; b=iNHLk9Soh1BgMmomizmi4fIcor2oN/NsBEzYcXn39v8n4anlIoYM5pz+LSafgd8Spu f+S7jCQINFEBJ4GDG4xVgihL44c++E/0Tg7Shs1Ps4QiMQ+Do8ke4XZtb91mtCCPSb17 8jgPfcy7ylRBXPBUjDLzy7qpdgFjobOdmL+AyehNXUbus45Wmkzcz9npQK6FoRh2lfld RgloPfjLJuxfGsc3KMrRsmMDzHu36mcWyIeIyYDOEtja0RuhZt+1QHUg64Sy4nQtummn SwblUn6R1sIWp1O85xu9BZGrKNkVu0yj2lUWmC2wFXq9newsw22roQLk7hwpoD5DrjFT RJtA== 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=8os47Jh+iH/mWhGJOKaN0Ikowvgw7Dsg6piAesimf+8=; b=sZNfeeZf/z4okzrfzyGYG+G6P4P1o0OEMBjch65i8j4ZBT1tma9wNvEoAg40m9Nzy7 XuHtowVwtYFroCH+qUsyWfbqeuigb/9v9e0fJmXP34ZoEGDiCs9yq0bO4w/yLOTFMPdY 5pdmZKrpl5atX+vvwH94Jx2veH6w18zm7DQWS9DUPo4AOZsuqyS7YwcevxaZNDPLEYpd FXruZN4N0iGpOzLTi6suV93C58nDDq8TrTppKbLz55AQ0EdqQeRFEKn59EBRpNcQm4LV wKs5eLwCLCFuG2xzCpUVClTwExW/QfNamHACPTzmTPr+toaZCmrMUsGw0YsoSynJtzs8 AReA== X-Gm-Message-State: APjAAAVpVDrlvs2dwYqlASfcNwsX2R+JAmnZrcPv5Fdmvlv9xVqBCgXn VOe2xYGyiMijyDwL0uqLUwGeNQ== X-Google-Smtp-Source: APXvYqzMOzjFtDVGl6edwO/7tSb9RrQo9+Hb9CFGAJn1i1sGI47f1x+xTj047nTS+b5NOSYS7F4xnw== X-Received: by 2002:adf:fcc4:: with SMTP id f4mr4493720wrs.247.1579601338751; Tue, 21 Jan 2020 02:08:58 -0800 (PST) Received: from google.com ([2a00:79e0:d:110:d6cc:2030:37c1:9964]) by smtp.gmail.com with ESMTPSA id u18sm51454016wrt.26.2020.01.21.02.08.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 02:08:58 -0800 (PST) Date: Tue, 21 Jan 2020 10:08:54 +0000 From: Quentin Perret To: Lukasz Luba Cc: Dietmar Eggemann , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-omap@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-imx@nxp.com, Morten.Rasmussen@arm.com, Chris.Redpath@arm.com, ionela.voinescu@arm.com, javi.merino@arm.com, cw00.choi@samsung.com, b.zolnierkie@samsung.com, rjw@rjwysocki.net, sudeep.holla@arm.com, viresh.kumar@linaro.org, nm@ti.com, sboyd@kernel.org, rui.zhang@intel.com, amit.kucheria@verdurent.com, daniel.lezcano@linaro.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com, kernel@pengutronix.de, khilman@kernel.org, agross@kernel.org, bjorn.andersson@linaro.org, robh@kernel.org, matthias.bgg@gmail.com, steven.price@arm.com, tomeu.vizoso@collabora.com, alyssa.rosenzweig@collabora.com, airlied@linux.ie, daniel@ffwll.ch, patrick.bellasi@matbug.net Subject: Re: [PATCH 1/4] PM / EM: and devices to Energy Model Message-ID: <20200121100854.GB157387@google.com> References: <20200116152032.11301-1-lukasz.luba@arm.com> <20200116152032.11301-2-lukasz.luba@arm.com> <17b77e0c-9455-0479-d37b-c57717c784c7@arm.com> <20200120152804.GB164543@google.com> <453034e5-f7b9-20f7-4e26-5d0d7164edd1@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <453034e5-f7b9-20f7-4e26-5d0d7164edd1@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday 20 Jan 2020 at 16:20:49 (+0000), Lukasz Luba wrote: > On 1/20/20 3:28 PM, Quentin Perret wrote: > > Agreed, this looks a bit confusing. It should be trivial to make > > em_dev_get() (or whatever we end up calling it) work for CPUs too, > > though. And we could always have a em_cpu_get(int cpu) API that is a > > basically a wrapper around em_dev_get() for convenience. > > The problem not only here is that we have a CPU index 'int cpu' > and if we ask for device like: > > struct device *dev = get_cpu_device(cpu); > > It might be not the same device that was used during the > registration, when we had i.e. 4 CPUs for the same policy: > > int cpu_id = cpumask_first(policy->cpus); > struct device *cpu_dev = get_cpu_device(cpu_id); > em_register_perf_domain(cpu_dev, nr_opp, &em_cb); > > That's why the em_cpu_get() is different than em_get_pd(), mainly by: > if (cpumask_test_cpu(cpu, em_span_cpus(em_pd))) > > It won't be simple wrapper, let me think how it could be handled > differently than it is now. Right so I suppose the easiest solution would be to do the opposite of my first suggestion. That is, make em_get_pd() call em_cpu_get() if the device is a CPU device, or proceed to the PD list iteration for other devices. And em_cpu_get() can remain as you originally suggested (that is, iterate over the PDs and test the mask). That should ensure em_get_pd() always works, em_cpu_get() is still there handy for the scheduler and such, and the two EM lookup functions (for CPUs or for devices) are kept cleanly separated. Thoughts ? Thanks, Quentin