Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
422 giacomo 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 */
17
extern unsigned long max_mapnr;
18
#endif
19
 
20
extern unsigned long num_physpages;
21
extern void * high_memory;
22
extern 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
 */
51
struct 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
 */
135
extern 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
 */
143
struct 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 unused);
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 */
151
struct pte_chain;
152
struct mmu_gather;
153
struct 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
 */
170
struct 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
 
230
extern void FASTCALL(__page_cache_release(struct page *));
231
 
232
#ifdef CONFIG_HUGETLB_PAGE
233
 
234
static 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
 
241
static 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
 
260
static inline void get_page(struct page *page)
261
{
262
        atomic_inc(&page->count);
263
}
264
 
265
static 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
 */
326
#define ZONE_SHIFT (BITS_PER_LONG - 8)
327
 
328
struct zone;
329
extern struct zone *zone_table[];
330
 
331
static inline struct zone *page_zone(struct page *page)
332
{
333
        return zone_table[page->flags >> ZONE_SHIFT];
334
}
335
 
336
static inline void set_page_zone(struct page *page, unsigned long zone_num)
337
{
338
        page->flags &= ~(~0UL << ZONE_SHIFT);
339
        page->flags |= zone_num << ZONE_SHIFT;
340
}
341
 
342
#ifndef CONFIG_DISCONTIGMEM
343
/* The array of struct pages - for discontigmem use pgdat->lmem_map */
344
extern struct page *mem_map;
345
#endif
346
 
347
static inline void *lowmem_page_address(struct page *page)
348
{
349
        return __va(page_to_pfn(page) << PAGE_SHIFT);
350
}
351
 
352
#if defined(CONFIG_HIGHMEM) && !defined(WANT_PAGE_VIRTUAL)
353
#define HASHED_PAGE_VIRTUAL
354
#endif
355
 
356
#if defined(WANT_PAGE_VIRTUAL)
357
#define page_address(page) ((page)->virtual)
358
#define set_page_address(page, address)                 \
359
        do {                                            \
360
                (page)->virtual = (address);            \
361
        } while(0)
362
#define page_address_init()  do { } while(0)
363
#endif
364
 
365
#if defined(HASHED_PAGE_VIRTUAL)
366
void *page_address(struct page *page);
367
void set_page_address(struct page *page, void *virtual);
368
void page_address_init(void);
369
#endif
370
 
371
#if !defined(HASHED_PAGE_VIRTUAL) && !defined(WANT_PAGE_VIRTUAL)
372
#define page_address(page) lowmem_page_address(page)
373
#define set_page_address(page, address)  do { } while(0)
374
#define page_address_init()  do { } while(0)
375
#endif
376
 
377
/*
378
 * Return true if this page is mapped into pagetables.  Subtle: test pte.direct
379
 * rather than pte.chain.  Because sometimes pte.direct is 64-bit, and .chain
380
 * is only 32-bit.
381
 */
382
static inline int page_mapped(struct page *page)
383
{
384
        return page->pte.direct != 0;
385
}
386
 
387
/*
388
 * Error return values for the *_nopage functions
389
 */
390
#define NOPAGE_SIGBUS   (NULL)
391
#define NOPAGE_OOM      ((struct page *) (-1))
392
 
393
/*
394
 * Different kinds of faults, as returned by handle_mm_fault().
395
 * Used to decide whether a process gets delivered SIGBUS or
396
 * just gets major/minor fault counters bumped up.
397
 */
398
#define VM_FAULT_OOM    (-1)
399
#define VM_FAULT_SIGBUS 0
400
#define VM_FAULT_MINOR  1
401
#define VM_FAULT_MAJOR  2
402
 
403
#define offset_in_page(p)       ((unsigned long)(p) & ~PAGE_MASK)
404
 
405
extern void show_free_areas(void);
406
 
407
struct page *shmem_nopage(struct vm_area_struct * vma,
408
                        unsigned long address, int unused);
409
struct file *shmem_file_setup(char * name, loff_t size, unsigned long flags);
410
void shmem_lock(struct file * file, int lock);
411
int shmem_zero_setup(struct vm_area_struct *);
412
 
413
void zap_page_range(struct vm_area_struct *vma, unsigned long address,
414
                        unsigned long size);
415
int unmap_vmas(struct mmu_gather **tlbp, struct mm_struct *mm,
416
                struct vm_area_struct *start_vma, unsigned long start_addr,
417
                unsigned long end_addr, unsigned long *nr_accounted);
418
void unmap_page_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
419
                        unsigned long address, unsigned long size);
420
void clear_page_tables(struct mmu_gather *tlb, unsigned long first, int nr);
421
int copy_page_range(struct mm_struct *dst, struct mm_struct *src,
422
                        struct vm_area_struct *vma);
423
int zeromap_page_range(struct vm_area_struct *vma, unsigned long from,
424
                        unsigned long size, pgprot_t prot);
425
 
426
extern void invalidate_mmap_range(struct address_space *mapping,
427
                                  loff_t const holebegin,
428
                                  loff_t const holelen);
429
extern int vmtruncate(struct inode * inode, loff_t offset);
430
extern pmd_t *FASTCALL(__pmd_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address));
431
extern pte_t *FASTCALL(pte_alloc_kernel(struct mm_struct *mm, pmd_t *pmd, unsigned long address));
432
extern pte_t *FASTCALL(pte_alloc_map(struct mm_struct *mm, pmd_t *pmd, unsigned long address));
433
extern int install_page(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, struct page *page, pgprot_t prot);
434
extern int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned long pgoff, pgprot_t prot);
435
extern int handle_mm_fault(struct mm_struct *mm,struct vm_area_struct *vma, unsigned long address, int write_access);
436
extern int make_pages_present(unsigned long addr, unsigned long end);
437
extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
438
extern long sys_remap_file_pages(unsigned long start, unsigned long size, unsigned long prot, unsigned long pgoff, unsigned long nonblock);
439
extern long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice);
440
void put_dirty_page(struct task_struct *tsk, struct page *page,
441
                        unsigned long address, pgprot_t prot);
442
 
443
int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start,
444
                int len, int write, int force, struct page **pages, struct vm_area_struct **vmas);
445
 
446
int __set_page_dirty_buffers(struct page *page);
447
int __set_page_dirty_nobuffers(struct page *page);
448
int set_page_dirty_lock(struct page *page);
449
 
450
/*
451
 * Prototype to add a shrinker callback for ageable caches.
452
 *
453
 * These functions are passed a count `nr_to_scan' and a gfpmask.  They should
454
 * scan `nr_to_scan' objects, attempting to free them.
455
 *
456
 * The callback must the number of objects which remain in the cache.
457
 *
458
 * The callback will be passes nr_to_scan == 0 when the VM is querying the
459
 * cache size, so a fastpath for that case is appropriate.
460
 */
461
typedef int (*shrinker_t)(int nr_to_scan, unsigned int gfp_mask);
462
 
463
/*
464
 * Add an aging callback.  The int is the number of 'seeks' it takes
465
 * to recreate one of the objects that these functions age.
466
 */
467
 
468
#define DEFAULT_SEEKS 2
469
struct shrinker;
470
extern struct shrinker *set_shrinker(int, shrinker_t);
471
extern void remove_shrinker(struct shrinker *shrinker);
472
 
473
/*
474
 * If the mapping doesn't provide a set_page_dirty a_op, then
475
 * just fall through and assume that it wants buffer_heads.
476
 * FIXME: make the method unconditional.
477
 */
478
static inline int set_page_dirty(struct page *page)
479
{
480
        if (page->mapping) {
481
                int (*spd)(struct page *);
482
 
483
                spd = page->mapping->a_ops->set_page_dirty;
484
                if (spd)
485
                        return (*spd)(page);
486
        }
487
        return __set_page_dirty_buffers(page);
488
}
489
 
490
/*
491
 * On a two-level page table, this ends up being trivial. Thus the
492
 * inlining and the symmetry break with pte_alloc_map() that does all
493
 * of this out-of-line.
494
 */
495
static inline pmd_t *pmd_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
496
{
497
        if (pgd_none(*pgd))
498
                return __pmd_alloc(mm, pgd, address);
499
        return pmd_offset(pgd, address);
500
}
501
 
502
extern void free_area_init(unsigned long * zones_size);
503
extern void free_area_init_node(int nid, pg_data_t *pgdat, struct page *pmap,
504
        unsigned long * zones_size, unsigned long zone_start_pfn,
505
        unsigned long *zholes_size);
506
extern void memmap_init_zone(struct page *, unsigned long, int,
507
        unsigned long, unsigned long);
508
extern void mem_init(void);
509
extern void show_mem(void);
510
extern void si_meminfo(struct sysinfo * val);
511
extern void si_meminfo_node(struct sysinfo *val, int nid);
512
 
513
/* mmap.c */
514
extern void insert_vm_struct(struct mm_struct *, struct vm_area_struct *);
515
extern void build_mmap_rb(struct mm_struct *);
516
extern void exit_mmap(struct mm_struct *);
517
 
518
extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
519
 
520
extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
521
        unsigned long len, unsigned long prot,
522
        unsigned long flag, unsigned long pgoff);
523
 
524
static inline unsigned long do_mmap(struct file *file, unsigned long addr,
525
        unsigned long len, unsigned long prot,
526
        unsigned long flag, unsigned long offset)
527
{
528
        unsigned long ret = -EINVAL;
529
        if ((offset + PAGE_ALIGN(len)) < offset)
530
                goto out;
531
        if (!(offset & ~PAGE_MASK))
532
                ret = do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
533
out:
534
        return ret;
535
}
536
 
537
extern int do_munmap(struct mm_struct *, unsigned long, size_t);
538
 
539
extern unsigned long do_brk(unsigned long, unsigned long);
540
 
541
static inline void
542
__vma_unlink(struct mm_struct *mm, struct vm_area_struct *vma,
543
                struct vm_area_struct *prev)
544
{
545
        prev->vm_next = vma->vm_next;
546
        rb_erase(&vma->vm_rb, &mm->mm_rb);
547
        if (mm->mmap_cache == vma)
548
                mm->mmap_cache = prev;
549
}
550
 
551
static inline int
552
can_vma_merge(struct vm_area_struct *vma, unsigned long vm_flags)
553
{
554
#ifdef CONFIG_MMU
555
        if (!vma->vm_file && vma->vm_flags == vm_flags)
556
                return 1;
557
#endif
558
        return 0;
559
}
560
 
561
/* filemap.c */
562
extern unsigned long page_unuse(struct page *);
563
extern void truncate_inode_pages(struct address_space *, loff_t);
564
 
565
/* generic vm_area_ops exported for stackable file systems */
566
extern struct page *filemap_nopage(struct vm_area_struct *, unsigned long, int);
567
 
568
/* mm/page-writeback.c */
569
int write_one_page(struct page *page, int wait);
570
 
571
/* readahead.c */
572
#define VM_MAX_READAHEAD        128     /* kbytes */
573
#define VM_MIN_READAHEAD        16      /* kbytes (includes current page) */
574
 
575
int do_page_cache_readahead(struct address_space *mapping, struct file *filp,
576
                        unsigned long offset, unsigned long nr_to_read);
577
int force_page_cache_readahead(struct address_space *mapping, struct file *filp,
578
                        unsigned long offset, unsigned long nr_to_read);
579
void page_cache_readahead(struct address_space *mapping,
580
                          struct file_ra_state *ra,
581
                          struct file *filp,
582
                          unsigned long offset);
583
void handle_ra_miss(struct address_space *mapping,
584
                    struct file_ra_state *ra, pgoff_t offset);
585
unsigned long max_sane_readahead(unsigned long nr);
586
 
587
/* Do stack extension */
588
extern int expand_stack(struct vm_area_struct * vma, unsigned long address);
589
 
590
/* Look up the first VMA which satisfies  addr < vm_end,  NULL if none. */
591
extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long addr);
592
extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
593
                                             struct vm_area_struct **pprev);
594
extern int split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
595
                     unsigned long addr, int new_below);
596
 
597
/* Look up the first VMA which intersects the interval start_addr..end_addr-1,
598
   NULL if none.  Assume start_addr < end_addr. */
599
static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
600
{
601
        struct vm_area_struct * vma = find_vma(mm,start_addr);
602
 
603
        if (vma && end_addr <= vma->vm_start)
604
                vma = NULL;
605
        return vma;
606
}
607
 
608
extern struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr);
609
 
610
extern unsigned int nr_used_zone_pages(void);
611
 
612
extern struct page * vmalloc_to_page(void *addr);
613
extern struct page * follow_page(struct mm_struct *mm, unsigned long address,
614
                int write);
615
extern int remap_page_range(struct vm_area_struct *vma, unsigned long from,
616
                unsigned long to, unsigned long size, pgprot_t prot);
617
 
618
#ifndef CONFIG_DEBUG_PAGEALLOC
619
static inline void
620
kernel_map_pages(struct page *page, int numpages, int enable)
621
{
622
}
623
#endif
624
 
625
#endif /* __KERNEL__ */
626
#endif /* _LINUX_MM_H */