Skip to contentSkip to conversation

mm/khugepaged: Remove unnecessary try_to_freeze()

PATCH Superseded Kevin Hao 2 participants 3 messages Dec 16, 2023 – Dec 19, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Kevin Hao

author
#0 lore raw

PATCH 1/1 mm/khugepaged: Remove unnecessary try_to_freeze()

A freezable kernel thread can enter frozen state during freezing by either calling try_to_freeze() or using wait_event_freezable() and its variants. However, there is no need to use both methods simultaneously. The freezable wait variants have been used in khugepaged_wait_work() and khugepaged_alloc_sleep(), so remove this unnecessary try_to_freeze().

---
 mm/khugepaged.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/khugepaged.c +1 -1
index 1002e9156388..9cdea59fb4c0 100644
@@ -2499,7 +2499,7 @@ static void khugepaged_do_scan(struct collapse_control *cc)
 	while (true) {
 		cond_resched();
 
-		if (unlikely(kthread_should_stop() || try_to_freeze()))
+		if (unlikely(kthread_should_stop()))
 			break;
 
 		spin_lock(&khugepaged_mm_lock);
Signature · 1 line
2.39.2
maintainer
#1 lore raw
Quoted 7 lines · On Sat, 16 Dec 2023 19:43:41 +0800 Kevin Hao <[email protected]> wrote:

A freezable kernel thread can enter frozen state during freezing by either calling try_to_freeze() or using wait_event_freezable() and its variants. However, there is no need to use both methods simultaneously. The freezable wait variants have been used in khugepaged_wait_work() and khugepaged_alloc_sleep(), so remove this unnecessary try_to_freeze().

Looks OK to me, but this will increase freezing latencies. How significant is this?

Also, we already have a patch from you with this same title. Please try to use different titles for different patches.

author
#2 lore raw
Quoted 10 lines · Andrew Morton
Quoted 7 lines · On Sat, 16 Dec 2023 19:43:41 +0800 Kevin Hao <[email protected]> wrote:

A freezable kernel thread can enter frozen state during freezing by either calling try_to_freeze() or using wait_event_freezable() and its variants. However, there is no need to use both methods simultaneously. The freezable wait variants have been used in khugepaged_wait_work() and khugepaged_alloc_sleep(), so remove this unnecessary try_to_freeze().

Quoted 2 lines

Looks OK to me, but this will increase freezing latencies. How significant is this?

I don't think this would cause observable freezing latencies, and most of time, we won't enter the freezing state, it is worthwhile to reduce the overhead of a function call.

On my Intel Alder Lake board (24 CPUs, 32G memory) with transparent hugepage enabled.

Before this patch:
Freezing user space processes
Freezing user space processes completed (elapsed 0.000 seconds) OOM killer disabled.
Freezing remaining freezable tasks
Freezing remaining freezable tasks completed (elapsed 0.001 seconds)

After this patch:
Freezing user space processes
Freezing user space processes completed (elapsed 0.000 seconds) OOM killer disabled.
Freezing remaining freezable tasks
Freezing remaining freezable tasks completed (elapsed 0.001 seconds)

Quoted 3 lines

Also, we already have a patch from you with this same title. Please try to use different titles for different patches.

Sure, I will tweak it in v2.

Thanks,
Kevin