Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1666028

Re: [PATCH 1/3] x86/mm: Provide pmdp_mknotpresent() helper

From Andrea Arcangeli <aarcange@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH 1/3] x86/mm: Provide pmdp_mknotpresent() helper
Date 2017-06-14 18:10 +0200
Message-ID <tSj1M-7nv-17@gated-at.bofh.it> (permalink)
References <tSgZX-5S3-3@gated-at.bofh.it> <tSgZX-5S3-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Jun 14, 2017 at 04:51:41PM +0300, Kirill A. Shutemov wrote:
> We need an atomic way to make pmd page table entry not-present.
> This is required to implement pmdp_invalidate() that doesn't loose dirty
> or access bits.

What does the cmpxchg() loop achieves compared to xchg() and then
return the old value (potentially with the dirty bit set when it was
not before we called xchg)?

> index f5af95a0c6b8..576420df12b8 100644
> --- a/arch/x86/include/asm/pgtable.h
> +++ b/arch/x86/include/asm/pgtable.h
> @@ -1092,6 +1092,19 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
>  	clear_bit(_PAGE_BIT_RW, (unsigned long *)pmdp);
>  }
>  
> +#ifndef pmdp_mknotpresent
> +#define pmdp_mknotpresent pmdp_mknotpresent
> +static inline void pmdp_mknotpresent(pmd_t *pmdp)
> +{
> +	pmd_t old, new;
> +
> +	{
> +		old = *pmdp;
> +		new = pmd_mknotpresent(old);
> +	} while (pmd_val(cmpxchg(pmdp, old, new)) != pmd_val(old));
> +}
> +#endif

Isn't it faster to do xchg(&xp->pmd, pmd_mknotpresent(pmd)) and have
the pmdp_invalidate caller can set the dirty bit in the page if it was
found set in the returned old pmd value (and skip the loop and cmpxchg)?

Thanks,
Andrea

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/3] x86/mm: Provide pmdp_mknotpresent() helper "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2017-06-14 16:00 +0200
  Re: [PATCH 1/3] x86/mm: Provide pmdp_mknotpresent() helper Andrea Arcangeli <aarcange@redhat.com> - 2017-06-14 18:10 +0200
  Re: [PATCH 1/3] x86/mm: Provide pmdp_mknotpresent() helper kbuild test robot <lkp@intel.com> - 2017-06-15 06:50 +0200

csiph-web