# Re: barriers: was: \[RFC PATCH v2 17/18\] livepatch: change to a per-task consistency model

- From: Peter Zijlstra \<peterz@infradead.org\>
- Date: 2016-05-04 13:53:42 
- List: linuxppc-dev
- Page: https://ratatoskr.run/linuxppc-dev/2016/05/4745444
- Thread: https://ratatoskr.run/linuxppc-dev/2016/04/4741670/t.md

```text
On Wed, May 04, 2016 at 02:39:40PM +0200, Petr Mladek wrote:
> > +	 * This barrier also ensures that if another CPU goes through the
> > +	 * syscall barrier, sees the TIF_PATCH_PENDING writes in
> > +	 * klp_start_transition(), and calls klp_patch_task(), it also sees the
> > +	 * above write to the target state.  Otherwise it can put the task in
> > +	 * the wrong universe.
> > +	 */
> 
> By other words, it makes sure that klp_patch_task() will assign the
> right patch_state. Where klp_patch_task() could not be called
> before we set TIF_PATCH_PENDING in klp_start_transition().
> 
> > +	smp_wmb();
> > +}

So I've not read the patch; but ending a function with an smp_wmb()
feels wrong.

A wmb orders two stores, and I feel both stores should be well visible
in the same function.
```
