madvise(MADV_WILLNEED) not for anonymous memory?

From: Stefan Hoffmeister (
Date: Wed Oct 10 2001 - 02:29:06 EST


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:


  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
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Mon Oct 15 2001 - 21:00:30 EST