From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755730AbdJJBYX (ORCPT ); Mon, 9 Oct 2017 21:24:23 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7531 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754079AbdJJBYW (ORCPT ); Mon, 9 Oct 2017 21:24:22 -0400 Message-ID: <59DC20CC.1030509@huawei.com> Date: Tue, 10 Oct 2017 09:22:20 +0800 From: Xishi Qiu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Michal Hocko CC: Vlastimil Babka , Joonsoo Kim , Mel Gorman , Linux MM , LKML , zhong jiang , yeyunfeng , , "Zhoukang (A)" Subject: Re: [RFC] a question about mlockall() and mprotect() References: <59CA0847.8000508@huawei.com> <20170926081716.xo375arjoyu5ytcb@dhcp22.suse.cz> <59CA125C.8000801@huawei.com> <20170926090255.jmocezs6s3lpd6p4@dhcp22.suse.cz> <59CA1A57.5000905@huawei.com> <59CA1C6E.4010501@huawei.com> <6b38ed08-62cb-97b1-9f16-1fd8e272b137@suse.cz> <20170926110012.jiw6plglsyksj5mc@dhcp22.suse.cz> <59CB3C4D.9090609@huawei.com> <20171009182656.ynu7tdzb5uwp5xnr@dhcp22.suse.cz> In-Reply-To: <20171009182656.ynu7tdzb5uwp5xnr@dhcp22.suse.cz> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.25.179] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090206.59DC2142.0073,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 680568639d747f2a0e3590340e04255b Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017/10/10 2:26, Michal Hocko wrote: > On Wed 27-09-17 13:51:09, Xishi Qiu wrote: >> On 2017/9/26 19:00, Michal Hocko wrote: >> >>> On Tue 26-09-17 11:45:16, Vlastimil Babka wrote: >>>> On 09/26/2017 11:22 AM, Xishi Qiu wrote: >>>>> On 2017/9/26 17:13, Xishi Qiu wrote: >>>>>>> This is still very fuzzy. What are you actually trying to achieve? >>>>>> >>>>>> I don't expect page fault any more after mlock. >>>>>> >>>>> >>>>> Our apps is some thing like RT, and page-fault maybe cause a lot of time, >>>>> e.g. lock, mem reclaim ..., so I use mlock and don't want page fault >>>>> any more. >>>> >>>> Why does your app then have restricted mprotect when calling mlockall() >>>> and only later adjusts the mprotect? >>> >>> Ahh, OK I see what is goging on. So you have PROT_NONE vma at the time >>> mlockall and then later mprotect it something else and want to fault all >>> that memory at the mprotect time? >>> >>> So basically to do >>> --- >>> diff --git a/mm/mprotect.c b/mm/mprotect.c >>> index 6d3e2f082290..b665b5d1c544 100644 >>> --- a/mm/mprotect.c >>> +++ b/mm/mprotect.c >>> @@ -369,7 +369,7 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev, >>> * Private VM_LOCKED VMA becoming writable: trigger COW to avoid major >>> * fault on access. >>> */ >>> - if ((oldflags & (VM_WRITE | VM_SHARED | VM_LOCKED)) == VM_LOCKED && >>> + if ((oldflags & (VM_WRITE | VM_LOCKED)) == VM_LOCKED && >>> (newflags & VM_WRITE)) { >>> populate_vma_page_range(vma, start, end, NULL); >>> } >>> >> >> Hi Michal, >> >> My kernel is v3.10, and I missed this code, thank you reminding me. > > I guess I didn't get your answer. Does the above diff resolves your > problem? Hi Michal, This upstream patch 36f881883c57941bb32d25cea6524f9612ab5a2c has already resolve my problem, thank you for your attention. Thanks, Xishi Qiu