Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753765AbdFPNkq (ORCPT ); Fri, 16 Jun 2017 09:40:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40286 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753593AbdFPNko (ORCPT ); Fri, 16 Jun 2017 09:40:44 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 90F7D97850 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=aarcange@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 90F7D97850 Date: Fri, 16 Jun 2017 15:40:41 +0200 From: Andrea Arcangeli To: "Kirill A. Shutemov" Cc: 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: <20170616134041.GF11676@redhat.com> References: <20170615145224.66200-1-kirill.shutemov@linux.intel.com> <20170615145224.66200-3-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170615145224.66200-3-kirill.shutemov@linux.intel.com> User-Agent: Mutt/1.8.3 (2017-05-23) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 16 Jun 2017 13:40:44 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1013 Lines: 23 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.