From: Andrew Morton <akpm@linux-foundation.org> To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Cc: Vlastimil Babka <vbabka@suse.cz>, Andrea Arcangeli <aarcange@redhat.com>, Michal Hocko <mhocko@kernel.org>, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>, "H . Peter Anvin" <hpa@zytor.com>, Thomas Gleixner <tglx@linutronix.de> Subject: Re: [PATCHv4 09/12] x86/mm: Provide pmdp_establish() helper Date: Wed, 13 Dec 2017 16:09:51 -0800 [thread overview] Message-ID: <20171213160951.249071f2aecdccb38b6bb646@linux-foundation.org> (raw) In-Reply-To: <20171213105756.69879-10-kirill.shutemov@linux.intel.com> On Wed, 13 Dec 2017 13:57:53 +0300 "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> wrote: > We need an atomic way to setup pmd page table entry, avoiding races with > CPU setting dirty/accessed bits. This is required to implement > pmdp_invalidate() that doesn't lose these bits. > > On PAE we can avoid expensive cmpxchg8b for cases when new page table > entry is not present. If it's present, fallback to cpmxchg loop. > > ... > > --- a/arch/x86/include/asm/pgtable-3level.h > +++ b/arch/x86/include/asm/pgtable-3level.h > @@ -158,7 +158,6 @@ static inline pte_t native_ptep_get_and_clear(pte_t *ptep) > #define native_ptep_get_and_clear(xp) native_local_ptep_get_and_clear(xp) > #endif > > -#ifdef CONFIG_SMP > union split_pmd { > struct { > u32 pmd_low; > @@ -166,6 +165,8 @@ union split_pmd { > }; > pmd_t pmd; > }; > + > +#ifdef CONFIG_SMP > static inline pmd_t native_pmdp_get_and_clear(pmd_t *pmdp) > { > union split_pmd res, *orig = (union split_pmd *)pmdp; > @@ -181,6 +182,40 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *pmdp) > #define native_pmdp_get_and_clear(xp) native_local_pmdp_get_and_clear(xp) > #endif > > +#ifndef pmdp_establish > +#define pmdp_establish pmdp_establish > +static inline pmd_t pmdp_establish(struct vm_area_struct *vma, > + unsigned long address, pmd_t *pmdp, pmd_t pmd) > +{ > + pmd_t old; > + > + /* > + * If pmd has present bit cleared we can get away without expensive > + * cmpxchg64: we can update pmdp half-by-half without racing with > + * anybody. > + */ > + if (!(pmd_val(pmd) & _PAGE_PRESENT)) { > + union split_pmd old, new, *ptr; > + > + ptr = (union split_pmd *)pmdp; > + > + new.pmd = pmd; > + > + /* xchg acts as a barrier before setting of the high bits */ > + old.pmd_low = xchg(&ptr->pmd_low, new.pmd_low); > + old.pmd_high = ptr->pmd_high; > + ptr->pmd_high = new.pmd_high; > + return old.pmd; > + } > + > + { > + old = *pmdp; > + } while (cmpxchg64(&pmdp->pmd, old.pmd, pmd.pmd) != old.pmd); um, what happened here? > + return old; > +} > +#endif
WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org> To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Cc: Vlastimil Babka <vbabka@suse.cz>, Andrea Arcangeli <aarcange@redhat.com>, Michal Hocko <mhocko@kernel.org>, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>, "H . Peter Anvin" <hpa@zytor.com>, Thomas Gleixner <tglx@linutronix.de> Subject: Re: [PATCHv4 09/12] x86/mm: Provide pmdp_establish() helper Date: Wed, 13 Dec 2017 16:09:51 -0800 [thread overview] Message-ID: <20171213160951.249071f2aecdccb38b6bb646@linux-foundation.org> (raw) In-Reply-To: <20171213105756.69879-10-kirill.shutemov@linux.intel.com> On Wed, 13 Dec 2017 13:57:53 +0300 "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> wrote: > We need an atomic way to setup pmd page table entry, avoiding races with > CPU setting dirty/accessed bits. This is required to implement > pmdp_invalidate() that doesn't lose these bits. > > On PAE we can avoid expensive cmpxchg8b for cases when new page table > entry is not present. If it's present, fallback to cpmxchg loop. > > ... > > --- a/arch/x86/include/asm/pgtable-3level.h > +++ b/arch/x86/include/asm/pgtable-3level.h > @@ -158,7 +158,6 @@ static inline pte_t native_ptep_get_and_clear(pte_t *ptep) > #define native_ptep_get_and_clear(xp) native_local_ptep_get_and_clear(xp) > #endif > > -#ifdef CONFIG_SMP > union split_pmd { > struct { > u32 pmd_low; > @@ -166,6 +165,8 @@ union split_pmd { > }; > pmd_t pmd; > }; > + > +#ifdef CONFIG_SMP > static inline pmd_t native_pmdp_get_and_clear(pmd_t *pmdp) > { > union split_pmd res, *orig = (union split_pmd *)pmdp; > @@ -181,6 +182,40 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *pmdp) > #define native_pmdp_get_and_clear(xp) native_local_pmdp_get_and_clear(xp) > #endif > > +#ifndef pmdp_establish > +#define pmdp_establish pmdp_establish > +static inline pmd_t pmdp_establish(struct vm_area_struct *vma, > + unsigned long address, pmd_t *pmdp, pmd_t pmd) > +{ > + pmd_t old; > + > + /* > + * If pmd has present bit cleared we can get away without expensive > + * cmpxchg64: we can update pmdp half-by-half without racing with > + * anybody. > + */ > + if (!(pmd_val(pmd) & _PAGE_PRESENT)) { > + union split_pmd old, new, *ptr; > + > + ptr = (union split_pmd *)pmdp; > + > + new.pmd = pmd; > + > + /* xchg acts as a barrier before setting of the high bits */ > + old.pmd_low = xchg(&ptr->pmd_low, new.pmd_low); > + old.pmd_high = ptr->pmd_high; > + ptr->pmd_high = new.pmd_high; > + return old.pmd; > + } > + > + { > + old = *pmdp; > + } while (cmpxchg64(&pmdp->pmd, old.pmd, pmd.pmd) != old.pmd); um, what happened here? > + return old; > +} > +#endif -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2017-12-14 0:09 UTC|newest] Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-12-13 10:57 [PATCHv4 00/12] Do not lose dirty bit on THP pages Kirill A. Shutemov 2017-12-13 10:57 ` Kirill A. Shutemov 2017-12-13 10:57 ` [PATCHv4 01/12] asm-generic: Provide generic_pmdp_establish() Kirill A. Shutemov 2017-12-13 10:57 ` Kirill A. Shutemov 2017-12-13 10:57 ` [PATCHv4 02/12] arc: Use generic_pmdp_establish as pmdp_establish Kirill A. Shutemov 2017-12-13 10:57 ` Kirill A. Shutemov 2017-12-13 10:57 ` [PATCHv4 03/12] arm/mm: Provide pmdp_establish() helper Kirill A. Shutemov 2017-12-13 10:57 ` Kirill A. Shutemov 2017-12-13 10:57 ` [PATCHv4 04/12] arm64: " Kirill A. Shutemov 2017-12-13 10:57 ` Kirill A. Shutemov 2017-12-13 10:57 ` [PATCHv4 05/12] mips: Use generic_pmdp_establish as pmdp_establish Kirill A. Shutemov 2017-12-13 10:57 ` Kirill A. Shutemov 2017-12-13 10:57 ` [PATCHv4 06/12] powerpc/mm: update pmdp_invalidate to return old pmd value Kirill A. Shutemov 2017-12-13 10:57 ` Kirill A. Shutemov 2017-12-13 10:57 ` [PATCHv4 07/12] s390/mm: Modify pmdp_invalidate to return old value Kirill A. Shutemov 2017-12-13 10:57 ` Kirill A. Shutemov 2017-12-13 10:57 ` [PATCHv4 08/12] sparc64: Update pmdp_invalidate() to return old pmd value Kirill A. Shutemov 2017-12-13 10:57 ` Kirill A. Shutemov 2017-12-14 0:06 ` Andrew Morton 2017-12-14 0:06 ` Andrew Morton 2017-12-14 0:06 ` Andrew Morton 2017-12-13 10:57 ` [PATCHv4 09/12] x86/mm: Provide pmdp_establish() helper Kirill A. Shutemov 2017-12-13 10:57 ` Kirill A. Shutemov 2017-12-14 0:09 ` Andrew Morton [this message] 2017-12-14 0:09 ` Andrew Morton 2017-12-14 0:33 ` Kirill A. Shutemov 2017-12-14 0:33 ` Kirill A. Shutemov 2017-12-14 0:36 ` Andrew Morton 2017-12-14 0:36 ` Andrew Morton 2017-12-14 0:42 ` Kirill A. Shutemov 2017-12-14 0:42 ` Kirill A. Shutemov 2017-12-15 13:49 ` Kirill A. Shutemov 2017-12-15 13:49 ` Kirill A. Shutemov 2017-12-13 10:57 ` [PATCHv4 10/12] mm: Do not lose dirty and access bits in pmdp_invalidate() Kirill A. Shutemov 2017-12-13 10:57 ` Kirill A. Shutemov 2017-12-13 10:57 ` [PATCHv4 11/12] mm: Use updated pmdp_invalidate() interface to track dirty/accessed bits Kirill A. Shutemov 2017-12-13 10:57 ` Kirill A. Shutemov 2017-12-13 10:57 ` [PATCHv4 12/12] mm/thp: Remove pmd_huge_split_prepare Kirill A. Shutemov 2017-12-13 10:57 ` Kirill A. Shutemov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20171213160951.249071f2aecdccb38b6bb646@linux-foundation.org \ --to=akpm@linux-foundation.org \ --cc=aarcange@redhat.com \ --cc=hpa@zytor.com \ --cc=kirill.shutemov@linux.intel.com \ --cc=linux-arch@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=mhocko@kernel.org \ --cc=mingo@kernel.org \ --cc=tglx@linutronix.de \ --cc=vbabka@suse.cz \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.