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@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>