1#ifndef _LINUX_MMZONE_H
2#define _LINUX_MMZONE_H
3
4#ifndef __ASSEMBLY__
5#ifndef __GENERATING_BOUNDS_H
6
7#include <linux/spinlock.h>
8#include <linux/list.h>
9#include <linux/wait.h>
10#include <linux/bitops.h>
11#include <linux/cache.h>
12#include <linux/threads.h>
13#include <linux/numa.h>
14#include <linux/init.h>
15#include <linux/seqlock.h>
16#include <linux/nodemask.h>
17#include <linux/pageblock-flags.h>
18#include <linux/bounds.h>
19#include <asm/atomic.h>
20#include <asm/page.h>
21
22
23#ifndef CONFIG_FORCE_MAX_ZONEORDER
24#define MAX_ORDER 11
25#else
26#define MAX_ORDER CONFIG_FORCE_MAX_ZONEORDER
27#endif
28#define MAX_ORDER_NR_PAGES (1 << (MAX_ORDER - 1))
29
30
31
32
33
34
35
36#define PAGE_ALLOC_COSTLY_ORDER 3
37
38#define MIGRATE_UNMOVABLE 0
39#define MIGRATE_RECLAIMABLE 1
40#define MIGRATE_MOVABLE 2
41#define MIGRATE_RESERVE 3
42#define MIGRATE_ISOLATE 4
43#define MIGRATE_TYPES 5
44
45#define for_each_migratetype_order(order, type) \
46 for (order = 0; order < MAX_ORDER; order++) \
47 for (type = 0; type < MIGRATE_TYPES; type++)
48
49extern int page_group_by_mobility_disabled;
50
51static inline int get_pageblock_migratetype(struct page *page)
52{
53 if (unlikely(page_group_by_mobility_disabled))
54 return MIGRATE_UNMOVABLE;
55
56 return get_pageblock_flags_group(page, PB_migrate, PB_migrate_end);
57}
58
59struct free_area {
60 struct list_head free_list[MIGRATE_TYPES];
61 unsigned long nr_free;
62};
63
64struct pglist_data;
65
66
67
68
69
70
71
72#if defined(CONFIG_SMP)
73struct zone_padding {
74 char x[0];
75} ____cacheline_internodealigned_in_smp;
76#define ZONE_PADDING(name) struct zone_padding name;
77#else
78#define ZONE_PADDING(name)
79#endif
80
81enum zone_stat_item {
82
83 NR_FREE_PAGES,
84 NR_LRU_BASE,
85 NR_INACTIVE_ANON = NR_LRU_BASE,
86 NR_ACTIVE_ANON,
87 NR_INACTIVE_FILE,
88 NR_ACTIVE_FILE,
89#ifdef CONFIG_UNEVICTABLE_LRU
90 NR_UNEVICTABLE,
91 NR_MLOCK,
92#else
93 NR_UNEVICTABLE = NR_ACTIVE_FILE,
94 NR_MLOCK = NR_ACTIVE_FILE,
95#endif
96 NR_ANON_PAGES,
97 NR_FILE_MAPPED,
98
99 NR_FILE_PAGES,
100 NR_FILE_DIRTY,
101 NR_WRITEBACK,
102 NR_SLAB_RECLAIMABLE,
103 NR_SLAB_UNRECLAIMABLE,
104 NR_PAGETABLE,
105 NR_UNSTABLE_NFS,
106 NR_BOUNCE,
107 NR_VMSCAN_WRITE,
108
109 NR_WRITEBACK_TEMP,
110#ifdef CONFIG_NUMA
111 NUMA_HIT,
112 NUMA_MISS,
113 NUMA_FOREIGN,
114 NUMA_INTERLEAVE_HIT,
115 NUMA_LOCAL,
116 NUMA_OTHER,
117#endif
118 NR_VM_ZONE_STAT_ITEMS };
119
120
121
122
123
124
125
126
127
128
129#define LRU_BASE 0
130#define LRU_ACTIVE 1
131#define LRU_FILE 2
132
133enum lru_list {
134 LRU_INACTIVE_ANON = LRU_BASE,
135 LRU_ACTIVE_ANON = LRU_BASE + LRU_ACTIVE,
136 LRU_INACTIVE_FILE = LRU_BASE + LRU_FILE,
137 LRU_ACTIVE_FILE = LRU_BASE + LRU_FILE + LRU_ACTIVE,
138#ifdef CONFIG_UNEVICTABLE_LRU
139 LRU_UNEVICTABLE,
140#else
141 LRU_UNEVICTABLE = LRU_ACTIVE_FILE,
142#endif
143 NR_LRU_LISTS
144};
145
146#define for_each_lru(l) for (l = 0; l < NR_LRU_LISTS; l++)
147
148#define for_each_evictable_lru(l) for (l = 0; l <= LRU_ACTIVE_FILE; l++)
149
150static inline int is_file_lru(enum lru_list l)
151{
152 return (l == LRU_INACTIVE_FILE || l == LRU_ACTIVE_FILE);
153}
154
155static inline int is_active_lru(enum lru_list l)
156{
157 return (l == LRU_ACTIVE_ANON || l == LRU_ACTIVE_FILE);
158}
159
160static inline int is_unevictable_lru(enum lru_list l)
161{
162#ifdef CONFIG_UNEVICTABLE_LRU
163 return (l == LRU_UNEVICTABLE);
164#else
165 return 0;
166#endif
167}
168
169struct per_cpu_pages {
170 int count;
171 int high;
172 int batch;
173 struct list_head list;
174};
175
176struct per_cpu_pageset {
177 struct per_cpu_pages pcp;
178#ifdef CONFIG_NUMA
179 s8 expire;
180#endif
181#ifdef CONFIG_SMP
182 s8 stat_threshold;
183 s8 vm_stat_diff[NR_VM_ZONE_STAT_ITEMS];
184#endif
185} ____cacheline_aligned_in_smp;
186
187#ifdef CONFIG_NUMA
188#define zone_pcp(__z, __cpu) ((__z)->pageset[(__cpu)])
189#else
190#define zone_pcp(__z, __cpu) (&(__z)->pageset[(__cpu)])
191#endif
192
193#endif
194
195enum zone_type {
196#ifdef CONFIG_ZONE_DMA
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215 ZONE_DMA,
216#endif
217#ifdef CONFIG_ZONE_DMA32
218
219
220
221
222
223 ZONE_DMA32,
224#endif
225
226
227
228
229
230 ZONE_NORMAL,
231#ifdef CONFIG_HIGHMEM
232
233
234
235
236
237
238
239
240 ZONE_HIGHMEM,
241#endif
242 ZONE_MOVABLE,
243 __MAX_NR_ZONES
244};
245
246#ifndef __GENERATING_BOUNDS_H
247
248
249
250
251
252
253
254
255
256#if MAX_NR_ZONES < 2
257#define ZONES_SHIFT 0
258#elif MAX_NR_ZONES <= 2
259#define ZONES_SHIFT 1
260#elif MAX_NR_ZONES <= 4
261#define ZONES_SHIFT 2
262#else
263#error ZONES_SHIFT -- too many zones configured adjust calculation
264#endif
265
266struct zone {
267
268 unsigned long pages_min, pages_low, pages_high;
269
270
271
272
273
274
275
276
277 unsigned long lowmem_reserve[MAX_NR_ZONES];
278
279#ifdef CONFIG_NUMA
280 int node;
281
282
283
284 unsigned long min_unmapped_pages;
285 unsigned long min_slab_pages;
286 struct per_cpu_pageset *pageset[NR_CPUS];
287#else
288 struct per_cpu_pageset pageset[NR_CPUS];
289#endif
290
291
292
293 spinlock_t lock;
294#ifdef CONFIG_MEMORY_HOTPLUG
295
296 seqlock_t span_seqlock;
297#endif
298 struct free_area free_area[MAX_ORDER];
299
300#ifndef CONFIG_SPARSEMEM
301
302
303
304
305 unsigned long *pageblock_flags;
306#endif
307
308
309 ZONE_PADDING(_pad1_)
310
311
312 spinlock_t lru_lock;
313 struct {
314 struct list_head list;
315 unsigned long nr_scan;
316 } lru[NR_LRU_LISTS];
317
318
319
320
321
322
323
324
325
326 unsigned long recent_rotated[2];
327 unsigned long recent_scanned[2];
328
329 unsigned long pages_scanned;
330 unsigned long flags;
331
332
333 atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348 int prev_priority;
349
350
351
352
353
354 unsigned int inactive_ratio;
355
356
357 ZONE_PADDING(_pad2_)
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384 wait_queue_head_t * wait_table;
385 unsigned long wait_table_hash_nr_entries;
386 unsigned long wait_table_bits;
387
388
389
390
391 struct pglist_data *zone_pgdat;
392
393 unsigned long zone_start_pfn;
394
395
396
397
398
399
400
401
402
403
404
405 unsigned long spanned_pages;
406 unsigned long present_pages;
407
408
409
410
411 const char *name;
412} ____cacheline_internodealigned_in_smp;
413
414typedef enum {
415 ZONE_ALL_UNRECLAIMABLE,
416 ZONE_RECLAIM_LOCKED,
417 ZONE_OOM_LOCKED,
418} zone_flags_t;
419
420static inline void zone_set_flag(struct zone *zone, zone_flags_t flag)
421{
422 set_bit(flag, &zone->flags);
423}
424
425static inline int zone_test_and_set_flag(struct zone *zone, zone_flags_t flag)
426{
427 return test_and_set_bit(flag, &zone->flags);
428}
429
430static inline void zone_clear_flag(struct zone *zone, zone_flags_t flag)
431{
432 clear_bit(flag, &zone->flags);
433}
434
435static inline int zone_is_all_unreclaimable(const struct zone *zone)
436{
437 return test_bit(ZONE_ALL_UNRECLAIMABLE, &zone->flags);
438}
439
440static inline int zone_is_reclaim_locked(const struct zone *zone)
441{
442 return test_bit(ZONE_RECLAIM_LOCKED, &zone->flags);
443}
444
445static inline int zone_is_oom_locked(const struct zone *zone)
446{
447 return test_bit(ZONE_OOM_LOCKED, &zone->flags);
448}
449
450
451
452
453
454
455#define DEF_PRIORITY 12
456
457
458#define MAX_ZONES_PER_ZONELIST (MAX_NUMNODES * MAX_NR_ZONES)
459
460#ifdef CONFIG_NUMA
461
462
463
464
465
466
467
468
469#define MAX_ZONELISTS 2
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531struct zonelist_cache {
532 unsigned short z_to_n[MAX_ZONES_PER_ZONELIST];
533 DECLARE_BITMAP(fullzones, MAX_ZONES_PER_ZONELIST);
534 unsigned long last_full_zap;
535};
536#else
537#define MAX_ZONELISTS 1
538struct zonelist_cache;
539#endif
540
541
542
543
544
545struct zoneref {
546 struct zone *zone;
547 int zone_idx;
548};
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567struct zonelist {
568 struct zonelist_cache *zlcache_ptr;
569 struct zoneref _zonerefs[MAX_ZONES_PER_ZONELIST + 1];
570#ifdef CONFIG_NUMA
571 struct zonelist_cache zlcache;
572#endif
573};
574
575#ifdef CONFIG_ARCH_POPULATES_NODE_MAP
576struct node_active_region {
577 unsigned long start_pfn;
578 unsigned long end_pfn;
579 int nid;
580};
581#endif
582
583#ifndef CONFIG_DISCONTIGMEM
584
585extern struct page *mem_map;
586#endif
587
588
589
590
591
592
593
594
595
596
597
598
599struct bootmem_data;
600typedef struct pglist_data {
601 struct zone node_zones[MAX_NR_ZONES];
602 struct zonelist node_zonelists[MAX_ZONELISTS];
603 int nr_zones;
604#ifdef CONFIG_FLAT_NODE_MEM_MAP
605 struct page *node_mem_map;
606#ifdef CONFIG_CGROUP_MEM_RES_CTLR
607 struct page_cgroup *node_page_cgroup;
608#endif
609#endif
610 struct bootmem_data *bdata;
611#ifdef CONFIG_MEMORY_HOTPLUG
612
613
614
615
616
617
618
619 spinlock_t node_size_lock;
620#endif
621 unsigned long node_start_pfn;
622 unsigned long node_present_pages;
623 unsigned long node_spanned_pages;
624
625 int node_id;
626 wait_queue_head_t kswapd_wait;
627 struct task_struct *kswapd;
628 int kswapd_max_order;
629} pg_data_t;
630
631#define node_present_pages(nid) (NODE_DATA(nid)->node_present_pages)
632#define node_spanned_pages(nid) (NODE_DATA(nid)->node_spanned_pages)
633#ifdef CONFIG_FLAT_NODE_MEM_MAP
634#define pgdat_page_nr(pgdat, pagenr) ((pgdat)->node_mem_map + (pagenr))
635#else
636#define pgdat_page_nr(pgdat, pagenr) pfn_to_page((pgdat)->node_start_pfn + (pagenr))
637#endif
638#define nid_page_nr(nid, pagenr) pgdat_page_nr(NODE_DATA(nid),(pagenr))
639
640#include <linux/memory_hotplug.h>
641
642void get_zone_counts(unsigned long *active, unsigned long *inactive,
643 unsigned long *free);
644void build_all_zonelists(void);
645void wakeup_kswapd(struct zone *zone, int order);
646int zone_watermark_ok(struct zone *z, int order, unsigned long mark,
647 int classzone_idx, int alloc_flags);
648enum memmap_context {
649 MEMMAP_EARLY,
650 MEMMAP_HOTPLUG,
651};
652extern int init_currently_empty_zone(struct zone *zone, unsigned long start_pfn,
653 unsigned long size,
654 enum memmap_context context);
655
656#ifdef CONFIG_HAVE_MEMORY_PRESENT
657void memory_present(int nid, unsigned long start, unsigned long end);
658#else
659static inline void memory_present(int nid, unsigned long start, unsigned long end) {}
660#endif
661
662#ifdef CONFIG_NEED_NODE_MEMMAP_SIZE
663unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long);
664#endif
665
666
667
668
669#define zone_idx(zone) ((zone) - (zone)->zone_pgdat->node_zones)
670
671static inline int populated_zone(struct zone *zone)
672{
673 return (!!zone->present_pages);
674}
675
676extern int movable_zone;
677
678static inline int zone_movable_is_highmem(void)
679{
680#if defined(CONFIG_HIGHMEM) && defined(CONFIG_ARCH_POPULATES_NODE_MAP)
681 return movable_zone == ZONE_HIGHMEM;
682#else
683 return 0;
684#endif
685}
686
687static inline int is_highmem_idx(enum zone_type idx)
688{
689#ifdef CONFIG_HIGHMEM
690 return (idx == ZONE_HIGHMEM ||
691 (idx == ZONE_MOVABLE && zone_movable_is_highmem()));
692#else
693 return 0;
694#endif
695}
696
697static inline int is_normal_idx(enum zone_type idx)
698{
699 return (idx == ZONE_NORMAL);
700}
701
702
703
704
705
706
707
708static inline int is_highmem(struct zone *zone)
709{
710#ifdef CONFIG_HIGHMEM
711 int zone_off = (char *)zone - (char *)zone->zone_pgdat->node_zones;
712 return zone_off == ZONE_HIGHMEM * sizeof(*zone) ||
713 (zone_off == ZONE_MOVABLE * sizeof(*zone) &&
714 zone_movable_is_highmem());
715#else
716 return 0;
717#endif
718}
719
720static inline int is_normal(struct zone *zone)
721{
722 return zone == zone->zone_pgdat->node_zones + ZONE_NORMAL;
723}
724
725static inline int is_dma32(struct zone *zone)
726{
727#ifdef CONFIG_ZONE_DMA32
728 return zone == zone->zone_pgdat->node_zones + ZONE_DMA32;
729#else
730 return 0;
731#endif
732}
733
734static inline int is_dma(struct zone *zone)
735{
736#ifdef CONFIG_ZONE_DMA
737 return zone == zone->zone_pgdat->node_zones + ZONE_DMA;
738#else
739 return 0;
740#endif
741}
742
743
744struct ctl_table;
745struct file;
746int min_free_kbytes_sysctl_handler(struct ctl_table *, int, struct file *,
747 void __user *, size_t *, loff_t *);
748extern int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1];
749int lowmem_reserve_ratio_sysctl_handler(struct ctl_table *, int, struct file *,
750 void __user *, size_t *, loff_t *);
751int percpu_pagelist_fraction_sysctl_handler(struct ctl_table *, int, struct file *,
752 void __user *, size_t *, loff_t *);
753int sysctl_min_unmapped_ratio_sysctl_handler(struct ctl_table *, int,
754 struct file *, void __user *, size_t *, loff_t *);
755int sysctl_min_slab_ratio_sysctl_handler(struct ctl_table *, int,
756 struct file *, void __user *, size_t *, loff_t *);
757
758extern int numa_zonelist_order_handler(struct ctl_table *, int,
759 struct file *, void __user *, size_t *, loff_t *);
760extern char numa_zonelist_order[];
761#define NUMA_ZONELIST_ORDER_LEN 16
762
763#include <linux/topology.h>
764
765#ifndef numa_node_id
766#define numa_node_id() (cpu_to_node(raw_smp_processor_id()))
767#endif
768
769#ifndef CONFIG_NEED_MULTIPLE_NODES
770
771extern struct pglist_data contig_page_data;
772#define NODE_DATA(nid) (&contig_page_data)
773#define NODE_MEM_MAP(nid) mem_map
774
775#else
776
777#include <asm/mmzone.h>
778
779#endif
780
781extern struct pglist_data *first_online_pgdat(void);
782extern struct pglist_data *next_online_pgdat(struct pglist_data *pgdat);
783extern struct zone *next_zone(struct zone *zone);
784
785
786
787
788
789#define for_each_online_pgdat(pgdat) \
790 for (pgdat = first_online_pgdat(); \
791 pgdat; \
792 pgdat = next_online_pgdat(pgdat))
793
794
795
796
797
798
799
800#define for_each_zone(zone) \
801 for (zone = (first_online_pgdat())->node_zones; \
802 zone; \
803 zone = next_zone(zone))
804
805static inline struct zone *zonelist_zone(struct zoneref *zoneref)
806{
807 return zoneref->zone;
808}
809
810static inline int zonelist_zone_idx(struct zoneref *zoneref)
811{
812 return zoneref->zone_idx;
813}
814
815static inline int zonelist_node_idx(struct zoneref *zoneref)
816{
817#ifdef CONFIG_NUMA
818
819 return zoneref->zone->node;
820#else
821 return 0;
822#endif
823}
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838struct zoneref *next_zones_zonelist(struct zoneref *z,
839 enum zone_type highest_zoneidx,
840 nodemask_t *nodes,
841 struct zone **zone);
842
843
844
845
846
847
848
849
850
851
852
853
854
855static inline struct zoneref *first_zones_zonelist(struct zonelist *zonelist,
856 enum zone_type highest_zoneidx,
857 nodemask_t *nodes,
858 struct zone **zone)
859{
860 return next_zones_zonelist(zonelist->_zonerefs, highest_zoneidx, nodes,
861 zone);
862}
863
864
865
866
867
868
869
870
871
872
873
874
875#define for_each_zone_zonelist_nodemask(zone, z, zlist, highidx, nodemask) \
876 for (z = first_zones_zonelist(zlist, highidx, nodemask, &zone); \
877 zone; \
878 z = next_zones_zonelist(++z, highidx, nodemask, &zone)) \
879
880
881
882
883
884
885
886
887
888
889#define for_each_zone_zonelist(zone, z, zlist, highidx) \
890 for_each_zone_zonelist_nodemask(zone, z, zlist, highidx, NULL)
891
892#ifdef CONFIG_SPARSEMEM
893#include <asm/sparsemem.h>
894#endif
895
896#if !defined(CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID) && \
897 !defined(CONFIG_ARCH_POPULATES_NODE_MAP)
898static inline unsigned long early_pfn_to_nid(unsigned long pfn)
899{
900 return 0;
901}
902#endif
903
904#ifdef CONFIG_FLATMEM
905#define pfn_to_nid(pfn) (0)
906#endif
907
908#define pfn_to_section_nr(pfn) ((pfn) >> PFN_SECTION_SHIFT)
909#define section_nr_to_pfn(sec) ((sec) << PFN_SECTION_SHIFT)
910
911#ifdef CONFIG_SPARSEMEM
912
913
914
915
916
917
918
919#define SECTIONS_SHIFT (MAX_PHYSMEM_BITS - SECTION_SIZE_BITS)
920
921#define PA_SECTION_SHIFT (SECTION_SIZE_BITS)
922#define PFN_SECTION_SHIFT (SECTION_SIZE_BITS - PAGE_SHIFT)
923
924#define NR_MEM_SECTIONS (1UL << SECTIONS_SHIFT)
925
926#define PAGES_PER_SECTION (1UL << PFN_SECTION_SHIFT)
927#define PAGE_SECTION_MASK (~(PAGES_PER_SECTION-1))
928
929#define SECTION_BLOCKFLAGS_BITS \
930 ((1UL << (PFN_SECTION_SHIFT - pageblock_order)) * NR_PAGEBLOCK_BITS)
931
932#if (MAX_ORDER - 1 + PAGE_SHIFT) > SECTION_SIZE_BITS
933#error Allocator MAX_ORDER exceeds SECTION_SIZE
934#endif
935
936struct page;
937struct page_cgroup;
938struct mem_section {
939
940
941
942
943
944
945
946
947
948
949
950
951 unsigned long section_mem_map;
952
953
954 unsigned long *pageblock_flags;
955#ifdef CONFIG_CGROUP_MEM_RES_CTLR
956
957
958
959
960 struct page_cgroup *page_cgroup;
961 unsigned long pad;
962#endif
963};
964
965#ifdef CONFIG_SPARSEMEM_EXTREME
966#define SECTIONS_PER_ROOT (PAGE_SIZE / sizeof (struct mem_section))
967#else
968#define SECTIONS_PER_ROOT 1
969#endif
970
971#define SECTION_NR_TO_ROOT(sec) ((sec) / SECTIONS_PER_ROOT)
972#define NR_SECTION_ROOTS (NR_MEM_SECTIONS / SECTIONS_PER_ROOT)
973#define SECTION_ROOT_MASK (SECTIONS_PER_ROOT - 1)
974
975#ifdef CONFIG_SPARSEMEM_EXTREME
976extern struct mem_section *mem_section[NR_SECTION_ROOTS];
977#else
978extern struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT];
979#endif
980
981static inline struct mem_section *__nr_to_section(unsigned long nr)
982{
983 if (!mem_section[SECTION_NR_TO_ROOT(nr)])
984 return NULL;
985 return &mem_section[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK];
986}
987extern int __section_nr(struct mem_section* ms);
988extern unsigned long usemap_size(void);
989
990
991
992
993
994
995#define SECTION_MARKED_PRESENT (1UL<<0)
996#define SECTION_HAS_MEM_MAP (1UL<<1)
997#define SECTION_MAP_LAST_BIT (1UL<<2)
998#define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1))
999#define SECTION_NID_SHIFT 2
1000
1001static inline struct page *__section_mem_map_addr(struct mem_section *section)
1002{
1003 unsigned long map = section->section_mem_map;
1004 map &= SECTION_MAP_MASK;
1005 return (struct page *)map;
1006}
1007
1008static inline int present_section(struct mem_section *section)
1009{
1010 return (section && (section->section_mem_map & SECTION_MARKED_PRESENT));
1011}
1012
1013static inline int present_section_nr(unsigned long nr)
1014{
1015 return present_section(__nr_to_section(nr));
1016}
1017
1018static inline int valid_section(struct mem_section *section)
1019{
1020 return (section && (section->section_mem_map & SECTION_HAS_MEM_MAP));
1021}
1022
1023static inline int valid_section_nr(unsigned long nr)
1024{
1025 return valid_section(__nr_to_section(nr));
1026}
1027
1028static inline struct mem_section *__pfn_to_section(unsigned long pfn)
1029{
1030 return __nr_to_section(pfn_to_section_nr(pfn));
1031}
1032
1033static inline int pfn_valid(unsigned long pfn)
1034{
1035 if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
1036 return 0;
1037 return valid_section(__nr_to_section(pfn_to_section_nr(pfn)));
1038}
1039
1040static inline int pfn_present(unsigned long pfn)
1041{
1042 if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
1043 return 0;
1044 return present_section(__nr_to_section(pfn_to_section_nr(pfn)));
1045}
1046
1047
1048
1049
1050
1051
1052#ifdef CONFIG_NUMA
1053#define pfn_to_nid(pfn) \
1054({ \
1055 unsigned long __pfn_to_nid_pfn = (pfn); \
1056 page_to_nid(pfn_to_page(__pfn_to_nid_pfn)); \
1057})
1058#else
1059#define pfn_to_nid(pfn) (0)
1060#endif
1061
1062#define early_pfn_valid(pfn) pfn_valid(pfn)
1063void sparse_init(void);
1064#else
1065#define sparse_init() do {} while (0)
1066#define sparse_index_init(_sec, _nid) do {} while (0)
1067#endif
1068
1069#ifdef CONFIG_NODES_SPAN_OTHER_NODES
1070#define early_pfn_in_nid(pfn, nid) (early_pfn_to_nid(pfn) == (nid))
1071#else
1072#define early_pfn_in_nid(pfn, nid) (1)
1073#endif
1074
1075#ifndef early_pfn_valid
1076#define early_pfn_valid(pfn) (1)
1077#endif
1078
1079void memory_present(int nid, unsigned long start, unsigned long end);
1080unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long);
1081
1082
1083
1084
1085
1086
1087
1088#ifdef CONFIG_HOLES_IN_ZONE
1089#define pfn_valid_within(pfn) pfn_valid(pfn)
1090#else
1091#define pfn_valid_within(pfn) (1)
1092#endif
1093
1094#endif
1095#endif
1096#endif
1097