Received: by 10.223.176.5 with SMTP id f5csp1509308wra; Wed, 31 Jan 2018 07:28:59 -0800 (PST) X-Google-Smtp-Source: AH8x226GLNqkDaIEQUuCS7zq59jHV3bq3qslczrtCQU8Pn4dgT6b18KWFteJoKKklGGaWPuyHRiY X-Received: by 10.99.102.193 with SMTP id a184mr10193166pgc.141.1517412539476; Wed, 31 Jan 2018 07:28:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517412539; cv=none; d=google.com; s=arc-20160816; b=iL4L82nzng2CFNBVhG0bUlG2SXB6sawAGxpYurV9ESPlY4vifI3/m6W1qftM2QEik5 KZnhC18J9t8zbHk3rQaYCmkPhz89cWja0w83A0HmkvtJu1Hfh7b0tvzFTirIY8IZ0YHy wI1fX74IRCgeapiSuEd7JzLVM9vgyrPu92Qduk+r91J+Bh4jA1fhg7iF4r3cPEXvwMms 7luFs/pL5WBBtsqNZTY7H+ijNYg+rcuSLPlZYLN2up3oYvOr21uTo2Q710jCBd0jRK6+ fymhw/K4GXg8JvoZG/9Lqa6Nma+5p4EUQOJE8nJIe3RqFoCl63q5c6eAa9oY4Lu+PFvv bDyA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=kg47gWzL/kVuwjVk0C/NHKbbnUIKIsXCb5Vzy4zbWY0=; b=q8clR8NDRaD3ivbxhDP9RuNuSBP3Zy/0yUdpa/RuJqWXwMjF97B9IGvKu+R9MdmT46 W16ls0E7JnTC95rzrGFj4b762wpL8gp/Bv2DlD8g2SFBcGcTdM1wkD3VZ7Ojve0pcgni N/RXhNeVFW/kp+t01CV6VkRWugeaIqmQGSBD3gXE+8GRGaIC9KXCuzTcOAH08WkGYwsQ oCgfKQfS4AQwTOBdFfhl3l614cixzxH8d/Yhv2C9SO2vWj8/uGmjWYo/MNIMJTnZmmtK sY5sYLdN90kQVGLBAC9r7vXM5V8AErm2bun4FcxaTFekDrO9m6mn28uALMVKVTQeZh53 KGGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SMJTIBjy; 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 v207si1371138pgb.47.2018.01.31.07.28.44; Wed, 31 Jan 2018 07:28:59 -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=SMJTIBjy; 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 S932203AbeAaP1v (ORCPT + 99 others); Wed, 31 Jan 2018 10:27:51 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:53164 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752497AbeAaP1s (ORCPT ); Wed, 31 Jan 2018 10:27:48 -0500 Received: by mail-wm0-f66.google.com with SMTP id g1so8931479wmg.2 for ; Wed, 31 Jan 2018 07:27:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=kg47gWzL/kVuwjVk0C/NHKbbnUIKIsXCb5Vzy4zbWY0=; b=SMJTIBjyjcj/eFJWTp+0MYEKs5jkZ1fUU8lthXs3GDAcU/HcnVeHiVwJNOx20TGwHx ZXyK2qyjkRZc2NMggsbyvkzdhyY6oSDqKxMow65ZaBa1P45yBD8niilDhTwub5Kq5NqP VjMd0qUvT1XcEAuQqH48L+mAmwJ4e5IujhxQM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=kg47gWzL/kVuwjVk0C/NHKbbnUIKIsXCb5Vzy4zbWY0=; b=TsJuW+k33re2YHzB64cHCuK+SmUAx1DSLa/S/ssYZjkNgluGPSuPEaxVeATQgquF/U viIvycJMzQdAPp6S4SS0/PpMfqyqrThIKdwX91+wgScr7hiRMcvSsvoZjBv0/OUabHFz z+gDFuJMgXq2FwAn5ucOpaa1Z4jCxGzUyBvHQnUxpWWNoK+lllGUJ6l3qFI+0622mlb2 fr3U44Gby+fJRp7uFSYQZ6DgmPsWbvseOS/kb9C14O7BEbHpZOzqZUBxKjhHDl6zLIz1 uvKz+OYhlTnRDbVGioANw1YHdHAO/xLAnHtuPFJzPjxZwYwy/tShasfIzKI++cvpXrlg Cdbg== X-Gm-Message-State: AKwxytcJ4E6N43vDag6k+DEXfNqisAwJYhENN9B2n2YsXjCiHlIDq04m KEIp14yZVp2KLn16MBzJ9u02XA== X-Received: by 10.80.180.184 with SMTP id w53mr31587421edd.149.1517412467043; Wed, 31 Jan 2018 07:27:47 -0800 (PST) Received: from ?IPv6:2001:41d0:fe90:b800:81e6:679:450f:9963? ([2001:41d0:fe90:b800:81e6:679:450f:9963]) by smtp.googlemail.com with ESMTPSA id c45sm9147786edb.17.2018.01.31.07.27.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Jan 2018 07:27:46 -0800 (PST) Subject: Re: [PATCH 5/8] thermal/drivers/cpu_cooling: Introduce the cpu idle cooling driver To: Vincent Guittot Cc: Eduardo Valentin , Kevin Wangtao , Leo Yan , Amit Kachhap , viresh kumar , linux-kernel , Zhang Rui , Javi Merino , "open list:THERMAL" 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> From: Daniel Lezcano Message-ID: <22f4c4fc-fd74-b635-6859-7e2f599695f7@linaro.org> Date: Wed, 31 Jan 2018 16:27:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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_cpus >>>>>> + * >>>>>> + * 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. 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; }; -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog