From patchwork Wed Nov 13 18:54:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 179343 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp10001576ilf; Wed, 13 Nov 2019 10:54:46 -0800 (PST) X-Google-Smtp-Source: APXvYqwmH9x5N/LPlbJxd7t5Z5SY59ZQAurR+CTwjSBJjiXUZ03ER6PK2QWyq8xloAfz8DSxa2nl X-Received: by 2002:aa7:d1c9:: with SMTP id g9mr5280537edp.162.1573671286126; Wed, 13 Nov 2019 10:54:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573671286; cv=none; d=google.com; s=arc-20160816; b=l+VDWq0WgrzG5aVh/IjXyVu58QUnvTlEntn1+KbV8sd4PhFEwQmviIUjK4GOKqe3I4 iXHO0J+ej6MF0wPnQVp1ZIn1GO5sRWwNof8kcH2zEO8ORSAevu5lhAm8zAUNmFd1cSbB W/+L4rvgffTedHWAXZYJp6sx46+oyxNuTE1TyKsW1aeCp8KxT5Jp5O/MyHvtpfjIhFSl KULgfaAKmLpK58LjOAiRBArWYTpe3z9TEJef9eBCTaRXilA95CQw7xzu6yEinYz6QAJY zfwjf0r1dwRK4EAcWzUab06B/BrmuLmKwbkrrR17XHuHljTAlLW3STzaZU8B/Zt23H9R cqwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=zn3z/ohxCZiMEpAOhI2pz3odCG7wV2XPFA28iErwpL0=; b=cMZ3ZnHWYgmqbV5OHGWHB5nMCoZggcR7jV/NsowvQxYk7haoyslDA75sT42HA4NvSf xRv7ReG7WLkGlVcmt+KbAZ6tqGwduPKFet+m5vXjrjSJvpMDg3+sqxvqF4ylnZ6OpVDt w4CEfr06wBaptzpbS1gm8486lgGuK4K/vmTI2uiy+RzqwZIU4/lxIIxPCeSPcV5KAP6q Gwb8yD0NftwH87IZogYnwkWdy5fRNOHGXYC+MD8M4NcegFPu5sy8nMKuVSF+njV0gxLY 3ObuJkcYXd0n9JJK/w3CaYhgrm64baploW/wGh+R1qO9r7C7XaJPAg0WBJDTjnlWH3Rq ATfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eg+szh1m; 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 l64si2200736edl.306.2019.11.13.10.54.45; Wed, 13 Nov 2019 10:54:46 -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=eg+szh1m; 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 S1728713AbfKMSyi (ORCPT + 26 others); Wed, 13 Nov 2019 13:54:38 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:37238 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728000AbfKMSyf (ORCPT ); Wed, 13 Nov 2019 13:54:35 -0500 Received: by mail-wm1-f66.google.com with SMTP id b17so3231556wmj.2 for ; Wed, 13 Nov 2019 10:54:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zn3z/ohxCZiMEpAOhI2pz3odCG7wV2XPFA28iErwpL0=; b=eg+szh1mA8xKUV7Uc2u6zplCS83M0epV5sOJ1ElLmuQk8iLAJG64JM63oPGXrwcUNv ZzfkqjN0Aa1V568LRe1nBtPAmUK3eOMcxda/eXV3TjHhvGfhZvqWCcil4DAXeSnBzIgv OZ4X1Pbmv01rE3XRIdbxNa7Uf0KZmc9SrUgiISMv6NlDDQrjxRssnlMVgdIACFsN6iUB asJ+n6EUkSxx5jmmWwV+x2H2OS5is4rgxmVWvPF047Pi27O5r99yRGWqxDvtFlyg4qEc MgPEr7KxjFrtr1vS//IMXBkK2LcClSMSFaMZ1i1+hKkDtGjxheiLnW4r2DVcp6db71jO gnkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zn3z/ohxCZiMEpAOhI2pz3odCG7wV2XPFA28iErwpL0=; b=HX6jvxVDU+Us7AOA2HpdnTKi/5DO2ZwSk6UW/E3l5YaaYAtBHKxc1dzxmdmzNcOiCo OWkso58IvhTuhyApriuyw2BKROQT2BUOTs3aOr+R+6zwpWW6dpvz1p1O+1lBkyV59ZTf eTEzYPb0RTxDJ7HPbKuqYLhw6q/X0FLASSi0M9CfsQACnQRFhYEUSUD9v2b5xvnoJYrp 7+m5d9Z3ZbpsqHmQgt0l1iqd38WG+l4CCzDrjnnuzeiVkUVtdxLpjJmzoEjhTmWCP4hA A0Oj1LOr4pGk7Vc1WCKh0qBZxyiQOz+4O6VEpOtes84rgmpETSrbVaGE3/c1sDfQ9R7u rZog== X-Gm-Message-State: APjAAAVa9k0Lgy+7c9FvLCLOdBB9x1heb+F16vuD0C9HGGFrN6F2tVLf sPBvZjZI1VbzSwdCEnZRCyPEDw== X-Received: by 2002:a1c:2dd0:: with SMTP id t199mr4027766wmt.58.1573671272661; Wed, 13 Nov 2019 10:54:32 -0800 (PST) Received: from localhost.localdomain ([2a01:e34:ed2f:f020:ec92:781d:6592:837]) by smtp.gmail.com with ESMTPSA id 17sm2652848wmg.19.2019.11.13.10.54.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2019 10:54:32 -0800 (PST) From: Daniel Lezcano To: rafael@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org Subject: [PATCH RFC 2/3] sched: idle: Add a latency parameter to the play_idle function Date: Wed, 13 Nov 2019 19:54:18 +0100 Message-Id: <20191113185419.13305-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191113185419.13305-1-daniel.lezcano@linaro.org> References: <20191113185419.13305-1-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org By default the play_idle() function leads to the deepest idle state selection which is not necessarily the state we are interested in when forcing the CPU to go to idle. Add a latency parameter to the play_idle() function, so the caller can use the constraint to allow a shallower state. Signed-off-by: Daniel Lezcano --- drivers/powercap/idle_inject.c | 2 +- drivers/thermal/intel/intel_powerclamp.c | 2 +- include/linux/cpu.h | 2 +- kernel/sched/idle.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/drivers/powercap/idle_inject.c b/drivers/powercap/idle_inject.c index cd1270614cc6..6f2bfb172e61 100644 --- a/drivers/powercap/idle_inject.c +++ b/drivers/powercap/idle_inject.c @@ -138,7 +138,7 @@ static void idle_inject_fn(unsigned int cpu) */ iit->should_run = 0; - play_idle(READ_ONCE(ii_dev->idle_duration_us)); + play_idle(READ_ONCE(ii_dev->idle_duration_us), UINT_MAX); } /** diff --git a/drivers/thermal/intel/intel_powerclamp.c b/drivers/thermal/intel/intel_powerclamp.c index 53216dcbe173..dd1330d59176 100644 --- a/drivers/thermal/intel/intel_powerclamp.c +++ b/drivers/thermal/intel/intel_powerclamp.c @@ -430,7 +430,7 @@ static void clamp_idle_injection_func(struct kthread_work *work) if (should_skip) goto balance; - play_idle(jiffies_to_usecs(w_data->duration_jiffies)); + play_idle(jiffies_to_usecs(w_data->duration_jiffies), UINT_MAX); balance: if (clamping && w_data->clamping && cpu_online(w_data->cpu)) diff --git a/include/linux/cpu.h b/include/linux/cpu.h index d0633ebdaa9c..241f558af17a 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -179,7 +179,7 @@ void arch_cpu_idle_dead(void); int cpu_report_state(int cpu); int cpu_check_up_prepare(int cpu); void cpu_set_state_online(int cpu); -void play_idle(unsigned long duration_us); +void play_idle(unsigned long duration_us, unsigned int latency); #ifdef CONFIG_HOTPLUG_CPU bool cpu_wait_death(unsigned int cpu, int seconds); diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index 00e064d3dfe1..56a8b9d35cb9 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -311,7 +311,7 @@ static enum hrtimer_restart idle_inject_timer_fn(struct hrtimer *timer) return HRTIMER_NORESTART; } -void play_idle(unsigned long duration_us) +void play_idle(unsigned long duration_us, unsigned int latency) { struct idle_timer it; @@ -328,7 +328,7 @@ void play_idle(unsigned long duration_us) rcu_sleep_check(); preempt_disable(); current->flags |= PF_IDLE; - cpuidle_use_latency(1); + cpuidle_use_latency(latency); it.done = 0; hrtimer_init_on_stack(&it.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); From patchwork Wed Nov 13 18:54:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 179342 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp10001572ilf; Wed, 13 Nov 2019 10:54:45 -0800 (PST) X-Google-Smtp-Source: APXvYqyX9oNb6gboIUSiidYKw+KcbfnhGXPANol+xwcOxKuXjkjohVt/Tr/EPt0+hgTXyhjmmiOY X-Received: by 2002:a17:907:206d:: with SMTP id qp13mr4216602ejb.92.1573671285725; Wed, 13 Nov 2019 10:54:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573671285; cv=none; d=google.com; s=arc-20160816; b=RxS/HA/7uBkq4TpHZt7Lg0oVmdCNeBNyBxCa5wRK3oEhJAM7+B+vrnR4nBABROYhk1 OX6BuFI3EE4jA1THWBUcIEU1766lGlHvR2h+aS+8aMKWSIFfGmijhbArWTWtgfQwfKBl TR9mljoxN7PhdeYA3bIOZT+pYN7xKmr7cuudl6j0Nsxv/sRRIP+b9CdF+FEmISonN/J/ v3sofJZCWtFmnN51tZSSXfWUCsGOS9z3LkipZIUb3LJu2g4JX2f9IsQvR7bCvGEE64ZX NTRwhRkIbFv1MVJH0H7WKwpDN/mS6CDqsSIwGgetcHNgq/Edo0yOVZvChv/rGF8td12g oqqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=znf7mo4G9jPIzVfiurHEWnDBV3kCfIxmHe1zoQ/j1JI=; b=hLIyiaLk54yJKatrKnprl1b2G+cH9alqTF687iFToSC2r5c8mgBDCIaR6W5oraVX1q 2xRv8cETWyzwGFJ+8hyA8ER8AkHT2JCzrhYhRNqUV/hgCFcr6b30AjM2CAikYtNaeZSU scU/rXQumr5oWbCanzyYdFehDp8cH6S5oC0+wslkA9bN3Iom0c0CSDTt4fdQandsOj7e vYNYWvX56WCsJEObi9ObMOz0T0XStfm1pGF6EGQ5XcTPXoYDLyzNkGcHGxmbK/H2l1ME AqODz65iSn1OmQ9Fu5Cg+HZ95KsJDebjiNIz0NMMbLZFh5DqfwDVUKvsLy8wmvjuTRbS hQiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jXqpKJGh; 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 l64si2200736edl.306.2019.11.13.10.54.45; Wed, 13 Nov 2019 10:54:45 -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=jXqpKJGh; 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 S1728726AbfKMSyj (ORCPT + 26 others); Wed, 13 Nov 2019 13:54:39 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:55937 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728092AbfKMSyf (ORCPT ); Wed, 13 Nov 2019 13:54:35 -0500 Received: by mail-wm1-f65.google.com with SMTP id b11so3129333wmb.5 for ; Wed, 13 Nov 2019 10:54:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=znf7mo4G9jPIzVfiurHEWnDBV3kCfIxmHe1zoQ/j1JI=; b=jXqpKJGh1V1p5/zJKPLSg8aHuXISAB+G6IUG18JBJ++ehzluBYs0E7RavYC25cumyh zylqE+mpEVyNVyEFmLw0uCdQi1P8cwzPE5q10jbtC157GvZwsg138aXk0Hv7RgOswA1q K9v27zdFW1hggQaqzvF9WZ1sz2eaKn/3YM6w9FbLsSPvPXR0K24Bn0jWRdqqhkM+V4ie gXaOtkQRnA5oINYeBEzRNQT7bHQO3YhGy+r10vMKcjpJyj74YWSegP0Ka9kz6r6QdKZn GkoqMj/u4If5cgtA70HuerUoNfQDA4sUz/4UV3lC+pfcttUY0x6tzv+iJwPQIFK84oUt Lacw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=znf7mo4G9jPIzVfiurHEWnDBV3kCfIxmHe1zoQ/j1JI=; b=iwHchvtB44EVRIcUVNAfrEXcgnjTg0oyFWTnRnAQ6ftuZwWGcmvu+48EtmPp+LNVe+ 207aySOE7ns4+g/h9qARYo5Amc4oIY0Vh9evhQWTT4wJlCGWijZEtuHzIqQuvI4eit67 cnsKmPDGmI+8cM1NDIRbkEl2INbl4dIJ40q6BmsE7WV6YUKR6xzvGUi78D9Xj5BIaEWy we6zgm2leuo+o+TnjNz3j8hf1n8UTxW/dLaFM8ob9Xd0WYOupl2xcf+1ITskQbwBBGrT Xu9568AH+NzVuB/osmQ4+d2kH4mffI62E9+nkYBa8Tw8W/ixthUdzyZSA52GYkFKB5z/ etkg== X-Gm-Message-State: APjAAAWchgVuYGw1i+1Z2IteguUOUP+RTpjeao7YHMxSuHBQJG0Obz37 W0I2INONc39ESVefUFPbdX1ds4uU96Q= X-Received: by 2002:a1c:f612:: with SMTP id w18mr4491750wmc.28.1573671273779; Wed, 13 Nov 2019 10:54:33 -0800 (PST) Received: from localhost.localdomain ([2a01:e34:ed2f:f020:ec92:781d:6592:837]) by smtp.gmail.com with ESMTPSA id 17sm2652848wmg.19.2019.11.13.10.54.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2019 10:54:33 -0800 (PST) From: Daniel Lezcano To: rafael@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org Subject: [PATCH RFC 3/3] cpuidle: Use the latency to call find_deepest_idle_state Date: Wed, 13 Nov 2019 19:54:19 +0100 Message-Id: <20191113185419.13305-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191113185419.13305-1-daniel.lezcano@linaro.org> References: <20191113185419.13305-1-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As the dev->use_latency is filled with the latency value when this function is called, use it as a parameter to the find_deepest_idle_state() function. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/cpuidle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index f68a6c9e8482..659d8b1ece6d 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -124,7 +124,7 @@ void cpuidle_use_latency(unsigned int latency) int cpuidle_find_deepest_state(struct cpuidle_driver *drv, struct cpuidle_device *dev) { - return find_deepest_state(drv, dev, UINT_MAX, 0, false); + return find_deepest_state(drv, dev, dev->use_latency, 0, false); } #ifdef CONFIG_SUSPEND