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
This commit is contained in:
Masamichi Takagi
2018-10-19 18:07:26 +09:00
committed by Dominique Martinet
parent 10dc87dd3f
commit ae9a1f39df
7 changed files with 20 additions and 52 deletions

View File

@ -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); 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, __return_syscall(ppd->ud->os, packet, -ERESTARTSYS,
packet->req.rtid); packet->req.rtid);
ihk_ikc_release_packet( ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet);
(struct ihk_ikc_free_packet *)packet,
(ppd->ud->ikc2linux[smp_processor_id()] ?
ppd->ud->ikc2linux[smp_processor_id()] :
ppd->ud->ikc2linux[0]));
/* Note that uti ptd needs another put by mcexec_terminate_thread() /* Note that uti ptd needs another put by mcexec_terminate_thread()
(see mcexec_syscall_wait()). (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 */ * process is gone and the application should be terminated */
__return_syscall(ppd->ud->os, packet, -ERESTARTSYS, __return_syscall(ppd->ud->os, packet, -ERESTARTSYS,
packet->req.rtid); packet->req.rtid);
ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet, 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_spinlock_unlock(&ppd->wq_list_lock, flags); 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 */ /* Handle requests that do not need the proxy process right now */
ret = __do_in_kernel_irq_syscall(ud->os, packet); ret = __do_in_kernel_irq_syscall(ud->os, packet);
if (ret != -ENOSYS) { if (ret != -ENOSYS) {
ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet, ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet);
(ud->ikc2linux[smp_processor_id()] ?
ud->ikc2linux[smp_processor_id()] :
ud->ikc2linux[0]));
return ret; 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 */ * process is gone and the application should be terminated */
__return_syscall(ud->os, packet, -ERESTARTSYS, __return_syscall(ud->os, packet, -ERESTARTSYS,
packet->req.rtid); packet->req.rtid);
ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet, ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet);
(ud->ikc2linux[smp_processor_id()] ?
ud->ikc2linux[smp_processor_id()] :
ud->ikc2linux[0]));
return -1; return -1;
} }
@ -1406,10 +1393,7 @@ retry_alloc:
task_tgid_vnr(current), task_tgid_vnr(current),
task_pid_vnr(current), task_pid_vnr(current),
packet->req.number); packet->req.number);
ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet, ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet);
(usrdata->ikc2linux[smp_processor_id()] ?
usrdata->ikc2linux[smp_processor_id()] :
usrdata->ikc2linux[0]));
goto retry; goto retry;
} }
@ -1637,10 +1621,7 @@ long mcexec_ret_syscall(ihk_os_t os, struct syscall_ret_desc *__user arg)
error = 0; error = 0;
out: out:
/* Free packet */ /* Free packet */
ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet, ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet);
(usrdata->ikc2linux[smp_processor_id()] ?
usrdata->ikc2linux[smp_processor_id()] :
usrdata->ikc2linux[0]));
put_ppd_out: put_ppd_out:
/* Drop a reference for this function */ /* Drop a reference for this function */
mcctrl_put_per_thread_data(ptd); 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; goto no_ptd;
} }
__return_syscall(usrdata->os, packet, code, tid); __return_syscall(usrdata->os, packet, code, tid);
ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet, ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet);
(usrdata->ikc2linux[smp_processor_id()] ?
usrdata->ikc2linux[smp_processor_id()] :
usrdata->ikc2linux[0]));
/* Drop reference for this function */ /* Drop reference for this function */
mcctrl_put_per_thread_data(ptd); mcctrl_put_per_thread_data(ptd);

View File

@ -241,10 +241,7 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
* mcexec_ret_syscall(), for the rest, free it here. * mcexec_ret_syscall(), for the rest, free it here.
*/ */
if (msg != SCD_MSG_SYSCALL_ONESIDE) { if (msg != SCD_MSG_SYSCALL_ONESIDE) {
ihk_ikc_release_packet((struct ihk_ikc_free_packet *)__packet, ihk_ikc_release_packet((struct ihk_ikc_free_packet *)__packet);
(usrdata->ikc2linux[smp_processor_id()] ?
usrdata->ikc2linux[smp_processor_id()] :
usrdata->ikc2linux[0]));
} }
return 0; return 0;
} }
@ -253,7 +250,7 @@ static int dummy_packet_handler(struct ihk_ikc_channel_desc *c,
void *__packet, void *__os) void *__packet, void *__os)
{ {
kprintf("%s: WARNING: packet received\n", __FUNCTION__); 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; return 0;
} }

View File

@ -128,6 +128,7 @@ struct uti_futex_resp {
}; };
struct ikc_scd_packet { struct ikc_scd_packet {
struct ihk_ikc_packet_header header;
int msg; int msg;
int err; int err;
void *reply; 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 */ int *spin_sleep; /* 1: waiting in linux_wait_event() 0: woken up by someone else */
} futex; } futex;
}; };
char padding[8]; /* char padding[8]; */ /* We want the size to be 128 bytes */
}; };

View File

@ -514,10 +514,7 @@ retry_alloc:
out: out:
/* Release packet sent from McKernel */ /* Release packet sent from McKernel */
if (free_packet) { if (free_packet) {
ihk_ikc_release_packet((struct ihk_ikc_free_packet *)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_device_unmap_virtual(ihk_os_to_dev(usrdata->os), resp, sizeof(*resp)); 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)); ihk_device_unmap_memory(ihk_os_to_dev(usrdata->os), phys, sizeof(*resp));
@ -744,10 +741,7 @@ retry_alloc:
out: out:
/* Release remote page-fault response packet */ /* Release remote page-fault response packet */
if (free_packet) { if (free_packet) {
ihk_ikc_release_packet((struct ihk_ikc_free_packet *)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_device_unmap_virtual(ihk_os_to_dev(usrdata->os), resp, sizeof(*resp)); 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; struct syscall_request *sc = &packet->req;
int error; int error;
long ret = -1; long ret = -1;
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
dprintk("%s: system call: %lx\n", __FUNCTION__, sc->args[0]); dprintk("%s: system call: %lx\n", __FUNCTION__, sc->args[0]);
switch (sc->number) { switch (sc->number) {
@ -2396,10 +2389,7 @@ sched_setparam_out:
} }
__return_syscall(os, packet, ret, 0); __return_syscall(os, packet, ret, 0);
ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet, ihk_ikc_release_packet((struct ihk_ikc_free_packet *)packet);
(usrdata->ikc2linux[smp_processor_id()] ?
usrdata->ikc2linux[smp_processor_id()] :
usrdata->ikc2linux[0]));
error = 0; error = 0;
out: out:

2
ihk

Submodule ihk updated: d9c74adf3f...a7a200fd3e

View File

@ -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; return ret;
} }
@ -787,7 +787,7 @@ static int dummy_packet_handler(struct ihk_ikc_channel_desc *c,
void *__packet, void *__os) void *__packet, void *__os)
{ {
struct ikc_scd_packet *packet = __packet; 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; return 0;
} }

View File

@ -17,6 +17,7 @@
#include <ihk/atomic.h> #include <ihk/atomic.h>
#include <ihk/context.h> #include <ihk/context.h>
#include <ihk/memconst.h> #include <ihk/memconst.h>
#include <ihk/ikc.h>
#include <rlimit.h> #include <rlimit.h>
#include <time.h> #include <time.h>
@ -242,6 +243,7 @@ enum mcctrl_os_cpu_operation {
}; };
struct ikc_scd_packet { struct ikc_scd_packet {
struct ihk_ikc_packet_header header;
int msg; int msg;
int err; int err;
void *reply; 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 */ int *spin_sleep; /* 1: waiting in linux_wait_event() 0: woken up by someone else */
} futex; } futex;
}; };
char padding[8]; /* char padding[8]; */ /* We want the size to be 128 bytes */
}; };
#define IHK_SCD_REQ_THREAD_SPINNING 0 #define IHK_SCD_REQ_THREAD_SPINNING 0