mmzone.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Written by Pat Gaughen (gone@us.ibm.com) Mar 2002
  4. *
  5. */
  6. #ifndef _ASM_MMZONE_H_
  7. #define _ASM_MMZONE_H_
  8. #include <asm/smp.h>
  9. #ifdef CONFIG_DISCONTIGMEM
  10. extern struct pglist_data *node_data[];
  11. #define NODE_DATA(nid) (node_data[nid])
  12. #define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn)
  13. #define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
  14. /*
  15. * pfn_valid should be made as fast as possible, and the current definition
  16. * is valid for machines that are NUMA, but still contiguous, which is what
  17. * is currently supported. A more generalised, but slower definition would
  18. * be something like this - mbligh:
  19. * ( pfn_to_pgdat(pfn) && ((pfn) < node_end_pfn(pfn_to_nid(pfn))) )
  20. */
  21. #if 1 /* M32R_FIXME */
  22. #define pfn_valid(pfn) (1)
  23. #else
  24. #define pfn_valid(pfn) ((pfn) < num_physpages)
  25. #endif
  26. /*
  27. * generic node memory support, the following assumptions apply:
  28. */
  29. static __inline__ int pfn_to_nid(unsigned long pfn)
  30. {
  31. int node;
  32. for (node = 0 ; node < MAX_NUMNODES ; node++)
  33. if (pfn >= node_start_pfn(node) && pfn < node_end_pfn(node))
  34. break;
  35. return node;
  36. }
  37. static __inline__ struct pglist_data *pfn_to_pgdat(unsigned long pfn)
  38. {
  39. return(NODE_DATA(pfn_to_nid(pfn)));
  40. }
  41. #endif /* CONFIG_DISCONTIGMEM */
  42. #endif /* _ASM_MMZONE_H_ */