From ae9a1f39dfa4dfe84afe371b19f282fd24cf713d Mon Sep 17 00:00:00 2001 From: Masamichi Takagi Date: Fri, 19 Oct 2018 18:07:26 +0900 Subject: [PATCH] ihk_ikc_recv: Record channel to packet for release ihk_ikc_release_packet takes the channel and puts the packet into its free-list. This fix makes it easy and safe to identify the proper channel. Change-Id: I5584b1e8a3ed675c2f9d68f0b5ed331b909197f6 Fujitsu: POSTK_DEBUG_TEMP_FIX_89 --- executer/kernel/mcctrl/control.c | 36 +++++++------------------------- executer/kernel/mcctrl/ikc.c | 7 ++----- executer/kernel/mcctrl/mcctrl.h | 3 ++- executer/kernel/mcctrl/syscall.c | 16 +++----------- ihk | 2 +- kernel/host.c | 4 ++-- kernel/include/syscall.h | 4 +++- 7 files changed, 20 insertions(+), 52 deletions(-) diff --git a/executer/kernel/mcctrl/control.c b/executer/kernel/mcctrl/control.c index 771aa3b8..3590defd 100644 --- a/executer/kernel/mcctrl/control.c +++ b/executer/kernel/mcctrl/control.c @@ -1120,11 +1120,7 @@ void mcctrl_put_per_proc_data(struct mcctrl_per_proc_data *ppd) dprintk("%s: calling __return_syscall (hash),target pid=%d,tid=%d\n", __FUNCTION__, ppd->pid, packet->req.rtid); __return_syscall(ppd->ud->os, packet, -ERESTARTSYS, packet->req.rtid); - ihk_ikc_release_packet( - (struct ihk_ikc_free_packet *)packet, - (ppd->ud->ikc2linux[smp_processor_id()] ? - ppd->ud->ikc2linux[smp_processor_id()] : - ppd->ud->ikc2linux[0])); + ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet); /* Note that uti ptd needs another put by mcexec_terminate_thread() (see mcexec_syscall_wait()). @@ -1148,10 +1144,7 @@ void mcctrl_put_per_proc_data(struct mcctrl_per_proc_data *ppd) * process is gone and the application should be terminated */ __return_syscall(ppd->ud->os, packet, -ERESTARTSYS, packet->req.rtid); - ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet, - (ppd->ud->ikc2linux[smp_processor_id()] ? - ppd->ud->ikc2linux[smp_processor_id()] : - ppd->ud->ikc2linux[0])); + ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet); } ihk_ikc_spinlock_unlock(&ppd->wq_list_lock, flags); @@ -1176,10 +1169,7 @@ int mcexec_syscall(struct mcctrl_usrdata *ud, struct ikc_scd_packet *packet) /* Handle requests that do not need the proxy process right now */ ret = __do_in_kernel_irq_syscall(ud->os, packet); if (ret != -ENOSYS) { - ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet, - (ud->ikc2linux[smp_processor_id()] ? - ud->ikc2linux[smp_processor_id()] : - ud->ikc2linux[0])); + ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet); return ret; } @@ -1195,10 +1185,7 @@ int mcexec_syscall(struct mcctrl_usrdata *ud, struct ikc_scd_packet *packet) * process is gone and the application should be terminated */ __return_syscall(ud->os, packet, -ERESTARTSYS, packet->req.rtid); - ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet, - (ud->ikc2linux[smp_processor_id()] ? - ud->ikc2linux[smp_processor_id()] : - ud->ikc2linux[0])); + ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet); return -1; } @@ -1406,10 +1393,7 @@ retry_alloc: task_tgid_vnr(current), task_pid_vnr(current), packet->req.number); - ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet, - (usrdata->ikc2linux[smp_processor_id()] ? - usrdata->ikc2linux[smp_processor_id()] : - usrdata->ikc2linux[0])); + ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet); goto retry; } @@ -1637,10 +1621,7 @@ long mcexec_ret_syscall(ihk_os_t os, struct syscall_ret_desc *__user arg) error = 0; out: /* Free packet */ - ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet, - (usrdata->ikc2linux[smp_processor_id()] ? - usrdata->ikc2linux[smp_processor_id()] : - usrdata->ikc2linux[0])); + ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet); put_ppd_out: /* Drop a reference for this function */ mcctrl_put_per_thread_data(ptd); @@ -2588,10 +2569,7 @@ static long mcexec_terminate_thread_unsafe(ihk_os_t os, int pid, int tid, long c goto no_ptd; } __return_syscall(usrdata->os, packet, code, tid); - ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet, - (usrdata->ikc2linux[smp_processor_id()] ? - usrdata->ikc2linux[smp_processor_id()] : - usrdata->ikc2linux[0])); + ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet); /* Drop reference for this function */ mcctrl_put_per_thread_data(ptd); diff --git a/executer/kernel/mcctrl/ikc.c b/executer/kernel/mcctrl/ikc.c index e07d67a2..030fd087 100644 --- a/executer/kernel/mcctrl/ikc.c +++ b/executer/kernel/mcctrl/ikc.c @@ -241,10 +241,7 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c, * mcexec_ret_syscall(), for the rest, free it here. */ if (msg != SCD_MSG_SYSCALL_ONESIDE) { - ihk_ikc_release_packet((struct ihk_ikc_free_packet *)__packet, - (usrdata->ikc2linux[smp_processor_id()] ? - usrdata->ikc2linux[smp_processor_id()] : - usrdata->ikc2linux[0])); + ihk_ikc_release_packet((struct ihk_ikc_free_packet *)__packet); } return 0; } @@ -253,7 +250,7 @@ static int dummy_packet_handler(struct ihk_ikc_channel_desc *c, void *__packet, void *__os) { kprintf("%s: WARNING: packet received\n", __FUNCTION__); - ihk_ikc_release_packet((struct ihk_ikc_free_packet *)__packet, c); + ihk_ikc_release_packet((struct ihk_ikc_free_packet *)__packet); return 0; } diff --git a/executer/kernel/mcctrl/mcctrl.h b/executer/kernel/mcctrl/mcctrl.h index fd3a54e6..35c0ce54 100644 --- a/executer/kernel/mcctrl/mcctrl.h +++ b/executer/kernel/mcctrl/mcctrl.h @@ -128,6 +128,7 @@ struct uti_futex_resp { }; struct ikc_scd_packet { + struct ihk_ikc_packet_header header; int msg; int err; void *reply; @@ -172,7 +173,7 @@ struct ikc_scd_packet { int *spin_sleep; /* 1: waiting in linux_wait_event() 0: woken up by someone else */ } futex; }; - char padding[8]; + /* char padding[8]; */ /* We want the size to be 128 bytes */ }; diff --git a/executer/kernel/mcctrl/syscall.c b/executer/kernel/mcctrl/syscall.c index 44c9a516..f430b1d0 100644 --- a/executer/kernel/mcctrl/syscall.c +++ b/executer/kernel/mcctrl/syscall.c @@ -514,10 +514,7 @@ retry_alloc: out: /* Release packet sent from McKernel */ if (free_packet) { - ihk_ikc_release_packet((struct ihk_ikc_free_packet *)free_packet, - (usrdata->ikc2linux[smp_processor_id()] ? - usrdata->ikc2linux[smp_processor_id()] : - usrdata->ikc2linux[0])); + ihk_ikc_release_packet((struct ihk_ikc_free_packet *)free_packet); } ihk_device_unmap_virtual(ihk_os_to_dev(usrdata->os), resp, sizeof(*resp)); ihk_device_unmap_memory(ihk_os_to_dev(usrdata->os), phys, sizeof(*resp)); @@ -744,10 +741,7 @@ retry_alloc: out: /* Release remote page-fault response packet */ if (free_packet) { - ihk_ikc_release_packet((struct ihk_ikc_free_packet *)free_packet, - (usrdata->ikc2linux[smp_processor_id()] ? - usrdata->ikc2linux[smp_processor_id()] : - usrdata->ikc2linux[0])); + ihk_ikc_release_packet((struct ihk_ikc_free_packet *)free_packet); } ihk_device_unmap_virtual(ihk_os_to_dev(usrdata->os), resp, sizeof(*resp)); @@ -2297,7 +2291,6 @@ int __do_in_kernel_syscall(ihk_os_t os, struct ikc_scd_packet *packet) struct syscall_request *sc = &packet->req; int error; long ret = -1; - struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os); dprintk("%s: system call: %lx\n", __FUNCTION__, sc->args[0]); switch (sc->number) { @@ -2396,10 +2389,7 @@ sched_setparam_out: } __return_syscall(os, packet, ret, 0); - ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet, - (usrdata->ikc2linux[smp_processor_id()] ? - usrdata->ikc2linux[smp_processor_id()] : - usrdata->ikc2linux[0])); + ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet); error = 0; out: diff --git a/ihk b/ihk index d9c74adf..a7a200fd 160000 --- a/ihk +++ b/ihk @@ -1 +1 @@ -Subproject commit d9c74adf3f3037b5e1c0d9f40dd2e18e4fa70165 +Subproject commit a7a200fd3ef3d5ef18da6d8452d16f4cab2ca578 diff --git a/kernel/host.c b/kernel/host.c index 1f015f1d..28e5700a 100644 --- a/kernel/host.c +++ b/kernel/host.c @@ -779,7 +779,7 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c, } - ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet, c); + ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet); return ret; } @@ -787,7 +787,7 @@ static int dummy_packet_handler(struct ihk_ikc_channel_desc *c, void *__packet, void *__os) { struct ikc_scd_packet *packet = __packet; - ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet, c); + ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet); return 0; } diff --git a/kernel/include/syscall.h b/kernel/include/syscall.h index 77a1e639..5871fd69 100644 --- a/kernel/include/syscall.h +++ b/kernel/include/syscall.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -242,6 +243,7 @@ enum mcctrl_os_cpu_operation { }; struct ikc_scd_packet { + struct ihk_ikc_packet_header header; int msg; int err; void *reply; @@ -286,7 +288,7 @@ struct ikc_scd_packet { int *spin_sleep; /* 1: waiting in linux_wait_event() 0: woken up by someone else */ } futex; }; - char padding[8]; + /* char padding[8]; */ /* We want the size to be 128 bytes */ }; #define IHK_SCD_REQ_THREAD_SPINNING 0