Received: by 10.223.176.5 with SMTP id f5csp2425850wra; Wed, 31 Jan 2018 23:59:17 -0800 (PST) X-Google-Smtp-Source: AH8x224KpNABuDfR/X1ZkPpwJOqtN1eRgFg3O6aYvNhHWeaTq9OM03whzkbyH6QuDKIwFG4zlC/D X-Received: by 2002:a17:902:3343:: with SMTP id a61-v6mr6953763plc.185.1517471957465; Wed, 31 Jan 2018 23:59:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517471957; cv=none; d=google.com; s=arc-20160816; b=NdAy6t8GQx+CwW7odB+QU3RY+5a4xctCa4J+K4AT7h+1jMqKUqPG0A7XBu7iwmSqem puT4YwlIIBt4fgByZWcFa+xGdIKGBfUnhZgHFUgXH82HRj1xnWq6UPBeMUEZRjBVNApl EErSwFsU72WiTe2y5raA4ufNhK7d9sx6s7o07UFXK+PtMwysyPeiz+pIE6blRPVrRQJO cox6Ny9D0Fw2nU8wJRkNzBdW6HI85IbrGQ+/45srSKOauOTPgnNRY+SoiVTTcH7fHT9e 0A7YRSvyKV9H3+U2f/T58fVaboSRLZYY9GPhUtN6FIZswWFknMFfMoYvyVFo/LNRuZqJ fN3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=mjYheY/i+dnyilNDMwBVaMTuprtCn+Y587lcEfz1pRY=; b=RD0TkpRxZWCJbfZORrK8JMdQX1IVmMe180LsfJmSHdoa0rUS75yzpN0FFgLKNgiUXy GyL3dTAKJzpcUs3qqj9ruLNza6MjzvNlsb+jKYFSbajV65/ydYb5+0+GoL2keIPhBB5Q S+H3UzLtT9MjXh61NPLU3/VYWCMQEUw5GjDhNzEsqg92wyEBYyqmFAFrENPexrPRQvOA rGu5AIidBxG6IAaWxqI7deDwrpobdp/5P1BVd8MngVAFzMUriCMA9ZLaIwOYFWjgoxr9 +muEr/Mx7QBSEqa0toVCCQ9Ie6vAVmIKKQl/DLDseaPvvuWOM0rJ00CElb5oiWvnLPRf +YUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bW1KmCoD; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t12si12464561pgs.106.2018.01.31.23.59.02; Wed, 31 Jan 2018 23:59:17 -0800 (PST) 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=pass header.i=@linaro.org header.s=google header.b=bW1KmCoD; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751831AbeBAH6J (ORCPT + 99 others); Thu, 1 Feb 2018 02:58:09 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:45700 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751272AbeBAH6G (ORCPT ); Thu, 1 Feb 2018 02:58:06 -0500 Received: by mail-io0-f195.google.com with SMTP id p188so18177644ioe.12 for ; Wed, 31 Jan 2018 23:58:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=mjYheY/i+dnyilNDMwBVaMTuprtCn+Y587lcEfz1pRY=; b=bW1KmCoD7B2s6554AWX4Hb+KtsnwaZyZrtN8waHRbqTroZ+4Z8av6wLwDPe48HPih4 2LgMeo4x7aEAv9gawrBR9XuiWbL20JGHey9Bn0qgkV+jOWC7O34OCKDyY8BGabplc032 pH7L2snAddkVWPq5nHSqqAKw9PFLvfGBwyAhk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=mjYheY/i+dnyilNDMwBVaMTuprtCn+Y587lcEfz1pRY=; b=sEhzKeEqGDMzdDJncSO/1zYeA/SAHY8GzZcPZ4C8M9qYX1YPazwZJVx76WQv9i2qWD uMu4Y9h8v6rrrgV1NptGOebMDlN8HHT1ydvl2c9/FI0VV0b7lRTJsTiPUo3770K1Esk/ FHdozuaT+w2we4RMBKN6x+8vvT5TiMZlv6OZghKBJ1ZEnncTXbMhr0+YLRTHdf9nqRKB 7xxfReO3ESz2ZNk+iaj7y4cGrA6JMKIXIzra1m0MO8u/UJxqpUCDdGxAcGVns4p3lDS9 pSbpeLKS7SNy3LtKZKxutqbn4AMxKbxtTO4pgzZQnSOfRzNobYpt/5W5scyHZfa2fUVY 0G1g== X-Gm-Message-State: AKwxytewAJOhR9S1QTPOlFPXiSiBRsJ9uQRXWEXCUhpcUveXEeP4EiU7 2PENxVfp3hfhyEUfylc1A1+CaWBDAYRF9K5u9EUTzQ== X-Received: by 10.107.169.94 with SMTP id s91mr5675177ioe.83.1517471885767; Wed, 31 Jan 2018 23:58:05 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.50.198 with HTTP; Wed, 31 Jan 2018 23:57:45 -0800 (PST) In-Reply-To: <22f4c4fc-fd74-b635-6859-7e2f599695f7@linaro.org> References: <1516721671-16360-1-git-send-email-daniel.lezcano@linaro.org> <1516721671-16360-6-git-send-email-daniel.lezcano@linaro.org> <11334876-ef8c-58fa-5e32-ab8499eebd7e@linaro.org> <6e776e6c-6f1e-b33b-58b7-b95410ca1f95@linaro.org> <22f4c4fc-fd74-b635-6859-7e2f599695f7@linaro.org> From: Vincent Guittot Date: Thu, 1 Feb 2018 08:57:45 +0100 Message-ID: Subject: Re: [PATCH 5/8] thermal/drivers/cpu_cooling: Introduce the cpu idle cooling driver To: Daniel Lezcano Cc: Eduardo Valentin , Kevin Wangtao , Leo Yan , Amit Kachhap , viresh kumar , linux-kernel , Zhang Rui , Javi Merino , "open list:THERMAL" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 31 January 2018 at 16:27, Daniel Lezcano wro= te: > On 31/01/2018 10:56, Vincent Guittot wrote: >> On 31 January 2018 at 10:50, Daniel Lezcano = wrote: >>> On 31/01/2018 10:46, Vincent Guittot wrote: >>>> On 31 January 2018 at 10:33, Daniel Lezcano wrote: >>>>> On 31/01/2018 10:01, Vincent Guittot wrote: >>>>>> Hi Daniel, >>>>>> >>>>>> On 23 January 2018 at 16:34, Daniel Lezcano wrote: >>>>> >>>>> [ ... ] (please trim :) >>>>> >>>>>>> + /* >>>>>>> + * Each cooling device is per package. Each package >>>>>>> + * has a set of cpus where the physical number is >>>>>>> + * duplicate in the kernel namespace. We need a way= to >>>>>>> + * address the waitq[] and tsk[] arrays with index >>>>>>> + * which are not Linux cpu numbered. >>>>>>> + * >>>>>>> + * One solution is to use the >>>>>>> + * topology_core_id(cpu). Other solution is to use = the >>>>>>> + * modulo. >>>>>>> + * >>>>>>> + * eg. 2 x cluster - 4 cores. >>>>>>> + * >>>>>>> + * Physical numbering -> Linux numbering -> % nr_cp= us >>>>>>> + * >>>>>>> + * Pkg0 - Cpu0 -> 0 -> 0 >>>>>>> + * Pkg0 - Cpu1 -> 1 -> 1 >>>>>>> + * Pkg0 - Cpu2 -> 2 -> 2 >>>>>>> + * Pkg0 - Cpu3 -> 3 -> 3 >>>>>>> + * >>>>>>> + * Pkg1 - Cpu0 -> 4 -> 0 >>>>>>> + * Pkg1 - Cpu1 -> 5 -> 1 >>>>>>> + * Pkg1 - Cpu2 -> 6 -> 2 >>>>>>> + * Pkg1 - Cpu3 -> 7 -> 3 >>>>>> >>>>>> >>>>>> I'm not sure that the assumption above for the CPU numbering is safe= . >>>>>> Can't you use a per cpu structure to point to resources that are per >>>>>> cpu instead ? so you will not have to rely on CPU ordering >>>>> >>>>> Can you elaborate ? I don't get the part with the percpu structure. >>>> >>>> Something like: >>>> >>>> struct cpuidle_cooling_cpu { >>>> struct task_struct *tsk; >>>> wait_queue_head_t waitq; >>>> }; >>>> >>>> DECLARE_PER_CPU(struct cpuidle_cooling_cpu *, cpu_data); >>> >>> I got this part but I don't get how that fixes the ordering thing. >> >> Because you don't care of the CPU ordering to retrieve the data as >> they are stored per cpu directly > > That's what I did initially, but for consistency reasons with the > cpufreq cpu cooling device which is stored in a list and the combo cpu > cooling device, the cpuidle cooling device must be per cluster and > stored in a list. I'm not sure to catch your problem. You can still have cpuidle cooling device per cluster and stored in the list but keep per cpu data in a AFAICT, you will not have more than one cpu cooling device registered per CPU so one per cpu variable that will gathers cpu private data should be enough ? > > Alternatively I can do: > > struct cpuidle_cooling_device { > struct thermal_cooling_device *cdev; > - struct task_struct **tsk; > + struct task_struct __percpu *tsk; > struct cpumask *cpumask; > struct list_head node; > struct hrtimer timer; > struct kref kref; > - wait_queue_head_t *waitq; > + wait_queue_head_t __percpu waitq; > atomic_t count; > unsigned int idle_cycle; > unsigned int state; > }; struct cpuidle_cooling_device { struct thermal_cooling_device *cdev; struct cpumask *cpumask; struct list_head node; struct hrtimer timer; struct kref kref; atomic_t count; unsigned int idle_cycle; unsigned int state; }; struct cpuidle_cooling_cpu { struct task_struct *tsk; wait_queue_head_t waitq; }; DECLARE_PER_CPU(struct cpuidle_cooling_cpu *, cpu_data); You continue to have cpuidle_cooling_device allocated dynamically per cluster and added in the list but task and waitq are stored per cpu > > > -- > Linaro.org =E2=94=82 Open source software for A= RM SoCs > > Follow Linaro: Facebook | > Twitter | > Blog >