Skip to contentSkip to conversation

PM: sleep: Drop spurious WARN_ON from pm_restore_gfp_mask()

PATCH Applied Youngjun Park 2 participants 2 messages Mar 22 – Mar 23

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

PATCH 1/1 PM: sleep: Drop spurious WARN_ON from pm_restore_gfp_mask()

Commit 35e4a69b2003f ("PM: sleep: Allow pm_restrict_gfp_mask() stacking") introduced refcount-based GFP mask management that warns when pm_restore_gfp_mask() is called with saved_gfp_count == 0.

Some hibernation paths call pm_restore_gfp_mask() defensively where the GFP mask may or may not be restricted depending on the execution path. For example, the uswsusp interface invokes it in SNAPSHOT_CREATE_IMAGE, SNAPSHOT_UNFREEZE, and snapshot_release(). Before the stacking change this was a silent no-op; it now triggers a spurious WARNING.

Remove the WARN_ON() wrapper from the !saved_gfp_count check while retaining the check itself, so that defensive calls remain harmless without producing false warnings.

Fixes 35e4a69b2003f ("PM: sleep: Allow pm_restrict_gfp_mask() stacking")

---
---
Split from the earlier pm_restore_gfp_mask_nowarn() series and agreed upon with Rafael to take this simpler approach instead:
https://lore.kernel.org/linux-mm/CAJZ5v0gBHLz7T2qRJRjBfOWY6UXM6L6+Kw8UcsY4+OaB7+qQcg@mail.gmail.com/T/#m10ee3346cd8dcd052749105d9a8e2052dbf3bc80

 kernel/power/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/main.c +1 -1
index 5f8c9e12eaec..5429e9f19b65 100644
@@ -40,7 +40,7 @@ void pm_restore_gfp_mask(void)
 {
 	WARN_ON(!mutex_is_locked(&system_transition_mutex));
 
-	if (WARN_ON(!saved_gfp_count) || --saved_gfp_count)
+	if (!saved_gfp_count || --saved_gfp_count)
 		return;
 
 	gfp_allowed_mask = saved_gfp_mask;

base-commit: f338e77383789c0cae23ca3d48adcc5e9e137e3c

Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 41 lines · Youngjun Park

Commit 35e4a69b2003f ("PM: sleep: Allow pm_restrict_gfp_mask() stacking") introduced refcount-based GFP mask management that warns when pm_restore_gfp_mask() is called with saved_gfp_count == 0.

Some hibernation paths call pm_restore_gfp_mask() defensively where the GFP mask may or may not be restricted depending on the execution path. For example, the uswsusp interface invokes it in SNAPSHOT_CREATE_IMAGE, SNAPSHOT_UNFREEZE, and snapshot_release(). Before the stacking change this was a silent no-op; it now triggers a spurious WARNING.

Remove the WARN_ON() wrapper from the !saved_gfp_count check while retaining the check itself, so that defensive calls remain harmless without producing false warnings.

Fixes 35e4a69b2003f ("PM: sleep: Allow pm_restrict_gfp_mask() stacking")

---
---
Split from the earlier pm_restore_gfp_mask_nowarn() series and agreed upon with Rafael to take this simpler approach instead:
https://lore.kernel.org/linux-mm/CAJZ5v0gBHLz7T2qRJRjBfOWY6UXM6L6+Kw8UcsY4+OaB7+qQcg@mail.gmail.com/T/#m10ee3346cd8dcd052749105d9a8e2052dbf3bc80

 kernel/power/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/main.c +1 -1
index 5f8c9e12eaec..5429e9f19b65 100644
@@ -40,7 +40,7 @@ void pm_restore_gfp_mask(void)
 {
        WARN_ON(!mutex_is_locked(&system_transition_mutex));
 
-       if (WARN_ON(!saved_gfp_count) || --saved_gfp_count)
+       if (!saved_gfp_count || --saved_gfp_count)
                return;
 
        gfp_allowed_mask = saved_gfp_mask;
Quoted 2 lines

base-commit: f338e77383789c0cae23ca3d48adcc5e9e137e3c --

Applied as 7.0-rc material, thanks!