mmzone.h
来自「此工具是arm-linux-GCC交叉编译工具(cross-3.4.4)」· C头文件 代码 · 共 610 行 · 第 1/2 页
H
610 行
#ifdef CONFIG_HAVE_MEMORY_PRESENTvoid memory_present(int nid, unsigned long start, unsigned long end);#elsestatic inline void memory_present(int nid, unsigned long start, unsigned long end) {}#endif#ifdef CONFIG_NEED_NODE_MEMMAP_SIZEunsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long);#endif/* * zone_idx() returns 0 for the ZONE_DMA zone, 1 for the ZONE_NORMAL zone, etc. */#define zone_idx(zone) ((zone) - (zone)->zone_pgdat->node_zones)/** * for_each_pgdat - helper macro to iterate over all nodes * @pgdat - pointer to a pg_data_t variable * * Meant to help with common loops of the form * pgdat = pgdat_list; * while(pgdat) { * ... * pgdat = pgdat->pgdat_next; * } */#define for_each_pgdat(pgdat) \ for (pgdat = pgdat_list; pgdat; pgdat = pgdat->pgdat_next)/* * next_zone - helper magic for for_each_zone() * Thanks to William Lee Irwin III for this piece of ingenuity. */static inline struct zone *next_zone(struct zone *zone){ pg_data_t *pgdat = zone->zone_pgdat; if (zone < pgdat->node_zones + MAX_NR_ZONES - 1) zone++; else if (pgdat->pgdat_next) { pgdat = pgdat->pgdat_next; zone = pgdat->node_zones; } else zone = NULL; return zone;}/** * for_each_zone - helper macro to iterate over all memory zones * @zone - pointer to struct zone variable * * The user only needs to declare the zone variable, for_each_zone * fills it in. This basically means for_each_zone() is an * easier to read version of this piece of code: * * for (pgdat = pgdat_list; pgdat; pgdat = pgdat->node_next) * for (i = 0; i < MAX_NR_ZONES; ++i) { * struct zone * z = pgdat->node_zones + i; * ... * } * } */#define for_each_zone(zone) \ for (zone = pgdat_list->node_zones; zone; zone = next_zone(zone))static inline int is_highmem_idx(int idx){ return (idx == ZONE_HIGHMEM);}static inline int is_normal_idx(int idx){ return (idx == ZONE_NORMAL);}/** * is_highmem - helper function to quickly check if a struct zone is a * highmem zone or not. This is an attempt to keep references * to ZONE_{DMA/NORMAL/HIGHMEM/etc} in general code to a minimum. * @zone - pointer to struct zone variable */static inline int is_highmem(struct zone *zone){ return zone == zone->zone_pgdat->node_zones + ZONE_HIGHMEM;}static inline int is_normal(struct zone *zone){ return zone == zone->zone_pgdat->node_zones + ZONE_NORMAL;}/* These two functions are used to setup the per zone pages min values */struct ctl_table;struct file;int min_free_kbytes_sysctl_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *);extern int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1];int lowmem_reserve_ratio_sysctl_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *);#include <linux/topology.h>/* Returns the number of the current Node. */#define numa_node_id() (cpu_to_node(raw_smp_processor_id()))#ifndef CONFIG_NEED_MULTIPLE_NODESextern struct pglist_data contig_page_data;#define NODE_DATA(nid) (&contig_page_data)#define NODE_MEM_MAP(nid) mem_map#define MAX_NODES_SHIFT 1#define pfn_to_nid(pfn) (0)#else /* CONFIG_NEED_MULTIPLE_NODES */#include <asm/mmzone.h>#endif /* !CONFIG_NEED_MULTIPLE_NODES */#ifdef CONFIG_SPARSEMEM#include <asm/sparsemem.h>#endif#if BITS_PER_LONG == 32 || defined(ARCH_HAS_ATOMIC_UNSIGNED)/* * with 32 bit page->flags field, we reserve 8 bits for node/zone info. * there are 3 zones (2 bits) and this leaves 8-2=6 bits for nodes. */#define FLAGS_RESERVED 8#elif BITS_PER_LONG == 64/* * with 64 bit flags field, there's plenty of room. */#define FLAGS_RESERVED 32#else#error BITS_PER_LONG not defined#endif#ifndef CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID#define early_pfn_to_nid(nid) (0UL)#endif#define pfn_to_section_nr(pfn) ((pfn) >> PFN_SECTION_SHIFT)#define section_nr_to_pfn(sec) ((sec) << PFN_SECTION_SHIFT)#ifdef CONFIG_SPARSEMEM/* * SECTION_SHIFT #bits space required to store a section # * * PA_SECTION_SHIFT physical address to/from section number * PFN_SECTION_SHIFT pfn to/from section number */#define SECTIONS_SHIFT (MAX_PHYSMEM_BITS - SECTION_SIZE_BITS)#define PA_SECTION_SHIFT (SECTION_SIZE_BITS)#define PFN_SECTION_SHIFT (SECTION_SIZE_BITS - PAGE_SHIFT)#define NR_MEM_SECTIONS (1UL << SECTIONS_SHIFT)#define PAGES_PER_SECTION (1UL << PFN_SECTION_SHIFT)#define PAGE_SECTION_MASK (~(PAGES_PER_SECTION-1))#if (MAX_ORDER - 1 + PAGE_SHIFT) > SECTION_SIZE_BITS#error Allocator MAX_ORDER exceeds SECTION_SIZE#endifstruct page;struct mem_section { /* * This is, logically, a pointer to an array of struct * pages. However, it is stored with some other magic. * (see sparse.c::sparse_init_one_section()) * * Making it a UL at least makes someone do a cast * before using it wrong. */ unsigned long section_mem_map;};#ifdef CONFIG_SPARSEMEM_EXTREME#define SECTIONS_PER_ROOT (PAGE_SIZE / sizeof (struct mem_section))#else#define SECTIONS_PER_ROOT 1#endif#define SECTION_NR_TO_ROOT(sec) ((sec) / SECTIONS_PER_ROOT)#define NR_SECTION_ROOTS (NR_MEM_SECTIONS / SECTIONS_PER_ROOT)#define SECTION_ROOT_MASK (SECTIONS_PER_ROOT - 1)#ifdef CONFIG_SPARSEMEM_EXTREMEextern struct mem_section *mem_section[NR_SECTION_ROOTS];#elseextern struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT];#endifstatic inline struct mem_section *__nr_to_section(unsigned long nr){ if (!mem_section[SECTION_NR_TO_ROOT(nr)]) return NULL; return &mem_section[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK];}/* * We use the lower bits of the mem_map pointer to store * a little bit of information. There should be at least * 3 bits here due to 32-bit alignment. */#define SECTION_MARKED_PRESENT (1UL<<0)#define SECTION_HAS_MEM_MAP (1UL<<1)#define SECTION_MAP_LAST_BIT (1UL<<2)#define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1))static inline struct page *__section_mem_map_addr(struct mem_section *section){ unsigned long map = section->section_mem_map; map &= SECTION_MAP_MASK; return (struct page *)map;}static inline int valid_section(struct mem_section *section){ return (section && (section->section_mem_map & SECTION_MARKED_PRESENT));}static inline int section_has_mem_map(struct mem_section *section){ return (section && (section->section_mem_map & SECTION_HAS_MEM_MAP));}static inline int valid_section_nr(unsigned long nr){ return valid_section(__nr_to_section(nr));}/* * Given a kernel address, find the home node of the underlying memory. */#define kvaddr_to_nid(kaddr) pfn_to_nid(__pa(kaddr) >> PAGE_SHIFT)static inline struct mem_section *__pfn_to_section(unsigned long pfn){ return __nr_to_section(pfn_to_section_nr(pfn));}#define pfn_to_page(pfn) \({ \ unsigned long __pfn = (pfn); \ __section_mem_map_addr(__pfn_to_section(__pfn)) + __pfn; \})#define page_to_pfn(page) \({ \ page - __section_mem_map_addr(__nr_to_section( \ page_to_section(page))); \})static inline int pfn_valid(unsigned long pfn){ if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS) return 0; return valid_section(__nr_to_section(pfn_to_section_nr(pfn)));}/* * These are _only_ used during initialisation, therefore they * can use __initdata ... They could have names to indicate * this restriction. */#ifdef CONFIG_NUMA#define pfn_to_nid early_pfn_to_nid#endif#define pfn_to_pgdat(pfn) \({ \ NODE_DATA(pfn_to_nid(pfn)); \})#define early_pfn_valid(pfn) pfn_valid(pfn)void sparse_init(void);#else#define sparse_init() do {} while (0)#define sparse_index_init(_sec, _nid) do {} while (0)#endif /* CONFIG_SPARSEMEM */#ifdef CONFIG_NODES_SPAN_OTHER_NODES#define early_pfn_in_nid(pfn, nid) (early_pfn_to_nid(pfn) == (nid))#else#define early_pfn_in_nid(pfn, nid) (1)#endif#ifndef early_pfn_valid#define early_pfn_valid(pfn) (1)#endifvoid memory_present(int nid, unsigned long start, unsigned long end);unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long);#endif /* !__ASSEMBLY__ */#endif /* __KERNEL__ */#endif /* _LINUX_MMZONE_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?