[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: When should ralloc.c be used?
From: |
Eli Zaretskii |
Subject: |
Re: When should ralloc.c be used? |
Date: |
Fri, 28 Oct 2016 11:27:44 +0300 |
> Cc: address@hidden, address@hidden, address@hidden
> From: Daniel Colascione <address@hidden>
> Date: Fri, 28 Oct 2016 01:11:08 -0700
>
> Say I mmap (anonymously, for simplicity) a page PROT_NONE. After the
> initial mapping, that address space is unavailable for other uses. But
> because the page protections are PROT_NONE, my program has no legal
> right to access that page, so the OS doesn't have to guarantee that it
> can find a physical page to back that page I've mmaped. In this state,
> the memory is reserved.
>
> The 20GB PROT_NONE address space reservation itself requires very little
> memory. It's just a note in the kernel's VM interval tree that says "the
> addresses in range [0x20000, 0x500020000) are reserved". Virtual memory is
>
> Now imagine I change the protections to PROT_READ|PROT_WRITE --- once
> the PROT_READ|PROT_WRITE mprotect succeeds, my program has every right
> to access that page; under a strict accounting scheme (that is, without
> overcommit), the OS has to guarantee that it'll be able to go find a
> physical page to back that virtual page. In this state, the memory is
> committed -- the kernel has committed to finding backing storage for
> that page at some point when the current process tries to access it.
I'm with you up to here. My question is whether PROT_READ|PROT_WRITE
call could fail after PROT_NONE succeeded. You seem to say it could;
I thought it couldn't.
> Say you have a strict-accounting system with 1GB of RAM and 1GB of swap.
> I can write a program that reserves 20GB of address space.
I thought such a reservation should fail, because you don't have
enough virtual memory for 20GB of addresses. IOW, I thought the
ability to reserve address space is restricted by the actual amount of
virtual memory available on the system at the time of the call. You
seem to say I was wrong.
- Re: When should ralloc.c be used?, (continued)
- Re: When should ralloc.c be used?, Daniel Colascione, 2016/10/24
- Re: When should ralloc.c be used?, Eli Zaretskii, 2016/10/24
- Re: When should ralloc.c be used?, Richard Stallman, 2016/10/24
- Re: When should ralloc.c be used?, Stefan Monnier, 2016/10/25
- Re: When should ralloc.c be used?, Stefan Monnier, 2016/10/25
- Re: When should ralloc.c be used?, Jérémie Courrèges-Anglas, 2016/10/28
- Re: When should ralloc.c be used?, Daniel Colascione, 2016/10/28
- Re: When should ralloc.c be used?, Jérémie Courrèges-Anglas, 2016/10/28
- Re: When should ralloc.c be used?, Eli Zaretskii, 2016/10/28
- Re: When should ralloc.c be used?, Daniel Colascione, 2016/10/28
- Re: When should ralloc.c be used?,
Eli Zaretskii <=
- Re: When should ralloc.c be used?, Daniel Colascione, 2016/10/28
- Re: When should ralloc.c be used?, Eli Zaretskii, 2016/10/28
- Re: When should ralloc.c be used?, Daniel Colascione, 2016/10/28
- Re: When should ralloc.c be used?, Eli Zaretskii, 2016/10/28
- Re: When should ralloc.c be used?, Stefan Monnier, 2016/10/28
- Re: When should ralloc.c be used?, Eli Zaretskii, 2016/10/28
- Re: When should ralloc.c be used?, Stefan Monnier, 2016/10/28
- Re: When should ralloc.c be used?, Daniel Colascione, 2016/10/28
- Re: When should ralloc.c be used?, Eli Zaretskii, 2016/10/29
- Re: When should ralloc.c be used?, Daniel Colascione, 2016/10/29