From patchwork Thu Oct 3 08:42:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 175063 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1235ill; Thu, 3 Oct 2019 01:43:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRxhvAtFsDzk89JZk263Gt9jqtWzX8MER3Dv+78HNd+NXM4URJB6QCAmlMdW1DZJnCn5Bt X-Received: by 2002:a05:6402:17eb:: with SMTP id t11mr7989743edy.97.1570092193133; Thu, 03 Oct 2019 01:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570092193; cv=none; d=google.com; s=arc-20160816; b=ofz9OJBk03Ir/u6e3SE/JStryTexGq7kPCOL6YOFDQiQwHQJfqPvbQoS7SP5F4H5se T++aGGFfLY+sEs5MfSKy7uDyjpiwQtG1+RGqEb5Onm98LX9vEdODKOBXXpGm1jcWTikm VdsME/57YCG7RGVZAQsQrlyaQjneq/Vw+RFNreEUZasLbbQ/ZjhPPW8lUJ3h3ICr9rkp n38H+BSyt9rDD7ns7ploF48tcES4HV0ghevZjRZv7hv3fCbkwwYkKEaFnUstmFLfoNSq 9bxlvI1DROrn3TJ5ZmdXb3FNapn/Oo+ZQeyUv1CI15to8YU7mu2I/yrGA5hf6rexixBR yweg== 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=PkzxXO0kBcxX7RILeE3FuUnuhQQatCZ5b0O6JmLXb1U=; b=M2e+xrPgCKXstH2x9ozwSPCaLry5S1DyqerMvoqeEEbGEsInf+r0T3rkpCise7WKAL HbEaZpKN/Z8j8Ao/L5C9qE+dy/v4GS9tiSwLTuLldYfVGypgujYD9rV881/RFs3LLo/+ 77pEs+9fxhZAB+lbvC0JCx4g1Fwn7kFlnm2OQzCwpua4hDLQGvMS+bu5lqs7GANUsQu9 /IgEW4iWrbIdrTtDyNgOPUchRDIfTrsjXfP3G27Ma5/snS1H5CK7puCvfHBxasCvD+pj Cz8h2qScZApwr+p7pgki17TjnrWtX+Z1leSqU9KCOutaq8m2de44XhHNntJYeksuKtA7 eo7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d2RA8XQD; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 j35si1166182eda.144.2019.10.03.01.43.12; Thu, 03 Oct 2019 01:43:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=d2RA8XQD; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1728766AbfJCInL (ORCPT + 10 others); Thu, 3 Oct 2019 04:43:11 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43825 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728842AbfJCInK (ORCPT ); Thu, 3 Oct 2019 04:43:10 -0400 Received: by mail-wr1-f67.google.com with SMTP id j18so1188965wrq.10 for ; Thu, 03 Oct 2019 01:43:09 -0700 (PDT) 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=PkzxXO0kBcxX7RILeE3FuUnuhQQatCZ5b0O6JmLXb1U=; b=d2RA8XQDgVDJJl9BkilqseaM9dtBxXTtwUEqFt77pIMNYH+ci1xYL3fa/Eq5QCmsfe xwa7z321VDwC4wqua7q2IMNbJ5gu00Vxy7VYEniqDQsQdK78Ldl22XUL/b4+WkKTx+V5 YHgO6cuhZ0Ixpk71nzExsfCtT7R6Mo+Fg61eCo5NIKDpCmWt0hNnm9L/l4i+t/kaOM00 P1bw/Z5pG7eZSAo7DprUaN+OrocugXDDxBUd1Z+x/1lAZipZULeVEGm/xOplnOsFM05S Nr5cy8pyZKntmP8IBmochESdb6Oz9EyDb3gRLEGnbENkBAQ1kxq6HIGXnVfzpsiO74Ml r1gw== 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=PkzxXO0kBcxX7RILeE3FuUnuhQQatCZ5b0O6JmLXb1U=; b=VToZZF0Gnmw85z7YbAY/6VVF26QqCre97M9scXr5+THwWFdcMTk+c26RwzkxMK9JRe MVMYj60x3CfUjSLsi9zp9x9erlwXyEjVdGvdLVnYxBqR8QJX/v4Fn5FlNPw3BEsql4LU fDP58oypxNSqU1dvpGCgzXXmLoQ8mRAve9NH0SH8IfoJVJgo3Z2Kmo7uSAjVX60WOJRR 4ma7Z/TFJj+Jb2sFzF6454GrV3T0fg7IoK7nLz916SVpbVXc1mFEKjzVp32nXed/QbMA DhbNggknlLaIK2FaH2epx85PkqqFGPyE4Uwu8+fJUFhDnTt/bQeX1Czj+wbLXSiIksXa sXxw== X-Gm-Message-State: APjAAAUieRm+sv0pycZpGjJzoGOmBbsrlTWzhya4mnb/K/jsvWU5AIuY gcR/uzkJ6F7oUtrCCzrOX6MSancz7oQ= X-Received: by 2002:adf:e386:: with SMTP id e6mr3459292wrm.91.1570092188817; Thu, 03 Oct 2019 01:43:08 -0700 (PDT) Received: from localhost.localdomain ([2a01:e34:ed2f:f020:7990:8bfa:5771:282b]) by smtp.gmail.com with ESMTPSA id z3sm1519702wmi.30.2019.10.03.01.43.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Oct 2019 01:43:08 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org Cc: Mathieu Poirier , "Rafael J. Wysocki" , Zhang Rui , Eduardo Valentin , Ingo Molnar , Peter Zijlstra , Greg Kroah-Hartman , Allison Randal , Thomas Gleixner , Amit Kucheria , Luc Van Oostenryck , Josh Poimboeuf , Jiri Kosina , Nicholas Piggin , linux-pm@vger.kernel.org (open list:POWER MANAGEMENT CORE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH V2 2/3] cpuidle: play_idle: Specify play_idle with an idle state Date: Thu, 3 Oct 2019 10:42:40 +0200 Message-Id: <20191003084242.8655-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191003084242.8655-1-daniel.lezcano@linaro.org> References: <20191003084242.8655-1-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Currently, the play_idle function does not allow to tell which idle state we want to go. Improve this by passing the idle state as parameter to the function. There is no functional changes, the cpuidle state is the deepest one. Signed-off-by: Daniel Lezcano Acked-by: Mathieu Poirier --- drivers/powercap/idle_inject.c | 3 ++- drivers/thermal/intel/intel_powerclamp.c | 4 +++- include/linux/cpu.h | 2 +- kernel/sched/idle.c | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/drivers/powercap/idle_inject.c b/drivers/powercap/idle_inject.c index cd1270614cc6..9b18667b9f26 100644 --- a/drivers/powercap/idle_inject.c +++ b/drivers/powercap/idle_inject.c @@ -138,7 +138,8 @@ 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), + cpuidle_find_deepest_state()); } /** diff --git a/drivers/thermal/intel/intel_powerclamp.c b/drivers/thermal/intel/intel_powerclamp.c index 53216dcbe173..b55786c169ae 100644 --- a/drivers/thermal/intel/intel_powerclamp.c +++ b/drivers/thermal/intel/intel_powerclamp.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -430,7 +431,8 @@ 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), + cpuidle_find_deepest_state()); balance: if (clamping && w_data->clamping && cpu_online(w_data->cpu)) diff --git a/include/linux/cpu.h b/include/linux/cpu.h index 88dc0c653925..76e3038b63ce 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, int state); #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 17da9cb309e1..ead439dab2b5 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, int state) { 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_state(cpuidle_find_deepest_state()); + cpuidle_use_state(state); it.done = 0; hrtimer_init_on_stack(&it.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); From patchwork Thu Oct 3 08:42:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 175064 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1289ill; Thu, 3 Oct 2019 01:43:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCowjSFhyg8qxpneBR9gdnfB2ELz5npc1S6W3ZdxypazoPncnkUpBGpQwvzV+cViM2kGRl X-Received: by 2002:a05:6402:17eb:: with SMTP id t11mr7989893edy.97.1570092196309; Thu, 03 Oct 2019 01:43:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570092196; cv=none; d=google.com; s=arc-20160816; b=bqp1nBm3LEL4EqwqLyZUF5BB4kVVUN2KAj++UsYivv/C5pp4z1vNEVslJGaOpg5ynf kqA83qxjFoYzFd29a41ozsNw/hgs3LvT5BlZwSnmKoWJEz+MG2gAn2qMtgnGKP1x60hr bNZFBWj1qJ0kFSANkRqnesH1JNht+OsGz3IIagCfvqXPWEVujd7ecB+9Wm8dNHVcG2xr NVW+2Dq+RAHNhZvT9Cu7e7kBBgEqHJTyFmBNt7jbRSbB1UhA+MaA8bmr33WqY3wEwQ5U gl056f7Aj6pDEjNMyLn+Ggg5RjepI24zRLB1w7is0+ZnP1wtBZtBB5mYUMOUSb5ad066 TWOQ== 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=Trt8B0Ci9I5T6my9f4Ys/e4jgqsO0QhMPAq+wm6jZoE=; b=P11MQif7jmpm/WrxwemyXqyUZFrgkfXt3iES7xZqnhFjsCIsGOOy7QpSqQXMCg5aqI 3Jcio3ksTb6vdV9B1Uk7HWa+zUZpbKknSmwBeHclOyC9JQ8lv5GkuQz5l/l8ADxIGQ9D TbZrM1bg9S+w9hoQnBlr9NWt+ow/uSUK4spdpz/s7pR7EJjCYyVy7oac+JMkUtri+/3+ vDCrVsKY3Ezi/ut1Bt/A7yrzWDKCGQHWsFo8shjpW/gk/BuIRfmbj35arO9AjiO3plpl cRS785Flxy15BweFJaVRBGW6QzEjZ91xag61NiDs483o4xz83obJjYYD/SAJmeElf1rC QaFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rBmONC0O; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 j35si1166182eda.144.2019.10.03.01.43.16; Thu, 03 Oct 2019 01:43:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=rBmONC0O; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1728842AbfJCInP (ORCPT + 10 others); Thu, 3 Oct 2019 04:43:15 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:34147 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729119AbfJCInP (ORCPT ); Thu, 3 Oct 2019 04:43:15 -0400 Received: by mail-wr1-f66.google.com with SMTP id a11so2036582wrx.1 for ; Thu, 03 Oct 2019 01:43:14 -0700 (PDT) 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=Trt8B0Ci9I5T6my9f4Ys/e4jgqsO0QhMPAq+wm6jZoE=; b=rBmONC0OMG067X9RLR1i4c7uxzZLb+zCjcCqb+aXuoyKhccH76Qd5ItSUyzb2v2mSN w3cy0/Or85QPmCjWuvfqpQo7hXpo2PTUDocbzbMv6pkIBkLix3XQ0GXzjisliwti6jTX 2cXw8bnmYmWcoQsiUppZ0RECva/qcIGjebNQvCeEpecHreXgytksXdvKjVnjUmb5xBo9 rJbRsZZqIhgMJAWLLC2ICuOsyd4Zbw8r6CTxRoyVFs5ZDLM+o9mcXTo6iOIJ02GcWOZ5 K5WsAnXceL5j7xR91eRiWvsbIZN9m990BzMTItIWmJGji4aTBE9zIR6im97iADLNa1YG Ze1w== 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=Trt8B0Ci9I5T6my9f4Ys/e4jgqsO0QhMPAq+wm6jZoE=; b=PylSuKQTqtySWuiFK+6+RADsBu15NDvMo5LfrNrbFxxfxMKywKsywjS5lNZDZM1AfA EGZgvV0txtBJ056UVqIXoIWvFS4EpE720H2QhTqSpunC/YBoJ/l0MKBSmiudsQ884g6J 0W/lds5Z/eaQFHkn2CF80v7PouGFP4Y9OLVViZgJRds12c8a5fW3YvwJUjKI9IoxTihu QFRCtgaLH08eOVSOg4Faf6Fruhnooamh8aXFK/iQfG0aQRbo+E68KAqm5Ip5X9oAkeqh NO1v0maisaglrHHS9hb+wD9rUQNR8helu0mvAyCl7CNCkAuy5OAH+Wl7kFR4kDED8YnW l7zw== X-Gm-Message-State: APjAAAX/1/9M2JqpiJbV3bo+s7WkBXpOHbjhXi4ry0cK+5DriI1Iafvl rhb0ZBAwWB3kf5dWs9Xa805fQQ== X-Received: by 2002:adf:fb11:: with SMTP id c17mr6528096wrr.0.1570092193745; Thu, 03 Oct 2019 01:43:13 -0700 (PDT) Received: from localhost.localdomain ([2a01:e34:ed2f:f020:7990:8bfa:5771:282b]) by smtp.gmail.com with ESMTPSA id z3sm1519702wmi.30.2019.10.03.01.43.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Oct 2019 01:43:13 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org Cc: Mathieu Poirier , "Rafael J. Wysocki" , linux-pm@vger.kernel.org (open list:POWER MANAGEMENT CORE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH V2 3/3] powercap/drivers/idle_inject: Specify the idle state to inject Date: Thu, 3 Oct 2019 10:42:41 +0200 Message-Id: <20191003084242.8655-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191003084242.8655-1-daniel.lezcano@linaro.org> References: <20191003084242.8655-1-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Currently the idle injection framework only allows to inject the deepest idle state available on the system. Give the opportunity to specify which idle state we want to inject by adding a new function helper to set the state and use it when calling play_idle(). There is no functional changes, the cpuidle state is the deepest one. Signed-off-by: Daniel Lezcano Acked-by: Mathieu Poirier --- drivers/powercap/idle_inject.c | 15 ++++++++++++++- include/linux/idle_inject.h | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/powercap/idle_inject.c b/drivers/powercap/idle_inject.c index 9b18667b9f26..a612c425d74c 100644 --- a/drivers/powercap/idle_inject.c +++ b/drivers/powercap/idle_inject.c @@ -38,6 +38,7 @@ #define pr_fmt(fmt) "ii_dev: " fmt #include +#include #include #include #include @@ -65,6 +66,7 @@ struct idle_inject_thread { */ struct idle_inject_device { struct hrtimer timer; + int state; unsigned int idle_duration_us; unsigned int run_duration_us; unsigned long int cpumask[0]; @@ -139,7 +141,7 @@ static void idle_inject_fn(unsigned int cpu) iit->should_run = 0; play_idle(READ_ONCE(ii_dev->idle_duration_us), - cpuidle_find_deepest_state()); + READ_ONCE(ii_dev->state)); } /** @@ -170,6 +172,16 @@ void idle_inject_get_duration(struct idle_inject_device *ii_dev, *idle_duration_us = READ_ONCE(ii_dev->idle_duration_us); } +/** + * idle_inject_set_state - set the idle state to inject + * @state: an integer for the idle state to inject + */ +void idle_inject_set_state(struct idle_inject_device *ii_dev, int state) +{ + if (state >= CPUIDLE_STATE_NOUSE && state < CPUIDLE_STATE_MAX) + WRITE_ONCE(ii_dev->state, state); +} + /** * idle_inject_start - start idle injections * @ii_dev: idle injection control device structure @@ -298,6 +310,7 @@ struct idle_inject_device *idle_inject_register(struct cpumask *cpumask) cpumask_copy(to_cpumask(ii_dev->cpumask), cpumask); hrtimer_init(&ii_dev->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); ii_dev->timer.function = idle_inject_timer_fn; + ii_dev->state = cpuidle_find_deepest_state(); for_each_cpu(cpu, to_cpumask(ii_dev->cpumask)) { diff --git a/include/linux/idle_inject.h b/include/linux/idle_inject.h index a445cd1a36c5..e2b26b9ccd34 100644 --- a/include/linux/idle_inject.h +++ b/include/linux/idle_inject.h @@ -26,4 +26,7 @@ void idle_inject_set_duration(struct idle_inject_device *ii_dev, void idle_inject_get_duration(struct idle_inject_device *ii_dev, unsigned int *run_duration_us, unsigned int *idle_duration_us); + +void idle_inject_set_state(struct idle_inject_device *ii_dev, int state); + #endif /* __IDLE_INJECT_H__ */