~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/asm-generic/mmzone.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/asm-generic/mmzone.h (Version linux-6.12-rc7) and /include/asm-i386/mmzone.h (Version linux-2.6.0)


  1 /* SPDX-License-Identifier: GPL-2.0 */         !!   1 /*
  2 #ifndef _ASM_GENERIC_MMZONE_H                  !!   2  * Written by Pat Gaughen (gone@us.ibm.com) Mar 2002
  3 #define _ASM_GENERIC_MMZONE_H                  !!   3  *
                                                   >>   4  */
  4                                                     5 
                                                   >>   6 #ifndef _ASM_MMZONE_H_
                                                   >>   7 #define _ASM_MMZONE_H_
                                                   >>   8 
                                                   >>   9 #include <asm/smp.h>
                                                   >>  10 
                                                   >>  11 #ifdef CONFIG_DISCONTIGMEM
                                                   >>  12 
                                                   >>  13 extern struct pglist_data *node_data[];
                                                   >>  14 
                                                   >>  15 /*
                                                   >>  16  * Following are macros that are specific to this numa platform.
                                                   >>  17  */
                                                   >>  18 #define reserve_bootmem(addr, size) \
                                                   >>  19         reserve_bootmem_node(NODE_DATA(0), (addr), (size))
                                                   >>  20 #define alloc_bootmem(x) \
                                                   >>  21         __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
                                                   >>  22 #define alloc_bootmem_low(x) \
                                                   >>  23         __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, 0)
                                                   >>  24 #define alloc_bootmem_pages(x) \
                                                   >>  25         __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
                                                   >>  26 #define alloc_bootmem_low_pages(x) \
                                                   >>  27         __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
                                                   >>  28 #define alloc_bootmem_node(ignore, x) \
                                                   >>  29         __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
                                                   >>  30 #define alloc_bootmem_pages_node(ignore, x) \
                                                   >>  31         __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
                                                   >>  32 #define alloc_bootmem_low_pages_node(ignore, x) \
                                                   >>  33         __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
                                                   >>  34 
                                                   >>  35 #define node_localnr(pfn, nid)          ((pfn) - node_data[nid]->node_start_pfn)
                                                   >>  36 
                                                   >>  37 /*
                                                   >>  38  * Following are macros that each numa implmentation must define.
                                                   >>  39  */
                                                   >>  40 
                                                   >>  41 /*
                                                   >>  42  * Given a kernel address, find the home node of the underlying memory.
                                                   >>  43  */
                                                   >>  44 #define kvaddr_to_nid(kaddr)    pfn_to_nid(__pa(kaddr) >> PAGE_SHIFT)
                                                   >>  45 
                                                   >>  46 /*
                                                   >>  47  * Return a pointer to the node data for node n.
                                                   >>  48  */
                                                   >>  49 #define NODE_DATA(nid)          (node_data[nid])
                                                   >>  50 
                                                   >>  51 #define node_mem_map(nid)       (NODE_DATA(nid)->node_mem_map)
                                                   >>  52 #define node_start_pfn(nid)     (NODE_DATA(nid)->node_start_pfn)
                                                   >>  53 #define node_end_pfn(nid)                                               \
                                                   >>  54 ({                                                                      \
                                                   >>  55         pg_data_t *__pgdat = NODE_DATA(nid);                            \
                                                   >>  56         __pgdat->node_start_pfn + __pgdat->node_spanned_pages;          \
                                                   >>  57 })
                                                   >>  58 
                                                   >>  59 #define local_mapnr(kvaddr)                                             \
                                                   >>  60 ({                                                                      \
                                                   >>  61         unsigned long __pfn = __pa(kvaddr) >> PAGE_SHIFT;               \
                                                   >>  62         (__pfn - node_start_pfn(pfn_to_nid(__pfn)));                    \
                                                   >>  63 })
                                                   >>  64 
                                                   >>  65 #define kern_addr_valid(kaddr)                                          \
                                                   >>  66 ({                                                                      \
                                                   >>  67         unsigned long __kaddr = (unsigned long)(kaddr);                 \
                                                   >>  68         pg_data_t *__pgdat = NODE_DATA(kvaddr_to_nid(__kaddr));         \
                                                   >>  69         test_bit(local_mapnr(__kaddr), __pgdat->valid_addr_bitmap);     \
                                                   >>  70 })
                                                   >>  71 
                                                   >>  72 #define pfn_to_page(pfn)                                                \
                                                   >>  73 ({                                                                      \
                                                   >>  74         unsigned long __pfn = pfn;                                      \
                                                   >>  75         int __node  = pfn_to_nid(__pfn);                                \
                                                   >>  76         &node_mem_map(__node)[node_localnr(__pfn,__node)];              \
                                                   >>  77 })
                                                   >>  78 
                                                   >>  79 #define page_to_pfn(pg)                                                 \
                                                   >>  80 ({                                                                      \
                                                   >>  81         struct page *__page = pg;                                       \
                                                   >>  82         struct zone *__zone = page_zone(__page);                        \
                                                   >>  83         (unsigned long)(__page - __zone->zone_mem_map)                  \
                                                   >>  84                 + __zone->zone_start_pfn;                               \
                                                   >>  85 })
                                                   >>  86 #define pmd_page(pmd)           (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
                                                   >>  87 /*
                                                   >>  88  * pfn_valid should be made as fast as possible, and the current definition 
                                                   >>  89  * is valid for machines that are NUMA, but still contiguous, which is what
                                                   >>  90  * is currently supported. A more generalised, but slower definition would
                                                   >>  91  * be something like this - mbligh:
                                                   >>  92  * ( pfn_to_pgdat(pfn) && ((pfn) < node_end_pfn(pfn_to_nid(pfn))) ) 
                                                   >>  93  */ 
                                                   >>  94 #define pfn_valid(pfn)          ((pfn) < num_physpages)
                                                   >>  95 
                                                   >>  96 /*
                                                   >>  97  * generic node memory support, the following assumptions apply:
                                                   >>  98  *
                                                   >>  99  * 1) memory comes in 256Mb contigious chunks which are either present or not
                                                   >> 100  * 2) we will not have more than 64Gb in total
                                                   >> 101  *
                                                   >> 102  * for now assume that 64Gb is max amount of RAM for whole system
                                                   >> 103  *    64Gb / 4096bytes/page = 16777216 pages
                                                   >> 104  */
                                                   >> 105 #define MAX_NR_PAGES 16777216
                                                   >> 106 #define MAX_ELEMENTS 256
                                                   >> 107 #define PAGES_PER_ELEMENT (MAX_NR_PAGES/MAX_ELEMENTS)
                                                   >> 108 
                                                   >> 109 extern u8 physnode_map[];
                                                   >> 110 
                                                   >> 111 static inline int pfn_to_nid(unsigned long pfn)
                                                   >> 112 {
                                                   >> 113         return(physnode_map[(pfn) / PAGES_PER_ELEMENT]);
                                                   >> 114 }
                                                   >> 115 static inline struct pglist_data *pfn_to_pgdat(unsigned long pfn)
                                                   >> 116 {
                                                   >> 117         return(NODE_DATA(pfn_to_nid(pfn)));
                                                   >> 118 }
                                                   >> 119 
                                                   >> 120 #ifdef CONFIG_X86_NUMAQ
                                                   >> 121 #include <asm/numaq.h>
                                                   >> 122 #elif CONFIG_ACPI_SRAT
                                                   >> 123 #include <asm/srat.h>
                                                   >> 124 #elif CONFIG_X86_PC
                                                   >> 125 #define get_zholes_size(n) (0)
                                                   >> 126 #else
                                                   >> 127 #define pfn_to_nid(pfn)         (0)
                                                   >> 128 #endif /* CONFIG_X86_NUMAQ */
                                                   >> 129 
                                                   >> 130 extern int get_memcfg_numa_flat(void );
                                                   >> 131 /*
                                                   >> 132  * This allows any one NUMA architecture to be compiled
                                                   >> 133  * for, and still fall back to the flat function if it
                                                   >> 134  * fails.
                                                   >> 135  */
                                                   >> 136 static inline void get_memcfg_numa(void)
                                                   >> 137 {
                                                   >> 138 #ifdef CONFIG_X86_NUMAQ
                                                   >> 139         if (get_memcfg_numaq())
                                                   >> 140                 return;
                                                   >> 141 #elif CONFIG_ACPI_SRAT
                                                   >> 142         if (get_memcfg_from_srat())
                                                   >> 143                 return;
  5 #endif                                            144 #endif
                                                   >> 145 
                                                   >> 146         get_memcfg_numa_flat();
                                                   >> 147 }
                                                   >> 148 
                                                   >> 149 #endif /* CONFIG_DISCONTIGMEM */
                                                   >> 150 #endif /* _ASM_MMZONE_H_ */
  6                                                   151 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php