Re: [RFC PATCH v2 3/9] mm, pgtable: Add ownership to PTE table

From: Chih-En Lin
Date: Tue Sep 27 2022 - 14:23:45 EST


On Tue, Sep 27, 2022 at 05:30:39PM +0000, Nadav Amit wrote:
> > +static inline void set_cow_pte_owner(pmd_t *pmd, pmd_t *owner)
> > +{
> > + smp_store_release(&pmd_page(*pmd)->cow_pte_owner, owner);
> > +}
> > +
> > +static inline bool cow_pte_owner_is_same(pmd_t *pmd, pmd_t *owner)
> > +{
> > + return smp_load_acquire(&pmd_page(*pmd)->cow_pte_owner) == owner;
> > +}
>
> Hiding synchronization primitives in such manner, and especially without
> proper comments, makes it hard to understand what the ordering is supposed
> to achieve.
>

It ensures that every time we write into the pointer, the reader
will ebserve the newest one.
I will add the comments.

Thanks,
Chih-En Lin