> Peng Du <imdup...@gmail.com> wrote:
> 
> > Hello, experts
> >
> > I have a question about syscall "madvise"
> (http://docs.sun.com/app/docs/doc/816-5168/madvise-3c?
> a=view). I want to know whether MADV_WILLNEED  and
> MADV_DONTNEED will affect pageout decisions. In my
> intuition, page scanner should try to keep
> MADV_WILLNEED pages in physical memory, and prefer
> MADV_DONTNEED pages for swapping out. 
> 
> I tried to use this 10 years ago in order to make
> star faster to no avail.
> I would like to see a way to tell Solaris to do read
> aheads but to remove 
> anything from the cache after it was read once.

As I'd said, I've seen MADV_DONTNEED work, at least in some situations.

But I think you'd have to look at the kernel code keeping in mind just how
you were trying to use MADV_DONTNEED.  Or do a search of opensolaris.org
for MADV_DONTNEED or perhaps MADV_SEQUENTIAL, to see how other programs
use them.

For example, I think they will _not_ behave as expected if applied to the 
buffer passed
to read(2), but only to pages of memory obtained from mmap(2).  That would be 
because read(2) does not necessarily read directly into your buffer, but rather 
pages in
enough pages of the file (if mmap-able rather than a STREAMS device or pipe
or somesuch) and copies from the mapped in pages to your buffer.  Pages in your
read() buffer are probably part of stack or heap (anonymous memory) or private
mapping of your data segment, in which case they're also backed by swap rather 
than
by the file you're reading.

(Maybe if one were using directio(3c) in a situation where it was supported, and
read()ing into a page-multiple-sized, page-aligned buffer, it might work to use
madvise() directly on that buffer;  I haven't investigated that.)

(I'm not saying that you made that particular mistake; I'm only saying that 
it's not
always as obvious as one might like just how madvise(3c)/memcntl(2) actually
work.)
-- 
This message posted from opensolaris.org
_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to