From: "Gautham R. Shenoy" <ego@linux.vnet.ibm.com>
To: Nathan Lynch <nathanl@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Tyrel Datwyler <tyreld@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>,
Kamalesh Babulal <kamaleshb@in.ibm.com>,
"Naveen N . Rao" <naveen.n.rao@linux.vnet.ibm.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
"Gautham R. Shenoy" <ego@linux.vnet.ibm.com>
Subject: [PATCH 2/2] pseries/hotplug-cpu: Add sysfs attribute for cede_offline
Date: Thu, 12 Sep 2019 16:05:41 +0530 [thread overview]
Message-ID: <1568284541-15169-3-git-send-email-ego@linux.vnet.ibm.com> (raw)
In-Reply-To: <1568284541-15169-1-git-send-email-ego@linux.vnet.ibm.com>
From: "Gautham R. Shenoy" <ego@linux.vnet.ibm.com>
Define a new sysfs attribute
"/sys/device/system/cpu/cede_offline_enabled" on PSeries Linux guests
to allow userspace programs to change the state into which the
offlined CPU need to be put to at runtime. This is intended for
userspace programs that fold CPUs for the purpose of saving energy
when the utilization is low.
Setting the value of this attribute ensures that subsequent CPU
offline operations will put the offlined CPUs to extended
cede. However, it will cause inconsistencies in the PURR accounting.
Clearing the attribute will make the offlined CPUs call the RTAS
"stop-self" call thereby returning the CPU to the hypervisor.
Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
---
Documentation/ABI/testing/sysfs-devices-system-cpu | 14 +++++
arch/powerpc/platforms/pseries/hotplug-cpu.c | 68 ++++++++++++++++++++--
2 files changed, 76 insertions(+), 6 deletions(-)
diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu
index 06d0931..b3c52cd 100644
--- a/Documentation/ABI/testing/sysfs-devices-system-cpu
+++ b/Documentation/ABI/testing/sysfs-devices-system-cpu
@@ -572,3 +572,17 @@ Description: Secure Virtual Machine
If 1, it means the system is using the Protected Execution
Facility in POWER9 and newer processors. i.e., it is a Secure
Virtual Machine.
+
+What: /sys/devices/system/cpu/cede_offline_enabled
+Date: August 2019
+Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org>
+ Linux for PowerPC mailing list <linuxppc-dev@ozlabs.org>
+Description: Offline CPU state control
+
+ If 1, it means that offline CPUs on PSeries guests
+ will be made to call an extended CEDE which provides
+ energy savings but at the expense of accuracy of PURR
+ accounting. If 0, the offline CPUs on PSeries guests
+ will be made to call RTAS "stop-self" call which will
+ return the CPUs to the Hypervisor and provide accurate
+ values of PURR. The value is 0 by default.
diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index f9d0366..4a04cf7 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -943,9 +943,64 @@ static int parse_cede_parameters(void)
CEDE_LATENCY_PARAM_MAX_LENGTH);
}
-static int __init pseries_cpu_hotplug_init(void)
+/*
+ * Must be guarded by
+ * cpu_maps_update_begin()...cpu_maps_update_done()
+ */
+static void update_default_offline_state(void)
{
int cpu;
+
+ if (cede_offline_enabled)
+ default_offline_state = CPU_STATE_INACTIVE;
+ else
+ default_offline_state = CPU_STATE_OFFLINE;
+
+ for_each_possible_cpu(cpu)
+ set_default_offline_state(cpu);
+}
+
+static ssize_t show_cede_offline_enabled(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ unsigned long ret = 0;
+
+ if (cede_offline_enabled)
+ ret = 1;
+
+ return sprintf(buf, "%lx\n", ret);
+}
+
+static ssize_t store_cede_offline_enabled(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ bool val;
+ int ret = 0;
+
+ ret = kstrtobool(buf, &val);
+ if (ret)
+ return -EINVAL;
+
+ cpu_maps_update_begin();
+ /* Check if anything needs to be done */
+ if (val == cede_offline_enabled)
+ goto done;
+ cede_offline_enabled = val;
+ update_default_offline_state();
+done:
+ cpu_maps_update_done();
+
+ return count;
+}
+
+static DEVICE_ATTR(cede_offline_enabled, 0600,
+ show_cede_offline_enabled,
+ store_cede_offline_enabled);
+
+static int __init pseries_cpu_hotplug_init(void)
+{
int qcss_tok;
#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
@@ -971,11 +1026,12 @@ static int __init pseries_cpu_hotplug_init(void)
if (firmware_has_feature(FW_FEATURE_LPAR)) {
of_reconfig_notifier_register(&pseries_smp_nb);
cpu_maps_update_begin();
- if (cede_offline_enabled && parse_cede_parameters() == 0) {
- default_offline_state = CPU_STATE_INACTIVE;
- for_each_online_cpu(cpu)
- set_default_offline_state(cpu);
- }
+ if (parse_cede_parameters() == 0)
+ device_create_file(cpu_subsys.dev_root,
+ &dev_attr_cede_offline_enabled);
+ else /* Extended cede is not supported */
+ cede_offline_enabled = false;
+ update_default_offline_state();
cpu_maps_update_done();
}
--
1.9.4
next prev parent reply other threads:[~2019-09-12 10:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-12 10:35 [PATCH 0/2] pseries/hotplug: Change the default behaviour of cede_offline Gautham R. Shenoy
2019-09-12 10:35 ` [PATCH 1/2] pseries/hotplug-cpu: Change default behaviour of cede_offline to "off" Gautham R. Shenoy
2019-09-12 10:35 ` Gautham R. Shenoy [this message]
2019-09-12 15:39 ` [PATCH 0/2] pseries/hotplug: Change the default behaviour of cede_offline Nathan Lynch
2019-09-15 7:42 ` Gautham R Shenoy
2019-09-17 17:36 ` Nathan Lynch
2019-09-18 5:17 ` Michael Ellerman
2019-09-18 12:30 ` Gautham R Shenoy
2019-09-18 17:08 ` Nathan Lynch
2019-09-18 5:14 ` Michael Ellerman
2019-09-18 6:52 ` Naveen N. Rao
2019-09-18 11:31 ` Michael Ellerman
2019-09-18 13:38 ` Aneesh Kumar K.V
2019-09-18 16:24 ` Naveen N. Rao
2019-09-18 12:51 ` Gautham R Shenoy
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=1568284541-15169-3-git-send-email-ego@linux.vnet.ibm.com \
--to=ego@linux.vnet.ibm.com \
--cc=aneesh.kumar@linux.ibm.com \
--cc=kamaleshb@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=nathanl@linux.ibm.com \
--cc=naveen.n.rao@linux.vnet.ibm.com \
--cc=npiggin@gmail.com \
--cc=svaidy@linux.vnet.ibm.com \
--cc=tyreld@linux.ibm.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
all inboxes | Powered by JetHome®