Skip to content

Commit 3f6935a

Browse files
committed
linux: get CPUModel and CPUFamily from /proc/cpuinfo on LoongArch
Signed-off-by: Brice Goglin <[email protected]>
1 parent 14ab4ed commit 3f6935a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

doc/hwloc.doxy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,6 +2095,10 @@ or to the root object (Machine) if package locality information is missing.
20952095
Currently available for x86 and Xeon Phi processors on most systems,
20962096
and for ia64 processors on Linux (except CPUStepping).
20972097
</dd>
2098+
<dt>CPUFamily</dt>
2099+
<dd>
2100+
The family of the CPU, currently only available on Linux on LoongArch platforms.
2101+
</dd>
20982102
<dt>CPURevision</dt>
20992103
<dd>
21002104
A POWER/PowerPC-specific general processor revision number,

hwloc/topology-linux.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct hwloc_linux_backend_data_s {
5353
HWLOC_LINUX_ARCH_ARM,
5454
HWLOC_LINUX_ARCH_POWER,
5555
HWLOC_LINUX_ARCH_S390,
56+
HWLOC_LINUX_ARCH_LOONGARCH,
5657
HWLOC_LINUX_ARCH_UNKNOWN
5758
} arch;
5859
int is_knl;
@@ -5287,6 +5288,21 @@ hwloc_linux_parse_cpuinfo_ppc(const char *prefix, const char *value,
52875288
return 0;
52885289
}
52895290

5291+
static int
5292+
hwloc_linux_parse_cpuinfo_loongarch(const char *prefix, const char *value,
5293+
struct hwloc_infos_s *infos,
5294+
int is_global __hwloc_attribute_unused)
5295+
{
5296+
if (!strcmp("Model Name", prefix)) {
5297+
if (value[0])
5298+
hwloc__add_info(infos, "CPUModel", value);
5299+
} else if (!strcmp("CPU Family", prefix)) {
5300+
if (value[0])
5301+
hwloc__add_info(infos, "CPUFamily", value);
5302+
}
5303+
return 0;
5304+
}
5305+
52905306
/*
52915307
* avr32: "chip type\t:" => OK
52925308
* blackfin: "model name\t:" => OK
@@ -5434,6 +5450,9 @@ hwloc_linux_parse_cpuinfo(struct hwloc_linux_backend_data_s *data,
54345450
case HWLOC_LINUX_ARCH_IA64:
54355451
parse_cpuinfo_func = hwloc_linux_parse_cpuinfo_ia64;
54365452
break;
5453+
case HWLOC_LINUX_ARCH_LOONGARCH:
5454+
parse_cpuinfo_func = hwloc_linux_parse_cpuinfo_loongarch;
5455+
break;
54375456
default:
54385457
parse_cpuinfo_func = hwloc_linux_parse_cpuinfo_generic;
54395458
}
@@ -5593,6 +5612,8 @@ hwloc_gather_system_info(struct hwloc_topology *topology,
55935612
data->arch = HWLOC_LINUX_ARCH_POWER;
55945613
else if (!strncmp(data->utsname.machine, "s390", 4))
55955614
data->arch = HWLOC_LINUX_ARCH_S390;
5615+
else if (!strncmp(data->utsname.machine, "loongarch", 9))
5616+
data->arch = HWLOC_LINUX_ARCH_LOONGARCH;
55965617
else if (!strcmp(data->utsname.machine, "ia64"))
55975618
data->arch = HWLOC_LINUX_ARCH_IA64;
55985619
}

0 commit comments

Comments
 (0)