Re: [PATCH v3 21/54] selftests/mm: add atexit() and signal handlers to thp_settings

Sarthak Sharma
2026-04-30T07:58:31Z

On 4/29/26 2:12 AM, Mike Rapoport wrote:
> From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
>
> khugepaged registers atexit() and signal handlers that ensure that THP
> settings are restored regardless of how the test exited.
>
> Make these handlers available for all users of thp_settings.
>
> The call to thp_save_settings() installs thp_restore_settings as the
> atexit() callback and makes sure that signals that kill a process would
> still call exit() and atexit() callback.
>
> Update child process in tests using thp_settings to use _exit() instead
> of exit() to avoid altering THP settings in the middle of a test.
>
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> ---

I ran the modified mm selftests after applying this patch and the THP
settings are being correctly restored to their original values both on
normal exit and when the test is being interrupted with Ctrl + C.

Tested-by: Sarthak Sharma <sarthak.sharma@arm.com>