Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1739662
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [RFC] a question about mlockall() and mprotect() |
| Date | 2017-09-26 10:20 +0200 |
| Message-ID | <utTfY-29X-23@gated-at.bofh.it> (permalink) |
| References | <utSWD-1N5-43@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Tue 26-09-17 15:56:55, Xishi Qiu wrote:
> When we call mlockall(), we will add VM_LOCKED to the vma,
> if the vma prot is ---p,
not sure what you mean here. apply_mlockall_flags will set the flag on
all vmas except for special mappings (mlock_fixup). This phase will
cause that memory reclaim will not free already mapped pages in those
vmas (see page_check_references and the lazy mlock pages move to
unevictable LRUs).
> then mm_populate -> get_user_pages will not alloc memory.
mm_populate all the vmas with pages. Well there are certainly some
constrains - e.g. memory cgroup hard limit might be hit and so the
faulting might fail.
> 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);
> }
But we do not report the failure because any failure past
apply_mlockall_flags would be tricky to handle. We have already dropped
the mmap_sem lock so some other address space operations could have
interfered.
> 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?
I do not understand your question but if you are asking how to get pages
to map your vmas then touching that area will fault the memory in.
--
Michal Hocko
SUSE Labs
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC] a question about mlockall() and mprotect() Xishi Qiu <qiuxishi@huawei.com> - 2017-09-26 10:00 +0200
Re: [RFC] a question about mlockall() and mprotect() Michal Hocko <mhocko@kernel.org> - 2017-09-26 10:20 +0200
Re: [RFC] a question about mlockall() and mprotect() Xishi Qiu <qiuxishi@huawei.com> - 2017-09-26 10:50 +0200
Re: [RFC] a question about mlockall() and mprotect() Michal Hocko <mhocko@kernel.org> - 2017-09-26 11:10 +0200
Re: [RFC] a question about mlockall() and mprotect() Xishi Qiu <qiuxishi@huawei.com> - 2017-09-26 11:20 +0200
Re: [RFC] a question about mlockall() and mprotect() Michal Hocko <mhocko@kernel.org> - 2017-09-26 11:30 +0200
Re: [RFC] a question about mlockall() and mprotect() Xishi Qiu <qiuxishi@huawei.com> - 2017-09-26 11:30 +0200
Re: [RFC] a question about mlockall() and mprotect() Vlastimil Babka <vbabka@suse.cz> - 2017-09-26 11:50 +0200
Re: [RFC] a question about mlockall() and mprotect() Michal Hocko <mhocko@kernel.org> - 2017-09-26 13:10 +0200
Re: [RFC] a question about mlockall() and mprotect() Xishi Qiu <qiuxishi@huawei.com> - 2017-09-27 08:00 +0200
csiph-web