/sound/usb/

-migration-affinity'>wip-migration-affinity The LITMUS^RT kernel.Bjoern Brandenburg
aboutsummaryrefslogblamecommitdiffstats
path: root/fs/file.c
blob: 4c6f0ea12c419c52154558c271586b7887dabf13 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14













                                                             
                          
                         







                              


                             

                                             






                                                                              
 
                                                   
 
                              


                                                 

 
                                                  
 

                                                                
            
                               

 
                                                  
 



                                                            
 
 
                                                       
 

                                                             
                            
 





                                                 


                                


                           
 
                                           

                                                                     
                                    
 
                     
 
                                              
                  

                                                                           
                   

                                                                               

                       
                                                                  
                               
                                     
                           
                



                                                         

                                                                     

                                                
         

 



                                                                        
                                                                    
 
                              
 

                                              
                       











                                                                      

 
                                                      
 

                            
 
          




                                                                               
           


                                             









                                                                                   
 

                                                          
                         














                                                                          
                   



                        
                   
    

                    
 
  




                                                                            




                                                             
                                          

                                       
                                    
                                     

                               
          









                                                                                  

                                                                              
           
                                       
                                     


                                                        
                                                       
                                              
                
                                                                 


                                    
         
                 



                




                                                                               


                                                    
                            
 
                                   
                                   
                              

                            
                                 



                                         
 




                                                                        
                                                 





                                  
                                

                                           
/*
 *  linux/fs/file.c
 *
 *  Copyright (C) 1998-1999, Stephen Tweedie and Bill Hawes
 *
 *  Manage the dynamic fd arrays in the process files_struct.
 */

#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/time.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/file.h>
#include <linux/fdtable.h>
#include <linux/bitops.h>
#include <linux/interrupt.h>
#include <linux/spinlock.h>
#include <linux/rcupdate.h>
#include <linux/workqueue.h>

struct fdtable_defer {
	spinlock_t lock;
	struct work_struct wq;
	struct fdtable *next;
};

int sysctl_nr_open __read_mostly = 1024*1024;

/*
 * We use this list to defer free fdtables that have vmalloced
 * sets/arrays. By keeping a per-cpu list, we avoid having to embed
 * the work_struct in fdtable itself which avoids a 64 byte (i386) increase in
 * this per-task structure.
 */
static DEFINE_PER_CPU(struct fdtable_defer, fdtable_defer_list);

static inline void * alloc_fdmem(unsigned int size)
{
	if (size <= PAGE_SIZE)
		return kmalloc(size, GFP_KERNEL);
	else
		return vmalloc(size);
}

static inline void free_fdarr(struct fdtable *fdt)
{
	if (fdt->max_fds <= (PAGE_SIZE / sizeof(struct file *)))
		kfree(fdt->fd);
	else
		vfree(fdt->fd);
}

static inline void free_fdset(struct fdtable *fdt)
{
	if (fdt->max_fds <= (PAGE_SIZE * BITS_PER_BYTE / 2))
		kfree(fdt->open_fds);
	else
		vfree(fdt->open_fds);
}

static void free_fdtable_work(struct work_struct *work)
{
	struct fdtable_defer *f =