refactoring /proc
This commit is contained in:
@ -72,9 +72,6 @@ int (*mcctrl_sys_mount)(char *dev_name,char *dir_name, char *type, unsigned long
|
||||
//static DECLARE_WAIT_QUEUE_HEAD(wq_prepare);
|
||||
//extern struct mcctrl_channel *channels;
|
||||
int mcctrl_ikc_set_recv_cpu(ihk_os_t os, int cpu);
|
||||
extern int procfs_create_entry(void *os, int ref, int osnum, int pid, char *name,
|
||||
int mode, void *opaque);
|
||||
extern void procfs_delete_entry(void *os, int osnum, char *fname);
|
||||
|
||||
static long mcexec_prepare_image(ihk_os_t os,
|
||||
struct program_load_desc * __user udesc)
|
||||
@ -290,12 +287,15 @@ static void release_handler(ihk_os_t os, void *param)
|
||||
{
|
||||
struct handlerinfo *info = param;
|
||||
struct ikc_scd_packet isp;
|
||||
int os_ind = ihk_host_os_get_index(os);
|
||||
|
||||
memset(&isp, '\0', sizeof isp);
|
||||
isp.msg = SCD_MSG_CLEANUP_PROCESS;
|
||||
isp.pid = info->pid;
|
||||
|
||||
mcctrl_ikc_send(os, 0, &isp);
|
||||
if(os_ind >= 0)
|
||||
delete_pid_entry(os_ind, info->pid);
|
||||
kfree(param);
|
||||
}
|
||||
|
||||
@ -861,7 +861,7 @@ int mcexec_open_exec(ihk_os_t os, char * __user filename)
|
||||
struct mckernel_exec_file *mcef_iter;
|
||||
int retval;
|
||||
int os_ind = ihk_host_os_get_index(os);
|
||||
char *proc_name, *pathbuf, *fullpath;
|
||||
char *pathbuf, *fullpath;
|
||||
|
||||
if (os_ind < 0) {
|
||||
return EINVAL;
|
||||
@ -872,12 +872,6 @@ int mcexec_open_exec(ihk_os_t os, char * __user filename)
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
proc_name = kmalloc(PATH_MAX, GFP_TEMPORARY);
|
||||
if (!proc_name) {
|
||||
retval = ENOMEM;
|
||||
goto out_error_free_path;
|
||||
}
|
||||
|
||||
file = open_exec(filename);
|
||||
retval = PTR_ERR(file);
|
||||
if (IS_ERR(file)) {
|
||||
@ -896,8 +890,6 @@ int mcexec_open_exec(ihk_os_t os, char * __user filename)
|
||||
goto out_put_file;
|
||||
}
|
||||
|
||||
snprintf(proc_name, 1024, "mcos%d/%d/exe", os_ind, current->tgid);
|
||||
|
||||
spin_lock_irq(&mckernel_exec_file_lock);
|
||||
/* Find previous file (if exists) and drop it */
|
||||
list_for_each_entry(mcef_iter, &mckernel_exec_files, list) {
|
||||
@ -906,9 +898,6 @@ int mcexec_open_exec(ihk_os_t os, char * __user filename)
|
||||
fput(mcef_iter->fp);
|
||||
list_del(&mcef_iter->list);
|
||||
kfree(mcef_iter);
|
||||
/* Drop old /proc/self/exe */
|
||||
procfs_delete_entry(os, os_ind, proc_name);
|
||||
dprintk("%d open_exec dropped previous executable \n", (int)current->tgid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -920,15 +909,12 @@ int mcexec_open_exec(ihk_os_t os, char * __user filename)
|
||||
list_add_tail(&mcef->list, &mckernel_exec_files);
|
||||
|
||||
/* Create /proc/self/exe entry */
|
||||
if (procfs_create_entry(os, 0, os_ind, current->tgid, proc_name,
|
||||
S_IFLNK, fullpath) != 0) {
|
||||
printk("ERROR: could not create a procfs entry for %s.\n", proc_name);
|
||||
}
|
||||
add_pid_entry(os_ind, current->tgid);
|
||||
proc_exe_link(os_ind, current->tgid, fullpath);
|
||||
spin_unlock(&mckernel_exec_file_lock);
|
||||
|
||||
dprintk("%d open_exec and holding file: %s\n", (int)current->tgid, filename);
|
||||
|
||||
kfree(proc_name);
|
||||
kfree(pathbuf);
|
||||
|
||||
return 0;
|
||||
@ -937,9 +923,6 @@ out_put_file:
|
||||
fput(file);
|
||||
|
||||
out_error_free:
|
||||
kfree(proc_name);
|
||||
|
||||
out_error_free_path:
|
||||
kfree(pathbuf);
|
||||
return -retval;
|
||||
}
|
||||
@ -950,7 +933,6 @@ int mcexec_close_exec(ihk_os_t os)
|
||||
struct mckernel_exec_file *mcef = NULL;
|
||||
int found = 0;
|
||||
int os_ind = ihk_host_os_get_index(os);
|
||||
char proc_name[1024];
|
||||
|
||||
if (os_ind < 0) {
|
||||
return EINVAL;
|
||||
@ -969,14 +951,6 @@ int mcexec_close_exec(ihk_os_t os)
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove /proc/self/exe and /proc/self directory
|
||||
* TODO: instead of removing directory explicitly, detect in procfs_delete_entry()
|
||||
* when a directory becomes empty and remove it automatically */
|
||||
snprintf(proc_name, 1024, "mcos%d/%d/exe", os_ind, current->tgid);
|
||||
procfs_delete_entry(os, os_ind, proc_name);
|
||||
snprintf(proc_name, 1024, "mcos%d/%d", os_ind, current->tgid);
|
||||
procfs_delete_entry(os, os_ind, proc_name);
|
||||
|
||||
spin_unlock(&mckernel_exec_file_lock);
|
||||
|
||||
return (found ? 0 : EINVAL);
|
||||
|
||||
@ -82,6 +82,12 @@ static struct ihk_os_user_call mcctrl_uc[OS_MAX_MINOR];
|
||||
|
||||
static ihk_os_t os[OS_MAX_MINOR];
|
||||
|
||||
ihk_os_t
|
||||
osnum_to_os(int n)
|
||||
{
|
||||
return os[n];
|
||||
}
|
||||
|
||||
static int __init mcctrl_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -41,9 +41,6 @@
|
||||
void mcexec_prepare_ack(ihk_os_t os, unsigned long arg, int err);
|
||||
static void mcctrl_ikc_init(ihk_os_t os, int cpu, unsigned long rphys, struct ihk_ikc_channel_desc *c);
|
||||
int mcexec_syscall(struct mcctrl_channel *c, int pid, unsigned long arg);
|
||||
void procfs_create(void *__os, int ref, int osnum, int pid, unsigned long arg);
|
||||
void procfs_delete(void *__os, int osnum, unsigned long arg);
|
||||
void procfs_answer(unsigned long arg, int err);
|
||||
void sig_done(unsigned long arg, int err);
|
||||
|
||||
static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
|
||||
@ -69,14 +66,6 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
|
||||
mcexec_syscall(usrdata->channels + pisp->ref, pisp->pid, pisp->arg);
|
||||
break;
|
||||
|
||||
case SCD_MSG_PROCFS_CREATE:
|
||||
procfs_create(__os, pisp->ref, pisp->osnum, pisp->pid, pisp->arg);
|
||||
break;
|
||||
|
||||
case SCD_MSG_PROCFS_DELETE:
|
||||
procfs_delete(__os, pisp->osnum, pisp->arg);
|
||||
break;
|
||||
|
||||
case SCD_MSG_PROCFS_ANSWER:
|
||||
procfs_answer(pisp->arg, pisp->err);
|
||||
break;
|
||||
@ -98,6 +87,14 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
|
||||
pisp->sysfs_arg1, pisp->sysfs_arg2);
|
||||
break;
|
||||
|
||||
case SCD_MSG_PROCFS_TID_CREATE:
|
||||
add_tid_entry(ihk_host_os_get_index(__os), pisp->pid, pisp->arg);
|
||||
break;
|
||||
|
||||
case SCD_MSG_PROCFS_TID_DELETE:
|
||||
delete_tid_entry(ihk_host_os_get_index(__os), pisp->pid, pisp->arg);
|
||||
break;
|
||||
|
||||
default:
|
||||
printk(KERN_ERR "mcctrl:syscall_packet_handler:"
|
||||
"unknown message (%d.%d.%d.%d.%d.%#lx)\n",
|
||||
|
||||
@ -81,6 +81,8 @@
|
||||
#define SCD_MSG_SYSFS_RESP_SETUP 0x41
|
||||
/* #define SCD_MSG_SYSFS_REQ_CLEANUP 0x42 */
|
||||
/* #define SCD_MSG_SYSFS_RESP_CLEANUP 0x43 */
|
||||
#define SCD_MSG_PROCFS_TID_CREATE 0x44
|
||||
#define SCD_MSG_PROCFS_TID_DELETE 0x45
|
||||
|
||||
#define DMA_PIN_SHIFT 21
|
||||
|
||||
@ -226,6 +228,8 @@ int mcctrl_ikc_is_valid_thread(ihk_os_t os, int cpu);
|
||||
int reserve_user_space(struct mcctrl_usrdata *usrdata, unsigned long *startp,
|
||||
unsigned long *endp);
|
||||
|
||||
ihk_os_t osnum_to_os(int n);
|
||||
|
||||
/* syscall.c */
|
||||
int init_peer_channel_registry(struct mcctrl_usrdata *ud);
|
||||
void destroy_peer_channel_registry(struct mcctrl_usrdata *ud);
|
||||
@ -244,6 +248,7 @@ struct procfs_read {
|
||||
int ret; /* read bytes (answer) */
|
||||
int status; /* non-zero if done (answer) */
|
||||
int newcpu; /* migrated new cpu (answer) */
|
||||
int readwrite; /* 0:read, 1:write */
|
||||
char fname[PROCFS_NAME_MAX]; /* procfs filename (request) */
|
||||
};
|
||||
|
||||
@ -253,6 +258,15 @@ struct procfs_file {
|
||||
char fname[PROCFS_NAME_MAX]; /* procfs filename (request) */
|
||||
};
|
||||
|
||||
void procfs_answer(unsigned int arg, int err);
|
||||
void add_tid_entry(int osnum, int pid, int tid);
|
||||
void add_pid_entry(int osnum, int pid);
|
||||
void delete_tid_entry(int osnum, int pid, int tid);
|
||||
void delete_pid_entry(int osnum, int pid);
|
||||
void proc_exe_link(int osnum, int pid, const char *path);
|
||||
void procfs_init(int osnum);
|
||||
void procfs_exit(int osnum);
|
||||
|
||||
/* sysfs_files.c */
|
||||
void setup_sysfs_files(ihk_os_t os);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user