2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00

Restore THP_DISABLE prctl.

The original commit added saving THP_DISABLED flag value, but missed
restoring it. There is restoring code, but used only when --lazy_pages
mode is enabled. Restore the prctl flag always. While at it, rename the
`has_thp_enabled` -> `!thp_disabled` for consistency.

Fixes: bbbd597b41 (2017-06-28 "mem: add dump state of THP_DISABLED prctl")
Signed-off-by: Michał Mirosław <emmir@google.com>
This commit is contained in:
Michał Mirosław
2023-06-02 18:02:38 +02:00
committed by Andrei Vagin
parent 9943dcde17
commit 21ce76263b
5 changed files with 8 additions and 18 deletions

View File

@@ -2971,7 +2971,7 @@ static int prepare_mm(pid_t pid, struct task_restore_args *args)
args->fd_exe_link = exe_fd;
args->has_thp_enabled = rsti(current)->has_thp_enabled;
args->thp_disabled = mm->has_thp_disabled && mm->thp_disabled;
ret = 0;
out:

View File

@@ -144,7 +144,7 @@ struct task_restore_args {
struct timeval logstart;
int uffd;
bool has_thp_enabled;
bool thp_disabled;
/* threads restoration */
int nr_threads; /* number of threads */

View File

@@ -73,8 +73,6 @@ struct rst_info {
*/
bool has_old_seccomp_filter;
bool has_thp_enabled;
struct rst_rseq *rseqe;
void *breakpoint;

View File

@@ -1217,8 +1217,6 @@ err_addr:
static int maybe_disable_thp(struct pstree_item *t, struct page_read *pr)
{
MmEntry *mm = rsti(t)->mm;
/*
* There is no need to disable it if the page read doesn't
* have parent. In this case VMA will be empty until
@@ -1241,8 +1239,6 @@ static int maybe_disable_thp(struct pstree_item *t, struct page_read *pr)
pr_perror("Cannot disable THP");
return -1;
}
if (!(mm->has_thp_disabled && mm->thp_disabled))
rsti(t)->has_thp_enabled = true;
return 0;
}

View File

@@ -1635,17 +1635,13 @@ long __export_restore_task(struct task_restore_args *args)
goto core_restore_end;
}
if (args->uffd > -1) {
/* re-enable THP if we disabled it previously */
if (args->has_thp_enabled) {
int ret;
ret = sys_prctl(PR_SET_THP_DISABLE, 0, 0, 0, 0);
if (ret) {
pr_err("Cannot re-enable THP: %d\n", ret);
goto core_restore_end;
}
}
ret = sys_prctl(PR_SET_THP_DISABLE, args->thp_disabled, 0, 0, 0);
if (ret) {
pr_err("Cannot restore THP_DISABLE=%d flag: %ld\n", args->thp_disabled, ret);
goto core_restore_end;
}
if (args->uffd > -1) {
pr_debug("lazy-pages: closing uffd %d\n", args->uffd);
/*
* All userfaultfd configuration has finished at this point.