2001-10-10 07:28:44

by Stefan Hoffmeister

[permalink] [raw]
Subject: madvise(MADV_WILLNEED) not for anonymous memory?


Hi,

Looking at the 2.4.10.SuSE-3 kernel sources, it seems as if the madvise
system call with MADV_WILLNEED does not support anonymous memory:

mm/filemap.c:

static long madvise_willneed(struct vm_area_struct * vma,
unsigned long start, unsigned long end)
{
long error = -EBADF;
struct file * file;
unsigned long size, rlim_rss;
loff_t rsize;

/* Doesn't work if there's no mapped file. */
if (!vma->vm_file)
return error;

FWIW, MADV_DONTNEED (madvise_dontneed) will happily call zap_page_range
without testing for file backing.

Is there a (less intuitive) way to give the VM a hint that the data of a
mmap'ed region (e.g. "stuff that may have been swapped out") is going to
be needed?

I realize, BTW, that despite the naming DONTNEED and WILLNEED are not
orthogonal (DONTNEED according to the comment in filemap.c will
"destroy" data).