powerpc: Fixes and optimization for the freezable kthread
cover powerpc: Fixes and optimization for the freezable kthread
Hi,
The main changes include:
- Invoke set_freezable() for the kthread which could be frozen
- Drop redundant try_to_freeze() invocation
Kevin Hao (3):
powerpc: mpc83xx: Add the missing set_freezable() for
agent_thread_fn()
powerpc: mpc83xx: Use wait_event_freezable() for freezable kthread
powerpc: ps3: Add missing set_freezable() for ps3_probe_thread()
arch/powerpc/platforms/83xx/suspend.c | 5 +++-- arch/powerpc/platforms/ps3/device-init.c | 1 + 2 files changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.39.2
PATCH 1/3 powerpc: mpc83xx: Add the missing set_freezable() for agent_thread_fn()
The kernel thread function agent_thread_fn() invokes the try_to_freeze() in its loop. But all the kernel threads are non-freezable by default. So if we want to make a kernel thread to be freezable, we have to invoke set_freezable() explicitly.
--- arch/powerpc/platforms/83xx/suspend.c | 2 ++ 1 file changed, 2 insertions(+)
arch/powerpc/platforms/83xx/suspend.c +2 -0
@@ -261,6 +261,8 @@ static int mpc83xx_suspend_begin(suspend_state_t state)static int agent_thread_fn (void *data) { +set_freezable (); +while (1 ) {wait_event_interruptible (agent_wq, pci_pm_state >=2 );try_to_freeze ();
Signature · 1 line
2.39.2
PATCH 2/3 powerpc: mpc83xx: Use wait_event_freezable() for freezable kthread
In reply to Kevin HaoA freezable kernel thread can enter frozen state during freezing by either calling try_to_freeze() or using wait_event_freezable() and its variants. So for the following snippet of code in a kernel thread loop:
wait_event_interruptible();
try_to_freeze();
We can change it to a simple wait_event_freezable() and then eliminate a function call.
--- arch/powerpc/platforms/83xx/suspend.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/powerpc/platforms/83xx/suspend.c +1 -2
@@ -264,8 +264,7 @@ static int agent_thread_fn(void *data)set_freezable ();while (1 ) { -wait_event_interruptible (agent_wq, pci_pm_state >=2 ); -try_to_freeze (); +wait_event_freezable (agent_wq, pci_pm_state >=2 );if (signal_pending (current) || pci_pm_state <2 )continue ;
Signature · 1 line
2.39.2
PATCH 3/3 powerpc: ps3: Add missing set_freezable() for ps3_probe_thread()
In reply to Kevin HaoThe kernel thread function ps3_probe_thread() invokes the try_to_freeze() in its loop. But all the kernel threads are non-freezable by default. So if we want to make a kernel thread to be freezable, we have to invoke set_freezable() explicitly.
--- arch/powerpc/platforms/ps3/device-init.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/platforms/ps3/device-init.c +1 -0
@@ -827,6 +827,7 @@ static int ps3_probe_thread(void *data)if (res) goto fail_free_irq; +set_freezable ();/* Loop here processing the requested notification events. */ do { try_to_freeze();
Signature · 1 line
2.39.2
Geoff Levand
maintainerRe: [PATCH 3/3] powerpc: ps3: Add missing set_freezable() for ps3_probe_thread()
Hi Kevin,
Quoted 15 lines · Kevin Hao
The kernel thread function
ps3_probe_thread()invokes thetry_to_freeze()in its loop. But all the kernel threads are non-freezable by default. So if we want to make a kernel thread to be freezable, we have to invokeset_freezable()explicitly.Signed-off-by Kevin Hao <[email protected]>--- arch/powerpc/platforms/ps3/device-init.c | 1 + 1 file changed, 1 insertion(+)arch/powerpc/platforms/ps3/device-init.c +0
-0
arch/powerpc/platforms/ps3/device-init.c static int ps3_probe_thread(void *data) · line 833
Quoted 7 lines
arch/powerpc/platforms/ps3/device-init.c +1
-0@@ -827,6 +827,7 @@ static int ps3_probe_thread(void *data)if (res) goto fail_free_irq; +set_freezable ();/* Loop here processing the requested notification events. */ do { try_to_freeze();
Seems like a reasonable addition.
Michael Ellerman
reviewerRe: [PATCH 3/3] powerpc: ps3: Add missing set_freezable() for ps3_probe_thread()
Quoted 21 lines · Geoff Levand
Hi Kevin,
Quoted 18 lines · Kevin Hao
The kernel thread function
ps3_probe_thread()invokes thetry_to_freeze()in its loop. But all the kernel threads are non-freezable by default. So if we want to make a kernel thread to be freezable, we have to invokeset_freezable()explicitly.Signed-off-by Kevin Hao <[email protected]>--- arch/powerpc/platforms/ps3/device-init.c | 1 + 1 file changed, 1 insertion(+)arch/powerpc/platforms/ps3/device-init.c +0
-0@@ -827,6 +827,7 @@ static int ps3_probe_thread(void *data)if (res) goto fail_free_irq;
Quoted 8 lines
arch/powerpc/platforms/ps3/device-init.c static int ps3_probe_thread(void *data) · line 833
Quoted 4 lines
arch/powerpc/platforms/ps3/device-init.c +1
-0+set_freezable ();/* Loop here processing the requested notification events. */ do { try_to_freeze();Seems like a reasonable addition.
Signed-off-by Geoff Levand <[email protected]>
I turned that into an Acked-by, which I think is what you meant :)
cheers
Michael Ellerman
AppliedQuoted 11 lines · Kevin Hao
The main changes include:
- Invokeset_freezable()for the kthread which could be frozen
- Drop redundanttry_to_freeze()invocationKevin Hao (3):
powerpc: mpc83xx: Add the missingset_freezable()for
agent_thread_fn()
powerpc: mpc83xx: Usewait_event_freezable()for freezable kthread
powerpc: ps3: Add missingset_freezable()forps3_probe_thread()[...]
Applied to powerpc/next.
[1/3] powerpc: mpc83xx: Add the missing set_freezable() for agent_thread_fn()
https://git.kernel.org/powerpc/c/6addc560e69cd1b2e68ef43ad62a878ac1956f51 [2/3] powerpc: mpc83xx: Use wait_event_freezable() for freezable kthread https://git.kernel.org/powerpc/c/11611d254c15cce1f58431b2965c6edb5aa7e610 [3/3] powerpc: ps3: Add missing set_freezable() for ps3_probe_thread() https://git.kernel.org/powerpc/c/ccc0f7b7673e63139ba9d916f4567d4fadb14b55
cheers