linux-bk/include/linux/mm.h
<<
>>
Prefs
   1#ifndef _LINUX_MM_H
   2#define _LINUX_MM_H
   3
   4#include <linux/sched.h>
   5#include <linux/errno.h>
   6
   7#ifdef __KERNEL__
   8
   9#include <linux/config.h>
  10#include <linux/gfp.h>
  11#include <linux/list.h>
  12#include <linux/mmzone.h>
  13#include <linux/rbtree.h>
  14#include <linux/fs.h>
  15
  16#ifndef CONFIG_DISCONTIGMEM          /* Don't use mapnrs, do it properly */
  17extern unsigned long max_mapnr;
  18#endif
  19
  20extern unsigned long num_physpages;
  21extern void * high_memory;
  22extern int page_cluster;
  23
  24#include <asm/page.h>
  25#include <asm/pgtable.h>
  26#include <asm/processor.h>
  27#include <asm/atomic.h>
  28
  29#ifndef MM_VM_SIZE
  30#define MM_VM_SIZE(mm)  TASK_SIZE
  31#endif
  32
  33/*
  34 * Linux kernel virtual memory manager primitives.
  35 * The idea being to have a "virtual" mm in the same way
  36 * we have a virtual fs - giving a cleaner interface to the
  37 * mm details, and allowing different kinds of memory mappings
  38 * (from shared memory to executable loading to arbitrary
  39 * mmap() functions).
  40 */
  41
  42/*
  43 * This struct defines a memory VMM memory area. There is one of these
  44 * per VM-area/task.  A VM area is any part of the process virtual memory
  45 * space that has a special rule for the page-fault handlers (ie a shared
  46 * library, the executable area etc).
  47 *
  48 * This structure is exactly 64 bytes on ia32.  Please think very, very hard
  49 * before adding anything to it.
  50 */
  51struct vm_area_struct {
  52        struct mm_struct * vm_mm;       /* The address space we belong to. */
  53        unsigned long vm_start;         /* Our start address within vm_mm. */
  54        unsigned long vm_end;           /* The first byte after our end address
  55                                           within vm_mm. */
  56
  57        /* linked list of VM areas per task, sorted by address */
  58        struct vm_area_struct *vm_next;
  59
  60        pgprot_t vm_page_prot;          /* Access permissions of this VMA. */
  61        unsigned long vm_flags;         /* Flags, listed below. */
  62
  63        struct rb_node vm_rb;
  64
  65        /*
  66         * For areas with an address space and backing store,
  67         * one of the address_space->i_mmap{,shared} lists,
  68         * for shm areas, the list of attaches, otherwise unused.
  69         */
  70        struct list_head shared;
  71
  72        /* Function pointers to deal with this struct. */
  73        struct vm_operations_struct * vm_ops;
  74
  75        /* Information about our backing store: */
  76        unsigned long vm_pgoff;         /* Offset (within vm_file) in PAGE_SIZE
  77                                           units, *not* PAGE_CACHE_SIZE */
  78        struct file * vm_file;          /* File we map to (can be NULL). */
  79        void * vm_private_data;         /* was vm_pte (shared mem) */
  80};
  81
  82/*
  83 * vm_flags..
  84 */
  85#define VM_READ         0x00000001      /* currently active flags */
  86#define VM_WRITE        0x00000002
  87#define VM_EXEC         0x00000004
  88#define VM_SHARED       0x00000008
  89
  90#define VM_MAYREAD      0x00000010      /* limits for mprotect() etc */
  91#define VM_MAYWRITE     0x00000020
  92#define VM_MAYEXEC      0x00000040
  93#define VM_MAYSHARE     0x00000080
  94
  95#define VM_GROWSDOWN    0x00000100      /* general info on the segment */
  96#define VM_GROWSUP      0x00000200
  97#define VM_SHM          0x00000400      /* shared memory area, don't swap out */
  98#define VM_DENYWRITE    0x00000800      /* ETXTBSY on write attempts.. */
  99
 100#define VM_EXECUTABLE   0x00001000
 101#define VM_LOCKED       0x00002000
 102#define VM_IO           0x00004000      /* Memory mapped I/O or similar */
 103
 104                                        /* Used by sys_madvise() */
 105#define VM_SEQ_READ     0x00008000      /* App will access data sequentially */
 106#define VM_RAND_READ    0x00010000      /* App will not benefit from clustered reads */
 107
 108#define VM_DONTCOPY     0x00020000      /* Do not copy this vma on fork */
 109#define VM_DONTEXPAND   0x00040000      /* Cannot expand with mremap() */
 110#define VM_RESERVED     0x00080000      /* Don't unmap it from swap_out */
 111#define VM_ACCOUNT      0x00100000      /* Is a VM accounted object */
 112#define VM_HUGETLB      0x00400000      /* Huge TLB Page VM */
 113#define VM_NONLINEAR    0x00800000      /* Is non-linear (remap_file_pages) */
 114
 115#ifndef VM_STACK_DEFAULT_FLAGS          /* arch can override this */
 116#define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS
 117#endif
 118
 119#ifdef CONFIG_STACK_GROWSUP
 120#define VM_STACK_FLAGS  (VM_GROWSUP | VM_STACK_DEFAULT_FLAGS | VM_ACCOUNT)
 121#else
 122#define VM_STACK_FLAGS  (VM_GROWSDOWN | VM_STACK_DEFAULT_FLAGS | VM_ACCOUNT)
 123#endif
 124
 125#define VM_READHINTMASK                 (VM_SEQ_READ | VM_RAND_READ)
 126#define VM_ClearReadHint(v)             (v)->vm_flags &= ~VM_READHINTMASK
 127#define VM_NormalReadHint(v)            (!((v)->vm_flags & VM_READHINTMASK))
 128#define VM_SequentialReadHint(v)        ((v)->vm_flags & VM_SEQ_READ)
 129#define VM_RandomReadHint(v)            ((v)->vm_flags & VM_RAND_READ)
 130
 131/*
 132 * mapping from the currently active vm_flags protection bits (the
 133 * low four bits) to a page protection mask..
 134 */
 135extern pgprot_t protection_map[16];
 136
 137
 138/*
 139 * These are the virtual MM functions - opening of an area, closing and
 140 * unmapping it (needed to keep files on disk up-to-date etc), pointer
 141 * to the functions called when a no-page or a wp-page exception occurs. 
 142 */
 143struct vm_operations_struct {
 144        void (*open)(struct vm_area_struct * area);
 145        void (*close)(struct vm_area_struct * area);
 146        struct page * (*nopage)(struct vm_area_struct * area, unsigned long address, int *type);
 147        int (*populate)(struct vm_area_struct * area, unsigned long address, unsigned long len, pgprot_t prot, unsigned long pgoff, int nonblock);
 148};
 149
 150/* forward declaration; pte_chain is meant to be internal to rmap.c */
 151struct pte_chain;
 152struct mmu_gather;
 153struct inode;
 154
 155/*
 156 * Each physical page in the system has a struct page associated with
 157 * it to keep track of whatever it is we are using the page for at the
 158 * moment. Note that we have no way to track which tasks are using
 159 * a page.
 160 *
 161 * Try to keep the most commonly accessed fields in single cache lines
 162 * here (16 bytes or greater).  This ordering should be particularly
 163 * beneficial on 32-bit processors.
 164 *
 165 * The first line is data used in page cache lookup, the second line
 166 * is used for linear searches (eg. clock algorithm scans). 
 167 *
 168 * TODO: make this structure smaller, it could be as small as 32 bytes.
 169 */
 170struct page {
 171        unsigned long flags;            /* atomic flags, some possibly
 172                                           updated asynchronously */
 173        atomic_t count;                 /* Usage count, see below. */
 174        struct list_head list;          /* ->mapping has some page lists. */
 175        struct address_space *mapping;  /* The inode (or ...) we belong to. */
 176        unsigned long index;            /* Our offset within mapping. */
 177        struct list_head lru;           /* Pageout list, eg. active_list;
 178                                           protected by zone->lru_lock !! */
 179        union {
 180                struct pte_chain *chain;/* Reverse pte mapping pointer.
 181                                         * protected by PG_chainlock */
 182                pte_addr_t direct;
 183        } pte;
 184        unsigned long private;          /* mapping-private opaque data */
 185
 186        /*
 187         * On machines where all RAM is mapped into kernel address space,
 188         * we can simply calculate the virtual address. On machines with
 189         * highmem some memory is mapped into kernel virtual memory
 190         * dynamically, so we need a place to store that address.
 191         * Note that this field could be 16 bits on x86 ... ;)
 192         *
 193         * Architectures with slow multiplication can define
 194         * WANT_PAGE_VIRTUAL in asm/page.h
 195         */
 196#if defined(WANT_PAGE_VIRTUAL)
 197        void *virtual;                  /* Kernel virtual address (NULL if
 198                                           not kmapped, ie. highmem) */
 199#endif /* WANT_PAGE_VIRTUAL */
 200};
 201
 202/*
 203 * FIXME: take this include out, include page-flags.h in
 204 * files which need it (119 of them)
 205 */
 206#include <linux/page-flags.h>
 207
 208/*
 209 * Methods to modify the page usage count.
 210 *
 211 * What counts for a page usage:
 212 * - cache mapping   (page->mapping)
 213 * - private data    (page->private)
 214 * - page mapped in a task's page tables, each mapping
 215 *   is counted separately
 216 *
 217 * Also, many kernel routines increase the page count before a critical
 218 * routine so they can be sure the page doesn't go away from under them.
 219 */
 220#define put_page_testzero(p)                            \
 221        ({                                              \
 222                BUG_ON(page_count(p) == 0);             \
 223                atomic_dec_and_test(&(p)->count);       \
 224        })
 225
 226#define page_count(p)           atomic_read(&(p)->count)
 227#define set_page_count(p,v)     atomic_set(&(p)->count, v)
 228#define __put_page(p)           atomic_dec(&(p)->count)
 229
 230extern void FASTCALL(__page_cache_release(struct page *));
 231
 232#ifdef CONFIG_HUGETLB_PAGE
 233
 234static inline void get_page(struct page *page)
 235{
 236        if (PageCompound(page))
 237                page = (struct page *)page->lru.next;
 238        atomic_inc(&page->count);
 239}
 240
 241static inline void put_page(struct page *page)
 242{
 243        if (PageCompound(page)) {
 244                page = (struct page *)page->lru.next;
 245                if (put_page_testzero(page)) {
 246                        if (page->lru.prev) {   /* destructor? */
 247                                (*(void (*)(struct page *))page->lru.prev)(page);
 248                        } else {
 249                                __page_cache_release(page);
 250                        }
 251                }
 252                return;
 253        }
 254        if (!PageReserved(page) && put_page_testzero(page))
 255                __page_cache_release(page);
 256}
 257
 258#else           /* CONFIG_HUGETLB_PAGE */
 259
 260static inline void get_page(struct page *page)
 261{
 262        atomic_inc(&page->count);
 263}
 264
 265static inline void put_page(struct page *page)
 266{
 267        if (!PageReserved(page) && put_page_testzero(page))
 268                __page_cache_release(page);
 269}
 270
 271#endif          /* CONFIG_HUGETLB_PAGE */
 272
 273/*
 274 * Multiple processes may "see" the same page. E.g. for untouched
 275 * mappings of /dev/null, all processes see the same page full of
 276 * zeroes, and text pages of executables and shared libraries have
 277 * only one copy in memory, at most, normally.
 278 *
 279 * For the non-reserved pages, page->count denotes a reference count.
 280 *   page->count == 0 means the page is free.
 281 *   page->count == 1 means the page is used for exactly one purpose
 282 *   (e.g. a private data page of one process).
 283 *
 284 * A page may be used for kmalloc() or anyone else who does a
 285 * __get_free_page(). In this case the page->count is at least 1, and
 286 * all other fields are unused but should be 0 or NULL. The
 287 * management of this page is the responsibility of the one who uses
 288 * it.
 289 *
 290 * The other pages (we may call them "process pages") are completely
 291 * managed by the Linux memory manager: I/O, buffers, swapping etc.
 292 * The following discussion applies only to them.
 293 *
 294 * A page may belong to an inode's memory mapping. In this case,
 295 * page->mapping is the pointer to the inode, and page->index is the
 296 * file offset of the page, in units of PAGE_CACHE_SIZE.
 297 *
 298 * A page contains an opaque `private' member, which belongs to the
 299 * page's address_space.  Usually, this is the address of a circular
 300 * list of the page's disk buffers.
 301 *
 302 * For pages belonging to inodes, the page->count is the number of
 303 * attaches, plus 1 if `private' contains something, plus one for
 304 * the page cache itself.
 305 *
 306 * All pages belonging to an inode are in these doubly linked lists:
 307 * mapping->clean_pages, mapping->dirty_pages and mapping->locked_pages;
 308 * using the page->list list_head. These fields are also used for
 309 * freelist managemet (when page->count==0).
 310 *
 311 * There is also a per-mapping radix tree mapping index to the page
 312 * in memory if present. The tree is rooted at mapping->root.  
 313 *
 314 * All process pages can do I/O:
 315 * - inode pages may need to be read from disk,
 316 * - inode pages which have been modified and are MAP_SHARED may need
 317 *   to be written to disk,
 318 * - private pages which have been modified may need to be swapped out
 319 *   to swap space and (later) to be read back into memory.
 320 */
 321
 322/*
 323 * The zone field is never updated after free_area_init_core()
 324 * sets it, so none of the operations on it need to be atomic.
 325 * We'll have up to log2(MAX_NUMNODES * MAX_NR_ZONES) zones
 326 * total, so we use NODES_SHIFT here to get enough bits.
 327 */
 328#define ZONE_SHIFT (BITS_PER_LONG - NODES_SHIFT - MAX_NR_ZONES_SHIFT)
 329
 330struct zone;
 331extern struct zone *zone_table[];
 332
 333static inline struct zone *page_zone(struct page *page)
 334{
 335        return zone_table[page->flags >> ZONE_SHIFT];
 336}
 337
 338static inline void set_page_zone(struct page *page, unsigned long zone_num)
 339{
 340        page->flags &= ~(~0UL << ZONE_SHIFT);
 341        page->flags |= zone_num << ZONE_SHIFT;
 342}
 343
 344#ifndef CONFIG_DISCONTIGMEM
 345/* The array of struct pages - for discontigmem use pgdat->lmem_map */
 346extern struct page *mem_map;
 347#endif
 348
 349static inline void *lowmem_page_address(struct page *page)
 350{
 351        return __va(page_to_pfn(page) << PAGE_SHIFT);
 352}
 353
 354#if defined(CONFIG_HIGHMEM) && !defined(WANT_PAGE_VIRTUAL)
 355#define HASHED_PAGE_VIRTUAL
 356#endif
 357
 358#if defined(WANT_PAGE_VIRTUAL)
 359#define page_address(page) ((page)->virtual)
 360#define set_page_address(page, address)                 \
 361        do {                                            \
 362                (page)->virtual = (address);            \
 363        } while(0)
 364#define page_address_init()  do { } while(0)
 365#endif
 366
 367#if defined(HASHED_PAGE_VIRTUAL)
 368void *page_address(struct page *page);
 369void set_page_address(struct page *page, void *virtual);
 370void page_address_init(void);
 371#endif
 372
 373#if !defined(HASHED_PAGE_VIRTUAL) && !defined(WANT_PAGE_VIRTUAL)
 374#define page_address(page) lowmem_page_address(page)
 375#define set_page_address(page, address)  do { } while(0)
 376#define page_address_init()  do { } while(0)
 377#endif
 378
 379/*
 380 * Return true if this page is mapped into pagetables.  Subtle: test pte.direct
 381 * rather than pte.chain.  Because sometimes pte.direct is 64-bit, and .chain
 382 * is only 32-bit.
 383 */
 384static inline int page_mapped(struct page *page)
 385{
 386        return page->pte.direct != 0;
 387}
 388
 389/*
 390 * Error return values for the *_nopage functions
 391 */
 392#define NOPAGE_SIGBUS   (NULL)
 393#define NOPAGE_OOM      ((struct page *) (-1))
 394
 395/*
 396 * Different kinds of faults, as returned by handle_mm_fault().
 397 * Used to decide whether a process gets delivered SIGBUS or
 398 * just gets major/minor fault counters bumped up.
 399 */
 400#define VM_FAULT_OOM    (-1)
 401#define VM_FAULT_SIGBUS 0
 402#define VM_FAULT_MINOR  1
 403#define VM_FAULT_MAJOR  2
 404
 405#define offset_in_page(p)       ((unsigned long)(p) & ~PAGE_MASK)
 406
 407extern void show_free_areas(void);
 408
 409struct page *shmem_nopage(struct vm_area_struct * vma,
 410                        unsigned long address, int *type);
 411struct file *shmem_file_setup(char * name, loff_t size, unsigned long flags);
 412void shmem_lock(struct file * file, int lock);
 413int shmem_zero_setup(struct vm_area_struct *);
 414
 415void zap_page_range(struct vm_area_struct *vma, unsigned long address,
 416                        unsigned long size);
 417int unmap_vmas(struct mmu_gather **tlbp, struct mm_struct *mm,
 418                struct vm_area_struct *start_vma, unsigned long start_addr,
 419                unsigned long end_addr, unsigned long *nr_accounted);
 420void unmap_page_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
 421                        unsigned long address, unsigned long size);
 422void clear_page_tables(struct mmu_gather *tlb, unsigned long first, int nr);
 423int copy_page_range(struct mm_struct *dst, struct mm_struct *src,
 424                        struct vm_area_struct *vma);
 425int zeromap_page_range(struct vm_area_struct *vma, unsigned long from,
 426                        unsigned long size, pgprot_t prot);
 427
 428extern void invalidate_mmap_range(struct address_space *mapping,
 429                                  loff_t const holebegin,
 430                                  loff_t const holelen);
 431extern int vmtruncate(struct inode * inode, loff_t offset);
 432extern pmd_t *FASTCALL(__pmd_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address));
 433extern pte_t *FASTCALL(pte_alloc_kernel(struct mm_struct *mm, pmd_t *pmd, unsigned long address));
 434extern pte_t *FASTCALL(pte_alloc_map(struct mm_struct *mm, pmd_t *pmd, unsigned long address));
 435extern int install_page(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, struct page *page, pgprot_t prot);
 436extern int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned long pgoff, pgprot_t prot);
 437extern int handle_mm_fault(struct mm_struct *mm,struct vm_area_struct *vma, unsigned long address, int write_access);
 438extern int make_pages_present(unsigned long addr, unsigned long end);
 439extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
 440extern long sys_remap_file_pages(unsigned long start, unsigned long size, unsigned long prot, unsigned long pgoff, unsigned long nonblock);
 441extern long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice);
 442void put_dirty_page(struct task_struct *tsk, struct page *page,
 443                        unsigned long address, pgprot_t prot);
 444
 445int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start,
 446                int len, int write, int force, struct page **pages, struct vm_area_struct **vmas);
 447
 448int __set_page_dirty_buffers(struct page *page);
 449int __set_page_dirty_nobuffers(struct page *page);
 450int set_page_dirty_lock(struct page *page);
 451
 452/*
 453 * Prototype to add a shrinker callback for ageable caches.
 454 * 
 455 * These functions are passed a count `nr_to_scan' and a gfpmask.  They should
 456 * scan `nr_to_scan' objects, attempting to free them.
 457 *
 458 * The callback must the number of objects which remain in the cache.
 459 *
 460 * The callback will be passes nr_to_scan == 0 when the VM is querying the
 461 * cache size, so a fastpath for that case is appropriate.
 462 */
 463typedef int (*shrinker_t)(int nr_to_scan, unsigned int gfp_mask);
 464
 465/*
 466 * Add an aging callback.  The int is the number of 'seeks' it takes
 467 * to recreate one of the objects that these functions age.
 468 */
 469
 470#define DEFAULT_SEEKS 2
 471struct shrinker;
 472extern struct shrinker *set_shrinker(int, shrinker_t);
 473extern void remove_shrinker(struct shrinker *shrinker);
 474
 475/*
 476 * If the mapping doesn't provide a set_page_dirty a_op, then
 477 * just fall through and assume that it wants buffer_heads.
 478 * FIXME: make the method unconditional.
 479 */
 480static inline int set_page_dirty(struct page *page)
 481{
 482        if (page->mapping) {
 483                int (*spd)(struct page *);
 484
 485                spd = page->mapping->a_ops->set_page_dirty;
 486                if (spd)
 487                        return (*spd)(page);
 488        }
 489        return __set_page_dirty_buffers(page);
 490}
 491
 492/*
 493 * On a two-level page table, this ends up being trivial. Thus the
 494 * inlining and the symmetry break with pte_alloc_map() that does all
 495 * of this out-of-line.
 496 */
 497static inline pmd_t *pmd_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
 498{
 499        if (pgd_none(*pgd))
 500                return __pmd_alloc(mm, pgd, address);
 501        return pmd_offset(pgd, address);
 502}
 503
 504extern void free_area_init(unsigned long * zones_size);
 505extern void free_area_init_node(int nid, pg_data_t *pgdat, struct page *pmap,
 506        unsigned long * zones_size, unsigned long zone_start_pfn, 
 507        unsigned long *zholes_size);
 508extern void memmap_init_zone(struct page *, unsigned long, int,
 509        unsigned long, unsigned long);
 510extern void mem_init(void);
 511extern void show_mem(void);
 512extern void si_meminfo(struct sysinfo * val);
 513extern void si_meminfo_node(struct sysinfo *val, int nid);
 514
 515/* mmap.c */
 516extern void insert_vm_struct(struct mm_struct *, struct vm_area_struct *);
 517extern void build_mmap_rb(struct mm_struct *);
 518extern void exit_mmap(struct mm_struct *);
 519
 520extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
 521
 522extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
 523        unsigned long len, unsigned long prot,
 524        unsigned long flag, unsigned long pgoff);
 525
 526static inline unsigned long do_mmap(struct file *file, unsigned long addr,
 527        unsigned long len, unsigned long prot,
 528        unsigned long flag, unsigned long offset)
 529{
 530        unsigned long ret = -EINVAL;
 531        if ((offset + PAGE_ALIGN(len)) < offset)
 532                goto out;
 533        if (!(offset & ~PAGE_MASK))
 534                ret = do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
 535out:
 536        return ret;
 537}
 538
 539extern int do_munmap(struct mm_struct *, unsigned long, size_t);
 540
 541extern unsigned long do_brk(unsigned long, unsigned long);
 542
 543static inline void
 544__vma_unlink(struct mm_struct *mm, struct vm_area_struct *vma,
 545                struct vm_area_struct *prev)
 546{
 547        prev->vm_next = vma->vm_next;
 548        rb_erase(&vma->vm_rb, &mm->mm_rb);
 549        if (mm->mmap_cache == vma)
 550                mm->mmap_cache = prev;
 551}
 552
 553static inline int
 554can_vma_merge(struct vm_area_struct *vma, unsigned long vm_flags)
 555{
 556#ifdef CONFIG_MMU
 557        if (!vma->vm_file && vma->vm_flags == vm_flags)
 558                return 1;
 559#endif
 560        return 0;
 561}
 562
 563/* filemap.c */
 564extern unsigned long page_unuse(struct page *);
 565extern void truncate_inode_pages(struct address_space *, loff_t);
 566
 567/* generic vm_area_ops exported for stackable file systems */
 568struct page *filemap_nopage(struct vm_area_struct *, unsigned long, int *);
 569
 570/* mm/page-writeback.c */
 571int write_one_page(struct page *page, int wait);
 572
 573/* readahead.c */
 574#define VM_MAX_READAHEAD        128     /* kbytes */
 575#define VM_MIN_READAHEAD        16      /* kbytes (includes current page) */
 576
 577int do_page_cache_readahead(struct address_space *mapping, struct file *filp,
 578                        unsigned long offset, unsigned long nr_to_read);
 579int force_page_cache_readahead(struct address_space *mapping, struct file *filp,
 580                        unsigned long offset, unsigned long nr_to_read);
 581void page_cache_readahead(struct address_space *mapping, 
 582                          struct file_ra_state *ra,
 583                          struct file *filp,
 584                          unsigned long offset);
 585void handle_ra_miss(struct address_space *mapping, 
 586                    struct file_ra_state *ra, pgoff_t offset);
 587unsigned long max_sane_readahead(unsigned long nr);
 588
 589/* Do stack extension */
 590extern int expand_stack(struct vm_area_struct * vma, unsigned long address);
 591
 592/* Look up the first VMA which satisfies  addr < vm_end,  NULL if none. */
 593extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long addr);
 594extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
 595                                             struct vm_area_struct **pprev);
 596extern int split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
 597                     unsigned long addr, int new_below);
 598
 599/* Look up the first VMA which intersects the interval start_addr..end_addr-1,
 600   NULL if none.  Assume start_addr < end_addr. */
 601static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
 602{
 603        struct vm_area_struct * vma = find_vma(mm,start_addr);
 604
 605        if (vma && end_addr <= vma->vm_start)
 606                vma = NULL;
 607        return vma;
 608}
 609
 610extern struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr);
 611
 612extern unsigned int nr_used_zone_pages(void);
 613
 614extern struct page * vmalloc_to_page(void *addr);
 615extern struct page * follow_page(struct mm_struct *mm, unsigned long address,
 616                int write);
 617extern int remap_page_range(struct vm_area_struct *vma, unsigned long from,
 618                unsigned long to, unsigned long size, pgprot_t prot);
 619
 620#ifndef CONFIG_DEBUG_PAGEALLOC
 621static inline void
 622kernel_map_pages(struct page *page, int numpages, int enable)
 623{
 624}
 625#endif
 626
 627#endif /* __KERNEL__ */
 628#endif /* _LINUX_MM_H */
 629
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.