Skip to contentSkip to conversation

cpuidle: governors: Remove remaining old module code

PATCH In review Daniel Lezcano 2 participants 6 messages Oct 5, 2016 – Oct 21, 2016 CPU idle time management framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 cpuidle: governors: Remove remaining old module code

The governor's code use try_module_get() and put_module() to refcount the governor's module. But the governors are not compiled as module.

The refcount does not prevent to switch the governor or unload a module as they aren't compiled as modules. So the code is pointless, removing it.

---
 drivers/cpuidle/governor.c         | 4 ----
 drivers/cpuidle/governors/ladder.c | 2 --
 drivers/cpuidle/governors/menu.c   | 2 --
 include/linux/cpuidle.h            | 2 --
 4 files changed, 10 deletions(-)
drivers/cpuidle/governor.c +0 -4
index fb9f511..4e78263 100644
@@ -9,7 +9,6 @@
  */
 
 #include <linux/mutex.h>
-#include <linux/module.h>
 #include <linux/cpuidle.h>
 
 #include "cpuidle.h"
@@ -53,14 +52,11 @@ int cpuidle_switch_governor(struct cpuidle_governor *gov)
 	if (cpuidle_curr_governor) {
 		list_for_each_entry(dev, &cpuidle_detected_devices, device_list)
 			cpuidle_disable_device(dev);
-		module_put(cpuidle_curr_governor->owner);
 	}
 
 	cpuidle_curr_governor = gov;
 
 	if (gov) {
-		if (!try_module_get(cpuidle_curr_governor->owner))
-			return -EINVAL;
 		list_for_each_entry(dev, &cpuidle_detected_devices, device_list)
 			cpuidle_enable_device(dev);
 		cpuidle_install_idle_handler();
drivers/cpuidle/governors/ladder.c +0 -2
index 63bd5a4..fe8f089 100644
@@ -15,7 +15,6 @@
 #include <linux/kernel.h>
 #include <linux/cpuidle.h>
 #include <linux/pm_qos.h>
-#include <linux/module.h>
 #include <linux/jiffies.h>
 #include <linux/tick.h>
 
@@ -177,7 +176,6 @@ static struct cpuidle_governor ladder_governor = {
 	.enable =	ladder_enable_device,
 	.select =	ladder_select_state,
 	.reflect =	ladder_reflect,
-	.owner =	THIS_MODULE,
 };
 
 /**
drivers/cpuidle/governors/menu.c +0 -2
index 03d38c2..d9b5b93 100644
@@ -19,7 +19,6 @@
 #include <linux/tick.h>
 #include <linux/sched.h>
 #include <linux/math64.h>
-#include <linux/module.h>
 
 /*
  * Please note when changing the tuning values:
@@ -484,7 +483,6 @@ static struct cpuidle_governor menu_governor = {
 	.enable =	menu_enable_device,
 	.select =	menu_select,
 	.reflect =	menu_reflect,
-	.owner =	THIS_MODULE,
 };
 
 /**
include/linux/cpuidle.h +0 -2
index bb31373..15deea4 100644
@@ -235,8 +235,6 @@ struct cpuidle_governor {
 	int  (*select)		(struct cpuidle_driver *drv,
 					struct cpuidle_device *dev);
 	void (*reflect)		(struct cpuidle_device *dev, int index);
-
-	struct module 		*owner;
 };
 
 #ifdef CONFIG_CPU_IDLE
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/2 cpuidle: governors: Move the files to the upper directory

Currently the different governors are stored in the subdir 'governors'. That is not a problem.

However, that forces to declare some private structure in the include/linux/cpuidle.h header because these governor files don't have access to the private 'cpuidle.h' located in drivers/cpuidle.

Instead of having the governors in the separate directory, move them along with the drivers and prefix them with 'governor-', that allows to do a proper cleanup in the cpuidle headers.

---
 drivers/cpuidle/Makefile           |   7 +-
 drivers/cpuidle/governor-ladder.c  | 197 +++++++++++++++
 drivers/cpuidle/governor-menu.c    | 496 +++++++++++++++++++++++++++++++++++++
 drivers/cpuidle/governors/Makefile |   6 -
 drivers/cpuidle/governors/ladder.c | 197 ---------------
 drivers/cpuidle/governors/menu.c   | 496 -------------------------------------
 6 files changed, 699 insertions(+), 700 deletions(-)
 create mode 100644 drivers/cpuidle/governor-ladder.c
 create mode 100644 drivers/cpuidle/governor-menu.c
 delete mode 100644 drivers/cpuidle/governors/Makefile
 delete mode 100644 drivers/cpuidle/governors/ladder.c
 delete mode 100644 drivers/cpuidle/governors/menu.c
drivers/cpuidle/Makefile +6 -1
index 3ba81b1..b21ada9 100644
@@ -2,7 +2,7 @@
 # Makefile for cpuidle.
 #
 
-obj-y += cpuidle.o driver.o governor.o sysfs.o governors/
+obj-y += cpuidle.o driver.o governor.o sysfs.o
 obj-$(CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED) += coupled.o
 obj-$(CONFIG_DT_IDLE_STATES)		  += dt_idle_states.o
 
@@ -27,3 +27,8 @@ obj-$(CONFIG_MIPS_CPS_CPUIDLE)		+= cpuidle-cps.o
 # POWERPC drivers
 obj-$(CONFIG_PSERIES_CPUIDLE)		+= cpuidle-pseries.o
 obj-$(CONFIG_POWERNV_CPUIDLE)		+= cpuidle-powernv.o
+
+###############################################################################
+# Governors
+obj-$(CONFIG_CPU_IDLE_GOV_LADDER) += governor-ladder.o
+obj-$(CONFIG_CPU_IDLE_GOV_MENU) += governor-menu.o
drivers/cpuidle/governor-ladder.c new file +197 -0

197 lines not on this page · raw message

drivers/cpuidle/governor-menu.c new file +496 -0

496 lines not on this page · raw message

drivers/cpuidle/governors/Makefile deleted +0 -6
deleted file mode 100644
index 1b51272..0000000
@@ -1,6 +0,0 @@
-#
-# Makefile for cpuidle governors.
-#
-
-obj-$(CONFIG_CPU_IDLE_GOV_LADDER) += ladder.o
-obj-$(CONFIG_CPU_IDLE_GOV_MENU) += menu.o
drivers/cpuidle/governors/ladder.c deleted +0 -197

197 lines not on this page · raw message

drivers/cpuidle/governors/menu.c deleted +0 -496

496 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH 2/2] cpuidle: governors: Move the files to the upper directory

Quoted 11 lines · Daniel Lezcano

Currently the different governors are stored in the subdir 'governors'. That is not a problem.

However, that forces to declare some private structure in the include/linux/cpuidle.h header because these governor files don't have access to the private 'cpuidle.h' located in drivers/cpuidle.

Instead of having the governors in the separate directory, move them along with the drivers and prefix them with 'governor-', that allows to do a proper cleanup in the cpuidle headers.

While I'm not particularly against this change, I'm sort of wondering about the reason.

What in particular would be wrong with doing

#include "../cpuidle.h"

in a governor .c file?

Thanks,
Rafael

#3 lore raw

Re: [PATCH 2/2] cpuidle: governors: Move the files to the upper directory

Quoted 14 lines · Rafael J. Wysocki
Quoted 11 lines · Daniel Lezcano

Currently the different governors are stored in the subdir 'governors'. That is not a problem.

However, that forces to declare some private structure in the include/linux/cpuidle.h header because these governor files don't have access to the private 'cpuidle.h' located in drivers/cpuidle.

Instead of having the governors in the separate directory, move them along with the drivers and prefix them with 'governor-', that allows to do a proper cleanup in the cpuidle headers.

Quoted 8 lines

While I'm not particularly against this change, I'm sort of wondering about the reason.

What in particular would be wrong with doing

#include "../cpuidle.h"

in a governor .c file?

Hi Rafael,

there is nothing wrong by doing this relative inclusion. It is an alternative to the proposed patch. I personally don't like relative inclusion but it is a matter of taste and I am perfectly fine to resend the patch by just moving the structure to the private header and change the inclusion.

On the other side, the cpufreq susbsytem has all the governors along with the drivers in the same directory, so perhaps it makes sense to have a similar files organization.

Actually, I'm fine with both approaches. Up to you to decide.

-- Daniel

#4 lore raw

Re: [PATCH 2/2] cpuidle: governors: Move the files to the upper directory

Quoted 31 lines · Daniel Lezcano
Quoted 14 lines · Rafael J. Wysocki
Quoted 11 lines · Daniel Lezcano

Currently the different governors are stored in the subdir 'governors'. That is not a problem.

However, that forces to declare some private structure in the include/linux/cpuidle.h header because these governor files don't have access to the private 'cpuidle.h' located in drivers/cpuidle.

Instead of having the governors in the separate directory, move them along with the drivers and prefix them with 'governor-', that allows to do a proper cleanup in the cpuidle headers.

Quoted 8 lines

While I'm not particularly against this change, I'm sort of wondering about the reason.

What in particular would be wrong with doing

#include "../cpuidle.h"

in a governor .c file?

Hi Rafael,

there is nothing wrong by doing this relative inclusion. It is an alternative to the proposed patch. I personally don't like relative inclusion but it is a matter of taste and I am perfectly fine to resend the patch by just moving the structure to the private header and change the inclusion.

Quoted 5 lines

On the other side, the cpufreq susbsytem has all the governors along with the drivers in the same directory, so perhaps it makes sense to have a similar files organization.

Actually, I'm fine with both approaches. Up to you to decide.

I'm thinking let's keep the code where it is in case people depend on the current location somehow (ie. have patches out of the tree or similar). We can still move it later if need be.

Thanks,
Rafael

#5 lore raw

Re: [PATCH 2/2] cpuidle: governors: Move the files to the upper directory

Quoted 37 lines · Rafael J. Wysocki
Quoted 35 lines · Daniel Lezcano
Quoted 14 lines · Rafael J. Wysocki
Quoted 11 lines · Daniel Lezcano

Currently the different governors are stored in the subdir 'governors'. That is not a problem.

However, that forces to declare some private structure in the include/linux/cpuidle.h header because these governor files don't have access to the private 'cpuidle.h' located in drivers/cpuidle.

Instead of having the governors in the separate directory, move them along with the drivers and prefix them with 'governor-', that allows to do a proper cleanup in the cpuidle headers.

Quoted 8 lines

While I'm not particularly against this change, I'm sort of wondering about the reason.

What in particular would be wrong with doing

#include "../cpuidle.h"

in a governor .c file?

Hi Rafael,

there is nothing wrong by doing this relative inclusion. It is an alternative to the proposed patch. I personally don't like relative inclusion but it is a matter of taste and I am perfectly fine to resend the patch by just moving the structure to the private header and change the inclusion.

On the other side, the cpufreq susbsytem has all the governors along with the drivers in the same directory, so perhaps it makes sense to have a similar files organization.

Quoted 5 lines
Quoted 1 line

Actually, I'm fine with both approaches. Up to you to decide.

I'm thinking let's keep the code where it is in case people depend on the current location somehow (ie. have patches out of the tree or similar). We can still move it later if need be.

Ok, I will resend the patch [2/2] by moving the structure from the exported header to the private header and add the relative inclusion path.

Thanks.

-- Daniel