Skip to content

Commit 11270e5

Browse files
davejiangdjbw
authored andcommitted
base/node / ACPI: Enumerate node access class for 'struct access_coordinate'
Both generic node and HMAT handling code have been using magic numbers to indicate access classes for 'struct access_coordinate'. Introduce enums to enumerate the access0 and access1 classes shared by the two subsystems. Update the function parameters and callers as appropriate to utilize the new enum. Access0 is named to ACCESS_COORDINATE_LOCAL in order to indicate that the access class is for 'struct access_coordinate' between a target node and the nearest initiator node. Access1 is named to ACCESS_COORDINATE_CPU in order to indicate that the access class is for 'struct access_coordinate' between a target node and the nearest CPU node. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Rafael J. Wysocki <rafael@kernel.org> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Tested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/20240308220055.2172956-3-dave.jiang@intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 54b9460 commit 11270e5

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

drivers/acpi/numa/hmat.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ struct target_cache {
5959
};
6060

6161
enum {
62-
NODE_ACCESS_CLASS_0 = 0,
63-
NODE_ACCESS_CLASS_1,
64-
NODE_ACCESS_CLASS_GENPORT_SINK,
62+
NODE_ACCESS_CLASS_GENPORT_SINK = ACCESS_COORDINATE_MAX,
6563
NODE_ACCESS_CLASS_MAX,
6664
};
6765

@@ -374,11 +372,11 @@ static __init void hmat_update_target(unsigned int tgt_pxm, unsigned int init_px
374372

375373
if (target && target->processor_pxm == init_pxm) {
376374
hmat_update_target_access(target, type, value,
377-
NODE_ACCESS_CLASS_0);
375+
ACCESS_COORDINATE_LOCAL);
378376
/* If the node has a CPU, update access 1 */
379377
if (node_state(pxm_to_node(init_pxm), N_CPU))
380378
hmat_update_target_access(target, type, value,
381-
NODE_ACCESS_CLASS_1);
379+
ACCESS_COORDINATE_CPU);
382380
}
383381
}
384382

@@ -709,7 +707,8 @@ static void hmat_update_target_attrs(struct memory_target *target,
709707
*/
710708
if (target->processor_pxm != PXM_INVAL) {
711709
cpu_nid = pxm_to_node(target->processor_pxm);
712-
if (access == 0 || node_state(cpu_nid, N_CPU)) {
710+
if (access == ACCESS_COORDINATE_LOCAL ||
711+
node_state(cpu_nid, N_CPU)) {
713712
set_bit(target->processor_pxm, p_nodes);
714713
return;
715714
}
@@ -737,7 +736,8 @@ static void hmat_update_target_attrs(struct memory_target *target,
737736
list_for_each_entry(initiator, &initiators, node) {
738737
u32 value;
739738

740-
if (access == 1 && !initiator->has_cpu) {
739+
if (access == ACCESS_COORDINATE_CPU &&
740+
!initiator->has_cpu) {
741741
clear_bit(initiator->processor_pxm, p_nodes);
742742
continue;
743743
}
@@ -782,8 +782,10 @@ static void hmat_register_target_initiators(struct memory_target *target)
782782
{
783783
static DECLARE_BITMAP(p_nodes, MAX_NUMNODES);
784784

785-
__hmat_register_target_initiators(target, p_nodes, 0);
786-
__hmat_register_target_initiators(target, p_nodes, 1);
785+
__hmat_register_target_initiators(target, p_nodes,
786+
ACCESS_COORDINATE_LOCAL);
787+
__hmat_register_target_initiators(target, p_nodes,
788+
ACCESS_COORDINATE_CPU);
787789
}
788790

789791
static void hmat_register_target_cache(struct memory_target *target)
@@ -854,8 +856,8 @@ static void hmat_register_target(struct memory_target *target)
854856
if (!target->registered) {
855857
hmat_register_target_initiators(target);
856858
hmat_register_target_cache(target);
857-
hmat_register_target_perf(target, NODE_ACCESS_CLASS_0);
858-
hmat_register_target_perf(target, NODE_ACCESS_CLASS_1);
859+
hmat_register_target_perf(target, ACCESS_COORDINATE_LOCAL);
860+
hmat_register_target_perf(target, ACCESS_COORDINATE_CPU);
859861
target->registered = true;
860862
}
861863
mutex_unlock(&target_lock);
@@ -927,7 +929,7 @@ static int hmat_calculate_adistance(struct notifier_block *self,
927929
return NOTIFY_OK;
928930

929931
mutex_lock(&target_lock);
930-
hmat_update_target_attrs(target, p_nodes, 1);
932+
hmat_update_target_attrs(target, p_nodes, ACCESS_COORDINATE_CPU);
931933
mutex_unlock(&target_lock);
932934

933935
perf = &target->coord[1];

drivers/base/node.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static void node_access_release(struct device *dev)
126126
}
127127

128128
static struct node_access_nodes *node_init_node_access(struct node *node,
129-
unsigned int access)
129+
enum access_coordinate_class access)
130130
{
131131
struct node_access_nodes *access_node;
132132
struct device *dev;
@@ -191,7 +191,7 @@ static struct attribute *access_attrs[] = {
191191
* @access: The access class the for the given attributes
192192
*/
193193
void node_set_perf_attrs(unsigned int nid, struct access_coordinate *coord,
194-
unsigned int access)
194+
enum access_coordinate_class access)
195195
{
196196
struct node_access_nodes *c;
197197
struct node *node;
@@ -689,7 +689,7 @@ int register_cpu_under_node(unsigned int cpu, unsigned int nid)
689689
*/
690690
int register_memory_node_under_compute_node(unsigned int mem_nid,
691691
unsigned int cpu_nid,
692-
unsigned int access)
692+
enum access_coordinate_class access)
693693
{
694694
struct node *init_node, *targ_node;
695695
struct node_access_nodes *initiator, *target;

include/linux/node.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ struct access_coordinate {
3434
unsigned int write_latency;
3535
};
3636

37+
/*
38+
* ACCESS_COORDINATE_LOCAL correlates to ACCESS CLASS 0
39+
* - access_coordinate between target node and nearest initiator node
40+
* ACCESS_COORDINATE_CPU correlates to ACCESS CLASS 1
41+
* - access_coordinate between target node and nearest CPU node
42+
*/
43+
enum access_coordinate_class {
44+
ACCESS_COORDINATE_LOCAL,
45+
ACCESS_COORDINATE_CPU,
46+
ACCESS_COORDINATE_MAX
47+
};
48+
3749
enum cache_indexing {
3850
NODE_CACHE_DIRECT_MAP,
3951
NODE_CACHE_INDEXED,
@@ -66,7 +78,7 @@ struct node_cache_attrs {
6678
#ifdef CONFIG_HMEM_REPORTING
6779
void node_add_cache(unsigned int nid, struct node_cache_attrs *cache_attrs);
6880
void node_set_perf_attrs(unsigned int nid, struct access_coordinate *coord,
69-
unsigned access);
81+
enum access_coordinate_class access);
7082
#else
7183
static inline void node_add_cache(unsigned int nid,
7284
struct node_cache_attrs *cache_attrs)
@@ -75,7 +87,7 @@ static inline void node_add_cache(unsigned int nid,
7587

7688
static inline void node_set_perf_attrs(unsigned int nid,
7789
struct access_coordinate *coord,
78-
unsigned access)
90+
enum access_coordinate_class access)
7991
{
8092
}
8193
#endif
@@ -137,7 +149,7 @@ extern void unregister_memory_block_under_nodes(struct memory_block *mem_blk);
137149

138150
extern int register_memory_node_under_compute_node(unsigned int mem_nid,
139151
unsigned int cpu_nid,
140-
unsigned access);
152+
enum access_coordinate_class access);
141153
#else
142154
static inline void node_dev_init(void)
143155
{

0 commit comments

Comments
 (0)