From 4b964b8e0d0715f85f330a9e49babb608bec8023 Mon Sep 17 00:00:00 2001 From: Balazs Gerofi Date: Fri, 10 Feb 2017 19:26:50 +0900 Subject: [PATCH] IKC: allocate Linux channel table dynamically --- kernel/host.c | 23 ++++++++++++++++++----- lib/include/ihk/cpu.h | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/kernel/host.c b/kernel/host.c index a55c49bd..d1e6c6db 100644 --- a/kernel/host.c +++ b/kernel/host.c @@ -41,10 +41,8 @@ #define dkprintf(...) do { if (0) kprintf(__VA_ARGS__); } while (0) #endif -/* Comment: McKernel側でのikc2linux(送信channel)の管理 - nr_cpu_ids が利用できない? - 配置場所の再考が必要?*/ -static struct ihk_ikc_channel_desc *ikc2linuxs[512]; +/* Linux channel table, indexec by Linux CPU id */ +static struct ihk_ikc_channel_desc **ikc2linuxs = NULL; void check_mapping_for_proc(struct thread *thread, unsigned long addr) { @@ -686,7 +684,22 @@ static int dummy_packet_handler(struct ihk_ikc_channel_desc *c, void init_host_ikc2linux(int linux_cpu) { struct ihk_ikc_connect_param param; - struct ihk_ikc_channel_desc *c = ikc2linuxs[linux_cpu]; + struct ihk_ikc_channel_desc *c; + + /* Main thread allocates channel pointer table */ + if (!ikc2linuxs) { + ikc2linuxs = kmalloc(sizeof(*ikc2linuxs) * + ihk_mc_get_nr_linux_cores(), IHK_MC_AP_NOWAIT); + if (!ikc2linuxs) { + kprintf("%s: error: allocating Linux channels\n", __FUNCTION__); + panic(""); + } + + memset(ikc2linuxs, 0, sizeof(*ikc2linuxs) * + ihk_mc_get_nr_linux_cores()); + } + + c = ikc2linuxs[linux_cpu]; if (!c) { param.port = 503; diff --git a/lib/include/ihk/cpu.h b/lib/include/ihk/cpu.h index bb4de8e4..c3e9f885 100644 --- a/lib/include/ihk/cpu.h +++ b/lib/include/ihk/cpu.h @@ -60,6 +60,7 @@ int ihk_mc_get_processor_id(void); int ihk_mc_get_hardware_processor_id(void); int ihk_mc_get_numa_id(void); int ihk_mc_get_nr_cores(); +int ihk_mc_get_nr_linux_cores(); int ihk_mc_get_core(int id, unsigned long *linux_core_id, unsigned long *apic_id, int *numa_id); int ihk_mc_get_apicid(int linux_core_id);