Re: [patch v11 09/13] task isolation: add preempt notifier to sync per-CPU vmstat dirty info to thread info

From: Frederic Weisbecker
Date: Mon Feb 07 2022 - 10:43:19 EST


On Fri, Feb 04, 2022 at 02:35:46PM -0300, Marcelo Tosatti wrote:
> If a thread has task isolation activated, is preempted by thread B,
> which marks vmstat information dirty, and is preempted back in,
> one might return to userspace with vmstat dirty information on the
> CPU in question.
>
> To address this problem, add a preempt notifier that transfers vmstat dirty
> information to TIF_TASK_ISOL thread flag.

Ah ok that answers my previous question :)

> Index: linux-2.6/mm/vmstat.c
> ===================================================================
> --- linux-2.6.orig/mm/vmstat.c
> +++ linux-2.6/mm/vmstat.c
> @@ -353,6 +353,13 @@ void init_sync_vmstat(void)
> set_thread_flag(TIF_TASK_ISOL);
> }
> EXPORT_SYMBOL_GPL(vmstat_dirty);
> +
> +void vmstat_dirty_to_thread_flag(void)
> +{
> + if (raw_cpu_read(vmstat_dirty) == true)

__this_cpu_read()?

> + set_thread_flag(TIF_TASK_ISOL);
> +}
> +EXPORT_SYMBOL_GPL(vmstat_dirty_to_thread_flag);
> #else
> static inline void mark_vmstat_dirty(void)
> {
>
>