mirror of
https://github.com/torvalds/linux.git
synced 2026-09-25 21:21:09 -04:00
selftests: mm: restore settings from only parent process
The atexit() is called from parent process as well as forked processes.
Hence the child restores the settings at exit while the parent is still
executing. Fix this by checking pid of atexit() calling process and only
restore THP number from parent process.
Link: https://lkml.kernel.org/r/[email protected]
Fixes: c23ea61726 ("selftests/mm: protection_keys: save/restore nr_hugepages settings")
Signed-off-by: Muhammad Usama Anjum <[email protected]>
Tested-by: Joey Gouly <[email protected]>
Cc: Shuah Khan <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
This commit is contained in:
committed by
Andrew Morton
parent
950bf45d3b
commit
c52eb6db7b
@@ -1745,9 +1745,12 @@ void pkey_setup_shadow(void)
|
||||
shadow_pkey_reg = __read_pkey_reg();
|
||||
}
|
||||
|
||||
pid_t parent_pid;
|
||||
|
||||
void restore_settings_atexit(void)
|
||||
{
|
||||
cat_into_file(buf, "/proc/sys/vm/nr_hugepages");
|
||||
if (parent_pid == getpid())
|
||||
cat_into_file(buf, "/proc/sys/vm/nr_hugepages");
|
||||
}
|
||||
|
||||
void save_settings(void)
|
||||
@@ -1773,6 +1776,7 @@ void save_settings(void)
|
||||
exit(__LINE__);
|
||||
}
|
||||
|
||||
parent_pid = getpid();
|
||||
atexit(restore_settings_atexit);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user