From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756350Ab2IDIsx (ORCPT ); Tue, 4 Sep 2012 04:48:53 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:49154 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754124Ab2IDIsw (ORCPT ); Tue, 4 Sep 2012 04:48:52 -0400 Message-ID: <5045C06F.4000507@gmail.com> Date: Tue, 04 Sep 2012 16:48:47 +0800 From: Cong Wang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: Jiri Kosina CC: Xin Tong , linux-kernel Subject: Re: linux page table References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/03/2012 02:26 AM, Jiri Kosina wrote: > On Sun, 2 Sep 2012, Xin Tong wrote: > >>>> 3. can two different processes have their CR3 being the same value >>>> even though they have different first level page tables ? >>> >>> Yes, if they are created by clone(CLONE_VM). In such case they share the >>> same mm_struct, and therefore mm_struct->pgd (which is exactly what is >>> loaded into cr3 in switch_mm()) is the same. >>> >> >> Is this the COW mechanism in linux. what if the cloned process need to >> have set of its own pages later. do the CR3s for the 2 processes >> become different at that point ? > > That is a different story. COW is applied on fork() (i.e. spawning new > process), not on clone(CLONE_VM) (i.e. spawning new thread). > Yeah, and unshare(2) does not implement the flag that reverses the effects of CLONE_VM.