4 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
8 * This file contains the default values for the operation of the
9 * Linux VM subsystem. Fine-tuning documentation can be found in
10 * Documentation/sysctl/vm.txt.
12 * Swap aging added 23.2.95, Stephen Tweedie.
13 * Buffermem limits added 12.3.98, Rik van Riel.
17 #include <linux/sched.h>
18 #include <linux/kernel_stat.h>
19 #include <linux/swap.h>
20 #include <linux/mman.h>
21 #include <linux/pagemap.h>
22 #include <linux/pagevec.h>
23 #include <linux/init.h>
24 #include <linux/export.h>
25 #include <linux/mm_inline.h>
26 #include <linux/percpu_counter.h>
27 #include <linux/percpu.h>
28 #include <linux/cpu.h>
29 #include <linux/notifier.h>
30 #include <linux/backing-dev.h>
31 #include <linux/memcontrol.h>
32 #include <linux/gfp.h>
33 #include <linux/uio.h>
34 #include <linux/hugetlb.h>
38 /* How many pages do we try to swap or page in/out together? */
41 static DEFINE_PER_CPU(struct pagevec[NR_LRU_LISTS], lru_add_pvecs);
42 static DEFINE_PER_CPU(struct pagevec, lru_rotate_pvecs);
43 static DEFINE_PER_CPU(struct pagevec, lru_deactivate_pvecs);
46 * This path almost never happens for VM activity - pages are normally
47 * freed via pagevecs. But it gets used by networking.
49 static void __page_cache_release(struct page *page)
52 struct zone *zone = page_zone(page);
53 struct lruvec *lruvec;
56 spin_lock_irqsave(&zone->lru_lock, flags);
57 lruvec = mem_cgroup_page_lruvec(page, zone);
58 VM_BUG_ON(!PageLRU(page));
60 del_page_from_lru_list(page, lruvec, page_off_lru(page));
61 spin_unlock_irqrestore(&zone->lru_lock, flags);
65 static void __put_single_page(struct page *page)
67 __page_cache_release(page);
68 free_hot_cold_page(page, 0);
71 static void __put_compound_page(struct page *page)
73 compound_page_dtor *dtor;
75 __page_cache_release(page);
76 dtor = get_compound_page_dtor(page);
80 static void put_compound_page(struct page *page)
83 * hugetlbfs pages cannot be split from under us. If this is a
84 * hugetlbfs page, check refcount on head page and release the page if
85 * the refcount becomes zero.
88 page = compound_head(page);
89 if (put_page_testzero(page))
90 __put_compound_page(page);
95 if (unlikely(PageTail(page))) {
96 /* __split_huge_page_refcount can run under us */
97 struct page *page_head = compound_trans_head(page);
99 if (likely(page != page_head &&
100 get_page_unless_zero(page_head))) {
104 * THP can not break up slab pages so avoid taking
105 * compound_lock(). Slab performs non-atomic bit ops
106 * on page->flags for better performance. In particular
107 * slab_unlock() in slub used to be a hot path. It is
108 * still hot on arches that do not support
109 * this_cpu_cmpxchg_double().
111 if (PageSlab(page_head)) {
112 if (PageTail(page)) {
113 if (put_page_testzero(page_head))
116 atomic_dec(&page->_mapcount);
122 * page_head wasn't a dangling pointer but it
123 * may not be a head page anymore by the time
124 * we obtain the lock. That is ok as long as it
125 * can't be freed from under us.
127 flags = compound_lock_irqsave(page_head);
128 if (unlikely(!PageTail(page))) {
129 /* __split_huge_page_refcount run before us */
130 compound_unlock_irqrestore(page_head, flags);
132 if (put_page_testzero(page_head))
133 __put_single_page(page_head);
135 if (put_page_testzero(page))
136 __put_single_page(page);
139 VM_BUG_ON(page_head != page->first_page);
141 * We can release the refcount taken by
142 * get_page_unless_zero() now that
143 * __split_huge_page_refcount() is blocked on
146 if (put_page_testzero(page_head))
148 /* __split_huge_page_refcount will wait now */
149 VM_BUG_ON(page_mapcount(page) <= 0);
150 atomic_dec(&page->_mapcount);
151 VM_BUG_ON(atomic_read(&page_head->_count) <= 0);
152 VM_BUG_ON(atomic_read(&page->_count) != 0);
153 compound_unlock_irqrestore(page_head, flags);
156 if (put_page_testzero(page_head)) {
157 if (PageHead(page_head))
158 __put_compound_page(page_head);
160 __put_single_page(page_head);
163 /* page_head is a dangling pointer */
164 VM_BUG_ON(PageTail(page));
167 } else if (put_page_testzero(page)) {
169 __put_compound_page(page);
171 __put_single_page(page);
175 void put_page(struct page *page)
177 if (unlikely(PageCompound(page)))
178 put_compound_page(page);
179 else if (put_page_testzero(page))
180 __put_single_page(page);
182 EXPORT_SYMBOL(put_page);
185 * This function is exported but must not be called by anything other
186 * than get_page(). It implements the slow path of get_page().
188 bool __get_page_tail(struct page *page)
191 * This takes care of get_page() if run on a tail page
192 * returned by one of the get_user_pages/follow_page variants.
193 * get_user_pages/follow_page itself doesn't need the compound
194 * lock because it runs __get_page_tail_foll() under the
195 * proper PT lock that already serializes against
199 struct page *page_head;
202 * If this is a hugetlbfs page it cannot be split under us. Simply
203 * increment refcount for the head page.
205 if (PageHuge(page)) {
206 page_head = compound_head(page);
207 atomic_inc(&page_head->_count);
212 page_head = compound_trans_head(page);
213 if (likely(page != page_head &&
214 get_page_unless_zero(page_head))) {
216 /* Ref to put_compound_page() comment. */
217 if (PageSlab(page_head)) {
218 if (likely(PageTail(page))) {
219 __get_page_tail_foll(page, false);
228 * page_head wasn't a dangling pointer but it
229 * may not be a head page anymore by the time
230 * we obtain the lock. That is ok as long as it
231 * can't be freed from under us.
233 flags = compound_lock_irqsave(page_head);
234 /* here __split_huge_page_refcount won't run anymore */
235 if (likely(PageTail(page))) {
236 __get_page_tail_foll(page, false);
239 compound_unlock_irqrestore(page_head, flags);
246 EXPORT_SYMBOL(__get_page_tail);
249 * put_pages_list() - release a list of pages
250 * @pages: list of pages threaded on page->lru
252 * Release a list of pages which are strung together on page.lru. Currently
253 * used by read_cache_pages() and related error recovery code.
255 void put_pages_list(struct list_head *pages)
257 while (!list_empty(pages)) {
260 victim = list_entry(pages->prev, struct page, lru);
261 list_del(&victim->lru);
262 page_cache_release(victim);
265 EXPORT_SYMBOL(put_pages_list);
268 * get_kernel_pages() - pin kernel pages in memory
269 * @kiov: An array of struct kvec structures
270 * @nr_segs: number of segments to pin
271 * @write: pinning for read/write, currently ignored
272 * @pages: array that receives pointers to the pages pinned.
273 * Should be at least nr_segs long.
275 * Returns number of pages pinned. This may be fewer than the number
276 * requested. If nr_pages is 0 or negative, returns 0. If no pages
277 * were pinned, returns -errno. Each page returned must be released
278 * with a put_page() call when it is finished with.
280 int get_kernel_pages(const struct kvec *kiov, int nr_segs, int write,
285 for (seg = 0; seg < nr_segs; seg++) {
286 if (WARN_ON(kiov[seg].iov_len != PAGE_SIZE))
289 pages[seg] = kmap_to_page(kiov[seg].iov_base);
290 page_cache_get(pages[seg]);
295 EXPORT_SYMBOL_GPL(get_kernel_pages);
298 * get_kernel_page() - pin a kernel page in memory
299 * @start: starting kernel address
300 * @write: pinning for read/write, currently ignored
301 * @pages: array that receives pointer to the page pinned.
302 * Must be at least nr_segs long.
304 * Returns 1 if page is pinned. If the page was not pinned, returns
305 * -errno. The page returned must be released with a put_page() call
306 * when it is finished with.
308 int get_kernel_page(unsigned long start, int write, struct page **pages)
310 const struct kvec kiov = {
311 .iov_base = (void *)start,
315 return get_kernel_pages(&kiov, 1, write, pages);
317 EXPORT_SYMBOL_GPL(get_kernel_page);
319 static void pagevec_lru_move_fn(struct pagevec *pvec,
320 void (*move_fn)(struct page *page, struct lruvec *lruvec, void *arg),
324 struct zone *zone = NULL;
325 struct lruvec *lruvec;
326 unsigned long flags = 0;
328 for (i = 0; i < pagevec_count(pvec); i++) {
329 struct page *page = pvec->pages[i];
330 struct zone *pagezone = page_zone(page);
332 if (pagezone != zone) {
334 spin_unlock_irqrestore(&zone->lru_lock, flags);
336 spin_lock_irqsave(&zone->lru_lock, flags);
339 lruvec = mem_cgroup_page_lruvec(page, zone);
340 (*move_fn)(page, lruvec, arg);
343 spin_unlock_irqrestore(&zone->lru_lock, flags);
344 release_pages(pvec->pages, pvec->nr, pvec->cold);
345 pagevec_reinit(pvec);
348 static void pagevec_move_tail_fn(struct page *page, struct lruvec *lruvec,
353 if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) {
354 enum lru_list lru = page_lru_base_type(page);
355 list_move_tail(&page->lru, &lruvec->lists[lru]);
361 * pagevec_move_tail() must be called with IRQ disabled.
362 * Otherwise this may cause nasty races.
364 static void pagevec_move_tail(struct pagevec *pvec)
368 pagevec_lru_move_fn(pvec, pagevec_move_tail_fn, &pgmoved);
369 __count_vm_events(PGROTATED, pgmoved);
373 * Writeback is about to end against a page which has been marked for immediate
374 * reclaim. If it still appears to be reclaimable, move it to the tail of the
377 void rotate_reclaimable_page(struct page *page)
379 if (!PageLocked(page) && !PageDirty(page) && !PageActive(page) &&
380 !PageUnevictable(page) && PageLRU(page)) {
381 struct pagevec *pvec;
384 page_cache_get(page);
385 local_irq_save(flags);
386 pvec = &__get_cpu_var(lru_rotate_pvecs);
387 if (!pagevec_add(pvec, page))
388 pagevec_move_tail(pvec);
389 local_irq_restore(flags);
393 static void update_page_reclaim_stat(struct lruvec *lruvec,
394 int file, int rotated)
396 struct zone_reclaim_stat *reclaim_stat = &lruvec->reclaim_stat;
398 reclaim_stat->recent_scanned[file]++;
400 reclaim_stat->recent_rotated[file]++;
403 static void __activate_page(struct page *page, struct lruvec *lruvec,
406 if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) {
407 int file = page_is_file_cache(page);
408 int lru = page_lru_base_type(page);
410 del_page_from_lru_list(page, lruvec, lru);
413 add_page_to_lru_list(page, lruvec, lru);
415 __count_vm_event(PGACTIVATE);
416 update_page_reclaim_stat(lruvec, file, 1);
421 static DEFINE_PER_CPU(struct pagevec, activate_page_pvecs);
423 static void activate_page_drain(int cpu)
425 struct pagevec *pvec = &per_cpu(activate_page_pvecs, cpu);
427 if (pagevec_count(pvec))
428 pagevec_lru_move_fn(pvec, __activate_page, NULL);
431 void activate_page(struct page *page)
433 if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) {
434 struct pagevec *pvec = &get_cpu_var(activate_page_pvecs);
436 page_cache_get(page);
437 if (!pagevec_add(pvec, page))
438 pagevec_lru_move_fn(pvec, __activate_page, NULL);
439 put_cpu_var(activate_page_pvecs);
444 static inline void activate_page_drain(int cpu)
448 void activate_page(struct page *page)
450 struct zone *zone = page_zone(page);
452 spin_lock_irq(&zone->lru_lock);
453 __activate_page(page, mem_cgroup_page_lruvec(page, zone), NULL);
454 spin_unlock_irq(&zone->lru_lock);
459 * Mark a page as having seen activity.
461 * inactive,unreferenced -> inactive,referenced
462 * inactive,referenced -> active,unreferenced
463 * active,unreferenced -> active,referenced
465 void mark_page_accessed(struct page *page)
467 if (!PageActive(page) && !PageUnevictable(page) &&
468 PageReferenced(page) && PageLRU(page)) {
470 ClearPageReferenced(page);
471 } else if (!PageReferenced(page)) {
472 SetPageReferenced(page);
475 EXPORT_SYMBOL(mark_page_accessed);
478 * Order of operations is important: flush the pagevec when it's already
479 * full, not when adding the last page, to make sure that last page is
480 * not added to the LRU directly when passed to this function. Because
481 * mark_page_accessed() (called after this when writing) only activates
482 * pages that are on the LRU, linear writes in subpage chunks would see
483 * every PAGEVEC_SIZE page activated, which is unexpected.
485 void __lru_cache_add(struct page *page, enum lru_list lru)
487 struct pagevec *pvec = &get_cpu_var(lru_add_pvecs)[lru];
489 page_cache_get(page);
490 if (!pagevec_space(pvec))
491 __pagevec_lru_add(pvec, lru);
492 pagevec_add(pvec, page);
493 put_cpu_var(lru_add_pvecs);
495 EXPORT_SYMBOL(__lru_cache_add);
498 * lru_cache_add_lru - add a page to a page list
499 * @page: the page to be added to the LRU.
500 * @lru: the LRU list to which the page is added.
502 void lru_cache_add_lru(struct page *page, enum lru_list lru)
504 if (PageActive(page)) {
505 VM_BUG_ON(PageUnevictable(page));
506 ClearPageActive(page);
507 } else if (PageUnevictable(page)) {
508 VM_BUG_ON(PageActive(page));
509 ClearPageUnevictable(page);
512 VM_BUG_ON(PageLRU(page) || PageActive(page) || PageUnevictable(page));
513 __lru_cache_add(page, lru);
517 * add_page_to_unevictable_list - add a page to the unevictable list
518 * @page: the page to be added to the unevictable list
520 * Add page directly to its zone's unevictable list. To avoid races with
521 * tasks that might be making the page evictable, through eg. munlock,
522 * munmap or exit, while it's not on the lru, we want to add the page
523 * while it's locked or otherwise "invisible" to other tasks. This is
524 * difficult to do when using the pagevec cache, so bypass that.
526 void add_page_to_unevictable_list(struct page *page)
528 struct zone *zone = page_zone(page);
529 struct lruvec *lruvec;
531 spin_lock_irq(&zone->lru_lock);
532 lruvec = mem_cgroup_page_lruvec(page, zone);
533 SetPageUnevictable(page);
535 add_page_to_lru_list(page, lruvec, LRU_UNEVICTABLE);
536 spin_unlock_irq(&zone->lru_lock);
540 * If the page can not be invalidated, it is moved to the
541 * inactive list to speed up its reclaim. It is moved to the
542 * head of the list, rather than the tail, to give the flusher
543 * threads some time to write it out, as this is much more
544 * effective than the single-page writeout from reclaim.
546 * If the page isn't page_mapped and dirty/writeback, the page
547 * could reclaim asap using PG_reclaim.
549 * 1. active, mapped page -> none
550 * 2. active, dirty/writeback page -> inactive, head, PG_reclaim
551 * 3. inactive, mapped page -> none
552 * 4. inactive, dirty/writeback page -> inactive, head, PG_reclaim
553 * 5. inactive, clean -> inactive, tail
556 * In 4, why it moves inactive's head, the VM expects the page would
557 * be write it out by flusher threads as this is much more effective
558 * than the single-page writeout from reclaim.
560 static void lru_deactivate_fn(struct page *page, struct lruvec *lruvec,
569 if (PageUnevictable(page))
572 /* Some processes are using the page */
573 if (page_mapped(page))
576 active = PageActive(page);
577 file = page_is_file_cache(page);
578 lru = page_lru_base_type(page);
580 del_page_from_lru_list(page, lruvec, lru + active);
581 ClearPageActive(page);
582 ClearPageReferenced(page);
583 add_page_to_lru_list(page, lruvec, lru);
585 if (PageWriteback(page) || PageDirty(page)) {
587 * PG_reclaim could be raced with end_page_writeback
588 * It can make readahead confusing. But race window
589 * is _really_ small and it's non-critical problem.
591 SetPageReclaim(page);
594 * The page's writeback ends up during pagevec
595 * We moves tha page into tail of inactive.
597 list_move_tail(&page->lru, &lruvec->lists[lru]);
598 __count_vm_event(PGROTATED);
602 __count_vm_event(PGDEACTIVATE);
603 update_page_reclaim_stat(lruvec, file, 0);
607 * Drain pages out of the cpu's pagevecs.
608 * Either "cpu" is the current CPU, and preemption has already been
609 * disabled; or "cpu" is being hot-unplugged, and is already dead.
611 void lru_add_drain_cpu(int cpu)
613 struct pagevec *pvecs = per_cpu(lru_add_pvecs, cpu);
614 struct pagevec *pvec;
618 pvec = &pvecs[lru - LRU_BASE];
619 if (pagevec_count(pvec))
620 __pagevec_lru_add(pvec, lru);
623 pvec = &per_cpu(lru_rotate_pvecs, cpu);
624 if (pagevec_count(pvec)) {
627 /* No harm done if a racing interrupt already did this */
628 local_irq_save(flags);
629 pagevec_move_tail(pvec);
630 local_irq_restore(flags);
633 pvec = &per_cpu(lru_deactivate_pvecs, cpu);
634 if (pagevec_count(pvec))
635 pagevec_lru_move_fn(pvec, lru_deactivate_fn, NULL);
637 activate_page_drain(cpu);
641 * deactivate_page - forcefully deactivate a page
642 * @page: page to deactivate
644 * This function hints the VM that @page is a good reclaim candidate,
645 * for example if its invalidation fails due to the page being dirty
646 * or under writeback.
648 void deactivate_page(struct page *page)
651 * In a workload with many unevictable page such as mprotect, unevictable
652 * page deactivation for accelerating reclaim is pointless.
654 if (PageUnevictable(page))
657 if (likely(get_page_unless_zero(page))) {
658 struct pagevec *pvec = &get_cpu_var(lru_deactivate_pvecs);
660 if (!pagevec_add(pvec, page))
661 pagevec_lru_move_fn(pvec, lru_deactivate_fn, NULL);
662 put_cpu_var(lru_deactivate_pvecs);
666 void lru_add_drain(void)
668 lru_add_drain_cpu(get_cpu());
672 static void lru_add_drain_per_cpu(struct work_struct *dummy)
678 * Returns 0 for success
680 int lru_add_drain_all(void)
682 return schedule_on_each_cpu(lru_add_drain_per_cpu);
686 * Batched page_cache_release(). Decrement the reference count on all the
687 * passed pages. If it fell to zero then remove the page from the LRU and
690 * Avoid taking zone->lru_lock if possible, but if it is taken, retain it
691 * for the remainder of the operation.
693 * The locking in this function is against shrink_inactive_list(): we recheck
694 * the page count inside the lock to see whether shrink_inactive_list()
695 * grabbed the page via the LRU. If it did, give up: shrink_inactive_list()
698 void release_pages(struct page **pages, int nr, int cold)
701 LIST_HEAD(pages_to_free);
702 struct zone *zone = NULL;
703 struct lruvec *lruvec;
704 unsigned long uninitialized_var(flags);
706 for (i = 0; i < nr; i++) {
707 struct page *page = pages[i];
709 if (unlikely(PageCompound(page))) {
711 spin_unlock_irqrestore(&zone->lru_lock, flags);
714 put_compound_page(page);
718 if (!put_page_testzero(page))
722 struct zone *pagezone = page_zone(page);
724 if (pagezone != zone) {
726 spin_unlock_irqrestore(&zone->lru_lock,
729 spin_lock_irqsave(&zone->lru_lock, flags);
732 lruvec = mem_cgroup_page_lruvec(page, zone);
733 VM_BUG_ON(!PageLRU(page));
734 __ClearPageLRU(page);
735 del_page_from_lru_list(page, lruvec, page_off_lru(page));
738 list_add(&page->lru, &pages_to_free);
741 spin_unlock_irqrestore(&zone->lru_lock, flags);
743 free_hot_cold_page_list(&pages_to_free, cold);
745 EXPORT_SYMBOL(release_pages);
748 * The pages which we're about to release may be in the deferred lru-addition
749 * queues. That would prevent them from really being freed right now. That's
750 * OK from a correctness point of view but is inefficient - those pages may be
751 * cache-warm and we want to give them back to the page allocator ASAP.
753 * So __pagevec_release() will drain those queues here. __pagevec_lru_add()
754 * and __pagevec_lru_add_active() call release_pages() directly to avoid
757 void __pagevec_release(struct pagevec *pvec)
760 release_pages(pvec->pages, pagevec_count(pvec), pvec->cold);
761 pagevec_reinit(pvec);
763 EXPORT_SYMBOL(__pagevec_release);
765 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
766 /* used by __split_huge_page_refcount() */
767 void lru_add_page_tail(struct page *page, struct page *page_tail,
768 struct lruvec *lruvec, struct list_head *list)
770 int uninitialized_var(active);
774 VM_BUG_ON(!PageHead(page));
775 VM_BUG_ON(PageCompound(page_tail));
776 VM_BUG_ON(PageLRU(page_tail));
777 VM_BUG_ON(NR_CPUS != 1 &&
778 !spin_is_locked(&lruvec_zone(lruvec)->lru_lock));
781 SetPageLRU(page_tail);
783 if (page_evictable(page_tail)) {
784 if (PageActive(page)) {
785 SetPageActive(page_tail);
787 lru = LRU_ACTIVE_ANON;
790 lru = LRU_INACTIVE_ANON;
793 SetPageUnevictable(page_tail);
794 lru = LRU_UNEVICTABLE;
797 if (likely(PageLRU(page)))
798 list_add_tail(&page_tail->lru, &page->lru);
800 /* page reclaim is reclaiming a huge page */
802 list_add_tail(&page_tail->lru, list);
804 struct list_head *list_head;
806 * Head page has not yet been counted, as an hpage,
807 * so we must account for each subpage individually.
809 * Use the standard add function to put page_tail on the list,
810 * but then correct its position so they all end up in order.
812 add_page_to_lru_list(page_tail, lruvec, lru);
813 list_head = page_tail->lru.prev;
814 list_move_tail(&page_tail->lru, list_head);
817 if (!PageUnevictable(page))
818 update_page_reclaim_stat(lruvec, file, active);
820 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
822 static void __pagevec_lru_add_fn(struct page *page, struct lruvec *lruvec,
825 enum lru_list lru = (enum lru_list)arg;
826 int file = is_file_lru(lru);
827 int active = is_active_lru(lru);
829 VM_BUG_ON(PageActive(page));
830 VM_BUG_ON(PageUnevictable(page));
831 VM_BUG_ON(PageLRU(page));
836 add_page_to_lru_list(page, lruvec, lru);
837 update_page_reclaim_stat(lruvec, file, active);
841 * Add the passed pages to the LRU, then drop the caller's refcount
842 * on them. Reinitialises the caller's pagevec.
844 void __pagevec_lru_add(struct pagevec *pvec, enum lru_list lru)
846 VM_BUG_ON(is_unevictable_lru(lru));
848 pagevec_lru_move_fn(pvec, __pagevec_lru_add_fn, (void *)lru);
850 EXPORT_SYMBOL(__pagevec_lru_add);
853 * pagevec_lookup - gang pagecache lookup
854 * @pvec: Where the resulting pages are placed
855 * @mapping: The address_space to search
856 * @start: The starting page index
857 * @nr_pages: The maximum number of pages
859 * pagevec_lookup() will search for and return a group of up to @nr_pages pages
860 * in the mapping. The pages are placed in @pvec. pagevec_lookup() takes a
861 * reference against the pages in @pvec.
863 * The search returns a group of mapping-contiguous pages with ascending
864 * indexes. There may be holes in the indices due to not-present pages.
866 * pagevec_lookup() returns the number of pages which were found.
868 unsigned pagevec_lookup(struct pagevec *pvec, struct address_space *mapping,
869 pgoff_t start, unsigned nr_pages)
871 pvec->nr = find_get_pages(mapping, start, nr_pages, pvec->pages);
872 return pagevec_count(pvec);
874 EXPORT_SYMBOL(pagevec_lookup);
876 unsigned pagevec_lookup_tag(struct pagevec *pvec, struct address_space *mapping,
877 pgoff_t *index, int tag, unsigned nr_pages)
879 pvec->nr = find_get_pages_tag(mapping, index, tag,
880 nr_pages, pvec->pages);
881 return pagevec_count(pvec);
883 EXPORT_SYMBOL(pagevec_lookup_tag);
886 * Perform any setup for the swap system
888 void __init swap_setup(void)
890 unsigned long megs = totalram_pages >> (20 - PAGE_SHIFT);
894 bdi_init(swapper_spaces[0].backing_dev_info);
895 for (i = 0; i < MAX_SWAPFILES; i++) {
896 spin_lock_init(&swapper_spaces[i].tree_lock);
897 INIT_LIST_HEAD(&swapper_spaces[i].i_mmap_nonlinear);
901 /* Use a smaller cluster for small-memory machines */
907 * Right now other parts of the system means that we
908 * _really_ don't want to cluster much more