mm.h
来自「Linux Kernel 2.6.9 for OMAP1710」· C头文件 代码 · 共 799 行 · 第 1/2 页
H
799 行
page->flags &= ~(~0UL << NODEZONE_SHIFT); page->flags |= nodezone_num << NODEZONE_SHIFT;}#ifndef CONFIG_DISCONTIGMEM/* The array of struct pages - for discontigmem use pgdat->lmem_map */extern struct page *mem_map;#endifstatic inline void *lowmem_page_address(struct page *page){ return __va(page_to_pfn(page) << PAGE_SHIFT);}#if defined(CONFIG_HIGHMEM) && !defined(WANT_PAGE_VIRTUAL)#define HASHED_PAGE_VIRTUAL#endif#if defined(WANT_PAGE_VIRTUAL)#define page_address(page) ((page)->virtual)#define set_page_address(page, address) \ do { \ (page)->virtual = (address); \ } while(0)#define page_address_init() do { } while(0)#endif#if defined(HASHED_PAGE_VIRTUAL)void *page_address(struct page *page);void set_page_address(struct page *page, void *virtual);void page_address_init(void);#endif#if !defined(HASHED_PAGE_VIRTUAL) && !defined(WANT_PAGE_VIRTUAL)#define page_address(page) lowmem_page_address(page)#define set_page_address(page, address) do { } while(0)#define page_address_init() do { } while(0)#endif/* * On an anonymous page mapped into a user virtual memory area, * page->mapping points to its anon_vma, not to a struct address_space; * with the PAGE_MAPPING_ANON bit set to distinguish it. * * Please note that, confusingly, "page_mapping" refers to the inode * address_space which maps the page from disk; whereas "page_mapped" * refers to user virtual address space into which the page is mapped. */#define PAGE_MAPPING_ANON 1extern struct address_space swapper_space;static inline struct address_space *page_mapping(struct page *page){ struct address_space *mapping = page->mapping; if (unlikely(PageSwapCache(page))) mapping = &swapper_space; else if (unlikely((unsigned long)mapping & PAGE_MAPPING_ANON)) mapping = NULL; return mapping;}static inline int PageAnon(struct page *page){ return ((unsigned long)page->mapping & PAGE_MAPPING_ANON) != 0;}/* * Return the pagecache index of the passed page. Regular pagecache pages * use ->index whereas swapcache pages use ->private */static inline pgoff_t page_index(struct page *page){ if (unlikely(PageSwapCache(page))) return page->private; return page->index;}/* * The atomic page->_mapcount, like _count, starts from -1: * so that transitions both from it and to it can be tracked, * using atomic_inc_and_test and atomic_add_negative(-1). */static inline void reset_page_mapcount(struct page *page){ atomic_set(&(page)->_mapcount, -1);}static inline int page_mapcount(struct page *page){ return atomic_read(&(page)->_mapcount) + 1;}/* * Return true if this page is mapped into pagetables. */static inline int page_mapped(struct page *page){ return atomic_read(&(page)->_mapcount) >= 0;}/* * Error return values for the *_nopage functions */#define NOPAGE_SIGBUS (NULL)#define NOPAGE_OOM ((struct page *) (-1))/* * Different kinds of faults, as returned by handle_mm_fault(). * Used to decide whether a process gets delivered SIGBUS or * just gets major/minor fault counters bumped up. */#define VM_FAULT_OOM (-1)#define VM_FAULT_SIGBUS 0#define VM_FAULT_MINOR 1#define VM_FAULT_MAJOR 2#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK)extern void show_free_areas(void);#ifdef CONFIG_SHMEMstruct page *shmem_nopage(struct vm_area_struct *vma, unsigned long address, int *type);int shmem_set_policy(struct vm_area_struct *vma, struct mempolicy *new);struct mempolicy *shmem_get_policy(struct vm_area_struct *vma, unsigned long addr);int shmem_lock(struct file *file, int lock, struct user_struct *user);#else#define shmem_nopage filemap_nopage#define shmem_lock(a, b, c) ({0;}) /* always in memory, no need to lock */#define shmem_set_policy(a, b) (0)#define shmem_get_policy(a, b) (NULL)#endifstruct file *shmem_file_setup(char *name, loff_t size, unsigned long flags);int shmem_zero_setup(struct vm_area_struct *);static inline int can_do_mlock(void){ if (capable(CAP_IPC_LOCK)) return 1; if (current->rlim[RLIMIT_MEMLOCK].rlim_cur != 0) return 1; return 0;}extern int user_shm_lock(size_t, struct user_struct *);extern void user_shm_unlock(size_t, struct user_struct *);/* * Parameter block passed down to zap_pte_range in exceptional cases. */struct zap_details { struct vm_area_struct *nonlinear_vma; /* Check page->index if set */ struct address_space *check_mapping; /* Check page->mapping if set */ pgoff_t first_index; /* Lowest page->index to unmap */ pgoff_t last_index; /* Highest page->index to unmap */ int atomic; /* May not schedule() */};void zap_page_range(struct vm_area_struct *vma, unsigned long address, unsigned long size, struct zap_details *);int unmap_vmas(struct mmu_gather **tlbp, struct mm_struct *mm, struct vm_area_struct *start_vma, unsigned long start_addr, unsigned long end_addr, unsigned long *nr_accounted, struct zap_details *);void clear_page_tables(struct mmu_gather *tlb, unsigned long first, int nr);int copy_page_range(struct mm_struct *dst, struct mm_struct *src, struct vm_area_struct *vma);int zeromap_page_range(struct vm_area_struct *vma, unsigned long from, unsigned long size, pgprot_t prot);void unmap_mapping_range(struct address_space *mapping, loff_t const holebegin, loff_t const holelen, int even_cows);static inline void unmap_shared_mapping_range(struct address_space *mapping, loff_t const holebegin, loff_t const holelen){ unmap_mapping_range(mapping, holebegin, holelen, 0);}extern int vmtruncate(struct inode * inode, loff_t offset);extern pmd_t *FASTCALL(__pmd_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address));extern pte_t *FASTCALL(pte_alloc_kernel(struct mm_struct *mm, pmd_t *pmd, unsigned long address));extern pte_t *FASTCALL(pte_alloc_map(struct mm_struct *mm, pmd_t *pmd, unsigned long address));extern int install_page(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, struct page *page, pgprot_t prot);extern int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned long pgoff, pgprot_t prot);extern int handle_mm_fault(struct mm_struct *mm,struct vm_area_struct *vma, unsigned long address, int write_access);extern int make_pages_present(unsigned long addr, unsigned long end);extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);void install_arg_page(struct vm_area_struct *, struct page *, unsigned long);int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start, int len, int write, int force, struct page **pages, struct vm_area_struct **vmas);int __set_page_dirty_buffers(struct page *page);int __set_page_dirty_nobuffers(struct page *page);int redirty_page_for_writepage(struct writeback_control *wbc, struct page *page);int FASTCALL(set_page_dirty(struct page *page));int set_page_dirty_lock(struct page *page);int clear_page_dirty_for_io(struct page *page);/* * Prototype to add a shrinker callback for ageable caches. * * These functions are passed a count `nr_to_scan' and a gfpmask. They should * scan `nr_to_scan' objects, attempting to free them. * * The callback must the number of objects which remain in the cache. * * The callback will be passes nr_to_scan == 0 when the VM is querying the * cache size, so a fastpath for that case is appropriate. */typedef int (*shrinker_t)(int nr_to_scan, unsigned int gfp_mask);/* * Add an aging callback. The int is the number of 'seeks' it takes * to recreate one of the objects that these functions age. */#define DEFAULT_SEEKS 2struct shrinker;extern struct shrinker *set_shrinker(int, shrinker_t);extern void remove_shrinker(struct shrinker *shrinker);/* * On a two-level page table, this ends up being trivial. Thus the * inlining and the symmetry break with pte_alloc_map() that does all * of this out-of-line. */static inline pmd_t *pmd_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address){ if (pgd_none(*pgd)) return __pmd_alloc(mm, pgd, address); return pmd_offset(pgd, address);}extern void free_area_init(unsigned long * zones_size);extern void free_area_init_node(int nid, pg_data_t *pgdat, unsigned long * zones_size, unsigned long zone_start_pfn, unsigned long *zholes_size);extern void memmap_init_zone(unsigned long, int, unsigned long, unsigned long);extern void mem_init(void);extern void show_mem(void);extern void si_meminfo(struct sysinfo * val);extern void si_meminfo_node(struct sysinfo *val, int nid);/* prio_tree.c */void vma_prio_tree_add(struct vm_area_struct *, struct vm_area_struct *old);void vma_prio_tree_insert(struct vm_area_struct *, struct prio_tree_root *);void vma_prio_tree_remove(struct vm_area_struct *, struct prio_tree_root *);struct vm_area_struct *vma_prio_tree_next(struct vm_area_struct *vma, struct prio_tree_iter *iter);#define vma_prio_tree_foreach(vma, iter, root, begin, end) \ for (prio_tree_iter_init(iter, root, begin, end), vma = NULL; \ (vma = vma_prio_tree_next(vma, iter)); )static inline void vma_nonlinear_insert(struct vm_area_struct *vma, struct list_head *list){ vma->shared.vm_set.parent = NULL; list_add_tail(&vma->shared.vm_set.list, list);}/* mmap.c */extern void vma_adjust(struct vm_area_struct *vma, unsigned long start, unsigned long end, pgoff_t pgoff, struct vm_area_struct *insert);extern struct vm_area_struct *vma_merge(struct mm_struct *, struct vm_area_struct *prev, unsigned long addr, unsigned long end, unsigned long vm_flags, struct anon_vma *, struct file *, pgoff_t, struct mempolicy *);extern struct anon_vma *find_mergeable_anon_vma(struct vm_area_struct *);extern int split_vma(struct mm_struct *, struct vm_area_struct *, unsigned long addr, int new_below);extern void insert_vm_struct(struct mm_struct *, struct vm_area_struct *);extern void __vma_link_rb(struct mm_struct *, struct vm_area_struct *, struct rb_node **, struct rb_node *);extern struct vm_area_struct *copy_vma(struct vm_area_struct **, unsigned long addr, unsigned long len, pgoff_t pgoff);extern void exit_mmap(struct mm_struct *);extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr, unsigned long len, unsigned long prot, unsigned long flag, unsigned long pgoff);static inline unsigned long do_mmap(struct file *file, unsigned long addr, unsigned long len, unsigned long prot, unsigned long flag, unsigned long offset){ unsigned long ret = -EINVAL; if ((offset + PAGE_ALIGN(len)) < offset) goto out; if (!(offset & ~PAGE_MASK)) ret = do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);out: return ret;}extern int do_munmap(struct mm_struct *, unsigned long, size_t);extern unsigned long do_brk(unsigned long, unsigned long);/* filemap.c */extern unsigned long page_unuse(struct page *);extern void truncate_inode_pages(struct address_space *, loff_t);/* generic vm_area_ops exported for stackable file systems */struct page *filemap_nopage(struct vm_area_struct *, unsigned long, int *);/* mm/page-writeback.c */int write_one_page(struct page *page, int wait);/* readahead.c */#define VM_MAX_READAHEAD 128 /* kbytes */#define VM_MIN_READAHEAD 16 /* kbytes (includes current page) */int do_page_cache_readahead(struct address_space *mapping, struct file *filp, unsigned long offset, unsigned long nr_to_read);int force_page_cache_readahead(struct address_space *mapping, struct file *filp, unsigned long offset, unsigned long nr_to_read);void page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra, struct file *filp, unsigned long offset);void handle_ra_miss(struct address_space *mapping, struct file_ra_state *ra, pgoff_t offset);unsigned long max_sane_readahead(unsigned long nr);/* Do stack extension */extern int expand_stack(struct vm_area_struct * vma, unsigned long address);/* Look up the first VMA which satisfies addr < vm_end, NULL if none. */extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long addr);extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr, struct vm_area_struct **pprev);/* Look up the first VMA which intersects the interval start_addr..end_addr-1, NULL if none. Assume start_addr < end_addr. */static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr){ struct vm_area_struct * vma = find_vma(mm,start_addr); if (vma && end_addr <= vma->vm_start) vma = NULL; return vma;}static inline unsigned long vma_pages(struct vm_area_struct *vma){ return (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;}extern struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr);extern struct page * vmalloc_to_page(void *addr);extern struct page * follow_page(struct mm_struct *mm, unsigned long address, int write);extern int remap_page_range(struct vm_area_struct *vma, unsigned long from, unsigned long to, unsigned long size, pgprot_t prot);#ifdef CONFIG_PROC_FSvoid __vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);#elsestatic inline void __vm_stat_account(struct mm_struct *mm, unsigned long flags, struct file *file, long pages){}#endif /* CONFIG_PROC_FS */static inline void vm_stat_account(struct vm_area_struct *vma){ __vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file, vma_pages(vma));}static inline void vm_stat_unaccount(struct vm_area_struct *vma){ __vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file, -vma_pages(vma));}#ifndef CONFIG_DEBUG_PAGEALLOCstatic inline voidkernel_map_pages(struct page *page, int numpages, int enable){}#endif#ifndef CONFIG_ARCH_GATE_AREAextern struct vm_area_struct *get_gate_vma(struct task_struct *tsk);int in_gate_area(struct task_struct *task, unsigned long addr);#endif#endif /* __KERNEL__ */#endif /* _LINUX_MM_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?