From: Chen Yu <yu.c.chen@intel.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>, Len Brown <lenb@kernel.org>
Cc: linux-kernel@vger.kernel.org, Chen Yu <yu.c.chen@intel.com>,
Jacob Pan <jacob.jun.pan@linux.intel.com>,
Rui Zhang <rui.zhang@intel.com>,
linux-acpi@vger.kernel.org
Subject: [PATCH][RFC] ACPI: acpi_pad: Do not launch acpi_pad threads on idle cpus
Date: Fri, 4 May 2018 16:08:42 +0800 [thread overview]
Message-ID: <1525421322-23431-1-git-send-email-yu.c.chen@intel.com> (raw)
According to current implementation of acpi_pad driver,
it does not make sense to spawn any power saving threads
on the cpus which are already idle - it might bring
unnecessary overhead on these idle cpus and causes power
waste. So verify the condition that if the number of 'busy'
cpus exceeds the amount of the 'forced idle' cpus - This is
applicable due to round-robin attribute of the power saving
threads, otherwise ignore the setting/ACPI notification.
Suggested-by: Lenny Szubowicz <lszubowi@redhat.com>
Suggested-by: Len Brown <lenb@kernel.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: Rui Zhang <rui.zhang@intel.com>
Cc: linux-acpi@vger.kernel.org
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
---
drivers/acpi/acpi_pad.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 552c1f7..190aa36 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -253,13 +253,36 @@ static void set_power_saving_task_num(unsigned int num)
destroy_power_saving_task();
}
}
+/*
+ * Extra acpi_pad threads should not be created until
+ * the requested idle count is less than/equals to the
+ * number of the busy cpus - it does not make sense to
+ * throttle the idle cpus.
+ */
+static bool idle_cpu_valid(unsigned int num_cpus)
+{
+ int busy_nr = 0, i = 0;
+
+ for_each_online_cpu(i) {
+ /*
+ * In case the acpi_pad threads are treated as
+ * idle in the future(as intel_powerclamp),
+ * the pad_busy_cpus_bits should be checked too.
+ */
+ if (!idle_cpu(i))
+ busy_nr++;
+ }
+
+ return (busy_nr >= num_cpus) ? true : false;
+}
static void acpi_pad_idle_cpus(unsigned int num_cpus)
{
get_online_cpus();
num_cpus = min_t(unsigned int, num_cpus, num_online_cpus());
- set_power_saving_task_num(num_cpus);
+ if (idle_cpu_valid(num_cpus))
+ set_power_saving_task_num(num_cpus);
put_online_cpus();
}
--
2.7.4
next reply other threads:[~2018-05-04 8:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-04 8:08 Chen Yu [this message]
2018-05-05 11:52 ` [PATCH][RFC] ACPI: acpi_pad: Do not launch acpi_pad threads on idle cpus Yu Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1525421322-23431-1-git-send-email-yu.c.chen@intel.com \
--to=yu.c.chen@intel.com \
--cc=jacob.jun.pan@linux.intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).