Received: by 10.213.65.68 with SMTP id h4csp515164imn; Tue, 27 Mar 2018 03:57:46 -0700 (PDT) X-Google-Smtp-Source: AG47ELsBDdF1f8XaHKd0HbbwTFdNX9LrbA9qjY8Rwd77LxNp5c8rUw7Js9Ofwi6fSLjh1aa6O3y7 X-Received: by 2002:a17:902:102:: with SMTP id 2-v6mr44540994plb.48.1522148266483; Tue, 27 Mar 2018 03:57:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522148266; cv=none; d=google.com; s=arc-20160816; b=DWtQL4wjKuxHQHUyjJIcBwdBNkWnM0/Fnm4Oeq34HcPHQKtuf4hG5F1LAQ5Wt2QdXr gP/jiP5bY+sjU1ieYcRxu2ks8S1HxrD/4IHQzh3W0lFKCMrRfxwSWuk1Yk5AvFt/dXe5 9Tzuy0HYTjMMVKJa3WlZswU1UCxOxxVJjy9BaAXb6uBPgIvKmJONAec1AI6BtwpWK40g zIe/G8g2JjMlGg33PnrGMBWvpOLZAmKsNfNE+o3xA6mD0TN22njzGT3sL1tni05WMRmx j43xf6/EE1EcMr8QcUoxTnuv/r5WhkyVkJ3FrhACuvRbcJC8Nsg/0xJhj2hbF3bDbsDg NuJw== 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=ZOWoeHj6prt6kOU9jXPm9jbQCKZeKGs8OaIkjufsfAg=; b=OVWIGdOXUkHotXPXfRhYikeni8e7xrrS3OSKH8zQeivDQNbSSE9S3gWtfF/b2tWqhG hpiSWsLltPBQfSimFQvY70PYmup4gF5YBGBTAVoPGBF+IQ+9l4kgV7p3U4ngMweUD+aT 8kSittazwRIzH9hKJkiKlSxY1TOS+3yYexZNJafVDBY+qTn+13gJPK9EObGHEPWCS3L+ cBwwCG1wamXHaJtZSHwk5wCimtIqrVkWuAhdeUun42nvGsiMVS1wxBGwk/ZjG/dnZyWl PAIl8lEgCG463YCw0JynkZykFpBvLBfjzzpBhYA7BHuGQFtw0Z95uPbr+uoPJZB5BR5t 720w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jl49sTxA; 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 h4-v6si1020008pln.744.2018.03.27.03.57.32; Tue, 27 Mar 2018 03:57:46 -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=pass header.i=@linaro.org header.s=google header.b=jl49sTxA; 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 S1752065AbeC0K4d (ORCPT + 99 others); Tue, 27 Mar 2018 06:56:33 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:38775 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751092AbeC0K4c (ORCPT ); Tue, 27 Mar 2018 06:56:32 -0400 Received: by mail-wm0-f67.google.com with SMTP id l16so20928999wmh.3 for ; Tue, 27 Mar 2018 03:56:31 -0700 (PDT) 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=ZOWoeHj6prt6kOU9jXPm9jbQCKZeKGs8OaIkjufsfAg=; b=jl49sTxArxQJlPhpSFwdJxUUiFfslBWHLwlQRMln8yBbWcsLx+8Ro4nqu0QWNxg6kk XWtDcAUNiUHFXTXYhzY4gO5AT6n56g1tTqCqVQ4GASaPdN/zXeR4Qv51uJSeX25FVxdg x+C03VBvn5y14t56oC1LsRsCQFrSeJN8JdhZ4= 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=ZOWoeHj6prt6kOU9jXPm9jbQCKZeKGs8OaIkjufsfAg=; b=VKVIEzoMQp+yZJj93/KWeX0wvakxXx6lswIcLm0okGk43CxgAjFtcrCI/8QFYio/pF +7Rij5UohZgzjcayIaiGu0/HrrU8Og1PsODg505pNvXT59SRCfKwTP0qw/DiSKHKZ9FD NR2j+0GjhLIUgQTFgHrdqQQ4bnIA5KaNRega6BaRK5P8WKUnxA8Sjf4eeCSgEZO/Y4su 7NxNu+TQFkxf/7Z8VNL4ap3zj0oiwQMhFhLcjvkXTmHtLHhVcqb9NxSmEsdWZEW6rL2b SmXwAE60EWqROnsY0LW9uAj95stpkWIBmw+6FNfxIkRKB94e3eeI9wjeQDWPqPPAnBm6 FMNg== X-Gm-Message-State: AElRT7HP4POURozifT51e6PPoF4ApGG/Fh2n2JgX2TsAlb3qJpceNqkB C7M93HkfJIlXxl6/EWv3Nmivnw== X-Received: by 10.28.54.200 with SMTP id y69mr18059392wmh.78.1522148190751; Tue, 27 Mar 2018 03:56:30 -0700 (PDT) Received: from ?IPv6:2001:41d0:fe90:b800:b0a9:da92:8c72:d9e2? ([2001:41d0:fe90:b800:b0a9:da92:8c72:d9e2]) by smtp.googlemail.com with ESMTPSA id c14sm1573446wmi.28.2018.03.27.03.56.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 03:56:30 -0700 (PDT) Subject: Re: [PATCH V2 6/7] thermal/drivers/cpu_cooling: Introduce the cpu idle cooling driver To: Leo Yan Cc: edubezval@gmail.com, kevin.wangtao@linaro.org, vincent.guittot@linaro.org, amit.kachhap@gmail.com, linux-kernel@vger.kernel.org, javi.merino@kernel.org, rui.zhang@intel.com, daniel.thompson@linaro.org, linux-pm@vger.kernel.org, Viresh Kumar References: <1519226968-19821-1-git-send-email-daniel.lezcano@linaro.org> <1519226968-19821-7-git-send-email-daniel.lezcano@linaro.org> <20180327033554.GB21693@leoy-ThinkPad-X240s> From: Daniel Lezcano Message-ID: <3d1ba2a7-5520-9e80-4e30-a1a413fb417f@linaro.org> Date: Tue, 27 Mar 2018 12:56:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180327033554.GB21693@leoy-ThinkPad-X240s> 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 27/03/2018 05:35, Leo Yan wrote: > On Wed, Feb 21, 2018 at 04:29:27PM +0100, Daniel Lezcano wrote: > > [...] > >> +/** >> + * cpuidle_cooling_injection_thread - Idle injection mainloop thread function >> + * @arg: a void pointer containing the idle cooling device address >> + * >> + * This main function does basically two operations: >> + * >> + * - Goes idle for a specific amount of time >> + * >> + * - Sets a timer to wake up all the idle injection threads after a >> + * running period >> + * >> + * That happens only when the mitigation is enabled, otherwise the >> + * task is scheduled out. >> + * >> + * In order to keep the tasks synchronized together, it is the last >> + * task exiting the idle period which is in charge of setting the >> + * timer. >> + * >> + * This function never returns. >> + */ >> +static int cpuidle_cooling_injection_thread(void *arg) >> +{ >> + struct sched_param param = { .sched_priority = MAX_USER_RT_PRIO/2 }; > > I am just wandering if should set priority to (MAX_RT_PRIO - 1)? > Otherwise I am concern it might be cannot enter deep idle state when > any CPU idle injection thread is preempted by other higher priority RT > threads so all CPUs have no alignment for idle state entering/exiting. I do believe we should consider other RT tasks more important than the idle injection threads. >> + struct cpuidle_cooling_device *idle_cdev = arg; >> + struct cpuidle_cooling_tsk *cct = per_cpu_ptr(&cpuidle_cooling_tsk, >> + smp_processor_id()); >> + DEFINE_WAIT(wait); >> + >> + set_freezable(); >> + >> + sched_setscheduler(current, SCHED_FIFO, ¶m); >> + >> + while (1) { >> + s64 next_wakeup; >> + >> + prepare_to_wait(&cct->waitq, &wait, TASK_INTERRUPTIBLE); >> + >> + schedule(); >> + >> + atomic_inc(&idle_cdev->count); >> + >> + play_idle(idle_cdev->idle_cycle / USEC_PER_MSEC); >> + >> + /* >> + * The last CPU waking up is in charge of setting the >> + * timer. If the CPU is hotplugged, the timer will >> + * move to another CPU (which may not belong to the >> + * same cluster) but that is not a problem as the >> + * timer will be set again by another CPU belonging to >> + * the cluster, so this mechanism is self adaptive and >> + * does not require any hotplugging dance. >> + */ >> + if (!atomic_dec_and_test(&idle_cdev->count)) >> + continue; >> + >> + if (!idle_cdev->state) >> + continue; >> + >> + next_wakeup = cpuidle_cooling_runtime(idle_cdev); >> + >> + hrtimer_start(&idle_cdev->timer, ns_to_ktime(next_wakeup), >> + HRTIMER_MODE_REL_PINNED); > > If SoC temperature descreases under tipping point, will the timer be > disabled for this case? Or will here set next timer event with big > value from next_wakeup? Another timer (the polling one) will update the 'state' variable to zero in the set_cur_state. In the worst case, we check the idle_cdev->state right before it is updated and we end up with an extra idle injection cycle which is perfectly fine. -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog