From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f70.google.com (mail-oi0-f70.google.com [209.85.218.70]) by kanga.kvack.org (Postfix) with ESMTP id 387E46B0038 for ; Tue, 26 Sep 2017 04:00:23 -0400 (EDT) Received: by mail-oi0-f70.google.com with SMTP id x85so11727844oix.3 for ; Tue, 26 Sep 2017 01:00:23 -0700 (PDT) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com. [45.249.212.190]) by mx.google.com with ESMTPS id j41si506913otb.154.2017.09.26.01.00.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 26 Sep 2017 01:00:22 -0700 (PDT) Message-ID: <59CA0847.8000508@huawei.com> Date: Tue, 26 Sep 2017 15:56:55 +0800 From: Xishi Qiu MIME-Version: 1.0 Subject: [RFC] a question about mlockall() and mprotect() Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko , Joonsoo Kim , Vlastimil Babka , Mel Gorman Cc: Linux MM , LKML , zhong jiang , yeyunfeng , wanghaitao12@huawei.com, "Zhoukang (A)" When we call mlockall(), we will add VM_LOCKED to the vma, if the vma prot is ---p, then mm_populate -> get_user_pages will not alloc memory. I find it said "ignore errors" in mm_populate() static inline void mm_populate(unsigned long addr, unsigned long len) { /* Ignore errors */ (void) __mm_populate(addr, len, 1); } And later we call mprotect() to change the prot, then it is still not alloc memory for the mlocked vma. My question is that, shall we alloc memory if the prot changed, and who(kernel, glibc, user) should alloc the memory? Thanks, Xishi Qiu -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967830AbdIZH5N (ORCPT ); Tue, 26 Sep 2017 03:57:13 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7000 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965054AbdIZH5J (ORCPT ); Tue, 26 Sep 2017 03:57:09 -0400 Message-ID: <59CA0847.8000508@huawei.com> Date: Tue, 26 Sep 2017 15:56:55 +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 , Joonsoo Kim , Vlastimil Babka , Mel Gorman CC: Linux MM , LKML , "zhong jiang" , yeyunfeng , , "Zhoukang (A)" Subject: [RFC] a question about mlockall() and mprotect() 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.0A0B0201.59CA0852.00CE,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: 35cfd41902834122c240ba04c19bde73 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When we call mlockall(), we will add VM_LOCKED to the vma, if the vma prot is ---p, then mm_populate -> get_user_pages will not alloc memory. I find it said "ignore errors" in mm_populate() static inline void mm_populate(unsigned long addr, unsigned long len) { /* Ignore errors */ (void) __mm_populate(addr, len, 1); } And later we call mprotect() to change the prot, then it is still not alloc memory for the mlocked vma. My question is that, shall we alloc memory if the prot changed, and who(kernel, glibc, user) should alloc the memory? Thanks, Xishi Qiu