Skip to content
Snippets Groups Projects
Select Git revision
  • ff17bf8a0d2d60a343db304b835c0e83efa660d9
  • master default
  • android-container
  • nanopc-t4
  • for-kernelci
  • WIP-syscall
  • v4.16-rc5
  • v4.16-rc4
  • v4.16-rc3
  • v4.16-rc2
  • v4.16-rc1
  • v4.15
  • v4.15-rc9
  • v4.15-rc8
  • v4.15-rc7
  • v4.15-rc6
  • v4.15-rc5
  • v4.15-rc4
  • v4.15-rc3
  • v4.15-rc2
  • v4.15-rc1
  • v4.14
  • v4.14-rc8
  • v4.14-rc7
  • v4.14-rc6
  • v4.14-rc5
26 results

fault.c

Blame
  • swap_state.c 22.42 KiB
    // SPDX-License-Identifier: GPL-2.0
    /*
     *  linux/mm/swap_state.c
     *
     *  Copyright (C) 1991, 1992, 1993, 1994  Linus Torvalds
     *  Swap reorganised 29.12.95, Stephen Tweedie
     *
     *  Rewritten to use page cache, (C) 1998 Stephen Tweedie
     */
    #include <linux/mm.h>
    #include <linux/gfp.h>
    #include <linux/kernel_stat.h>
    #include <linux/swap.h>
    #include <linux/swapops.h>
    #include <linux/init.h>
    #include <linux/pagemap.h>
    #include <linux/backing-dev.h>
    #include <linux/blkdev.h>
    #include <linux/pagevec.h>
    #include <linux/migrate.h>
    #include <linux/vmalloc.h>
    #include <linux/swap_slots.h>
    #include <linux/huge_mm.h>
    
    #include <asm/pgtable.h>
    
    /*
     * swapper_space is a fiction, retained to simplify the path through
     * vmscan's shrink_page_list.
     */
    static const struct address_space_operations swap_aops = {
    	.writepage	= swap_writepage,
    	.set_page_dirty	= swap_set_page_dirty,
    #ifdef CONFIG_MIGRATION
    	.migratepage	= migrate_page,
    #endif
    };
    
    struct address_space *swapper_spaces[MAX_SWAPFILES] __read_mostly;
    static unsigned int nr_swapper_spaces[MAX_SWAPFILES] __read_mostly;
    static bool enable_vma_readahead __read_mostly = true;
    
    #define SWAP_RA_WIN_SHIFT	(PAGE_SHIFT / 2)
    #define SWAP_RA_HITS_MASK	((1UL << SWAP_RA_WIN_SHIFT) - 1)
    #define SWAP_RA_HITS_MAX	SWAP_RA_HITS_MASK
    #define SWAP_RA_WIN_MASK	(~PAGE_MASK & ~SWAP_RA_HITS_MASK)
    
    #define SWAP_RA_HITS(v)		((v) & SWAP_RA_HITS_MASK)
    #define SWAP_RA_WIN(v)		(((v) & SWAP_RA_WIN_MASK) >> SWAP_RA_WIN_SHIFT)
    #define SWAP_RA_ADDR(v)		((v) & PAGE_MASK)
    
    #define SWAP_RA_VAL(addr, win, hits)				\
    	(((addr) & PAGE_MASK) |					\
    	 (((win) << SWAP_RA_WIN_SHIFT) & SWAP_RA_WIN_MASK) |	\
    	 ((hits) & SWAP_RA_HITS_MASK))
    
    /* Initial readahead hits is 4 to start up with a small window */
    #define GET_SWAP_RA_VAL(vma)					\
    	(atomic_long_read(&(vma)->swap_readahead_info) ? : 4)
    
    #define INC_CACHE_INFO(x)	do { swap_cache_info.x++; } while (0)
    #define ADD_CACHE_INFO(x, nr)	do { swap_cache_info.x += (nr); } while (0)
    
    static struct {
    	unsigned long add_total;
    	unsigned long del_total;
    	unsigned long find_success;
    	unsigned long find_total;
    } swap_cache_info;