From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751038AbdFSN3T (ORCPT ); Mon, 19 Jun 2017 09:29:19 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:35866 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750811AbdFSN3R (ORCPT ); Mon, 19 Jun 2017 09:29:17 -0400 Date: Mon, 19 Jun 2017 16:29:13 +0300 From: "Kirill A. Shutemov" To: Andrea Arcangeli Cc: "Kirill A. Shutemov" , Andrew Morton , Vlastimil Babka , Vineet Gupta , Russell King , Will Deacon , Catalin Marinas , Ralf Baechle , "David S. Miller" , "Aneesh Kumar K . V" , Martin Schwidefsky , Heiko Carstens , linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv2 2/3] mm: Do not loose dirty and access bits in pmdp_invalidate() Message-ID: <20170619132913.se67bp4addreqovn@node.shutemov.name> References: <20170615145224.66200-1-kirill.shutemov@linux.intel.com> <20170615145224.66200-3-kirill.shutemov@linux.intel.com> <20170616134041.GF11676@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170616134041.GF11676@redhat.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 16, 2017 at 03:40:41PM +0200, Andrea Arcangeli wrote: > On Thu, Jun 15, 2017 at 05:52:23PM +0300, Kirill A. Shutemov wrote: > > -void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, > > +pmd_t pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, > > pmd_t *pmdp) > > { > > - pmd_t entry = *pmdp; > > - set_pmd_at(vma->vm_mm, address, pmdp, pmd_mknotpresent(entry)); > > - flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE); > > + pmd_t old = pmdp_establish(pmdp, pmd_mknotpresent(*pmdp)); > > + if (pmd_present(old)) > > + flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE); > > + return old; > > } > > #endif > > The pmd_present() check added above is superflous because there's no > point to call pmdp_invalidate if the pmd is not present (present as in > pmd_present) already. pmd_present returns true if _PAGE_PSE is set > and it was always set before calling pmdp_invalidate. > > It looks like we could skip the flush if _PAGE_PRESENT is not set > (i.e. for example if the pmd is PROTNONE) but that's not what the above > pmd_present will do. You are right. We seems don't have a generic way to check the entry is present to CPU. I guess I'll drop the check then. -- Kirill A. Shutemov From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f71.google.com (mail-lf0-f71.google.com [209.85.215.71]) by kanga.kvack.org (Postfix) with ESMTP id C9D286B03C1 for ; Mon, 19 Jun 2017 09:29:17 -0400 (EDT) Received: by mail-lf0-f71.google.com with SMTP id x81so23174449lfb.10 for ; Mon, 19 Jun 2017 06:29:17 -0700 (PDT) Received: from mail-lf0-x244.google.com (mail-lf0-x244.google.com. [2a00:1450:4010:c07::244]) by mx.google.com with ESMTPS id a3si5498621lfk.20.2017.06.19.06.29.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 06:29:16 -0700 (PDT) Received: by mail-lf0-x244.google.com with SMTP id x81so10526708lfb.3 for ; Mon, 19 Jun 2017 06:29:16 -0700 (PDT) Date: Mon, 19 Jun 2017 16:29:13 +0300 From: "Kirill A. Shutemov" Subject: Re: [PATCHv2 2/3] mm: Do not loose dirty and access bits in pmdp_invalidate() Message-ID: <20170619132913.se67bp4addreqovn@node.shutemov.name> References: <20170615145224.66200-1-kirill.shutemov@linux.intel.com> <20170615145224.66200-3-kirill.shutemov@linux.intel.com> <20170616134041.GF11676@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170616134041.GF11676@redhat.com> Sender: owner-linux-mm@kvack.org List-ID: To: Andrea Arcangeli Cc: "Kirill A. Shutemov" , Andrew Morton , Vlastimil Babka , Vineet Gupta , Russell King , Will Deacon , Catalin Marinas , Ralf Baechle , "David S. Miller" , "Aneesh Kumar K . V" , Martin Schwidefsky , Heiko Carstens , linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org On Fri, Jun 16, 2017 at 03:40:41PM +0200, Andrea Arcangeli wrote: > On Thu, Jun 15, 2017 at 05:52:23PM +0300, Kirill A. Shutemov wrote: > > -void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, > > +pmd_t pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, > > pmd_t *pmdp) > > { > > - pmd_t entry = *pmdp; > > - set_pmd_at(vma->vm_mm, address, pmdp, pmd_mknotpresent(entry)); > > - flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE); > > + pmd_t old = pmdp_establish(pmdp, pmd_mknotpresent(*pmdp)); > > + if (pmd_present(old)) > > + flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE); > > + return old; > > } > > #endif > > The pmd_present() check added above is superflous because there's no > point to call pmdp_invalidate if the pmd is not present (present as in > pmd_present) already. pmd_present returns true if _PAGE_PSE is set > and it was always set before calling pmdp_invalidate. > > It looks like we could skip the flush if _PAGE_PRESENT is not set > (i.e. for example if the pmd is PROTNONE) but that's not what the above > pmd_present will do. You are right. We seems don't have a generic way to check the entry is present to CPU. I guess I'll drop the check then. -- Kirill A. Shutemov -- 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: email@kvack.org