IKC: distribute IKC-interrupt to Linux cpus.

This commit is contained in:
Ken Sato
2017-02-09 17:18:26 +09:00
committed by Balazs Gerofi
parent eaa4d35fab
commit 8daffa939e
13 changed files with 138 additions and 102 deletions

View File

@@ -48,6 +48,7 @@ extern struct ihk_os_monitor *monitor;
static void ap_wait(void)
{
struct ihk_mc_cpu_info *cpu_info = ihk_mc_get_cpu_info();
init_tick();
while (ap_stop) {
barrier();
@@ -63,7 +64,14 @@ static void ap_wait(void)
mcs_lock_node_t mcs_node;
mcs_lock_lock_noirq(&ap_syscall_semaphore, &mcs_node);
init_host_syscall_channel();
/* Comment: 自CPUのikc2mckernel と ikc2linuxの準備 */
init_host_ikc2mckernel();
int num = cpu_info->ikc_cpus[ihk_mc_get_processor_id()];
if (num == 1 ) {
num = 0;
}
init_host_ikc2linux(num);
//init_host_ikc2linux(cpu_info->ikc_cpus[ihk_mc_get_processor_id()] - 1);
mcs_lock_unlock_noirq(&ap_syscall_semaphore, &mcs_node);
}

View File

@@ -41,6 +41,11 @@
#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];
void check_mapping_for_proc(struct thread *thread, unsigned long addr)
{
unsigned long __phys;
@@ -475,6 +480,9 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
{
struct ikc_scd_packet *packet = __packet;
struct ikc_scd_packet pckt;
/* Comment: 受信したchannel に返事をする方式から、
自CPUのikc2linux に返事をするよう変更 */
struct ihk_ikc_channel_desc *resp_channel = cpu_local_var(ikc2linux);
int rc;
struct mcs_rwlock_node_irqsave lock;
struct thread *thread;
@@ -510,7 +518,7 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
}
pckt.ref = packet->ref;
pckt.arg = packet->arg;
syscall_channel_send(c, &pckt);
syscall_channel_send(resp_channel, &pckt);
ret = 0;
break;
@@ -567,7 +575,7 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
pckt.err = 0;
pckt.ref = packet->ref;
pckt.arg = packet->arg;
syscall_channel_send(c, &pckt);
syscall_channel_send(resp_channel, &pckt);
rc = do_kill(NULL, info.pid, info.tid, info.sig, &info.info, 0);
kprintf("SCD_MSG_SEND_SIGNAL: do_kill(pid=%d, tid=%d, sig=%d)=%d\n", info.pid, info.tid, info.sig, rc);
@@ -669,54 +677,64 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
return ret;
}
void init_host_syscall_channel(void)
/* Comment: パケット受信を想定しないchannel用のハンドラ */
static int dummy_packet_handler(struct ihk_ikc_channel_desc *c,
void *__packet, void *__os)
{
struct ihk_ikc_connect_param param;
struct ikc_scd_packet pckt;
param.port = 501;
param.pkt_size = sizeof(struct ikc_scd_packet);
param.queue_size = PAGE_SIZE * 4;
param.magic = 0x1129;
param.handler = syscall_packet_handler;
dkprintf("(syscall) Trying to connect host ...");
while (ihk_ikc_connect(NULL, &param) != 0) {
dkprintf(".");
ihk_mc_delay_us(1000 * 1000);
}
dkprintf("connected.\n");
get_this_cpu_local_var()->syscall_channel = param.channel;
pckt.msg = SCD_MSG_INIT_CHANNEL;
pckt.ref = ihk_mc_get_processor_id();
pckt.arg = virt_to_phys(&cpu_local_var(iip));
syscall_channel_send(param.channel, &pckt);
struct ikc_scd_packet *packet = __packet;
ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet, c);
return 0;
}
void init_host_syscall_channel2(void)
/* Comment: ikc2linux の接続と自CPUへの設定を行う */
void init_host_ikc2linux(int linux_cpu)
{
struct ihk_ikc_connect_param param;
struct ikc_scd_packet pckt;
struct ihk_ikc_channel_desc *c = ikc2linuxs[linux_cpu];
param.port = 502;
if (!c) {
/* Comment: 対象Linux_cpu 宛のikc2linuxが存在しなければ、接続 */
param.port = 503;
param.intr_cpu = linux_cpu;
param.pkt_size = sizeof(struct ikc_scd_packet);
param.queue_size = PAGE_SIZE * 4;
param.magic = 0x1129;
param.handler = dummy_packet_handler;
dkprintf("(ikc2linux) Trying to connect host ...");
while (ihk_ikc_connect(NULL, &param) != 0) {
dkprintf(".");
ihk_mc_delay_us(1000 * 1000);
}
dkprintf("connected.\n");
ikc2linuxs[linux_cpu] = param.channel;
c = param.channel;
}
get_this_cpu_local_var()->ikc2linux = c;
}
/* Comment: ikc2mckernelの接続と自CPUへの設定を行う */
void init_host_ikc2mckernel(void)
{
struct ihk_ikc_connect_param param;
param.port = 501;
param.intr_cpu = -1;
param.pkt_size = sizeof(struct ikc_scd_packet);
param.queue_size = PAGE_SIZE * 4;
param.magic = 0x1329;
param.handler = syscall_packet_handler;
dkprintf("(syscall) Trying to connect host ...");
dkprintf("(ikc2mckernel) Trying to connect host ...");
while (ihk_ikc_connect(NULL, &param) != 0) {
dkprintf(".");
ihk_mc_delay_us(1000 * 1000);
}
dkprintf("connected.\n");
get_this_cpu_local_var()->syscall_channel2 = param.channel;
pckt.msg = SCD_MSG_INIT_CHANNEL;
pckt.ref = ihk_mc_get_processor_id();
pckt.arg = virt_to_phys(&cpu_local_var(iip2));
syscall_channel_send(param.channel, &pckt);
/* Comment: 待ち受け処理channel_list に追加する */
ihk_ikc_add_intr_channel(NULL, param.channel, ihk_ikc_get_processor_id());
}

View File

@@ -75,11 +75,9 @@ struct cpu_local_var {
struct list_head runq;
size_t runq_len;
struct ihk_ikc_channel_desc *syscall_channel;
struct ikc_scd_init_param iip;
/* Comment: 送信用するchannelをsyscall_channel から ikc2linux へ変更 */
struct ihk_ikc_channel_desc *ikc2linux;
struct ihk_ikc_channel_desc *syscall_channel2;
struct ikc_scd_init_param iip2;
struct resource_set *resource_set;
int status;

View File

@@ -24,8 +24,9 @@ extern void cpu_local_var_init(void);
extern void kmalloc_init(void);
extern void ap_start(void);
extern void ihk_mc_dma_init(void);
extern void init_host_syscall_channel(void);
extern void init_host_syscall_channel2(void);
extern void init_host_ikc2linux(int linux_cpu);
extern void init_host_ikc2mckernel(void);
//extern void set_ikc2linux_to_local(int linux_cpu);
extern void sched_init(void);
extern void pc_ap_init(void);
extern void cpu_sysfs_setup(void);

View File

@@ -360,6 +360,7 @@ extern int num_processors;
static void post_init(void)
{
struct ihk_mc_cpu_info *cpu_info = ihk_mc_get_cpu_info();
cpu_enable_interrupt();
while (!host_ikc_inited) {
@@ -368,8 +369,8 @@ static void post_init(void)
}
if (find_command_line("hidos")) {
init_host_syscall_channel();
init_host_syscall_channel2();
init_host_ikc2mckernel();
init_host_ikc2linux(cpu_info->ikc_cpus[ihk_mc_get_processor_id()]);
}
arch_setup_vdso();

View File

@@ -47,7 +47,7 @@ procfs_thread_ctl(struct thread *thread, int msg)
struct ihk_ikc_channel_desc *syscall_channel;
struct ikc_scd_packet packet;
syscall_channel = cpu_local_var(syscall_channel);
syscall_channel = cpu_local_var(ikc2linux);
memset(&packet, '\0', sizeof packet);
packet.arg = thread->tid;
packet.msg = msg;
@@ -96,7 +96,7 @@ void process_procfs_request(struct ikc_scd_packet *rpacket)
dprintf("process_procfs_request: invoked.\n");
syscall_channel = get_cpu_local_var(0)->syscall_channel;
syscall_channel = get_cpu_local_var(0)->ikc2linux;
dprintf("rarg: %x\n", rarg);
parg = ihk_mc_map_memory(NULL, rarg, sizeof(struct procfs_read));

View File

@@ -337,18 +337,14 @@ SYSCALL_DECLARE(track_syscalls)
static void send_syscall(struct syscall_request *req, int cpu, int pid, struct syscall_response *res)
{
struct ikc_scd_packet packet IHK_DMA_ALIGN;
struct ihk_ikc_channel_desc *syscall_channel;
struct ihk_ikc_channel_desc *syscall_channel = get_cpu_local_var(cpu)->ikc2linux;
int ret;
if(req->number == __NR_exit_group ||
req->number == __NR_kill){ // interrupt syscall
extern int num_processors;
syscall_channel = get_cpu_local_var(0)->syscall_channel2;
/* XXX: is this really going to work if multiple processes
* exit/receive signals at the same time?? */
cpu = num_processors;
if (req->number == __NR_kill) {
req->rtid = -1;
pid = req->args[0];
@@ -356,9 +352,6 @@ static void send_syscall(struct syscall_request *req, int cpu, int pid, struct s
if (req->number == __NR_gettid)
pid = req->args[1];
}
else{
syscall_channel = get_cpu_local_var(cpu)->syscall_channel;
}
res->status = 0;
req->valid = 0;

View File

@@ -113,7 +113,7 @@ sysfs_createf(struct sysfs_ops *ops, void *instance, int mode,
packet.msg = SCD_MSG_SYSFS_REQ_CREATE;
packet.sysfs_arg1 = virt_to_phys(param);
error = ihk_ikc_send(cpu_local_var(syscall_channel), &packet, 0);
error = ihk_ikc_send(cpu_local_var(ikc2linux), &packet, 0);
if (error) {
ekprintf("sysfs_createf:ihk_ikc_send failed. %d\n", error);
goto out;
@@ -183,7 +183,7 @@ sysfs_mkdirf(sysfs_handle_t *dirhp, const char *fmt, ...)
packet.msg = SCD_MSG_SYSFS_REQ_MKDIR;
packet.sysfs_arg1 = virt_to_phys(param);
error = ihk_ikc_send(cpu_local_var(syscall_channel), &packet, 0);
error = ihk_ikc_send(cpu_local_var(ikc2linux), &packet, 0);
if (error) {
ekprintf("sysfs_mkdirf:ihk_ikc_send failed. %d\n", error);
goto out;
@@ -257,7 +257,7 @@ sysfs_symlinkf(sysfs_handle_t targeth, const char *fmt, ...)
packet.msg = SCD_MSG_SYSFS_REQ_SYMLINK;
packet.sysfs_arg1 = virt_to_phys(param);
error = ihk_ikc_send(cpu_local_var(syscall_channel), &packet, 0);
error = ihk_ikc_send(cpu_local_var(ikc2linux), &packet, 0);
if (error) {
ekprintf("sysfs_symlinkf:ihk_ikc_send failed. %d\n", error);
goto out;
@@ -328,7 +328,7 @@ sysfs_lookupf(sysfs_handle_t *objhp, const char *fmt, ...)
packet.msg = SCD_MSG_SYSFS_REQ_LOOKUP;
packet.sysfs_arg1 = virt_to_phys(param);
error = ihk_ikc_send(cpu_local_var(syscall_channel), &packet, 0);
error = ihk_ikc_send(cpu_local_var(ikc2linux), &packet, 0);
if (error) {
ekprintf("sysfs_lookupf:ihk_ikc_send failed. %d\n", error);
goto out;
@@ -402,7 +402,7 @@ sysfs_unlinkf(int flags, const char *fmt, ...)
packet.msg = SCD_MSG_SYSFS_REQ_UNLINK;
packet.sysfs_arg1 = virt_to_phys(param);
error = ihk_ikc_send(cpu_local_var(syscall_channel), &packet, 0);
error = ihk_ikc_send(cpu_local_var(ikc2linux), &packet, 0);
if (error) {
ekprintf("sysfs_unlinkf:ihk_ikc_send failed. %d\n", error);
goto out;
@@ -462,7 +462,7 @@ sysfss_req_show(long nodeh, struct sysfs_ops *ops, void *instance)
packet.sysfs_arg1 = nodeh;
packet.sysfs_arg2 = ssize;
error = ihk_ikc_send(cpu_local_var(syscall_channel), &packet, 0);
error = ihk_ikc_send(cpu_local_var(ikc2linux), &packet, 0);
if (error) {
ekprintf("sysfss_req_show:ihk_ikc_send failed. %d\n", error);
/* through */
@@ -508,7 +508,7 @@ sysfss_req_store(long nodeh, struct sysfs_ops *ops, void *instance,
packet.sysfs_arg1 = nodeh;
packet.sysfs_arg2 = ssize;
error = ihk_ikc_send(cpu_local_var(syscall_channel), &packet, 0);
error = ihk_ikc_send(cpu_local_var(ikc2linux), &packet, 0);
if (error) {
ekprintf("sysfss_req_store:ihk_ikc_send failed. %d\n", error);
/* through */
@@ -539,7 +539,7 @@ sysfss_req_release(long nodeh, struct sysfs_ops *ops, void *instance)
packet.err = 0;
packet.sysfs_arg1 = nodeh;
error = ihk_ikc_send(cpu_local_var(syscall_channel), &packet, 0);
error = ihk_ikc_send(cpu_local_var(ikc2linux), &packet, 0);
if (error) {
ekprintf("sysfss_req_release:ihk_ikc_send failed. %d\n",
error);
@@ -623,7 +623,7 @@ sysfs_init(void)
packet.msg = SCD_MSG_SYSFS_REQ_SETUP;
packet.sysfs_arg1 = virt_to_phys(param);
error = ihk_ikc_send(cpu_local_var(syscall_channel), &packet, 0);
error = ihk_ikc_send(cpu_local_var(ikc2linux), &packet, 0);
if (error) {
ekprintf("sysfs_init:ihk_ikc_send failed. %d\n", error);
goto out;