Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753964AbaBSP2n (ORCPT ); Wed, 19 Feb 2014 10:28:43 -0500 Received: from mail-lb0-f171.google.com ([209.85.217.171]:48057 "EHLO mail-lb0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753804AbaBSP2l (ORCPT ); Wed, 19 Feb 2014 10:28:41 -0500 MIME-Version: 1.0 Date: Wed, 19 Feb 2014 10:28:40 -0500 Message-ID: Subject: How pte_mkspecial makes zero-page COW on x86 ARCH From: Hu Yaohui To: "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi All, I read the code in do_anonymous_page of the latest linux kernel. I am pretty confused how pte_mkspecial to make the zero-page COW on x86 architecture static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long address, pte_t *page_table, pmd_t *pmd, unsigned int flags) { ..... /* Use the zero-page for reads */ if (!(flags & FAULT_FLAG_WRITE)) { entry = pte_mkspecial(pfn_pte(my_zero_pfn(address), vma->vm_page_prot)); page_table = pte_offset_map_lock(mm, pmd, address, &ptl); if (!pte_none(*page_table)) goto unlock; goto setpte; } ...... } In the previous linux kernel, this is done by pte_wrprotect to make page COW. Thanks for your time! Best Wishes, Yaohui -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/