Skip to contentSkip to conversation

Interesting VM feature?

DISCUSSION [email protected] 5 participants 5 messages Aug 15, 2003 – Aug 21, 2003

lore
Share & tools
lore
#0 lore raw
Quoted 2 lines · Jamie Lokier

You can call madvise(start, length, MADV_DONTNEED), or you can mmap() fresh empty pages into the region.

madvise appears to be exactly what I'm looking for. (almost...)

Quoted 1 line

I have no idea if either of these methods is

efficient enough to be

Quoted 1 line

useful. Also, I don't know whether mmap() would

create multiple VMAs,

Quoted 1 line

or if it is clever enough to merge adjacent vmas

of anonymous private

Quoted 1 line

mappings regardles of offset.

Enough possible pitfalls that madvise becomes the
better solution.

Quoted 1 line

The ideal implementation would give the kernel the

_option_ of

Quoted 1 line

discarding pages until they are next touched, so

that they are

Quoted 1 line

discarded when there is memory pressure but

retained if not, avoiding

Quoted 1 line

the unnecessary zero-fill and cache flush.

Is madvise required to result in zero filled pages by a standard, or is this just the commonly accepted behavior?

Quoted 1 line

-- Jamie

Thanks a bunch,
Ted

#1 lore raw
Quoted 3 lines · On Fri, Aug 15, 2003 at 02:56:02PM -0500, [email protected] wrote:

Is madvise required to result in zero filled pages by a standard, or is this just the commonly accepted behavior?

I believe it is the standard for clean pages, though someone else will have to point out where...

#2 lore raw
Quoted 7 lines · Mike Fedyk
Quoted 3 lines · On Fri, Aug 15, 2003 at 02:56:02PM -0500, [email protected] wrote:

Is madvise required to result in zero filled pages by a standard, or is this just the commonly accepted behavior?

I believe it is the standard for clean pages, though someone else will have to point out where...

That's the answer to a different question.

The unanswered question is: what should madvise(MADV_DONTNEED) do, given dirty pages?

man madvise(*) says that it zero-fills anonymous private mappings, and restores private file-backed mappings to the original file pages.

That is not surprising, as the CPU-friendly semantic is more complicated to implement, needing an extra flag in the page table (or rmap structure).

-- Jamie

#3 lore raw
Followup to:  <[email protected]>
By author:    Jamie Lokier <[email protected]>
In newsgroup: linux.dev.kernel
Quoted 15 lines
Quoted 7 lines · Mike Fedyk
Quoted 3 lines · On Fri, Aug 15, 2003 at 02:56:02PM -0500, [email protected] wrote:

Is madvise required to result in zero filled pages by a standard, or is this just the commonly accepted behavior?

I believe it is the standard for clean pages, though someone else will have to point out where...

That's the answer to a different question.

The unanswered question is: what should madvise(MADV_DONTNEED) do, given dirty pages?

Quoted 7 lines

man madvise(*) says that it zero-fills anonymous private mappings, and restores private file-backed mappings to the original file pages.

That is not surprising, as the CPU-friendly semantic is more complicated to implement, needing an extra flag in the page table (or rmap structure).

Sounds entirely reasonable.

It *would* be nice with a way to be able to say to the kernel "you may discard this but if so I want SIGSEGV", for things like LPSM and the like.

-hpa

Signature · 4 lines
<[email protected]> at work, <[email protected]> in private!
If you send me mail in HTML format I will assume it's spam.
"Unix gives you enough rope to shoot yourself in the foot."
Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64
#4 lore raw
Quoted 3 lines · [email protected] said:

It *would* be nice with a way to be able to say to the kernel "you may discard this but if so I want SIGSEGV", for things like LPSM and the like.

Yeah, UML could put this to good use, as well...

Jeff