Skip to contentSkip to conversation

PM backports for pm_test / CONFIG_PM_DEBUG

stable -3.14 In review Brian Norris 4 participants 11 messages Sep 4, 2014 – Sep 5, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi,

If I enable CONFIG_PM_DEBUG on a 3.14.y kernel, I can see the following results:

    # cat /sys/power/state
    freeze standby mem
    # cat /sys/power/pm_test
    [none] core processors platform devices freezer
    # echo core > /sys/power/pm_test
    # cat /sys/power/state
    [   22.581289] Unsupported pm_test mode for freeze state, please choose none/freezer/devices/platform.
    standby mem

Note how 'freeze' is dropped from the supported states, and I get an extra printk message when I'm just checking if the state is valid.

It looks like if I backport a few fixes, I get more sane behavior, where the warnings (and -EAGAIN) appear only when I actually try to enter an unsupported test mode:

    # echo core > /sys/power/pm_test
    # cat /sys/power/state
    freeze standby mem
    # echo freeze > /sys/power/state
    [   27.833141] PM: Unsupported test mode for freeze state,please choose none/freezer/devices/platform.
    sh: echo: write error: Resource temporarily unavailable

I think I've narrowed it down to this commit that should be backported to -stable (for 3.9+?):

43e8317b0bba PM / sleep: Use valid_state() for platform-dependent sleep states only

But it needs to drag along this dependency too:

    27ddcc6596e5 PM / sleep: Add state field to pm_states[] entries

While at this, it looks like this commit might be deserving of -stable (3.9+). I haven't tested this one, as I don't have a good freeze+cpuidle setup; it just shows up in the commit log with an interesting description and a 'Fixes' tag:

f3f125324fc1 PM / suspend: Make cpuidle work in the "freeze" state

Regards,
Brian

#1 lore raw
Quoted 28 lines · Brian Norris

Hi,

If I enable CONFIG_PM_DEBUG on a 3.14.y kernel, I can see the following results:

    # cat /sys/power/state
    freeze standby mem
    # cat /sys/power/pm_test
    [none] core processors platform devices freezer
    # echo core > /sys/power/pm_test
    # cat /sys/power/state
    [   22.581289] Unsupported pm_test mode for freeze state, please choose none/freezer/devices/platform.
    standby mem

Note how 'freeze' is dropped from the supported states, and I get an extra printk message when I'm just checking if the state is valid.

It looks like if I backport a few fixes, I get more sane behavior, where the warnings (and -EAGAIN) appear only when I actually try to enter an unsupported test mode:

    # echo core > /sys/power/pm_test
    # cat /sys/power/state
    freeze standby mem
    # echo freeze > /sys/power/state
    [   27.833141] PM: Unsupported test mode for freeze state,please choose none/freezer/devices/platform.
    sh: echo: write error: Resource temporarily unavailable
Quoted 8 lines

I think I've narrowed it down to this commit that should be backported to -stable (for 3.9+?):

43e8317b0bba PM / sleep: Use valid_state() for platform-dependent sleep states only

But it needs to drag along this dependency too:

    27ddcc6596e5 PM / sleep: Add state field to pm_states[] entries

That sounds OK.

Can you please send a formal request to include the two commits above to Greg/stable?

Quoted 6 lines

While at this, it looks like this commit might be deserving of -stable (3.9+). I haven't tested this one, as I don't have a good freeze+cpuidle setup; it just shows up in the commit log with an interesting description and a 'Fixes' tag:

f3f125324fc1 PM / suspend: Make cpuidle work in the "freeze" state

Well, it basically makes the freeze state save energy, but it's not essential.

I'm not seeing the "Fixes:" tag on it, though.

Rafael

#2 lore raw
Quoted 6 lines · Rafael J. Wysocki
Quoted 5 lines · Brian Norris

I think I've narrowed it down to this commit that should be backported to -stable (for 3.9+?):

43e8317b0bba PM / sleep: Use valid_state() for platform-dependent sleep states only

Quoted 7 lines
Quoted 3 lines

But it needs to drag along this dependency too:

    27ddcc6596e5 PM / sleep: Add state field to pm_states[] entries

That sounds OK.

Can you please send a formal request to include the two commits above to Greg/stable?

Sure. I've never done a post-merge -stable request; the format isn't 100% clear, but I'll give it a go.

Quoted 10 lines
Quoted 6 lines

While at this, it looks like this commit might be deserving of -stable (3.9+). I haven't tested this one, as I don't have a good freeze+cpuidle setup; it just shows up in the commit log with an interesting description and a 'Fixes' tag:

f3f125324fc1 PM / suspend: Make cpuidle work in the "freeze" state

Well, it basically makes the freeze state save energy, but it's not essential.

I'm not seeing the "Fixes:" tag on it, though.

Oops, I must have been looking at a different commit. Sorry!

Brian

#3 lore raw

PATCH 1/1 PM / sleep: Use valid_state() for platform-dependent sleep states only

In reply to Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

[Upstream commit 43e8317b0bba1d6eb85f38a4a233d82d7c20d732]

Use the observation that, for platform-dependent sleep states (PM_SUSPEND_STANDBY, PM_SUSPEND_MEM), a given state is either always supported or always unsupported and store that information in pm_states[] instead of calling valid_state() every time we need to check it.

Also do not use valid_state() for PM_SUSPEND_FREEZE, which is always valid, and move the pm_test_level validity check for PM_SUSPEND_FREEZE directly into enter_state().

Cc <[email protected]> # 3.10+: 27ddcc6596e5: PM / sleep: Add state field to pm_states[] entries
Cc <[email protected]> # 3.10+

---
This is a backport request for these two commits upstream:

27ddcc6596e5 PM / sleep: Add state field to pm_states[] entries 43e8317b0bba PM / sleep: Use valid_state() for platform-dependent sleep states only

Rafael ack'd this:

https://lkml.org/lkml/2014/9/4/543

I've tested these on 3.14, and it looks like they could go back as far as 3.10.

 kernel/power/main.c         |  9 ++++---
 kernel/power/power.h        |  2 --
 kernel/power/suspend.c      | 60 ++++++++++++++++++++++-----------------------
 kernel/power/suspend_test.c |  2 +-
 4 files changed, 36 insertions(+), 37 deletions(-)
kernel/power/main.c +5 -4
index 8e818432253c..9f51f0ab3d86 100644
@@ -296,7 +296,7 @@ static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr,
 	suspend_state_t i;
 
 	for (i = PM_SUSPEND_MIN; i < PM_SUSPEND_MAX; i++)
-		if (valid_state(i))
+		if (pm_states[i].state)
 			s += sprintf(s,"%s ", pm_states[i].label);
 
 #endif
@@ -328,8 +328,9 @@ static suspend_state_t decode_state(const char *buf, size_t n)
 
 #ifdef CONFIG_SUSPEND
 	for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++)
-		if (len == strlen(s->label) && !strncmp(buf, s->label, len))
-			return state;
+		if (s->state && len == strlen(s->label)
+		    && !strncmp(buf, s->label, len))
+			return s->state;
 #endif
 
 	return PM_SUSPEND_ON;
@@ -447,7 +448,7 @@ static ssize_t autosleep_show(struct kobject *kobj,
 
 #ifdef CONFIG_SUSPEND
 	if (state < PM_SUSPEND_MAX)
-		return sprintf(buf, "%s\n", valid_state(state) ?
+		return sprintf(buf, "%s\n", pm_states[state].state ?
 					pm_states[state].label : "error");
 #endif
 #ifdef CONFIG_HIBERNATION
kernel/power/power.h +0 -2
index 99539c5da844..c60f13b5270a 100644
@@ -186,14 +186,12 @@ struct pm_sleep_state {
 /* kernel/power/suspend.c */
 extern struct pm_sleep_state pm_states[];
 
-extern bool valid_state(suspend_state_t state);
 extern int suspend_devices_and_enter(suspend_state_t state);
 #else /* !CONFIG_SUSPEND */
 static inline int suspend_devices_and_enter(suspend_state_t state)
 {
 	return -ENOSYS;
 }
-static inline bool valid_state(suspend_state_t state) { return false; }
 #endif /* !CONFIG_SUSPEND */
 
 #ifdef CONFIG_PM_TEST_SUSPEND
kernel/power/suspend.c +30 -30

90 lines not on this page · raw message

kernel/power/suspend_test.c +1 -1
index d4e3ab167a73..269b097e78ea 100644
@@ -162,7 +162,7 @@ static int __init test_suspend(void)
 	/* PM is initialized by now; is that state testable? */
 	if (test_state == PM_SUSPEND_ON)
 		goto done;
-	if (!valid_state(test_state)) {
+	if (!pm_states[test_state].state) {
 		printk(warn_bad_state, pm_states[test_state].label);
 		goto done;
 	}
Signature · 1 line
1.9.1
#4 lore raw

Re: [PATCH 3.10.y+] PM / sleep: Use valid_state() for platform-dependent sleep states only

Hello,

Quoted 14 lines · Brian Norris

From: "Rafael J. Wysocki" <[email protected]>

[Upstream commit 43e8317b0bba1d6eb85f38a4a233d82d7c20d732]

Use the observation that, for platform-dependent sleep states (PM_SUSPEND_STANDBY, PM_SUSPEND_MEM), a given state is either always supported or always unsupported and store that information in pm_states[] instead of calling valid_state() every time we need to check it.

Also do not use valid_state() for PM_SUSPEND_FREEZE, which is always valid, and move the pm_test_level validity check for PM_SUSPEND_FREEZE directly into enter_state().

Quoted 9 lines
Cc <[email protected]> # 3.10+: 27ddcc6596e5: PM / sleep: Add state field to pm_states[] entries
Cc <[email protected]> # 3.10+

---
This is a backport request for these two commits upstream:

27ddcc6596e5 PM / sleep: Add state field to pm_states[] entries 43e8317b0bba PM / sleep: Use valid_state() for platform-dependent sleep states only

Wouldn't it be cleaner to have 2 separate backports then ?

Thanks for the backport anyways.

#5 lore raw

Re: [PATCH 3.10.y+] PM / sleep: Use valid_state() for platform-dependent sleep states only

Quoted 1 line · Francis Moreau

On 09/04/2014 11:21 PM, Brian Norris wrote:

[...]

Quoted 11 lines
Quoted 9 lines
Cc <[email protected]> # 3.10+: 27ddcc6596e5: PM / sleep: Add state field to pm_states[] entries
Cc <[email protected]> # 3.10+

---
This is a backport request for these two commits upstream:

27ddcc6596e5 PM / sleep: Add state field to pm_states[] entries 43e8317b0bba PM / sleep: Use valid_state() for platform-dependent sleep states only

Wouldn't it be cleaner to have 2 separate backports then ?

The first is purely a dependency for the second. It has no value on its own. So I thought the above form made sense and followed the process mentioned in Documentation/stable_kernel_rules.txt.

Admittedly, it's a little asymmetric. But I really don't know what the "best" option is, since I'd prefer not having to send around any patch text at all, unless the backport is not trivial (these apply cleanly).

Related: I don't feel like Documentation/stable_kernel_rules.txt is very clear under the "Procedure" section. It lists a series of non-sequential steps, some of which are mutually exclusive.

Any tips on making my post-merge -stable submissions better are appreciated. And recommendations on improving the text (or just my interpretation) of Documentation/stable_kernel_rules.txt are welcome too.

Brian

#6 lore raw

Re: [PATCH 3.10.y+] PM / sleep: Use valid_state() for platform-dependent sleep states only

Quoted 15 lines · Brian Norris
Quoted 1 line · Francis Moreau

On 09/04/2014 11:21 PM, Brian Norris wrote:

[...]

Quoted 11 lines
Quoted 9 lines
Cc <[email protected]> # 3.10+: 27ddcc6596e5: PM / sleep: Add state field to pm_states[] entries
Cc <[email protected]> # 3.10+

---
This is a backport request for these two commits upstream:

27ddcc6596e5 PM / sleep: Add state field to pm_states[] entries 43e8317b0bba PM / sleep: Use valid_state() for platform-dependent sleep states only

Wouldn't it be cleaner to have 2 separate backports then ?

Quoted 7 lines

The first is purely a dependency for the second. It has no value on its own. So I thought the above form made sense and followed the process mentioned in Documentation/stable_kernel_rules.txt.

Admittedly, it's a little asymmetric. But I really don't know what the "best" option is, since I'd prefer not having to send around any patch text at all, unless the backport is not trivial (these apply cleanly).

I don't know, I just find cleaner to cherry-pick upstream commits when possible so I can retrieve them easily later when inspecting a stable kernel.

My 2 cents.

#7 lore raw

Re: [PATCH 3.10.y+] PM / sleep: Use valid_state() for platform-dependent sleep states only

In reply to Brian Norris
Quoted 15 lines · Brian Norris
Quoted 1 line · Francis Moreau

On 09/04/2014 11:21 PM, Brian Norris wrote:

[...]

Quoted 11 lines
Quoted 9 lines
Cc <[email protected]> # 3.10+: 27ddcc6596e5: PM / sleep: Add state field to pm_states[] entries
Cc <[email protected]> # 3.10+

---
This is a backport request for these two commits upstream:

27ddcc6596e5 PM / sleep: Add state field to pm_states[] entries 43e8317b0bba PM / sleep: Use valid_state() for platform-dependent sleep states only

Wouldn't it be cleaner to have 2 separate backports then ?

Quoted 7 lines

The first is purely a dependency for the second. It has no value on its own. So I thought the above form made sense and followed the process mentioned in Documentation/stable_kernel_rules.txt.

Admittedly, it's a little asymmetric. But I really don't know what the "best" option is, since I'd prefer not having to send around any patch text at all, unless the backport is not trivial (these apply cleanly).

If they apply cleanly, then just list the git commit ids, and I can take care of the rest.

Don't merge patches together, it just causes problems and makes it harder to track what is going on.

thanks,

greg k-h

#8 lore raw

Re: [PATCH 3.10.y+] PM / sleep: Use valid_state() for platform-dependent sleep states only

Quoted 20 lines · Greg Kroah-Hartman
Quoted 19 lines · Brian Norris
Quoted 1 line · Francis Moreau

On 09/04/2014 11:21 PM, Brian Norris wrote:

[...]

Quoted 11 lines
Quoted 9 lines
Cc <[email protected]> # 3.10+: 27ddcc6596e5: PM / sleep: Add state field to pm_states[] entries
Cc <[email protected]> # 3.10+

---
This is a backport request for these two commits upstream:

27ddcc6596e5 PM / sleep: Add state field to pm_states[] entries 43e8317b0bba PM / sleep: Use valid_state() for platform-dependent sleep states only

Wouldn't it be cleaner to have 2 separate backports then ?

The first is purely a dependency for the second. It has no value on its own. So I thought the above form made sense and followed the process mentioned in Documentation/stable_kernel_rules.txt.

Quoted 6 lines
Quoted 3 lines

Admittedly, it's a little asymmetric. But I really don't know what the "best" option is, since I'd prefer not having to send around any patch text at all, unless the backport is not trivial (these apply cleanly).

If they apply cleanly, then just list the git commit ids, and I can take care of the rest.

OK. Is this a policy that should be documented? AIUI, we have a few options:

1. Include 'Cc: [email protected]' in the original commit that gets to Linus

2. Send an email to [email protected] that just contains the commit IDs, after they've made it to Linus

3. Send patches to [email protected], if backporting is not trivial

#1 is most common, and #2 seems like it would handle most of what misses #1. #3 seems inferior, whenever #2 would suffice. But #2 is not in stable_kernel_rules.txt.

Quoted 2 lines

Don't merge patches together, it just causes problems and makes it harder to track what is going on.

To be clear, the diff I sent is actually just a single patch (the fix); it is not a squashed version of both. I realize now that this was probably unclear.

Brian

#9 lore raw

Re: [PATCH 3.10.y+] PM / sleep: Use valid_state() for platform-dependent sleep states only

Quoted 37 lines · Brian Norris
Quoted 20 lines · Greg Kroah-Hartman
Quoted 19 lines · Brian Norris
Quoted 1 line · Francis Moreau

On 09/04/2014 11:21 PM, Brian Norris wrote:

[...]

Quoted 11 lines
Quoted 9 lines
Cc <[email protected]> # 3.10+: 27ddcc6596e5: PM / sleep: Add state field to pm_states[] entries
Cc <[email protected]> # 3.10+

---
This is a backport request for these two commits upstream:

27ddcc6596e5 PM / sleep: Add state field to pm_states[] entries 43e8317b0bba PM / sleep: Use valid_state() for platform-dependent sleep states only

Wouldn't it be cleaner to have 2 separate backports then ?

The first is purely a dependency for the second. It has no value on its own. So I thought the above form made sense and followed the process mentioned in Documentation/stable_kernel_rules.txt.

Quoted 6 lines
Quoted 3 lines

Admittedly, it's a little asymmetric. But I really don't know what the "best" option is, since I'd prefer not having to send around any patch text at all, unless the backport is not trivial (these apply cleanly).

If they apply cleanly, then just list the git commit ids, and I can take care of the rest.

OK. Is this a policy that should be documented? AIUI, we have a few options:

1. Include 'Cc: [email protected]' in the original commit that gets to Linus

2. Send an email to [email protected] that just contains the commit IDs, after they've made it to Linus

Quoted 6 lines

3. Send patches to [email protected], if backporting is not trivial

#1 is most common, and #2 seems like it would handle most of what misses #1. #3 seems inferior, whenever #2 would suffice. But #2 is not in stable_kernel_rules.txt.

I always gladly take patches to that .txt file if you wish to make it clearer.

thanks,

greg k-h

#10 lore raw

Re: [PATCH 3.10.y+] PM / sleep: Use valid_state() for platform-dependent sleep states only

Quoted 15 lines · Greg Kroah-Hartman
Quoted 15 lines
Quoted 2 lines

If they apply cleanly, then just list the git commit ids, and I can take care of the rest.

OK. Is this a policy that should be documented? AIUI, we have a few options:

1. Include 'Cc: [email protected]' in the original commit that gets to Linus

2. Send an email to [email protected] that just contains the commit IDs, after they've made it to Linus

3. Send patches to [email protected], if backporting is not trivial

Quoted 6 lines
Quoted 3 lines

#1 is most common, and #2 seems like it would handle most of what misses #1. #3 seems inferior, whenever #2 would suffice. But #2 is not in stable_kernel_rules.txt.

I always gladly take patches to that .txt file if you wish to make it clearer.

I was interested in whether I had my facts straight before trying to document them. I'll take your response to mean I'm not far off base, so I'll take a stab at patching the file.

Thanks,
Brian