From: Jamie Lokier <lk@tantalophile.demon.co.uk>
To: Chuck Lever <cel@monkey.org>
Cc: linux-mm@kvack.org
Subject: /dev/recycle
Date: Fri, 24 Mar 2000 01:00:31 +0100 [thread overview]
Message-ID: <20000324010031.B20140@pcep-jamie.cern.ch> (raw)
In-Reply-To: <Pine.BSO.4.10.10003231332080.20600-100000@funky.monkey.org>; from Chuck Lever on Thu, Mar 23, 2000 at 01:53:22PM -0500
This discussion needs to split into two: one about memory allocators
responding to overall system memory pressure, and another about
applications cacheing recomputable objects, which also want to respond
to system memory pressure.pa
The issues are different and the requirements are different.
Perhaps trying to use the name MADV_FREE to cover them both is just
confusing.
For the record, I'm going to talk about memory allocators, and the
subject has changed to reflect that.
So hi Chuck! I've thought of something maybe better than MADV_FREE for
memory allocators. It's neat, it's simple, it's cute... But first I'll
explain MADV_FREE a bit more.
Chuck Lever wrote:
> > MADV_FREE only discards private modifications when there is paging
> > pressure to do so. The decisions to do so are deferred, for
> > architectures that support this. (Includes x86).
>
> i still don't see a big difference. the private modifications, in both
> cases, won't be written to swap. in both cases, the application cannot
> rely on the contents of these pages after the madvise call.
Correct. The difference is that with MADV_FREE, clear_page() operations
are skipped when there's no memory pressure from the kernel.
> for private mappings, pages are freed immediately by DONTNEED; FREE will
> cause the pages to be freed later if the system is low on memory. that's
> six of one, half dozen of the other. freeing later may mean the
> application saves a little time now,
It may save the time overall -- if the page is next reused by the
application before the kernel recycles it. Note that nobody, neither
the application nor the kernel, knows in advance if this will be the
case.
> but freeing immediately could mean postponing a low memory scenario,
> and would allow the system to reuse a page that is still in hardware
> caches.
The system is free to reuse MADV_FREE pages immediately if it wishes --
the system doesn't lose here. In fact if you're already low on memory
at the time madvise() is called, the kernel would reclaim as many pages
as it needs immediately, just as if you'd called MADV_DONTNEED for those
pages. The remainder get marked reclaimable.
Look at it from the point of view of an application writer. Why would I
ever call MADV_DONTNEED for anything but large memory areas? It
penalises my application on systems that aren't swapping.. (Though
MADV_FREE is also a penalty, but a smaller one).
> but you said before that the number of small dynamically allocated objects
> dwarfs the number of large objects. so either there is a problem here, or
> there isn't! :)
We're talking about free areas, not objects :-) Think of the kernel,
specifically only the memory managed by kmalloc/slab. It handles lots
of small allocations, but nevertheless produces free pages which the
kernel can use when there's memory pressure.
But anyway...
Better than MADV_FREE: /dev/recycle
--------------------------------------------------
What about this whacky idea?
MAP_RECYCLE|MAP_ANON initially allocates pages like MAP_ANON. Mapping
/dev/recycle is similar (but subtly different).
MADV_DONTNEED or munmap discard private modifications, but record this
process as the page owner. If the process later accesses the page, a
page is allocated again but the MAP_RECYCLE means it may return a page
already marked as belonging to this process without clearing it.
That's better for app allocators than MADV_FREE: they're giving the
kernel more freedom with not much loss in performance. And the kernel
likes this too -- no need for vmscan to release references, as the pages
are free already.
-- Jamie
--
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.eu.org/Linux-MM/
next prev parent reply other threads:[~2000-03-24 0:00 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20000320135939.A3390@pcep-jamie.cern.ch>
2000-03-20 19:09 ` MADV_SPACEAVAIL and MADV_FREE in pre2-3 Chuck Lever
2000-03-21 1:20 ` madvise (MADV_FREE) Jamie Lokier
2000-03-21 2:24 ` William J. Earl
2000-03-21 14:08 ` Jamie Lokier
2000-03-22 16:24 ` Chuck Lever
2000-03-22 18:05 ` Jamie Lokier
2000-03-22 21:39 ` Chuck Lever
2000-03-22 22:31 ` Jamie Lokier
2000-03-22 22:44 ` Stephen C. Tweedie
2000-03-23 18:53 ` Chuck Lever
2000-03-24 0:00 ` Jamie Lokier [this message]
2000-03-24 9:14 ` /dev/recycle Christoph Rohland
2000-03-24 13:10 ` /dev/recycle Jamie Lokier
2000-03-24 13:54 ` /dev/recycle Christoph Rohland
2000-03-24 14:17 ` /dev/recycle Jamie Lokier
2000-03-24 17:40 ` /dev/recycle Christoph Rohland
2000-03-24 18:13 ` /dev/recycle Jamie Lokier
2000-03-25 8:35 ` /dev/recycle Christoph Rohland
2000-03-28 0:48 ` /dev/recycle Chuck Lever
2000-03-24 0:21 ` madvise (MADV_FREE) Jamie Lokier
2000-03-24 7:21 ` lars brinkhoff
2000-03-24 17:42 ` Jeff Dike
2000-03-24 16:49 ` Jamie Lokier
2000-03-24 17:08 ` Stephen C. Tweedie
2000-03-24 19:58 ` Jeff Dike
2000-03-25 0:30 ` Stephen C. Tweedie
2000-03-22 22:33 ` Stephen C. Tweedie
2000-03-22 22:45 ` Jamie Lokier
2000-03-22 22:48 ` Stephen C. Tweedie
2000-03-22 22:55 ` Q. about swap-cache orphans Jamie Lokier
2000-03-22 22:58 ` Stephen C. Tweedie
2000-03-22 18:15 ` madvise (MADV_FREE) Christoph Rohland
2000-03-22 18:30 ` Jamie Lokier
2000-03-23 16:56 ` Christoph Rohland
2000-03-21 1:29 ` MADV_DONTNEED Jamie Lokier
2000-03-22 17:04 ` MADV_DONTNEED Chuck Lever
2000-03-22 17:10 ` MADV_DONTNEED Stephen C. Tweedie
2000-03-22 17:32 ` MADV_DONTNEED Jamie Lokier
2000-03-22 17:33 ` MADV_DONTNEED Jamie Lokier
2000-03-22 17:37 ` MADV_DONTNEED Stephen C. Tweedie
2000-03-22 17:43 ` MADV_DONTNEED Jamie Lokier
2000-03-22 21:54 ` MADV_DONTNEED Chuck Lever
2000-03-22 22:41 ` MADV_DONTNEED Jamie Lokier
2000-03-23 19:13 ` MADV_DONTNEED James Antill
2000-03-21 1:47 ` Extensions to mincore Jamie Lokier
2000-03-21 9:11 ` Eric W. Biederman
2000-03-21 9:40 ` lars brinkhoff
2000-03-21 11:34 ` Stephen C. Tweedie
2000-03-21 15:15 ` Jamie Lokier
2000-03-21 15:41 ` Stephen C. Tweedie
2000-03-21 15:55 ` Jamie Lokier
2000-03-21 16:08 ` Stephen C. Tweedie
2000-03-21 16:48 ` Jamie Lokier
2000-03-22 7:36 ` Eric W. Biederman
2000-03-21 1:50 ` MADV flags as mmap options Jamie Lokier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20000324010031.B20140@pcep-jamie.cern.ch \
--to=lk@tantalophile.demon.co.uk \
--cc=cel@monkey.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox