get_one_cpu_topology: Renumber core_id (physical core id)

Change-Id: I4e4857e9a063d16d19d73adfabfc18a4b461bbfb
Refs: #1439
This commit is contained in:
Toshiyuki Takahashi
2020-02-14 11:27:49 +09:00
committed by Masamichi Takagi
parent bb7e140655
commit 0a4e6b49b4
10 changed files with 536 additions and 1 deletions

View File

@ -298,6 +298,7 @@ struct mcctrl_cpu_topology {
//struct mcctrl_usrdata *udp;
struct ihk_cpu_topology *saved;
int mckernel_cpu_id;
int mckernel_core_id;
cpumask_t core_siblings;
cpumask_t thread_siblings;

View File

@ -12,6 +12,7 @@
*/
#include <linux/kernel.h>
#include <linux/hashtable.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/version.h>
@ -23,6 +24,14 @@
#define wprintk(...) do { if (1) printk(KERN_WARNING __VA_ARGS__); } while (0)
#define eprintk(...) do { if (1) printk(KERN_ERR __VA_ARGS__); } while (0)
struct physical_core_id {
int linux_core_id;
int mckernel_core_id;
struct hlist_node next;
};
DEFINE_HASHTABLE(physical_core_id_map, 10);
static ssize_t
show_int(struct sysfsm_ops *ops, void *instance, void *buf, size_t size)
{
@ -188,6 +197,9 @@ static void free_cpu_topology(struct mcctrl_usrdata *udp)
void free_topology_info(ihk_os_t os)
{
struct mcctrl_usrdata *udp = ihk_host_os_get_usrdata(os);
int bkt;
struct hlist_node *tmp;
struct physical_core_id *cur;
if (!udp) {
pr_warn("%s: warning: mcctrl_usrdata not found\n", __func__);
@ -197,6 +209,11 @@ void free_topology_info(ihk_os_t os)
free_node_topology(udp);
free_cpu_topology(udp);
hash_for_each_safe(physical_core_id_map, bkt, tmp, cur, next) {
hash_del(&cur->next);
kfree(cur);
}
return;
} /* free_topology_info() */
@ -348,6 +365,11 @@ static struct mcctrl_cpu_topology *get_one_cpu_topology(struct mcctrl_usrdata *u
struct mcctrl_cpu_topology *topology = NULL;
struct cache_topology *cache;
struct ihk_cache_topology *saved_cache;
int linux_core_id;
int mckernel_core_id;
struct physical_core_id *entry;
struct physical_core_id *cur;
static int nr_mckernel_core;
dprintk("get_one_cpu_topology(%p,%d)\n", udp, index);
topology = kmalloc(sizeof(*topology), GFP_KERNEL);
@ -391,6 +413,22 @@ static struct mcctrl_cpu_topology *get_one_cpu_topology(struct mcctrl_usrdata *u
goto out;
}
linux_core_id = topology->saved->core_id;
mckernel_core_id = -1;
hash_for_each_possible(physical_core_id_map, cur, next, linux_core_id) {
mckernel_core_id = cur->mckernel_core_id;
break;
}
if (mckernel_core_id < 0) {
mckernel_core_id = nr_mckernel_core++;
entry = kmalloc(sizeof(struct physical_core_id), GFP_KERNEL);
entry->linux_core_id = linux_core_id;
entry->mckernel_core_id = mckernel_core_id;
hash_add(physical_core_id_map,
&entry->next, entry->linux_core_id);
}
topology->mckernel_core_id = mckernel_core_id;
list_for_each_entry(saved_cache,
&topology->saved->cache_topology_list, chain) {
cache = get_cache_topology(udp, topology, saved_cache);
@ -512,7 +550,7 @@ static void setup_cpu_sysfs_files(struct mcctrl_usrdata *udp,
"%s/cpu%d/topology/physical_package_id",
prefix, cpu_number);
sysfsm_createf(udp->os, SYSFS_SNOOPING_OPS_d32,
&cpu->saved->core_id, 0444,
&cpu->mckernel_core_id, 0444,
"%s/cpu%d/topology/core_id",
prefix, cpu_number);