# Re: \[RFC\]\[PATCH 7/7\] livepatch,context\_tracking: Avoid disturbing NOHZ\_FULL tasks

- From: Peter Zijlstra \<peterz@infradead.org\>
- Date: 2021-09-23 13:33:01 
- List: live-patching
- Page: https://ratatoskr.run/live-patching/2021/09/1519566
- Thread: https://ratatoskr.run/live-patching/2021/09/1518181/t.md

```text
On Thu, Sep 23, 2021 at 03:14:48PM +0200, Petr Mladek wrote:

> IMHO, this is not safe:
> 
> CPU0				CPU1
> 
> klp_check_task(A)
>   if (context_tracking_state_cpu(task_cpu(task)) == CONTEXT_USER)
>      goto complete;
> 
>   clear_tsk_thread_flag(task, TIF_PATCH_PENDING);
> 
> 				# task switching to kernel space
> 				klp_update_patch_state(A)
> 				       if (test_and_clear_tsk_thread_flag(task,	TIF_PATCH_PENDING))
> 				       //false
> 
> 				# calling kernel code with old task->patch_state
> 
> 	task->patch_state = klp_target_state;
> 
> BANG: CPU0 sets task->patch_state when task A is already running
> 	kernel code on CPU1.

Why is that a problem? That is, who actually cares about
task->patch_state ? I was under the impression that state was purely for
klp itself, to track which task has observed the new state.
```
