/fs/reiserfs/

tion> The LITMUS^RT kernel.Bjoern Brandenburg
aboutsummaryrefslogblamecommitdiffstats
path: root/mm/madvise.c
blob: 93ee375b38e7edc7b414b7a2b6891411a45d0b0c (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                                        
                            
                          
                        

  

















                                                                       


                                                   


                                                                          


                                           
                      
                                      

                           


                                                                     
                             
                                                                      

                         
                                                                      
                      




                                          


                      

                                         
                         










                                                                          












                                                     
        


                                                                    
                                  










                                                                     
                                                           



                                                                    


                              




                                                            
                    





























                                                                          
                                                           

                                                                    
                    
                                                             












                                                                  







                                                                       
                                                             


                                                                       

                              
 
                                                               
 







                                                                


                                                                           





                                                                

                                                                    
                                        
                                                                
                                          
                     

 


                                                                     
 
                   
 
                           





                                            


                             
                                                                          
                      
                         
                                                              
                      

                           
                                                                


                           
                                                                





                                
























                                                                        

                                                                     













                                                                             

                                           

                               
                  

                   

                                                  


                                                   



















                                                                            
                                                             
           
                                                       


                                         





                                        
                                                     


                                                 

                                         

                 



                                                                     
 

                                                                             

                                 
                            
                                                 



                                             



                                                             
         
    
                  



                                                 

                     
/*
 *	linux/mm/madvise.c
 *
 * Copyright (C) 1999  Linus Torvalds
 * Copyright (C) 2002  Christoph Hellwig
 */

#include <linux/mman.h>
#include <linux/pagemap.h>
#include <linux/syscalls.h>
#include <linux/mempolicy.h>
#include <linux/hugetlb.h>
#include <linux/sched.h>

/*
 * Any behaviour which results in changes to the vma->vm_flags needs to
 * take mmap_sem for writing. Others, which simply traverse vmas, need
 * to only take it for reading.
 */
static int madvise_need_mmap_write(int behavior)
{
	switch (behavior) {
	case MADV_REMOVE:
	case MADV_WILLNEED:
	case MADV_DONTNEED:
		return 0;
	default:
		/* be safe, default to 1. list exceptions explicitly */
		return 1;
	}
}

/*
 * We can potentially split a vm area into separate
 * areas, each area with its own behavior.
 */
static long madvise_behavior(struct vm_area_struct * vma,
		     struct vm_area_struct **prev,
		     unsigned long start, unsigned long end, int behavior)
{
	struct mm_struct * mm = vma->vm_mm;
	int error = 0;
	pgoff_t pgoff;
	int new_flags = vma->vm_flags;

	switch (behavior) {
	case MADV_NORMAL:
		new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
		break;
	case MADV_SEQUENTIAL:
		new_flags = (new_flags & ~VM_RAND_READ) | VM_SEQ_READ;
		break;