kernels/linux-2.4.0/mm/filemap.c
/*
 * Application no longer needs these pages.  If the pages are dirty,
 * it's OK to just throw them away.  The app will be more careful about
 * data it wants to keep.  Be sure to free swap resources too.  The
 * zap_page_range call sets things up for refill_inactive to actually free
 * these pages later if no one else has touched them in the meantime,
 * although we could add these pages to a global reuse list for
 * refill_inactive to pick up before reclaiming other pages.
 *
 * NB: This interface discards data rather than pushes it out to swap,
 * as some implementations do.  This has performance implications for
 * applications like large transactional databases which want to discard
 * pages in anonymous maps after committing to backing store the data
 * that was kept in them.  There is no reason to write this data out to
 * the swap area if the application is discarding it.
 *
 * An interface that causes the system to free clean pages and flush
 * dirty pages is already available as msync(MS_INVALIDATE).
 */
Application no longer needs these pages.  If the pages are dirty,
it's OK to just throw them away.  The app will be more careful about
data it wants to keep.  Be sure to free swap resources too.  The
zap_page_range call sets things up for refill_inactive to actually free
these pages later if no one else has touched them in the meantime,
although we could add these pages to a global reuse list for
refill_inactive to pick up before reclaiming other pages.

This interface discards data rather than pushes it out to swap,
as some implementations do.  This has performance implications for
applications like large transactional databases which want to discard
pages in anonymous maps after committing to backing store the data
that was kept in them.  There is no reason to write this data out to
the swap area if the application is discarding it.

An interface that causes the system to free clean pages and flush
dirty pages is already available as msync(MS_INVALIDATE).
Application no longer needs these pages . If the pages are dirty it ' s OK to just throw them away . The app will be more careful about data it wants to keep . Be sure to free swap resources too . The zap_page_range call sets things up for refill_inactive to actually free these pages later if no one else has touched them in the meantime although we could add these pages to a global reuse list for refill_inactive to pick up before reclaiming other pages . This interface discards data rather than pushes it out to swap as some implementations do . This has performance implications for applications like large transactional databases which want to discard pages in anonymous maps after committing to backing store the data that was kept in them . There is no reason to write this data out to the swap area if the application is discarding it . An interface that causes the system to free clean pages and flush dirty pages is already available as msync ( MS_INVALIDATE ) .
static long madvise_dontneed(struct vm_area_struct * vma,
	unsigned long start, unsigned long end)
{
	if (vma->vm_flags & VM_LOCKED)
		return -EINVAL;
	flush_cache_range(vma->vm_mm, start, end);
	zap_page_range(vma->vm_mm, start, end - start);
	flush_tlb_range(vma->vm_mm, start, end);
	return 0;
}
static long madvise_dontneed ( struct vm_area_struct * vma , unsigned long start , unsigned long end ) { if ( vma -> vm_flags & VM_LOCKED ) return - EINVAL ; flush_cache_range ( vma -> vm_mm , start , end ) ; zap_page_range ( vma -> vm_mm , start , end - start ) ; flush_tlb_range ( vma -> vm_mm , start , end ) ; return 0 ; }
Application no longer needs these pages.
Application no longer needs these pages .