Skip to content

Commit ee9dcae

Browse files
yhuang-intelakpm00
authored andcommitted
acpi, hmat: refactor hmat_register_target_initiators()
Previously, in hmat_register_target_initiators(), the performance attributes are calculated and the corresponding sysfs links and files are created too. Which is called during memory onlining. But now, to calculate the abstract distance of a memory target before memory onlining, we need to calculate the performance attributes for a memory target without creating sysfs links and files. To do that, hmat_register_target_initiators() is refactored to make it possible to calculate performance attributes separately. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: "Huang, Ying" <[email protected]> Reviewed-by: Alistair Popple <[email protected]> Tested-by: Alistair Popple <[email protected]> Cc: Aneesh Kumar K.V <[email protected]> Cc: Wei Xu <[email protected]> Cc: Dan Williams <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Davidlohr Bueso <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Jonathan Cameron <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Yang Shi <[email protected]> Cc: Rafael J Wysocki <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent b0fefe6 commit ee9dcae

File tree

1 file changed

+30
-51
lines changed

1 file changed

+30
-51
lines changed

drivers/acpi/numa/hmat.c

Lines changed: 30 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -582,28 +582,25 @@ static int initiators_to_nodemask(unsigned long *p_nodes)
582582
return 0;
583583
}
584584

585-
static void hmat_register_target_initiators(struct memory_target *target)
585+
static void hmat_update_target_attrs(struct memory_target *target,
586+
unsigned long *p_nodes, int access)
586587
{
587-
static DECLARE_BITMAP(p_nodes, MAX_NUMNODES);
588588
struct memory_initiator *initiator;
589-
unsigned int mem_nid, cpu_nid;
589+
unsigned int cpu_nid;
590590
struct memory_locality *loc = NULL;
591591
u32 best = 0;
592-
bool access0done = false;
593592
int i;
594593

595-
mem_nid = pxm_to_node(target->memory_pxm);
594+
bitmap_zero(p_nodes, MAX_NUMNODES);
596595
/*
597-
* If the Address Range Structure provides a local processor pxm, link
596+
* If the Address Range Structure provides a local processor pxm, set
598597
* only that one. Otherwise, find the best performance attributes and
599-
* register all initiators that match.
598+
* collect all initiators that match.
600599
*/
601600
if (target->processor_pxm != PXM_INVAL) {
602601
cpu_nid = pxm_to_node(target->processor_pxm);
603-
register_memory_node_under_compute_node(mem_nid, cpu_nid, 0);
604-
access0done = true;
605-
if (node_state(cpu_nid, N_CPU)) {
606-
register_memory_node_under_compute_node(mem_nid, cpu_nid, 1);
602+
if (access == 0 || node_state(cpu_nid, N_CPU)) {
603+
set_bit(target->processor_pxm, p_nodes);
607604
return;
608605
}
609606
}
@@ -617,47 +614,10 @@ static void hmat_register_target_initiators(struct memory_target *target)
617614
* We'll also use the sorting to prime the candidate nodes with known
618615
* initiators.
619616
*/
620-
bitmap_zero(p_nodes, MAX_NUMNODES);
621617
list_sort(NULL, &initiators, initiator_cmp);
622618
if (initiators_to_nodemask(p_nodes) < 0)
623619
return;
624620

625-
if (!access0done) {
626-
for (i = WRITE_LATENCY; i <= READ_BANDWIDTH; i++) {
627-
loc = localities_types[i];
628-
if (!loc)
629-
continue;
630-
631-
best = 0;
632-
list_for_each_entry(initiator, &initiators, node) {
633-
u32 value;
634-
635-
if (!test_bit(initiator->processor_pxm, p_nodes))
636-
continue;
637-
638-
value = hmat_initiator_perf(target, initiator,
639-
loc->hmat_loc);
640-
if (hmat_update_best(loc->hmat_loc->data_type, value, &best))
641-
bitmap_clear(p_nodes, 0, initiator->processor_pxm);
642-
if (value != best)
643-
clear_bit(initiator->processor_pxm, p_nodes);
644-
}
645-
if (best)
646-
hmat_update_target_access(target, loc->hmat_loc->data_type,
647-
best, 0);
648-
}
649-
650-
for_each_set_bit(i, p_nodes, MAX_NUMNODES) {
651-
cpu_nid = pxm_to_node(i);
652-
register_memory_node_under_compute_node(mem_nid, cpu_nid, 0);
653-
}
654-
}
655-
656-
/* Access 1 ignores Generic Initiators */
657-
bitmap_zero(p_nodes, MAX_NUMNODES);
658-
if (initiators_to_nodemask(p_nodes) < 0)
659-
return;
660-
661621
for (i = WRITE_LATENCY; i <= READ_BANDWIDTH; i++) {
662622
loc = localities_types[i];
663623
if (!loc)
@@ -667,7 +627,7 @@ static void hmat_register_target_initiators(struct memory_target *target)
667627
list_for_each_entry(initiator, &initiators, node) {
668628
u32 value;
669629

670-
if (!initiator->has_cpu) {
630+
if (access == 1 && !initiator->has_cpu) {
671631
clear_bit(initiator->processor_pxm, p_nodes);
672632
continue;
673633
}
@@ -681,14 +641,33 @@ static void hmat_register_target_initiators(struct memory_target *target)
681641
clear_bit(initiator->processor_pxm, p_nodes);
682642
}
683643
if (best)
684-
hmat_update_target_access(target, loc->hmat_loc->data_type, best, 1);
644+
hmat_update_target_access(target, loc->hmat_loc->data_type, best, access);
685645
}
646+
}
647+
648+
static void __hmat_register_target_initiators(struct memory_target *target,
649+
unsigned long *p_nodes,
650+
int access)
651+
{
652+
unsigned int mem_nid, cpu_nid;
653+
int i;
654+
655+
mem_nid = pxm_to_node(target->memory_pxm);
656+
hmat_update_target_attrs(target, p_nodes, access);
686657
for_each_set_bit(i, p_nodes, MAX_NUMNODES) {
687658
cpu_nid = pxm_to_node(i);
688-
register_memory_node_under_compute_node(mem_nid, cpu_nid, 1);
659+
register_memory_node_under_compute_node(mem_nid, cpu_nid, access);
689660
}
690661
}
691662

663+
static void hmat_register_target_initiators(struct memory_target *target)
664+
{
665+
static DECLARE_BITMAP(p_nodes, MAX_NUMNODES);
666+
667+
__hmat_register_target_initiators(target, p_nodes, 0);
668+
__hmat_register_target_initiators(target, p_nodes, 1);
669+
}
670+
692671
static void hmat_register_target_cache(struct memory_target *target)
693672
{
694673
unsigned mem_nid = pxm_to_node(target->memory_pxm);

0 commit comments

Comments
 (0)