• Kevin Hao's avatar
    mm/khugepaged: remove redundant try_to_freeze() · b39ca208
    Kevin Hao authored
    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().
    
    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.
    
    Link: https://lkml.kernel.org/r/20231219231753.683171-1-haokexin@gmail.comSigned-off-by: default avatarKevin Hao <haokexin@gmail.com>
    Cc: Pavel Machek <pavel@ucw.cz>
    Cc: Rafael J. Wysocki <rafael@kernel.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    b39ca208
khugepaged.c 71.7 KB