MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_numa_memory_affinity

Function rt_numa_memory_affinity

components/drivers/core/numa.c:60–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60rt_err_t rt_numa_memory_affinity(rt_uint64_t phy_addr, rt_bitmap_t *out_affinity)
61{
62 struct numa_memory *nm;
63
64 if (!out_affinity)
65 {
66 return -RT_EINVAL;
67 }
68
69 if (!numa_enabled)
70 {
71 /* Default to CPU#0 */
72 RT_IRQ_AFFINITY_SET(out_affinity, 0);
73
74 return RT_EOK;
75 }
76
77 rt_memset(out_affinity, 0, sizeof(*out_affinity) * RT_BITMAP_LEN(RT_CPUS_NR));
78
79 rt_list_for_each_entry(nm, &numa_memory_nodes, list)
80 {
81 if (phy_addr >= nm->start && phy_addr < nm->end)
82 {
83 for (int i = 0; i < RT_ARRAY_SIZE(cpu_numa_map); ++i)
84 {
85 if (cpu_numa_map[i] == nm->nid)
86 {
87 RT_IRQ_AFFINITY_SET(out_affinity, i);
88 }
89 }
90
91 return RT_EOK;
92 }
93 }
94
95 return -RT_EEMPTY;
96}
97
98#ifdef RT_USING_OFW
99static int numa_ofw_init(void)

Callers 1

msi_affinity_initFunction · 0.85

Calls 1

rt_memsetFunction · 0.85

Tested by

no test coverage detected