numa.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Author: Jianmin Lv <[email protected]>
  4. * Huacai Chen <[email protected]>
  5. *
  6. * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
  7. */
  8. #ifndef _ASM_LOONGARCH_NUMA_H
  9. #define _ASM_LOONGARCH_NUMA_H
  10. #include <linux/nodemask.h>
  11. #define NODE_ADDRSPACE_SHIFT 44
  12. #define pa_to_nid(addr) (((addr) & 0xf00000000000) >> NODE_ADDRSPACE_SHIFT)
  13. #define nid_to_addrbase(nid) (_ULCAST_(nid) << NODE_ADDRSPACE_SHIFT)
  14. #ifdef CONFIG_NUMA
  15. extern int numa_off;
  16. extern s16 __cpuid_to_node[CONFIG_NR_CPUS];
  17. extern nodemask_t numa_nodes_parsed __initdata;
  18. struct numa_memblk {
  19. u64 start;
  20. u64 end;
  21. int nid;
  22. };
  23. #define NR_NODE_MEMBLKS (MAX_NUMNODES*2)
  24. struct numa_meminfo {
  25. int nr_blks;
  26. struct numa_memblk blk[NR_NODE_MEMBLKS];
  27. };
  28. extern int __init numa_add_memblk(int nodeid, u64 start, u64 end);
  29. extern void __init early_numa_add_cpu(int cpuid, s16 node);
  30. extern void numa_add_cpu(unsigned int cpu);
  31. extern void numa_remove_cpu(unsigned int cpu);
  32. static inline void numa_clear_node(int cpu)
  33. {
  34. }
  35. static inline void set_cpuid_to_node(int cpuid, s16 node)
  36. {
  37. __cpuid_to_node[cpuid] = node;
  38. }
  39. extern int early_cpu_to_node(int cpu);
  40. #else
  41. static inline void early_numa_add_cpu(int cpuid, s16 node) { }
  42. static inline void numa_add_cpu(unsigned int cpu) { }
  43. static inline void numa_remove_cpu(unsigned int cpu) { }
  44. static inline int early_cpu_to_node(int cpu)
  45. {
  46. return 0;
  47. }
  48. #endif /* CONFIG_NUMA */
  49. #endif /* _ASM_LOONGARCH_NUMA_H */