From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932147AbcBPPaG (ORCPT ); Tue, 16 Feb 2016 10:30:06 -0500 Received: from mga01.intel.com ([192.55.52.88]:21605 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751730AbcBPPaE (ORCPT ); Tue, 16 Feb 2016 10:30:04 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,455,1449561600"; d="scan'208";a="916069353" Subject: Re: [PATCHv2 04/28] mm: make remove_migration_ptes() beyond mm/migration.c To: "Kirill A. Shutemov" References: <1455200516-132137-1-git-send-email-kirill.shutemov@linux.intel.com> <1455200516-132137-5-git-send-email-kirill.shutemov@linux.intel.com> <56BE0E62.60806@intel.com> <20160216095428.GB46557@black.fi.intel.com> Cc: Hugh Dickins , Andrea Arcangeli , Andrew Morton , Vlastimil Babka , Christoph Lameter , Naoya Horiguchi , Jerome Marchand , Yang Shi , Sasha Levin , linux-kernel@vger.kernel.org, linux-mm@kvack.org From: Dave Hansen Message-ID: <56C34073.6010208@intel.com> Date: Tue, 16 Feb 2016 07:29:55 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20160216095428.GB46557@black.fi.intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/16/2016 01:54 AM, Kirill A. Shutemov wrote: > On Fri, Feb 12, 2016 at 08:54:58AM -0800, Dave Hansen wrote: >> On 02/11/2016 06:21 AM, Kirill A. Shutemov wrote >>> We also shouldn't try to mlock() pte-mapped huge pages: pte-mapeed THP >>> pages are never mlocked. >> >> That's kinda subtle. Can you explain more? >> >> If we did the following: >> >> ptr = mmap(NULL, 512*PAGE_SIZE, ...); >> mlock(ptr, 512*PAGE_SIZE); >> fork(); >> munmap(ptr + 100 * PAGE_SIZE, PAGE_SIZE); >> >> I'd expect to get two processes, each mapping the same compound THP, one >> with a PMD and the other with 511 ptes and one hole. Is there something >> different that goes on? > > I'm not sure what exactly you want to ask with this code, but it will have > the following result: > > - After fork() process will split the pmd in munlock(). For file thp > split pmd, means clear it out. Mapping split_huge_pmd() would munlock > the page as we do for anon thp; > > - In child process the page is never mapped as mlock() is not inherited > and we don't copy page tables for shared VMA as they can re-faulted > later; Huh, I didn't realize we don't inherit mlock() across fork(). Learn something every day! > The basic semantic for mlock()ed file THP would be the same as for anon > THP: we only keep the page mlocked as long as it's mapped only with PMDs. > This way it's relatively simple to make sure that we don't leak mlocked > pages. Ahh, I forgot about that bit. Could you add some of that description to the changelog so I don't forget again?