madvise(MADV_WILLNEED) not for anonymous memory?

Stefan Hoffmeister (lkml.2001@econos.de)
Wed, 10 Oct 2001 09:29:06 +0200


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).
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/