Skip to contentSkip to conversation

PM_QOS api update to use handles 1/5

RFC In review 640E9920 3 participants 11 messages Nov 30, 2009 – Jan 7, 2010 Power management core

lore
Share & tools
lore

640E9920

author
#0 lore raw

RFC 1/1 PM_QOS api update to use handles 1/5

I'm using this crazy email address because I have problems getting to linux.intel.com from home, and my work at intel has changed a bit.

This is the first in a 5 part series that attempts to update PM_QOS to use handles instead of named strings in its kernel api. It seams that some folks are using pm_qos on hot paths and the overhead of the list walks and string compares is a problem.

Most of the changes came from [email protected], and I spent some time cleaning up the API.

Also, I couldn't resist myself in renaming the API's a bit give the fact that the signatures changed enough that I had to touch all the pm_qos users anyway. I changed *requirement* to *request* in keeping with the way PM_QOS really only does best effort. I've felt "requirement" is too strong a word for the way it works.

If folks would rather me do the function re-naming in a separate patch set we can do that too.

diffstat:

drivers/acpi/processor_idle.c          |    2 
drivers/cpuidle/governors/ladder.c     |    2 
drivers/cpuidle/governors/menu.c       |    2 
drivers/net/e1000e/netdev.c            |   13 +-
drivers/net/igbvf/netdev.c             |    5 
drivers/net/wireless/ipw2x00/ipw2100.c |   11 +
include/linux/pm_qos_params.h          |   14 +-
include/sound/pcm.h                    |    3 
kernel/pm_qos_params.c                 |  186 ++++++++++++++-------------------
net/mac80211/mlme.c                    |    2 
sound/core/pcm.c                       |    3 
sound/core/pcm_native.c                |   12 +-
12 files changed, 117 insertions(+), 138 deletions(-)
---
 include/linux/pm_qos_params.h |   14 ++--
 kernel/pm_qos_params.c        |  186 ++++++++++++++++++-----------------------
 2 files changed, 90 insertions(+), 110 deletions(-)
include/linux/pm_qos_params.h +8 -6
index d74f75e..8ba440e 100644
@@ -14,12 +14,14 @@
 #define PM_QOS_NUM_CLASSES 4
 #define PM_QOS_DEFAULT_VALUE -1
 
-int pm_qos_add_requirement(int qos, char *name, s32 value);
-int pm_qos_update_requirement(int qos, char *name, s32 new_value);
-void pm_qos_remove_requirement(int qos, char *name);
+struct pm_qos_request_list;
 
-int pm_qos_requirement(int qos);
+struct pm_qos_request_list *pm_qos_add_request(int pm_qos_class, s32 value);
+void pm_qos_update_request(struct pm_qos_request_list *pm_qos_req,
+		s32 new_value);
+void pm_qos_remove_request(struct pm_qos_request_list *pm_qos_req);
 
-int pm_qos_add_notifier(int qos, struct notifier_block *notifier);
-int pm_qos_remove_notifier(int qos, struct notifier_block *notifier);
+int pm_qos_request(int pm_qos_class);
+int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier);
+int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier);
 
kernel/pm_qos_params.c +82 -104

361 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#1 lore raw
Quoted 8 lines · On Sun 2009-11-29 17:09:53, 640E9920 wrote:

I'm using this crazy email address because I have problems getting to linux.intel.com from home, and my work at intel has changed a bit.

This is the first in a 5 part series that attempts to update PM_QOS to use handles instead of named strings in its kernel api. It seams that some folks are using pm_qos on hot paths and the overhead of the list walks and string compares is a problem.

Quoted 8 lines

Most of the changes came from [email protected], and I spent some time cleaning up the API.

Also, I couldn't resist myself in renaming the API's a bit give the fact that the signatures changed enough that I had to touch all the pm_qos users anyway. I changed *requirement* to *request* in keeping with the way PM_QOS really only does best effort. I've felt "requirement" is too strong a word for the way it works.

Looks good on quick scan. Moving away from strings is certainly good.

Quoted 9 lines
kernel/pm_qos_params.c +1 -2
@@ -384,15 +363,14 @@ static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
 		size_t count, loff_t *f_pos)
 {
 	s32 value;
-	int pm_qos_class;
+	struct pm_qos_request_list *pm_qos_req;
 
-	pm_qos_class = (long)filp->private_data;
 	if (count != sizeof(s32))

kernel/pm_qos_params.c static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, · line 376

Quoted 10 lines
kernel/pm_qos_params.c +2 -2
 		return -EINVAL;
 	if (copy_from_user(&value, buf, sizeof(s32)))
 		return -EFAULT;
-	sprintf(name, "process_%d", current->pid);
-	pm_qos_update_requirement(pm_qos_class, name, value);
+	pm_qos_req = (struct pm_qos_request_list *)filp->private_data;
+	pm_qos_update_request(pm_qos_req, value);
 
 	return  sizeof(s32);
 }

Umm.. passing binary numbers like that... is not exactly good interface. Think endianness issues when writing to it from high-level language.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#2 lore raw
In reply to 640E9920
Quoted 8 lines · On Sun 2009-11-29 17:09:53, 640E9920 wrote:

I'm using this crazy email address because I have problems getting to linux.intel.com from home, and my work at intel has changed a bit.

This is the first in a 5 part series that attempts to update PM_QOS to use handles instead of named strings in its kernel api. It seams that some folks are using pm_qos on hot paths and the overhead of the list walks and string compares is a problem.

Quoted 8 lines

Most of the changes came from [email protected], and I spent some time cleaning up the API.

Also, I couldn't resist myself in renaming the API's a bit give the fact that the signatures changed enough that I had to touch all the pm_qos users anyway. I changed *requirement* to *request* in keeping with the way PM_QOS really only does best effort. I've felt "requirement" is too strong a word for the way it works.

Looks good on quick scan. Moving away from strings is certainly good.

Quoted 9 lines
kernel/pm_qos_params.c +1 -2
@@ -384,15 +363,14 @@ static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
 		size_t count, loff_t *f_pos)
 {
 	s32 value;
-	int pm_qos_class;
+	struct pm_qos_request_list *pm_qos_req;
 
-	pm_qos_class = (long)filp->private_data;
 	if (count != sizeof(s32))

kernel/pm_qos_params.c static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, · line 376

Quoted 10 lines
kernel/pm_qos_params.c +2 -2
 		return -EINVAL;
 	if (copy_from_user(&value, buf, sizeof(s32)))
 		return -EFAULT;
-	sprintf(name, "process_%d", current->pid);
-	pm_qos_update_requirement(pm_qos_class, name, value);
+	pm_qos_req = (struct pm_qos_request_list *)filp->private_data;
+	pm_qos_update_request(pm_qos_req, value);
 
 	return  sizeof(s32);
 }

Umm.. passing binary numbers like that... is not exactly good interface. Think endianness issues when writing to it from high-level language.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#3 lore raw
Quoted 12 lines · Pavel Machek
Quoted 11 lines · On Sun 2009-11-29 17:09:53, 640E9920 wrote:

I'm using this crazy email address because I have problems getting to linux.intel.com from home, and my work at intel has changed a bit.

This is the first in a 5 part series that attempts to update PM_QOS to use handles instead of named strings in its kernel api. It seams that some folks are using pm_qos on hot paths and the overhead of the list walks and string compares is a problem.

Most of the changes came from [email protected], and I spent some time cleaning up the API.

Quoted 7 lines
Quoted 5 lines

Also, I couldn't resist myself in renaming the API's a bit give the fact that the signatures changed enough that I had to touch all the pm_qos users anyway. I changed *requirement* to *request* in keeping with the way PM_QOS really only does best effort. I've felt "requirement" is too strong a word for the way it works.

Looks good on quick scan. Moving away from strings is certainly good.

thanks I'll target to get this into linux-next for 2.6.34.

Quoted 18 lines
Quoted 18 lines
kernel/pm_qos_params.c +3 -4
@@ -384,15 +363,14 @@ static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
 		size_t count, loff_t *f_pos)
 {
 	s32 value;
-	int pm_qos_class;
+	struct pm_qos_request_list *pm_qos_req;
 
-	pm_qos_class = (long)filp->private_data;
 	if (count != sizeof(s32))
 		return -EINVAL;
 	if (copy_from_user(&value, buf, sizeof(s32)))
 		return -EFAULT;
-	sprintf(name, "process_%d", current->pid);
-	pm_qos_update_requirement(pm_qos_class, name, value);
+	pm_qos_req = (struct pm_qos_request_list *)filp->private_data;
+	pm_qos_update_request(pm_qos_req, value);
 
Quoted 7 lines

kernel/pm_qos_params.c static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, · line 376

Quoted 2 lines
kernel/pm_qos_params.c +0 -0
 	return  sizeof(s32);
 }

Umm.. passing binary numbers like that... is not exactly good interface. Think endianness issues when writing to it from high-level language.

yeah. At the moment I can't recall why I went binary for the ABI, we can revisit this, but its been in the wild for a few years now :(

I guess I can do some tricks to see if its a hex string representation of a number and parse that as well as supporting the s32. i.e. accept strings "0x0000000" ... "0xFFFFFFFF" and return -EINVAL for anything else.

--mgross

Quoted 8 lines

Pavel

Signature · 6 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#4 lore raw
In reply to Pavel Machek
Quoted 12 lines · Pavel Machek
Quoted 11 lines · On Sun 2009-11-29 17:09:53, 640E9920 wrote:

I'm using this crazy email address because I have problems getting to linux.intel.com from home, and my work at intel has changed a bit.

This is the first in a 5 part series that attempts to update PM_QOS to use handles instead of named strings in its kernel api. It seams that some folks are using pm_qos on hot paths and the overhead of the list walks and string compares is a problem.

Most of the changes came from [email protected], and I spent some time cleaning up the API.

Quoted 7 lines
Quoted 5 lines

Also, I couldn't resist myself in renaming the API's a bit give the fact that the signatures changed enough that I had to touch all the pm_qos users anyway. I changed *requirement* to *request* in keeping with the way PM_QOS really only does best effort. I've felt "requirement" is too strong a word for the way it works.

Looks good on quick scan. Moving away from strings is certainly good.

thanks I'll target to get this into linux-next for 2.6.34.

Quoted 18 lines
Quoted 18 lines
kernel/pm_qos_params.c +3 -4
@@ -384,15 +363,14 @@ static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
 		size_t count, loff_t *f_pos)
 {
 	s32 value;
-	int pm_qos_class;
+	struct pm_qos_request_list *pm_qos_req;
 
-	pm_qos_class = (long)filp->private_data;
 	if (count != sizeof(s32))
 		return -EINVAL;
 	if (copy_from_user(&value, buf, sizeof(s32)))
 		return -EFAULT;
-	sprintf(name, "process_%d", current->pid);
-	pm_qos_update_requirement(pm_qos_class, name, value);
+	pm_qos_req = (struct pm_qos_request_list *)filp->private_data;
+	pm_qos_update_request(pm_qos_req, value);
 
Quoted 7 lines

kernel/pm_qos_params.c static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, · line 376

Quoted 2 lines
kernel/pm_qos_params.c +0 -0
 	return  sizeof(s32);
 }

Umm.. passing binary numbers like that... is not exactly good interface. Think endianness issues when writing to it from high-level language.

yeah. At the moment I can't recall why I went binary for the ABI, we can revisit this, but its been in the wild for a few years now :(

I guess I can do some tricks to see if its a hex string representation of a number and parse that as well as supporting the s32. i.e. accept strings "0x0000000" ... "0xFFFFFFFF" and return -EINVAL for anything else.

--mgross

Quoted 8 lines

Pavel

Signature · 6 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#5 lore raw

Hi!

Quoted 11 lines
Quoted 3 lines

Umm.. passing binary numbers like that... is not exactly good interface. Think endianness issues when writing to it from high-level language.

yeah. At the moment I can't recall why I went binary for the ABI, we can revisit this, but its been in the wild for a few years now :(

I guess I can do some tricks to see if its a hex string representation of a number and parse that as well as supporting the s32. i.e. accept strings "0x0000000" ... "0xFFFFFFFF" and return -EINVAL for anything else.

Maybe you could use length for detection? If they are writing 4 bytes, it is s32, 10 bytes means ascii?
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#6 lore raw
In reply to mark gross

Hi!

Quoted 11 lines
Quoted 3 lines

Umm.. passing binary numbers like that... is not exactly good interface. Think endianness issues when writing to it from high-level language.

yeah. At the moment I can't recall why I went binary for the ABI, we can revisit this, but its been in the wild for a few years now :(

I guess I can do some tricks to see if its a hex string representation of a number and parse that as well as supporting the s32. i.e. accept strings "0x0000000" ... "0xFFFFFFFF" and return -EINVAL for anything else.

Maybe you could use length for detection? If they are writing 4 bytes, it is s32, 10 bytes means ascii?
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#7 lore raw
Quoted 9 lines · Pavel Machek

Hi!

Quoted 7 lines
Quoted 3 lines

Umm.. passing binary numbers like that... is not exactly good interface. Think endianness issues when writing to it from high-level language.

yeah. At the moment I can't recall why I went binary for the ABI, we can revisit this, but its been in the wild for a few years now :(

Quoted 7 lines
Quoted 4 lines

I guess I can do some tricks to see if its a hex string representation of a number and parse that as well as supporting the s32. i.e. accept strings "0x0000000" ... "0xFFFFFFFF" and return -EINVAL for anything else.

Maybe you could use length for detection? If they are writing 4 bytes, it is s32, 10 bytes means ascii?

That is what I was thinking + making sure the chars in the string where valid hex digits ;) It would be easy to do. Let me know if you think I should attempt to roll that into the kernel ABI exposed by this thing.

--mgross

#8 lore raw
In reply to Pavel Machek
Quoted 9 lines · Pavel Machek

Hi!

Quoted 7 lines
Quoted 3 lines

Umm.. passing binary numbers like that... is not exactly good interface. Think endianness issues when writing to it from high-level language.

yeah. At the moment I can't recall why I went binary for the ABI, we can revisit this, but its been in the wild for a few years now :(

Quoted 7 lines
Quoted 4 lines

I guess I can do some tricks to see if its a hex string representation of a number and parse that as well as supporting the s32. i.e. accept strings "0x0000000" ... "0xFFFFFFFF" and return -EINVAL for anything else.

Maybe you could use length for detection? If they are writing 4 bytes, it is s32, 10 bytes means ascii?

That is what I was thinking + making sure the chars in the string where valid hex digits ;) It would be easy to do. Let me know if you think I should attempt to roll that into the kernel ABI exposed by this thing.

--mgross

#9 lore raw
Quoted 15 lines · mark gross
Quoted 14 lines · Pavel Machek

Hi!

Quoted 11 lines
Quoted 3 lines

Umm.. passing binary numbers like that... is not exactly good interface. Think endianness issues when writing to it from high-level language.

yeah. At the moment I can't recall why I went binary for the ABI, we can revisit this, but its been in the wild for a few years now :(

I guess I can do some tricks to see if its a hex string representation of a number and parse that as well as supporting the s32. i.e. accept strings "0x0000000" ... "0xFFFFFFFF" and return -EINVAL for anything else.

Quoted 6 lines
Quoted 2 lines

Maybe you could use length for detection? If they are writing 4 bytes, it is s32, 10 bytes means ascii?

That is what I was thinking + making sure the chars in the string where valid hex digits ;) It would be easy to do. Let me know if you think I should attempt to roll that into the kernel ABI exposed by this thing.

I think that would be nice, yes.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#10 lore raw
In reply to mark gross
Quoted 15 lines · mark gross
Quoted 14 lines · Pavel Machek

Hi!

Quoted 11 lines
Quoted 3 lines

Umm.. passing binary numbers like that... is not exactly good interface. Think endianness issues when writing to it from high-level language.

yeah. At the moment I can't recall why I went binary for the ABI, we can revisit this, but its been in the wild for a few years now :(

I guess I can do some tricks to see if its a hex string representation of a number and parse that as well as supporting the s32. i.e. accept strings "0x0000000" ... "0xFFFFFFFF" and return -EINVAL for anything else.

Quoted 6 lines
Quoted 2 lines

Maybe you could use length for detection? If they are writing 4 bytes, it is s32, 10 bytes means ascii?

That is what I was thinking + making sure the chars in the string where valid hex digits ;) It would be easy to do. Let me know if you think I should attempt to roll that into the kernel ABI exposed by this thing.

I think that would be nice, yes.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html