61 lines
2.0 KiB
Diff
61 lines
2.0 KiB
Diff
From 6b767a2fce615384f062ecb392cd332452bf4482 Mon Sep 17 00:00:00 2001
|
|
From: Lostwayzxc <luoshengwei@huawei.com>
|
|
Date: Wed, 1 Sep 2021 21:00:16 +0800
|
|
Subject: [PATCH] modify cpu parse for adapting to new bios version
|
|
|
|
---
|
|
ras-cpu-isolation.c | 20 ++++++++++++++++++--
|
|
1 file changed, 18 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/ras-cpu-isolation.c b/ras-cpu-isolation.c
|
|
index 6dcff70..b1643c4 100644
|
|
--- a/ras-cpu-isolation.c
|
|
+++ b/ras-cpu-isolation.c
|
|
@@ -25,6 +25,7 @@
|
|
|
|
static struct cpu_info *cpu_infos = NULL;
|
|
static unsigned int ncores, cores_per_socket, cores_per_die;
|
|
+static unsigned int cores_per_cluster = 4;
|
|
static unsigned int sockets, dies = 1;
|
|
static unsigned int enabled = 1;
|
|
static const char *cpu_path_format = "/sys/devices/system/cpu/cpu%d/online";
|
|
@@ -432,18 +433,33 @@ static unsigned long get_bit_value(int64_t value, unsigned offset, unsigned size
|
|
|
|
static unsigned get_cpu_index(int64_t mpidr)
|
|
{
|
|
- unsigned core_id, socket_id, die_id, cpu;
|
|
+ unsigned core_id, cluster_id, socket_id, die_id, cpu;
|
|
/*
|
|
* Adapt to certain BIOS
|
|
* In the MPIDR:
|
|
* bit 8:15: core id
|
|
+ * bit 16:18: cluster id
|
|
* bit 19:20: die_id
|
|
* bit 21:22: socket_id
|
|
*/
|
|
core_id = get_bit_value(mpidr, 8, 8);
|
|
+ cluster_id = get_bit_value(mpidr, 16, 3);
|
|
socket_id = get_bit_value(mpidr, 21, 2);
|
|
die_id = get_bit_value(mpidr, 19, 2);
|
|
- cpu = core_id + socket_id * cores_per_socket + die_id * cores_per_die;
|
|
+
|
|
+ /* When die id parsed from MPIDR is 1, it means TotemA, and when it's 3,
|
|
+ * it means TotemB. When cores per die equal to cores per socket, it means
|
|
+ * that there is only one die in the socket, in case that the only die is
|
|
+ * TotemB in CPU 1620s, we set die id to 0 directly.
|
|
+ */
|
|
+ if (cores_per_die == cores_per_socket) {
|
|
+ die_id = 0;
|
|
+ }
|
|
+ else {
|
|
+ die_id = (die_id == 1 ? 0:1);
|
|
+ }
|
|
+ cpu = core_id + socket_id * cores_per_socket + die_id * cores_per_die +
|
|
+ cluster_id * cores_per_cluster;
|
|
|
|
return cpu;
|
|
}
|
|
--
|
|
2.27.0
|
|
|