All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC v2 PATCH 0/6] cpuidle: Make cpuidle governor switchable to be the default behaviour
@ 2020-04-30  8:39 Hanjun Guo
  2020-04-30  8:39 ` [RFC v2 PATCH 1/6] cpuidle: sysfs: Fix the overlap for showing available governors Hanjun Guo
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Hanjun Guo @ 2020-04-30  8:39 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano, Doug Smythies
  Cc: linux-pm, Jonathan Corbet, Hanjun Guo

For now cpuidle governor can be switched via sysfs only when the
boot option "cpuidle_sysfs_switch" is passed, but it's important
to switch the governor to adapt to different workloads, especially
after TEO and haltpoll governor were introduced.

Make cpuidle governor switchable to be the default behaviour by removing
the sysfs_switch and switch attributes, also update the document as well.

v1->v2:
 - Add two bugfix patch which can be triggered if the governor name is 15
   characters, it is not a 'real' bug for now as we don't have such usecases
   so we can merge them together via this patchset.
 - Remove the sysfs_switch, not introduce a CONFIG option to make cpuidle
   governor switchable in default, suggested by Daniel.
 - Update the document after cpuidle_sysfs_switch is removed, suggested by
   Doug Smythies.

Hanjun Guo (6):
  cpuidle: sysfs: Fix the overlap for showing available governors
  cpuidle: sysfs: Accept governor name with 15 characters
  cpuidle: Make cpuidle governor switchable to be the default behaviour
  cpuidle: sysfs: Remove sysfs_switch and switch attributes
  Documentation: cpuidle: update the document
  Documentation: ABI: make current_governer_ro as a candidate for
    removal

 Documentation/ABI/obsolete/sysfs-cpuidle           |  9 ++++
 Documentation/ABI/testing/sysfs-devices-system-cpu | 24 ++++------
 Documentation/admin-guide/pm/cpuidle.rst           | 20 ++++----
 Documentation/driver-api/pm/cpuidle.rst            |  5 +-
 drivers/cpuidle/sysfs.c                            | 56 ++++++----------------
 5 files changed, 44 insertions(+), 70 deletions(-)
 create mode 100644 Documentation/ABI/obsolete/sysfs-cpuidle

-- 
1.7.12.4


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [RFC v2 PATCH 1/6] cpuidle: sysfs: Fix the overlap for showing available governors
  2020-04-30  8:39 [RFC v2 PATCH 0/6] cpuidle: Make cpuidle governor switchable to be the default behaviour Hanjun Guo
@ 2020-04-30  8:39 ` Hanjun Guo
  2020-05-18 14:20   ` Daniel Lezcano
  2020-04-30  8:39 ` [RFC v2 PATCH 2/6] cpuidle: sysfs: Accept governor name with 15 characters Hanjun Guo
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Hanjun Guo @ 2020-04-30  8:39 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano, Doug Smythies
  Cc: linux-pm, Jonathan Corbet, Hanjun Guo

When showing the available governors, it's "%s " in scnprintf(),
not "%s", so if the governor name has 15 characters, it will
overlap with the later one, fix it by adding one more for the
size.

While we are at it, fix the minor coding sytle as well.

Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
---
 drivers/cpuidle/sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index d3ef1d7..3485210 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -35,10 +35,10 @@ static ssize_t show_available_governors(struct device *dev,
 
 	mutex_lock(&cpuidle_lock);
 	list_for_each_entry(tmp, &cpuidle_governors, governor_list) {
-		if (i >= (ssize_t) ((PAGE_SIZE/sizeof(char)) -
+		if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char)) -
 				    CPUIDLE_NAME_LEN - 2))
 			goto out;
-		i += scnprintf(&buf[i], CPUIDLE_NAME_LEN, "%s ", tmp->name);
+		i += scnprintf(&buf[i], CPUIDLE_NAME_LEN + 1, "%s ", tmp->name);
 	}
 
 out:
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [RFC v2 PATCH 2/6] cpuidle: sysfs: Accept governor name with 15 characters
  2020-04-30  8:39 [RFC v2 PATCH 0/6] cpuidle: Make cpuidle governor switchable to be the default behaviour Hanjun Guo
  2020-04-30  8:39 ` [RFC v2 PATCH 1/6] cpuidle: sysfs: Fix the overlap for showing available governors Hanjun Guo
@ 2020-04-30  8:39 ` Hanjun Guo
  2020-04-30  8:39 ` [RFC v2 PATCH 3/6] cpuidle: Make cpuidle governor switchable to be the default behaviour Hanjun Guo
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Hanjun Guo @ 2020-04-30  8:39 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano, Doug Smythies
  Cc: linux-pm, Jonathan Corbet, Hanjun Guo

CPUIDLE_NAME_LEN is 16, so it's possible to accept governor name
with 15 characters, but now store_current_governor() rejects
governor name with 15 characters as it returns -EINVAL if count
equals CPUIDLE_NAME_LEN.

Refactor the code to accept such case and simplify the code.

Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
---
 drivers/cpuidle/sysfs.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index 3485210..af5a65f 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -85,34 +85,25 @@ static ssize_t store_current_governor(struct device *dev,
 				      struct device_attribute *attr,
 				      const char *buf, size_t count)
 {
-	char gov_name[CPUIDLE_NAME_LEN];
-	int ret = -EINVAL;
-	size_t len = count;
+	char gov_name[CPUIDLE_NAME_LEN + 1];
+	int ret;
 	struct cpuidle_governor *gov;
 
-	if (!len || len >= sizeof(gov_name))
+	ret = sscanf(buf, "%" __stringify(CPUIDLE_NAME_LEN) "s", gov_name);
+	if (ret != 1)
 		return -EINVAL;
 
-	memcpy(gov_name, buf, len);
-	gov_name[len] = '\0';
-	if (gov_name[len - 1] == '\n')
-		gov_name[--len] = '\0';
-
 	mutex_lock(&cpuidle_lock);
-
+	ret = -EINVAL;
 	list_for_each_entry(gov, &cpuidle_governors, governor_list) {
-		if (strlen(gov->name) == len && !strcmp(gov->name, gov_name)) {
+		if (!strncmp(gov->name, gov_name, CPUIDLE_NAME_LEN)) {
 			ret = cpuidle_switch_governor(gov);
 			break;
 		}
 	}
-
 	mutex_unlock(&cpuidle_lock);
 
-	if (ret)
-		return ret;
-	else
-		return count;
+	return ret ? ret : count;
 }
 
 static DEVICE_ATTR(current_driver, 0444, show_current_driver, NULL);
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [RFC v2 PATCH 3/6] cpuidle: Make cpuidle governor switchable to be the default behaviour
  2020-04-30  8:39 [RFC v2 PATCH 0/6] cpuidle: Make cpuidle governor switchable to be the default behaviour Hanjun Guo
  2020-04-30  8:39 ` [RFC v2 PATCH 1/6] cpuidle: sysfs: Fix the overlap for showing available governors Hanjun Guo
  2020-04-30  8:39 ` [RFC v2 PATCH 2/6] cpuidle: sysfs: Accept governor name with 15 characters Hanjun Guo
@ 2020-04-30  8:39 ` Hanjun Guo
  2020-05-18 14:24   ` Daniel Lezcano
  2020-04-30  8:39 ` [RFC v2 PATCH 4/6] cpuidle: sysfs: Remove sysfs_switch and switch attributes Hanjun Guo
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Hanjun Guo @ 2020-04-30  8:39 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano, Doug Smythies
  Cc: linux-pm, Jonathan Corbet, Hanjun Guo

For now cpuidle governor can be switched via sysfs only when the
boot option "cpuidle_sysfs_switch" is passed, but it's important
to switch the governor to adapt to different workloads, especially
after TEO and haltpoll governor were introduced.

Add available_governors and current_governor into the default
attributes, but reserve the current_governor_ro for temporal
compatibility.

Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
---
 drivers/cpuidle/sysfs.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index af5a65f..2425c6a 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -106,19 +106,20 @@ static ssize_t store_current_governor(struct device *dev,
 	return ret ? ret : count;
 }
 
+static DEVICE_ATTR(available_governors, 0444, show_available_governors, NULL);
 static DEVICE_ATTR(current_driver, 0444, show_current_driver, NULL);
+static DEVICE_ATTR(current_governor, 0644, show_current_governor,
+				   store_current_governor);
 static DEVICE_ATTR(current_governor_ro, 0444, show_current_governor, NULL);
 
 static struct attribute *cpuidle_default_attrs[] = {
+	&dev_attr_available_governors.attr,
 	&dev_attr_current_driver.attr,
+	&dev_attr_current_governor.attr,
 	&dev_attr_current_governor_ro.attr,
 	NULL
 };
 
-static DEVICE_ATTR(available_governors, 0444, show_available_governors, NULL);
-static DEVICE_ATTR(current_governor, 0644, show_current_governor,
-		   store_current_governor);
-
 static struct attribute *cpuidle_switch_attrs[] = {
 	&dev_attr_available_governors.attr,
 	&dev_attr_current_driver.attr,
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [RFC v2 PATCH 4/6] cpuidle: sysfs: Remove sysfs_switch and switch attributes
  2020-04-30  8:39 [RFC v2 PATCH 0/6] cpuidle: Make cpuidle governor switchable to be the default behaviour Hanjun Guo
                   ` (2 preceding siblings ...)
  2020-04-30  8:39 ` [RFC v2 PATCH 3/6] cpuidle: Make cpuidle governor switchable to be the default behaviour Hanjun Guo
@ 2020-04-30  8:39 ` Hanjun Guo
  2020-05-18 20:19   ` Daniel Lezcano
  2020-04-30  8:39 ` [RFC v2 PATCH 5/6] Documentation: cpuidle: update the document Hanjun Guo
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Hanjun Guo @ 2020-04-30  8:39 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano, Doug Smythies
  Cc: linux-pm, Jonathan Corbet, Hanjun Guo

Since the cpuidle governor can be switched via sysfs in default,
remove sysfs_switch and cpuidle_switch_attrs.

Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
---
 drivers/cpuidle/sysfs.c | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index 2425c6a..c3bbfc7 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -18,14 +18,6 @@
 
 #include "cpuidle.h"
 
-static unsigned int sysfs_switch;
-static int __init cpuidle_sysfs_setup(char *unused)
-{
-	sysfs_switch = 1;
-	return 1;
-}
-__setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup);
-
 static ssize_t show_available_governors(struct device *dev,
 					struct device_attribute *attr,
 					char *buf)
@@ -112,7 +104,7 @@ static DEVICE_ATTR(current_governor, 0644, show_current_governor,
 				   store_current_governor);
 static DEVICE_ATTR(current_governor_ro, 0444, show_current_governor, NULL);
 
-static struct attribute *cpuidle_default_attrs[] = {
+static struct attribute *cpuidle_attrs[] = {
 	&dev_attr_available_governors.attr,
 	&dev_attr_current_driver.attr,
 	&dev_attr_current_governor.attr,
@@ -120,15 +112,8 @@ static DEVICE_ATTR(current_governor, 0644, show_current_governor,
 	NULL
 };
 
-static struct attribute *cpuidle_switch_attrs[] = {
-	&dev_attr_available_governors.attr,
-	&dev_attr_current_driver.attr,
-	&dev_attr_current_governor.attr,
-	NULL
-};
-
 static struct attribute_group cpuidle_attr_group = {
-	.attrs = cpuidle_default_attrs,
+	.attrs = cpuidle_attrs,
 	.name = "cpuidle",
 };
 
@@ -138,9 +123,6 @@ static DEVICE_ATTR(current_governor, 0644, show_current_governor,
  */
 int cpuidle_add_interface(struct device *dev)
 {
-	if (sysfs_switch)
-		cpuidle_attr_group.attrs = cpuidle_switch_attrs;
-
 	return sysfs_create_group(&dev->kobj, &cpuidle_attr_group);
 }
 
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [RFC v2 PATCH 5/6] Documentation: cpuidle: update the document
  2020-04-30  8:39 [RFC v2 PATCH 0/6] cpuidle: Make cpuidle governor switchable to be the default behaviour Hanjun Guo
                   ` (3 preceding siblings ...)
  2020-04-30  8:39 ` [RFC v2 PATCH 4/6] cpuidle: sysfs: Remove sysfs_switch and switch attributes Hanjun Guo
@ 2020-04-30  8:39 ` Hanjun Guo
  2020-04-30  8:39 ` [RFC v2 PATCH 6/6] Documentation: ABI: make current_governer_ro as a candidate for removal Hanjun Guo
  2020-05-12 21:17 ` [RFC v2 PATCH 0/6] cpuidle: Make cpuidle governor switchable to be the default behaviour Doug Smythies
  6 siblings, 0 replies; 14+ messages in thread
From: Hanjun Guo @ 2020-04-30  8:39 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano, Doug Smythies
  Cc: linux-pm, Jonathan Corbet, Hanjun Guo

Update the document after the remove of cpuidle_sysfs_switch.

Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
---
 Documentation/ABI/testing/sysfs-devices-system-cpu | 24 ++++++++--------------
 Documentation/admin-guide/pm/cpuidle.rst           | 20 ++++++++----------
 Documentation/driver-api/pm/cpuidle.rst            |  5 ++---
 3 files changed, 20 insertions(+), 29 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu
index 2e0e3b4..6b5dafa 100644
--- a/Documentation/ABI/testing/sysfs-devices-system-cpu
+++ b/Documentation/ABI/testing/sysfs-devices-system-cpu
@@ -106,10 +106,10 @@ Description:	CPU topology files that describe a logical CPU's relationship
 		See Documentation/admin-guide/cputopology.rst for more information.
 
 
-What:		/sys/devices/system/cpu/cpuidle/current_driver
-		/sys/devices/system/cpu/cpuidle/current_governer_ro
-		/sys/devices/system/cpu/cpuidle/available_governors
+What:		/sys/devices/system/cpu/cpuidle/available_governors
+		/sys/devices/system/cpu/cpuidle/current_driver
 		/sys/devices/system/cpu/cpuidle/current_governor
+		/sys/devices/system/cpu/cpuidle/current_governer_ro
 Date:		September 2007
 Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
 Description:	Discover cpuidle policy and mechanism
@@ -119,24 +119,18 @@ Description:	Discover cpuidle policy and mechanism
 		consumption during idle.
 
 		Idle policy (governor) is differentiated from idle mechanism
-		(driver)
-
-		current_driver: (RO) displays current idle mechanism
-
-		current_governor_ro: (RO) displays current idle policy
-
-		With the cpuidle_sysfs_switch boot option enabled (meant for
-		developer testing), the following three attributes are visible
-		instead:
-
-		current_driver: same as described above
+		(driver).
 
 		available_governors: (RO) displays a space separated list of
-		available governors
+		available governors.
+
+		current_driver: (RO) displays current idle mechanism.
 
 		current_governor: (RW) displays current idle policy. Users can
 		switch the governor at runtime by writing to this file.
 
+		current_governor_ro: (RO) displays current idle policy.
+
 		See Documentation/admin-guide/pm/cpuidle.rst and
 		Documentation/driver-api/pm/cpuidle.rst for more information.
 
diff --git a/Documentation/admin-guide/pm/cpuidle.rst b/Documentation/admin-guide/pm/cpuidle.rst
index 5605cc6..a96a423 100644
--- a/Documentation/admin-guide/pm/cpuidle.rst
+++ b/Documentation/admin-guide/pm/cpuidle.rst
@@ -159,17 +159,15 @@ governor uses that information depends on what algorithm is implemented by it
 and that is the primary reason for having more than one governor in the
 ``CPUIdle`` subsystem.
 
-There are three ``CPUIdle`` governors available, ``menu``, `TEO <teo-gov_>`_
-and ``ladder``.  Which of them is used by default depends on the configuration
-of the kernel and in particular on whether or not the scheduler tick can be
-`stopped by the idle loop <idle-cpus-and-tick_>`_.  It is possible to change the
-governor at run time if the ``cpuidle_sysfs_switch`` command line parameter has
-been passed to the kernel, but that is not safe in general, so it should not be
-done on production systems (that may change in the future, though).  The name of
-the ``CPUIdle`` governor currently used by the kernel can be read from the
-:file:`current_governor_ro` (or :file:`current_governor` if
-``cpuidle_sysfs_switch`` is present in the kernel command line) file under
-:file:`/sys/devices/system/cpu/cpuidle/` in ``sysfs``.
+There are four ``CPUIdle`` governors available, ``menu``, `TEO <teo-gov_>`_,
+``ladder`` and ``haltpoll``.  Which of them is used by default depends on the
+configuration of the kernel and in particular on whether or not the scheduler
+tick can be `stopped by the idle loop <idle-cpus-and-tick_>`_.  Available
+governors can be read from the :file:`available_governors`, and the governor
+can be changed at runtime.  The name of the ``CPUIdle`` governor currently
+used by the kernel can be read from the :file:`current_governor_ro` or
+:file:`current_governor` file under :file:`/sys/devices/system/cpu/cpuidle/`
+in ``sysfs``.
 
 Which ``CPUIdle`` driver is used, on the other hand, usually depends on the
 platform the kernel is running on, but there are platforms with more than one
diff --git a/Documentation/driver-api/pm/cpuidle.rst b/Documentation/driver-api/pm/cpuidle.rst
index 006cf6d..3588bf0 100644
--- a/Documentation/driver-api/pm/cpuidle.rst
+++ b/Documentation/driver-api/pm/cpuidle.rst
@@ -68,9 +68,8 @@ only one in the list (that is, the list was empty before) or the value of its
 governor currently in use, or the name of the new governor was passed to the
 kernel as the value of the ``cpuidle.governor=`` command line parameter, the new
 governor will be used from that point on (there can be only one ``CPUIdle``
-governor in use at a time).  Also, if ``cpuidle_sysfs_switch`` is passed to the
-kernel in the command line, user space can choose the ``CPUIdle`` governor to
-use at run time via ``sysfs``.
+governor in use at a time).  Also, user space can choose the ``CPUIdle``
+governor to use at run time via ``sysfs``.
 
 Once registered, ``CPUIdle`` governors cannot be unregistered, so it is not
 practical to put them into loadable kernel modules.
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [RFC v2 PATCH 6/6] Documentation: ABI: make current_governer_ro as a candidate for removal
  2020-04-30  8:39 [RFC v2 PATCH 0/6] cpuidle: Make cpuidle governor switchable to be the default behaviour Hanjun Guo
                   ` (4 preceding siblings ...)
  2020-04-30  8:39 ` [RFC v2 PATCH 5/6] Documentation: cpuidle: update the document Hanjun Guo
@ 2020-04-30  8:39 ` Hanjun Guo
  2020-05-18 14:27   ` Daniel Lezcano
  2020-05-19  2:04   ` Hanjun Guo
  2020-05-12 21:17 ` [RFC v2 PATCH 0/6] cpuidle: Make cpuidle governor switchable to be the default behaviour Doug Smythies
  6 siblings, 2 replies; 14+ messages in thread
From: Hanjun Guo @ 2020-04-30  8:39 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano, Doug Smythies
  Cc: linux-pm, Jonathan Corbet, Hanjun Guo

Since both current_governor and current_governor_ro co-exist under
/sys/devices/te system/cpu/cpuidle/ file, and it's duplicate,
make current_governer_ro as a candidate for removal.

Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
---
 Documentation/ABI/obsolete/sysfs-cpuidle | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 Documentation/ABI/obsolete/sysfs-cpuidle

diff --git a/Documentation/ABI/obsolete/sysfs-cpuidle b/Documentation/ABI/obsolete/sysfs-cpuidle
new file mode 100644
index 00000000..f984b9c
--- /dev/null
+++ b/Documentation/ABI/obsolete/sysfs-cpuidle
@@ -0,0 +1,9 @@
+What:		/sys/devices/system/cpu/cpuidle/current_governor_ro
+Date:		April, 2020
+Contact:	linux-pm@vger.kernel.org
+Description:
+	current_governor_ro shows current using cpuidle governor, but read only.
+	with the update that cpuidle governor can be changed at runtime in default,
+	both current_governor and current_governor_ro co-exist under
+	/sys/devices/te system/cpu/cpuidle/ file, it's duplicate so make
+	current_governor_ro obselete.
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* RE: [RFC v2 PATCH 0/6] cpuidle: Make cpuidle governor switchable to be the default behaviour
  2020-04-30  8:39 [RFC v2 PATCH 0/6] cpuidle: Make cpuidle governor switchable to be the default behaviour Hanjun Guo
                   ` (5 preceding siblings ...)
  2020-04-30  8:39 ` [RFC v2 PATCH 6/6] Documentation: ABI: make current_governer_ro as a candidate for removal Hanjun Guo
@ 2020-05-12 21:17 ` Doug Smythies
  6 siblings, 0 replies; 14+ messages in thread
From: Doug Smythies @ 2020-05-12 21:17 UTC (permalink / raw)
  To: 'Hanjun Guo'
  Cc: linux-pm, 'Jonathan Corbet', 'Rafael J. Wysocki',
	'Daniel Lezcano'

On 2020.04.30 01:40 Hanjun Guo wrote:

> For now cpuidle governor can be switched via sysfs only when the
> boot option "cpuidle_sysfs_switch" is passed, but it's important
>to switch the governor to adapt to different workloads, especially
> after TEO and haltpoll governor were introduced.
>
> Make cpuidle governor switchable to be the default behaviour by removing
> the sysfs_switch and switch attributes, also update the document as well.
>
> v1->v2:
> - Add two bugfix patch which can be triggered if the governor name is 15
>   characters, it is not a 'real' bug for now as we don't have such usecases
>   so we can merge them together via this patchset.
> - Remove the sysfs_switch, not introduce a CONFIG option to make cpuidle
>   governor switchable in default, suggested by Daniel.
> - Update the document after cpuidle_sysfs_switch is removed, suggested by
>   Doug Smythies.
>
> Hanjun Guo (6):
>  cpuidle: sysfs: Fix the overlap for showing available governors
>  cpuidle: sysfs: Accept governor name with 15 characters
>  cpuidle: Make cpuidle governor switchable to be the default behaviour
>  cpuidle: sysfs: Remove sysfs_switch and switch attributes
>  Documentation: cpuidle: update the document
>  Documentation: ABI: make current_governer_ro as a candidate for
>    removal
>
> Documentation/ABI/obsolete/sysfs-cpuidle           |  9 ++++
> Documentation/ABI/testing/sysfs-devices-system-cpu | 24 ++++------
> Documentation/admin-guide/pm/cpuidle.rst           | 20 ++++----
> Documentation/driver-api/pm/cpuidle.rst            |  5 +-
> drivers/cpuidle/sysfs.c                            | 56 ++++++----------------
> 5 files changed, 44 insertions(+), 70 deletions(-)
> create mode 100644 Documentation/ABI/obsolete/sysfs-cpuidle

Thanks,

Reviewed and tested by Doug Smythies <dsmythies@telus.net>
  


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC v2 PATCH 1/6] cpuidle: sysfs: Fix the overlap for showing available governors
  2020-04-30  8:39 ` [RFC v2 PATCH 1/6] cpuidle: sysfs: Fix the overlap for showing available governors Hanjun Guo
@ 2020-05-18 14:20   ` Daniel Lezcano
  2020-05-19  1:59     ` Hanjun Guo
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Lezcano @ 2020-05-18 14:20 UTC (permalink / raw)
  To: Hanjun Guo, Rafael J. Wysocki, Doug Smythies; +Cc: linux-pm, Jonathan Corbet

On 30/04/2020 10:39, Hanjun Guo wrote:
> When showing the available governors, it's "%s " in scnprintf(),
> not "%s", so if the governor name has 15 characters, it will
> overlap with the later one, fix it by adding one more for the
> size.
> 
> While we are at it, fix the minor coding sytle as well.
> 
> Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
> ---
>  drivers/cpuidle/sysfs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
> index d3ef1d7..3485210 100644
> --- a/drivers/cpuidle/sysfs.c
> +++ b/drivers/cpuidle/sysfs.c
> @@ -35,10 +35,10 @@ static ssize_t show_available_governors(struct device *dev,
>  
>  	mutex_lock(&cpuidle_lock);
>  	list_for_each_entry(tmp, &cpuidle_governors, governor_list) {
> -		if (i >= (ssize_t) ((PAGE_SIZE/sizeof(char)) -
> +		if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char)) -

Is is possible to have a sizeof(char) != 1 ?

>  				    CPUIDLE_NAME_LEN - 2))
>  			goto out;
> -		i += scnprintf(&buf[i], CPUIDLE_NAME_LEN, "%s ", tmp->name);
> +		i += scnprintf(&buf[i], CPUIDLE_NAME_LEN + 1, "%s ", tmp->name);
>  	}
>  
>  out:
> 


-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC v2 PATCH 3/6] cpuidle: Make cpuidle governor switchable to be the default behaviour
  2020-04-30  8:39 ` [RFC v2 PATCH 3/6] cpuidle: Make cpuidle governor switchable to be the default behaviour Hanjun Guo
@ 2020-05-18 14:24   ` Daniel Lezcano
  0 siblings, 0 replies; 14+ messages in thread
From: Daniel Lezcano @ 2020-05-18 14:24 UTC (permalink / raw)
  To: Hanjun Guo, Rafael J. Wysocki, Doug Smythies; +Cc: linux-pm, Jonathan Corbet

On 30/04/2020 10:39, Hanjun Guo wrote:
> For now cpuidle governor can be switched via sysfs only when the
> boot option "cpuidle_sysfs_switch" is passed, but it's important
> to switch the governor to adapt to different workloads, especially
> after TEO and haltpoll governor were introduced.
> 
> Add available_governors and current_governor into the default
> attributes, but reserve the current_governor_ro for temporal
> compatibility.
> 
> Signed-off-by: Hanjun Guo <guohanjun@huawei.com>

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>


-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC v2 PATCH 6/6] Documentation: ABI: make current_governer_ro as a candidate for removal
  2020-04-30  8:39 ` [RFC v2 PATCH 6/6] Documentation: ABI: make current_governer_ro as a candidate for removal Hanjun Guo
@ 2020-05-18 14:27   ` Daniel Lezcano
  2020-05-19  2:04   ` Hanjun Guo
  1 sibling, 0 replies; 14+ messages in thread
From: Daniel Lezcano @ 2020-05-18 14:27 UTC (permalink / raw)
  To: Hanjun Guo, Rafael J. Wysocki, Doug Smythies; +Cc: linux-pm, Jonathan Corbet

On 30/04/2020 10:39, Hanjun Guo wrote:
> Since both current_governor and current_governor_ro co-exist under
> /sys/devices/te system/cpu/cpuidle/ file, and it's duplicate,
> make current_governer_ro as a candidate for removal.
> 
> Signed-off-by: Hanjun Guo <guohanjun@huawei.com>

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>

> ---
>  Documentation/ABI/obsolete/sysfs-cpuidle | 9 +++++++++
>  1 file changed, 9 insertions(+)
>  create mode 100644 Documentation/ABI/obsolete/sysfs-cpuidle
> 
> diff --git a/Documentation/ABI/obsolete/sysfs-cpuidle b/Documentation/ABI/obsolete/sysfs-cpuidle
> new file mode 100644
> index 00000000..f984b9c
> --- /dev/null
> +++ b/Documentation/ABI/obsolete/sysfs-cpuidle
> @@ -0,0 +1,9 @@
> +What:		/sys/devices/system/cpu/cpuidle/current_governor_ro
> +Date:		April, 2020
> +Contact:	linux-pm@vger.kernel.org
> +Description:
> +	current_governor_ro shows current using cpuidle governor, but read only.
> +	with the update that cpuidle governor can be changed at runtime in default,
> +	both current_governor and current_governor_ro co-exist under
> +	/sys/devices/te system/cpu/cpuidle/ file, it's duplicate so make
> +	current_governor_ro obselete.
> 


-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC v2 PATCH 4/6] cpuidle: sysfs: Remove sysfs_switch and switch attributes
  2020-04-30  8:39 ` [RFC v2 PATCH 4/6] cpuidle: sysfs: Remove sysfs_switch and switch attributes Hanjun Guo
@ 2020-05-18 20:19   ` Daniel Lezcano
  0 siblings, 0 replies; 14+ messages in thread
From: Daniel Lezcano @ 2020-05-18 20:19 UTC (permalink / raw)
  To: Hanjun Guo, Rafael J. Wysocki, Doug Smythies; +Cc: linux-pm, Jonathan Corbet

On 30/04/2020 10:39, Hanjun Guo wrote:
> Since the cpuidle governor can be switched via sysfs in default,
> remove sysfs_switch and cpuidle_switch_attrs.
> 
> Signed-off-by: Hanjun Guo <guohanjun@huawei.com>

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>


-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC v2 PATCH 1/6] cpuidle: sysfs: Fix the overlap for showing available governors
  2020-05-18 14:20   ` Daniel Lezcano
@ 2020-05-19  1:59     ` Hanjun Guo
  0 siblings, 0 replies; 14+ messages in thread
From: Hanjun Guo @ 2020-05-19  1:59 UTC (permalink / raw)
  To: Daniel Lezcano, Rafael J. Wysocki, Doug Smythies
  Cc: linux-pm, Jonathan Corbet

On 2020/5/18 22:20, Daniel Lezcano wrote:
> On 30/04/2020 10:39, Hanjun Guo wrote:
>> When showing the available governors, it's "%s " in scnprintf(),
>> not "%s", so if the governor name has 15 characters, it will
>> overlap with the later one, fix it by adding one more for the
>> size.
>>
>> While we are at it, fix the minor coding sytle as well.

I got a typo here, s/sytle/style...

>>
>> Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
>> ---
>>   drivers/cpuidle/sysfs.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
>> index d3ef1d7..3485210 100644
>> --- a/drivers/cpuidle/sysfs.c
>> +++ b/drivers/cpuidle/sysfs.c
>> @@ -35,10 +35,10 @@ static ssize_t show_available_governors(struct device *dev,
>>   
>>   	mutex_lock(&cpuidle_lock);
>>   	list_for_each_entry(tmp, &cpuidle_governors, governor_list) {
>> -		if (i >= (ssize_t) ((PAGE_SIZE/sizeof(char)) -
>> +		if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char)) -
> 
> Is is possible to have a sizeof(char) != 1 ?

Not from my knowledge, I even didn't notice it, I'd happy to
update this patch set to remove the sizeof(char), and adding
ack and review/test tags from you and Doug.

Thanks
Hanjun


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC v2 PATCH 6/6] Documentation: ABI: make current_governer_ro as a candidate for removal
  2020-04-30  8:39 ` [RFC v2 PATCH 6/6] Documentation: ABI: make current_governer_ro as a candidate for removal Hanjun Guo
  2020-05-18 14:27   ` Daniel Lezcano
@ 2020-05-19  2:04   ` Hanjun Guo
  1 sibling, 0 replies; 14+ messages in thread
From: Hanjun Guo @ 2020-05-19  2:04 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano, Doug Smythies
  Cc: linux-pm, Jonathan Corbet

On 2020/4/30 16:39, Hanjun Guo wrote:
> Since both current_governor and current_governor_ro co-exist under
> /sys/devices/te system/cpu/cpuidle/  file, and it's duplicate,
> make current_governer_ro as a candidate for removal.
> 
> Signed-off-by: Hanjun Guo<guohanjun@huawei.com>
> ---
>   Documentation/ABI/obsolete/sysfs-cpuidle | 9 +++++++++
>   1 file changed, 9 insertions(+)
>   create mode 100644 Documentation/ABI/obsolete/sysfs-cpuidle
> 
> diff --git a/Documentation/ABI/obsolete/sysfs-cpuidle b/Documentation/ABI/obsolete/sysfs-cpuidle
> new file mode 100644
> index 00000000..f984b9c
> --- /dev/null
> +++ b/Documentation/ABI/obsolete/sysfs-cpuidle
> @@ -0,0 +1,9 @@
> +What:		/sys/devices/system/cpu/cpuidle/current_governor_ro
> +Date:		April, 2020
> +Contact:	linux-pm@vger.kernel.org
> +Description:
> +	current_governor_ro shows current using cpuidle governor, but read only.
> +	with the update that cpuidle governor can be changed at runtime in default,
> +	both current_governor and current_governor_ro co-exist under
> +	/sys/devices/te system/cpu/cpuidle/  file, it's duplicate so make

Another typo here, s/te system/system, I will update it, since
it minor, I think Doug's reivew and Daniel's ack are still
valid.

Thanks
Hanjun


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-05-19  2:04 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-30  8:39 [RFC v2 PATCH 0/6] cpuidle: Make cpuidle governor switchable to be the default behaviour Hanjun Guo
2020-04-30  8:39 ` [RFC v2 PATCH 1/6] cpuidle: sysfs: Fix the overlap for showing available governors Hanjun Guo
2020-05-18 14:20   ` Daniel Lezcano
2020-05-19  1:59     ` Hanjun Guo
2020-04-30  8:39 ` [RFC v2 PATCH 2/6] cpuidle: sysfs: Accept governor name with 15 characters Hanjun Guo
2020-04-30  8:39 ` [RFC v2 PATCH 3/6] cpuidle: Make cpuidle governor switchable to be the default behaviour Hanjun Guo
2020-05-18 14:24   ` Daniel Lezcano
2020-04-30  8:39 ` [RFC v2 PATCH 4/6] cpuidle: sysfs: Remove sysfs_switch and switch attributes Hanjun Guo
2020-05-18 20:19   ` Daniel Lezcano
2020-04-30  8:39 ` [RFC v2 PATCH 5/6] Documentation: cpuidle: update the document Hanjun Guo
2020-04-30  8:39 ` [RFC v2 PATCH 6/6] Documentation: ABI: make current_governer_ro as a candidate for removal Hanjun Guo
2020-05-18 14:27   ` Daniel Lezcano
2020-05-19  2:04   ` Hanjun Guo
2020-05-12 21:17 ` [RFC v2 PATCH 0/6] cpuidle: Make cpuidle governor switchable to be the default behaviour Doug Smythies

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.