Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
page_alloc.c File Reference
#include <linux/stddef.h>
#include <linux/mm.h>
#include <linux/swap.h>
#include <linux/interrupt.h>
#include <linux/pagemap.h>
#include <linux/jiffies.h>
#include <linux/bootmem.h>
#include <linux/memblock.h>
#include <linux/compiler.h>
#include <linux/kernel.h>
#include <linux/kmemcheck.h>
#include <linux/module.h>
#include <linux/suspend.h>
#include <linux/pagevec.h>
#include <linux/blkdev.h>
#include <linux/slab.h>
#include <linux/ratelimit.h>
#include <linux/oom.h>
#include <linux/notifier.h>
#include <linux/topology.h>
#include <linux/sysctl.h>
#include <linux/cpu.h>
#include <linux/cpuset.h>
#include <linux/memory_hotplug.h>
#include <linux/nodemask.h>
#include <linux/vmalloc.h>
#include <linux/vmstat.h>
#include <linux/mempolicy.h>
#include <linux/stop_machine.h>
#include <linux/sort.h>
#include <linux/pfn.h>
#include <linux/backing-dev.h>
#include <linux/fault-inject.h>
#include <linux/page-isolation.h>
#include <linux/page_cgroup.h>
#include <linux/debugobjects.h>
#include <linux/kmemleak.h>
#include <linux/compaction.h>
#include <trace/events/kmem.h>
#include <linux/ftrace_event.h>
#include <linux/memcontrol.h>
#include <linux/prefetch.h>
#include <linux/migrate.h>
#include <linux/page-debug-flags.h>
#include <asm/tlbflush.h>
#include <asm/div64.h>
#include "internal.h"

Go to the source code of this file.

Macros

#define K(x)   ((x) << (PAGE_SHIFT-10))
 
#define ZONELIST_ORDER_DEFAULT   0
 
#define ZONELIST_ORDER_NODE   1
 
#define ZONELIST_ORDER_ZONE   2
 
#define PAGES_PER_WAITQUEUE   256
 
#define LONG_ALIGN(x)   (((x)+(sizeof(long))-1)&~((sizeof(long))-1))
 
#define memmap_init(size, nid, zone, start_pfn)   memmap_init_zone((size), (nid), (zone), (start_pfn), MEMMAP_EARLY)
 

Functions

 EXPORT_SYMBOL (node_states)
 
 EXPORT_SYMBOL (totalram_pages)
 
void set_pageblock_migratetype (struct page *page, int migratetype)
 
void prep_compound_page (struct page *page, unsigned long order)
 
void __meminit __free_pages_bootmem (struct page *page, unsigned int order)
 
int move_freepages (struct zone *zone, struct page *start_page, struct page *end_page, int migratetype)
 
int move_freepages_block (struct zone *zone, struct page *page, int migratetype)
 
void drain_local_pages (void *arg)
 
void drain_all_pages (void)
 
void free_hot_cold_page (struct page *page, int cold)
 
void free_hot_cold_page_list (struct list_head *list, int cold)
 
void split_page (struct page *page, unsigned int order)
 
int capture_free_page (struct page *page, int alloc_order, int migratetype)
 
int split_free_page (struct page *page)
 
bool zone_watermark_ok (struct zone *z, int order, unsigned long mark, int classzone_idx, int alloc_flags)
 
bool zone_watermark_ok_safe (struct zone *z, int order, unsigned long mark, int classzone_idx, int alloc_flags)
 
void warn_alloc_failed (gfp_t gfp_mask, int order, const char *fmt,...)
 
bool gfp_pfmemalloc_allowed (gfp_t gfp_mask)
 
struct page__alloc_pages_nodemask (gfp_t gfp_mask, unsigned int order, struct zonelist *zonelist, nodemask_t *nodemask)
 
 EXPORT_SYMBOL (__alloc_pages_nodemask)
 
unsigned long __get_free_pages (gfp_t gfp_mask, unsigned int order)
 
 EXPORT_SYMBOL (__get_free_pages)
 
unsigned long get_zeroed_page (gfp_t gfp_mask)
 
 EXPORT_SYMBOL (get_zeroed_page)
 
void __free_pages (struct page *page, unsigned int order)
 
 EXPORT_SYMBOL (__free_pages)
 
void free_pages (unsigned long addr, unsigned int order)
 
 EXPORT_SYMBOL (free_pages)
 
voidalloc_pages_exact (size_t size, gfp_t gfp_mask)
 
 EXPORT_SYMBOL (alloc_pages_exact)
 
voidalloc_pages_exact_nid (int nid, size_t size, gfp_t gfp_mask)
 
 EXPORT_SYMBOL (alloc_pages_exact_nid)
 
void free_pages_exact (void *virt, size_t size)
 
 EXPORT_SYMBOL (free_pages_exact)
 
unsigned int nr_free_buffer_pages (void)
 
 EXPORT_SYMBOL_GPL (nr_free_buffer_pages)
 
unsigned int nr_free_pagecache_pages (void)
 
void si_meminfo (struct sysinfo *val)
 
 EXPORT_SYMBOL (si_meminfo)
 
bool skip_free_areas_node (unsigned int flags, int nid)
 
void show_free_areas (unsigned int filter)
 
 DEFINE_MUTEX (zonelists_mutex)
 
void __ref build_all_zonelists (pg_data_t *pgdat, struct zone *zone)
 
void __meminit memmap_init_zone (unsigned long size, int nid, unsigned long zone, unsigned long start_pfn, enum memmap_context context)
 
void __init setup_per_cpu_pageset (void)
 
int __meminit init_currently_empty_zone (struct zone *zone, unsigned long zone_start_pfn, unsigned long size, enum memmap_context context)
 
void __init set_pageblock_order (void)
 
void __paginginit free_area_init_node (int nid, unsigned long *zones_size, unsigned long node_start_pfn, unsigned long *zholes_size)
 
void __init set_dma_reserve (unsigned long new_dma_reserve)
 
void __init free_area_init (unsigned long *zones_size)
 
void __init page_alloc_init (void)
 
void setup_per_zone_wmarks (void)
 
int __meminit init_per_zone_wmark_min (void)
 
 module_init (init_per_zone_wmark_min)
 
int lowmem_reserve_ratio_sysctl_handler (ctl_table *table, int write, void __user *buffer, size_t *length, loff_t *ppos)
 
int percpu_pagelist_fraction_sysctl_handler (ctl_table *table, int write, void __user *buffer, size_t *length, loff_t *ppos)
 
void *__init alloc_large_system_hash (const char *tablename, unsigned long bucketsize, unsigned long numentries, int scale, int flags, unsigned int *_hash_shift, unsigned int *_hash_mask, unsigned long low_limit, unsigned long high_limit)
 
unsigned long get_pageblock_flags_group (struct page *page, int start_bitidx, int end_bitidx)
 
void set_pageblock_flags_group (struct page *page, unsigned long flags, int start_bitidx, int end_bitidx)
 
bool has_unmovable_pages (struct zone *zone, struct page *page, int count)
 
bool is_pageblock_removable_nolock (struct page *page)
 
void dump_page (struct page *page)
 

Variables

nodemask_t node_states[NR_NODE_STATES__read_mostly
 
int percpu_pagelist_fraction
 
int sysctl_lowmem_reserve_ratio [MAX_NR_ZONES-1]
 
int min_free_kbytes = 1024
 
int hashdist = HASHDIST_DEFAULT
 

Macro Definition Documentation

#define K (   x)    ((x) << (PAGE_SHIFT-10))

Definition at line 2878 of file page_alloc.c.

#define LONG_ALIGN (   x)    (((x)+(sizeof(long))-1)&~((sizeof(long))-1))

Definition at line 3696 of file page_alloc.c.

#define memmap_init (   size,
  nid,
  zone,
  start_pfn 
)    memmap_init_zone((size), (nid), (zone), (start_pfn), MEMMAP_EARLY)

Definition at line 3869 of file page_alloc.c.

#define PAGES_PER_WAITQUEUE   256

Definition at line 3641 of file page_alloc.c.

#define ZONELIST_ORDER_DEFAULT   0

Definition at line 3072 of file page_alloc.c.

#define ZONELIST_ORDER_NODE   1

Definition at line 3073 of file page_alloc.c.

#define ZONELIST_ORDER_ZONE   2

Definition at line 3074 of file page_alloc.c.

Function Documentation

struct page* __alloc_pages_nodemask ( gfp_t  gfp_mask,
unsigned int  order,
struct zonelist zonelist,
nodemask_t nodemask 
)
read

Definition at line 2590 of file page_alloc.c.

void __free_pages ( struct page page,
unsigned int  order 
)

Definition at line 2682 of file page_alloc.c.

void __meminit __free_pages_bootmem ( struct page page,
unsigned int  order 
)

Definition at line 733 of file page_alloc.c.

unsigned long __get_free_pages ( gfp_t  gfp_mask,
unsigned int  order 
)

Definition at line 2659 of file page_alloc.c.

void* __init alloc_large_system_hash ( const char tablename,
unsigned long  bucketsize,
unsigned long  numentries,
int  scale,
int  flags,
unsigned int _hash_shift,
unsigned int _hash_mask,
unsigned long  low_limit,
unsigned long  high_limit 
)

Definition at line 5401 of file page_alloc.c.

void* alloc_pages_exact ( size_t  size,
gfp_t  gfp_mask 
)

alloc_pages_exact - allocate an exact number physically-contiguous pages. : the number of bytes to allocate : GFP flags for the allocation

This function is similar to alloc_pages(), except that it allocates the minimum number of pages to satisfy the request. alloc_pages() can only allocate memory in power-of-two pages.

This function is also limited by MAX_ORDER.

Memory allocated by this function must be released by free_pages_exact().

Definition at line 2732 of file page_alloc.c.

void* alloc_pages_exact_nid ( int  nid,
size_t  size,
gfp_t  gfp_mask 
)

alloc_pages_exact_nid - allocate an exact number of physically-contiguous pages on a node. : the preferred node ID where memory should be allocated : the number of bytes to allocate : GFP flags for the allocation

Like alloc_pages_exact(), but try to allocate on node nid first before falling back. Note this is not alloc_pages_exact_node() which allocates on a specific node, but is not exact.

Definition at line 2754 of file page_alloc.c.

void __ref build_all_zonelists ( pg_data_t pgdat,
struct zone zone 
)

Definition at line 3588 of file page_alloc.c.

int capture_free_page ( struct page page,
int  alloc_order,
int  migratetype 
)

Definition at line 1384 of file page_alloc.c.

DEFINE_MUTEX ( zonelists_mutex  )
void drain_all_pages ( void  )

Definition at line 1218 of file page_alloc.c.

void drain_local_pages ( void arg)

Definition at line 1204 of file page_alloc.c.

void dump_page ( struct page page)

Definition at line 6093 of file page_alloc.c.

EXPORT_SYMBOL ( node_states  )
EXPORT_SYMBOL ( totalram_pages  )
EXPORT_SYMBOL ( __alloc_pages_nodemask  )
EXPORT_SYMBOL ( __get_free_pages  )
EXPORT_SYMBOL ( get_zeroed_page  )
EXPORT_SYMBOL ( __free_pages  )
EXPORT_SYMBOL ( free_pages  )
EXPORT_SYMBOL ( alloc_pages_exact  )
EXPORT_SYMBOL ( alloc_pages_exact_nid  )
EXPORT_SYMBOL ( free_pages_exact  )
EXPORT_SYMBOL ( si_meminfo  )
EXPORT_SYMBOL_GPL ( nr_free_buffer_pages  )
void __init free_area_init ( unsigned long zones_size)

Definition at line 5008 of file page_alloc.c.

void __paginginit free_area_init_node ( int  nid,
unsigned long zones_size,
unsigned long  node_start_pfn,
unsigned long zholes_size 
)

Definition at line 4564 of file page_alloc.c.

void free_hot_cold_page ( struct page page,
int  cold 
)

Definition at line 1293 of file page_alloc.c.

void free_hot_cold_page_list ( struct list_head list,
int  cold 
)

Definition at line 1341 of file page_alloc.c.

void free_pages ( unsigned long  addr,
unsigned int  order 
)

Definition at line 2694 of file page_alloc.c.

void free_pages_exact ( void virt,
size_t  size 
)

free_pages_exact - release memory allocated via alloc_pages_exact() : the value returned by alloc_pages_exact. : size of allocation, same value as passed to alloc_pages_exact().

Release the memory allocated by a previous call to alloc_pages_exact.

Definition at line 2771 of file page_alloc.c.

unsigned long get_pageblock_flags_group ( struct page page,
int  start_bitidx,
int  end_bitidx 
)

Definition at line 5521 of file page_alloc.c.

unsigned long get_zeroed_page ( gfp_t  gfp_mask)

Definition at line 2676 of file page_alloc.c.

bool gfp_pfmemalloc_allowed ( gfp_t  gfp_mask)

Definition at line 2376 of file page_alloc.c.

bool has_unmovable_pages ( struct zone zone,
struct page page,
int  count 
)

Definition at line 5579 of file page_alloc.c.

int __meminit init_currently_empty_zone ( struct zone zone,
unsigned long  zone_start_pfn,
unsigned long  size,
enum memmap_context  context 
)

Definition at line 4043 of file page_alloc.c.

int __meminit init_per_zone_wmark_min ( void  )

Definition at line 5271 of file page_alloc.c.

bool is_pageblock_removable_nolock ( struct page page)

Definition at line 5635 of file page_alloc.c.

int lowmem_reserve_ratio_sysctl_handler ( ctl_table table,
int  write,
void __user buffer,
size_t length,
loff_t *  ppos 
)

Definition at line 5347 of file page_alloc.c.

void __meminit memmap_init_zone ( unsigned long  size,
int  nid,
unsigned long  zone,
unsigned long  start_pfn,
enum memmap_context  context 
)

Definition at line 3801 of file page_alloc.c.

module_init ( init_per_zone_wmark_min  )

Definition at line 5288 of file page_alloc.c.

int move_freepages ( struct zone zone,
struct page start_page,
struct page end_page,
int  migratetype 
)

Definition at line 914 of file page_alloc.c.

int move_freepages_block ( struct zone zone,
struct page page,
int  migratetype 
)

Definition at line 958 of file page_alloc.c.

unsigned int nr_free_buffer_pages ( void  )

Definition at line 2806 of file page_alloc.c.

unsigned int nr_free_pagecache_pages ( void  )

Definition at line 2815 of file page_alloc.c.

void __init page_alloc_init ( void  )

Definition at line 5043 of file page_alloc.c.

int percpu_pagelist_fraction_sysctl_handler ( ctl_table table,
int  write,
void __user buffer,
size_t length,
loff_t *  ppos 
)

Definition at line 5361 of file page_alloc.c.

void prep_compound_page ( struct page page,
unsigned long  order 
)

Definition at line 348 of file page_alloc.c.

void __init set_dma_reserve ( unsigned long  new_dma_reserve)

set_dma_reserve - set the specified number of pages reserved in the first zone : The number of pages to mark reserved

The per-cpu batchsize and zone watermarks are determined by present_pages. In the DMA zone, a significant percentage may be consumed by kernel image and other unfreeable allocations which can skew the watermarks badly. This function may optionally be used to account for unfreeable pages in the first zone (e.g., ZONE_DMA). The effect will be lower watermarks and smaller per-cpu batchsize.

Definition at line 5003 of file page_alloc.c.

void set_pageblock_flags_group ( struct page page,
unsigned long  flags,
int  start_bitidx,
int  end_bitidx 
)

Definition at line 5549 of file page_alloc.c.

void set_pageblock_migratetype ( struct page page,
int  migratetype 
)

Definition at line 226 of file page_alloc.c.

void __init set_pageblock_order ( void  )

Definition at line 4430 of file page_alloc.c.

void __init setup_per_cpu_pageset ( void  )

Definition at line 3977 of file page_alloc.c.

void setup_per_zone_wmarks ( void  )

setup_per_zone_wmarks - called when min_free_kbytes changes or when memory is hot-{added|removed}

Ensures that the watermark[min,low,high] values for each zone are set correctly with respect to min_free_kbytes.

Definition at line 5197 of file page_alloc.c.

void show_free_areas ( unsigned int  filter)

Definition at line 2887 of file page_alloc.c.

void si_meminfo ( struct sysinfo val)

Definition at line 2826 of file page_alloc.c.

bool skip_free_areas_node ( unsigned int  flags,
int  nid 
)

Definition at line 2862 of file page_alloc.c.

int split_free_page ( struct page page)

Definition at line 1438 of file page_alloc.c.

void split_page ( struct page page,
unsigned int  order 
)

Definition at line 1359 of file page_alloc.c.

void warn_alloc_failed ( gfp_t  gfp_mask,
int  order,
const char fmt,
  ... 
)

Definition at line 2006 of file page_alloc.c.

bool zone_watermark_ok ( struct zone z,
int  order,
unsigned long  mark,
int  classzone_idx,
int  alloc_flags 
)

Definition at line 1658 of file page_alloc.c.

bool zone_watermark_ok_safe ( struct zone z,
int  order,
unsigned long  mark,
int  classzone_idx,
int  alloc_flags 
)

Definition at line 1665 of file page_alloc.c.

Variable Documentation

bool oom_killer_disabled __read_mostly
Initial value:
= {
[N_ONLINE] = { { [0] = 1UL } },
[N_NORMAL_MEMORY] = { { [0] = 1UL } },
[N_CPU] = { { [0] = 1UL } },
}

Definition at line 85 of file page_alloc.c.

int hashdist = HASHDIST_DEFAULT

Definition at line 5382 of file page_alloc.c.

int min_free_kbytes = 1024

Definition at line 194 of file page_alloc.c.

int percpu_pagelist_fraction

Definition at line 108 of file page_alloc.c.

int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1]
Initial value:
= {
32,
}

Definition at line 165 of file page_alloc.c.