From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Kirill A. Shutemov" Subject: Re: [PATCH 1/3] mm: New pfn_mkwrite same as page_mkwrite for VM_PFNMAP Date: Wed, 25 Mar 2015 17:13:54 +0200 Message-ID: <20150325151354.GA12387@node.dhcp.inet.fi> References: <5512B961.8070409@plexistor.com> <5512BA5D.8070609@plexistor.com> <5512CF68.5040509@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Boaz Harrosh , Dave Chinner , Matthew Wilcox , Andrew Morton , "Kirill A. Shutemov" , Jan Kara , Hugh Dickins , Mel Gorman , linux-mm@kvack.org, linux-nvdimm , linux-fsdevel , Eryu Guan To: Dave Hansen Return-path: Content-Disposition: inline In-Reply-To: <5512CF68.5040509@intel.com> Sender: owner-linux-mm@kvack.org List-Id: linux-fsdevel.vger.kernel.org On Wed, Mar 25, 2015 at 08:08:24AM -0700, Dave Hansen wrote: > On 03/25/2015 06:38 AM, Boaz Harrosh wrote: > > /* > > * This routine handles present pages, when users try to write > > * to a shared page. It is done by copying the page to a new address > > @@ -2025,8 +2042,17 @@ static int do_wp_page(struct mm_struct *mm, struct vm_area_struct *vma, > > * accounting on raw pfn maps. > > */ > > if ((vma->vm_flags & (VM_WRITE|VM_SHARED)) == > > - (VM_WRITE|VM_SHARED)) > > + (VM_WRITE|VM_SHARED)) { > > + pte_unmap_unlock(page_table, ptl); > > + ret = do_pfn_mkwrite(vma, address); > > + if (ret & VM_FAULT_ERROR) > > + return ret; > > + page_table = pte_offset_map_lock(mm, pmd, address, > > + &ptl); > > + if (!pte_same(*page_table, orig_pte)) > > + goto unlock; > > goto reuse; > > + } > > goto gotten; > > } > > This adds a lock release/reacquire in a place where the lock was > previously just held. Could you explain a bit why this is safe? It's common practice in page fault codepath. See code around ->page_mkwrite for example. > > Also, that pte_same() check looks a bit fragile. It seems like it would > fail if the hardware, for instance, set the accessed bit in here > somewhere. Is that what we want? In this case we will cancel this fault handling and fault again. No problems here. -- 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