* [PATCH v2] mm/khugepaged: Remove redundant try_to_freeze()
@ 2023-12-19 23:17 Kevin Hao
2023-12-20 0:00 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Hao @ 2023-12-19 23:17 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-mm, Rafael J. Wysocki, Pavel Machek
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 redundant
try_to_freeze().
Signed-off-by: Kevin Hao <haokexin@gmail.com>
---
v2: Adjust the patch subject to make it look more unique.
mm/khugepaged.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 5bf9a4d0e47e..13c6eadbeda3 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -2500,7 +2500,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);
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] mm/khugepaged: Remove redundant try_to_freeze()
2023-12-19 23:17 [PATCH v2] mm/khugepaged: Remove redundant try_to_freeze() Kevin Hao
@ 2023-12-20 0:00 ` Andrew Morton
2023-12-20 12:38 ` Kevin Hao
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2023-12-20 0:00 UTC (permalink / raw)
To: Kevin Hao; +Cc: linux-mm, Rafael J. Wysocki, Pavel Machek
On Wed, 20 Dec 2023 07:17:53 +0800 Kevin Hao <haokexin@gmail.com> 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 redundant
> try_to_freeze().
>
> ...
>
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -2500,7 +2500,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);
What are the effects upon worst-case freezing latency?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] mm/khugepaged: Remove redundant try_to_freeze()
2023-12-20 0:00 ` Andrew Morton
@ 2023-12-20 12:38 ` Kevin Hao
0 siblings, 0 replies; 3+ messages in thread
From: Kevin Hao @ 2023-12-20 12:38 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-mm, Rafael J. Wysocki, Pavel Machek
[-- Attachment #1: Type: text/plain, Size: 1825 bytes --]
On Tue, Dec 19, 2023 at 04:00:33PM -0800, Andrew Morton wrote:
> On Wed, 20 Dec 2023 07:17:53 +0800 Kevin Hao <haokexin@gmail.com> 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 redundant
> > try_to_freeze().
> >
> > ...
> >
> > --- a/mm/khugepaged.c
> > +++ b/mm/khugepaged.c
> > @@ -2500,7 +2500,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);
>
> What are the effects upon worst-case freezing latency?
I used the following stress-ng command to generate some memory load on my Intel
Alder Lake board (24 CPUs, 32G memory).
stress-ng --vm 48 --vm-bytes 90%
The worst freezing latency is:
Freezing user space processes
Freezing user space processes completed (elapsed 0.040 seconds)
OOM killer disabled.
Freezing remaining freezable tasks
Freezing remaining freezable tasks completed (elapsed 0.001 seconds)
Without the faked memory load, the freezing latency is:
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)
I didn't see any observable difference whether this patch is applied or not.
Thanks,
Kevin
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-20 12:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-19 23:17 [PATCH v2] mm/khugepaged: Remove redundant try_to_freeze() Kevin Hao
2023-12-20 0:00 ` Andrew Morton
2023-12-20 12:38 ` Kevin Hao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox