Re: [patch V3 3/8] task isolation: sync vmstats on return to userspace

From: nsaenzju
Date: Fri Sep 10 2021 - 09:49:53 EST


Hi Marcelo,

On Tue, 2021-08-24 at 12:24 -0300, Marcelo Tosatti wrote:
> The logic to disable vmstat worker thread, when entering
> nohz full, does not cover all scenarios. For example, it is possible
> for the following to happen:
>
> 1) enter nohz_full, which calls refresh_cpu_vm_stats, syncing the stats.
> 2) app runs mlock, which increases counters for mlock'ed pages.
> 3) start -RT loop
>
> Since refresh_cpu_vm_stats from nohz_full logic can happen _before_
> the mlock, vmstat shepherd can restart vmstat worker thread on
> the CPU in question.
>
> To fix this, use the task isolation prctl interface to quiesce
> deferred actions when returning to userspace.
>
> Signed-off-by: Marcelo Tosatti <mtosatti@xxxxxxxxxx>
>
> ---

[...]

> Index: linux-2.6/kernel/entry/common.c
> ===================================================================
> --- linux-2.6.orig/kernel/entry/common.c
> +++ linux-2.6/kernel/entry/common.c
> @@ -6,6 +6,7 @@
> #include <linux/livepatch.h>
> #include <linux/audit.h>
> #include <linux/tick.h>
> +#include <linux/task_isolation.h>
>
> #include "common.h"
>
> @@ -287,6 +288,7 @@ static void syscall_exit_to_user_mode_pr
> static __always_inline void __syscall_exit_to_user_mode_work(struct pt_regs *regs)
> {
> syscall_exit_to_user_mode_prepare(regs);
> + isolation_exit_to_user_mode_prepare();

Are safe from migration at this stage?

--
Nicolás Sáenz