Re: Fwd: RE: patch for migshm(for 2.4.26-om1)
Ratna Manoj Bolla <[email protected]>
| Newsgroups | gmane.linux.cluster.openmosix.devel |
|---|---|
| Message-ID | <[email protected]> |
This patch does not depend on the kernel semaphores operations. There is no need for the applications to synchronize their shared data with kernel semaphores. -Manoj. On Thu, 11 May 2006, Bruce Knox wrote: >>>> "Jason Coutu" <[email protected]> 5/10/2006 10:29 PM >>> > A quick code review of this patch, every thing looks good. There are > some > nice new feature in here, however none of the issues that exist in the > migshm patch have been addressed. > > The semaphores are still backwards. The synchronization of the shared > memory > based on kernel semaphores only resynchronizes the data on a negative > value > for the semaphore increment. > > The migration of shared memory will never work with properly written > software until this is fixed. > > Jason Coutu > > -----Original Message----- > From: openmosix-devel-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > [mailto:openmosix-devel-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org] On Behalf Of > Ratna > Manoj Bolla > Sent: May 8, 2006 7:41 AM > To: openmosix-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > Cc: [email protected] > Subject: [Openmosix-devel] patch for migshm(for 2.4.26-om1) > > > > Below is the patch for MigShm. > > - No STAY_FOR_MONKEY flag > - implemented Distributed shared memory. > - MAP_SHARED mappings can now migrate. > > > -more debugging has to be done. > plz report bugs and suggestions. > > > below is my one of the test program followed by patch. > > #include<stdio.h> > #include<sys/mman.h> > #include <sys/types.h> > #include <sys/stat.h> > #include <fcntl.h> > #include <unistd.h> > char *pid2proc_path(int); > char path[50]; > int b[80]; > main() { > int fd = open("om_file",O_RDWR); > char *a = mmap(0,4096*15,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0); > int i = 0; > unsigned long k=0; > char *b =a;// > mmap(0,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE,fd,0); > fork(); > fork(); > fork(); > fork(); > while(k++ <= 0xffffff00); k=0; > while(k++ <= 0xffffff00); k=0; > // while(k++ <= 0xffffff00); k=0; > // while(k++ <= 0xffffff00); k=0; > // while(k++ <= 0xffffff00); k=0; > > char ch = 'A'; > while(1) { > i++; > if(i== 15000) > break; > // sleep(1); > if(ch == 'Z') > ch = 'A'; > *a = ch; > // sleep(1); > printf("p:%d-%c\n",i,*a); > a+=3; > ch++; > } > } > > Patch: > > diff -Naur linux-2.4.26-om1/fs/file_table.c > linux-2.4.26-om1-o/fs/file_table.c > --- linux-2.4.26-om1/fs/file_table.c 2006-05-08 15:01:47.000000000 > +0530 > +++ linux-2.4.26-om1-o/fs/file_table.c 2006-05-07 17:56:02.000000000 > +0530 > @@ -13,6 +13,7 @@ > #include <linux/smp_lock.h> > #include <linux/iobuf.h> > > +#include <hpc/mig_shm.h> > /* sysctl tunables... */ > struct files_stat_struct files_stat = {0, 0, NR_FILE}; > > @@ -104,8 +105,12 @@ > struct inode * inode = dentry->d_inode; > > if (atomic_dec_and_test(&file->f_count)) { > +#ifdef CONFIG_MOSIX + if(current->mosix.dflags & DREMOTE) + > shm_send_message(current->mosix.deppe,(struct shm_page > *)(home_file(file)),NULL,PUT_FILE); > +#endif /* CONFIG_MOSIX */ > locks_remove_flock(file); > - > + > if (file->f_iobuf) > free_kiovec(1, &file->f_iobuf); > > diff -Naur linux-2.4.26-om1/fs/read_write.c > linux-2.4.26-om1-o/fs/read_write.c > --- linux-2.4.26-om1/fs/read_write.c 2006-05-08 15:01:50.000000000 > +0530 > +++ linux-2.4.26-om1-o/fs/read_write.c 2006-05-07 17:56:02.000000000 > +0530 > @@ -169,10 +169,26 @@ > } > #endif > > +#ifdef CONFIG_MOSIX > + > +extern void > +put_pages(struct address_space *mapping,loff_t offset,size_t count,int > > writer,unsigned long error); > + > +extern unsigned long > +get_pages(struct address_space *mapping,loff_t offset,size_t count,int > > writer); > + > +#endif /* CONFIG_MOSIX */ > + > + > + > asmlinkage ssize_t sys_read(unsigned int fd, char * buf, size_t > count) > { > ssize_t ret; > struct file * file; > +#ifdef CONFIG_MOSIX > + unsigned long error=0; > + loff_t offset; > +#endif /* CONFIG_MOSIX */ > > #ifdef CONFIG_MOSIX_DFSA > dfsa_syscall_on_file(fd, 1); > @@ -186,10 +202,23 @@ > if (!ret) { > ssize_t (*read)(struct file *, char *, > size_t, > loff_t *); > ret = -EINVAL; > - if (file->f_op && (read = > file->f_op->read) > != > NULL) > - ret = read(file, buf, count, > &file->f_pos); > + if (file->f_op && (read = > file->f_op->read) > != > NULL) +#ifdef CONFIG_MOSIX > + { > + error = > get_pages(file->f_dentry->d_inode->i_mapping,(offset = > file->f_pos),count,0); > + if(!error) > +#endif /* CONFIG_MOSIX */ > + ret > = > read(file, buf, count, &file->f_pos); +#ifdef CONFIG_MOSIX + > put_pages(file->f_dentry->d_inode->i_mapping,offset,count,0,error); + > } > +#endif /* CONFIG_MOSIX */ > } > } > + > + if(error) > + ret = -1; > + > if (ret > 0) > dnotify_parent(file->f_dentry, DN_ACCESS); > fput(file); > @@ -201,6 +230,10 @@ > { > ssize_t ret; > struct file * file; > +#ifdef CONFIG_MOSIX > + unsigned long error=0; > + loff_t offset; > +#endif /* CONFIG_MOSIX */ > > #ifdef CONFIG_MOSIX_DFSA > dfsa_syscall_on_file(fd, 1); > @@ -215,10 +248,23 @@ > if (!ret) { > ssize_t (*write)(struct file *, const > char > *, > size_t, loff_t *); > ret = -EINVAL; > - if (file->f_op && (write = > file->f_op->write) > != NULL) > - ret = write(file, buf, count, > &file->f_pos); > - } > + if (file->f_op && (write = > file->f_op->write) > != NULL) +#ifdef CONFIG_MOSIX > + { > + error = > get_pages(file->f_dentry->d_inode->i_mapping,(offset = > file->f_pos),count,1); > + + if(!error) > +#endif /* CONFIG_MOSIX */ > + ret = write(file, buf, > count, > &file->f_pos); > +#ifdef CONFIG_MOSIX + > put_pages(file->f_dentry->d_inode->i_mapping,offset,count,1,error); > + } > +#endif /* CONFIG_MOSIX */ + } > } > + > + if(error) > + ret = -1; > if (ret > 0) > dnotify_parent(file->f_dentry, DN_MODIFY); > fput(file); > diff -Naur linux-2.4.26-om1/hpc/comm.c linux-2.4.26-om1-o/hpc/comm.c > --- linux-2.4.26-om1/hpc/comm.c 2006-05-08 15:02:17.000000000 > +0530 > +++ linux-2.4.26-om1-o/hpc/comm.c 2006-05-07 17:56:02.000000000 > +0530 > @@ -31,7 +31,6 @@ > > #define MIG_DAEMON_PORT 0x3412 > #define INFO_DAEMON_PORT 0x3415 > - > /* > * mosix specific data per contact > */ > @@ -65,7 +64,7 @@ > #define COMM_SOCKET_BUFFER 131072 > > #define COMM_REMOTE_TIMO ((unsigned long) 200*HZ) /* > changed > form > 300 */ > -#define COMM_CONNECT_TIMO ((unsigned long) 4*HZ) /* changed from > 5 */ > +#define COMM_CONNECT_TIMO ((unsigned long) 10*HZ) /* changed from > 5 */ > #define COMM_RECONN_TIMO ((unsigned long) 10*HZ) > > #ifdef CONFIG_MOSIX_DFSA > @@ -171,7 +170,6 @@ > static int comm_waitaccept(void); > static int comm_poll(int, int, unsigned long); > static void comm_data_ready(struct sock *, int); > -static int comm_getname(struct socket *, struct sockaddr *); > static void comm_shutdown(mosix_link *); > > static inline struct socket *comm_set_address(int, struct sockaddr > *, > int); > @@ -315,8 +313,6 @@ > him = ((int *) ptr)[0]; > me = ((int *) ptr)[1]; > > - if (him & 0x80000000) > - rinode_flush_files(him & ~0x80000000); > if (comm_getpeer(current->mosix.contact) == (him & 0x7fffffff) > && PE == me) > ret = 2 * sizeof (int); > @@ -367,6 +363,8 @@ > */ > > switch (mos) { > + case MIGSHM_COMM: + case COMM_MIGSHM: > case COMM_INFO: > sock->sk->data_ready = comm_data_ready; > break; > @@ -493,6 +491,8 @@ > case COMM_LOOSE: > bind = 0; > /* fall through */ > + case MIGSHM_COMM: > + case COMM_MIGSHM: > case COMM_INFO: > listen = 0; > /* fall through */ > @@ -763,7 +763,7 @@ > mosix_panic("comm_free() # 1"); > > out: > - > + return; > } > > /* > @@ -1564,6 +1564,7 @@ > return (error); > } > > +unsigned long AVG_TRIES = 2; > /* > * comm_recvfrom() - receive a datagram from someone > * NOTE NOTE NOTE: the timeout is in microseconds -- NOT ticks! > @@ -1580,7 +1581,14 @@ > int error; > int nrecv = len, msgflg = 0; > DECLARE_WAITQUEUE(wait, current); > + unsigned long tries = LONG_MAX; > + unsigned long for_avg = 0; > > + if (timo == GTIME_OUT) > + tries = 3 * AVG_TRIES-1; > + else if (timo == INT_TIME_OUT) > + tries = 4 * AVG_TRIES * NPE - 1; > + else > if (timo) { > #if MILLION % HZ > timo = timo * HZ / MILLION; > @@ -1591,13 +1599,13 @@ > oldfs = get_fs(); > set_fs(KERNEL_DS); > > - if (timo) > - msgflg |= MSG_DONTWAIT; > + if(timo == GTIME_OUT || timo == INT_TIME_OUT || !timo) > + timo = MAX_SCHEDULE_TIMEOUT; > else > - timo = MAX_SCHEDULE_TIMEOUT; > + msgflg |= MSG_DONTWAIT; > > add_wait_queue(mlink->sock->sk->sleep, &wait); > - while (1) { > + while (tries) { > set_current_state(msgflg ? TASK_UNINTERRUPTIBLE : > TASK_INTERRUPTIBLE); > > @@ -1622,6 +1630,10 @@ > error = -EINTR; > break; > } > + if(tries != LONG_MAX) { > + tries--; > + for_avg++; > + } > } > remove_wait_queue(mlink->sock->sk->sleep, &wait); > set_current_state(TASK_RUNNING); > @@ -1629,6 +1641,12 @@ > > if (msg.msg_flags & MSG_TRUNC) { > error = -EDIST; > + } else if(!tries) > + error = -ETIME; > + else if (tries != LONG_MAX ) { > + AVG_TRIES = (AVG_TRIES + for_avg) / 2; > + if(AVG_TRIES < 2) > + AVG_TRIES = 2; > } > > return (error); > @@ -1681,7 +1699,7 @@ > /* > * comm_getname: fill in our name > */ > -static int > +int > comm_getname(struct socket *sock, struct sockaddr *saddr) > { > switch (comm_type) { > @@ -1741,6 +1759,7 @@ > case COMM_TOADDR: > /* address was set by the caller */ > break; > + case COMM_MIGSHM: > case COMM_INFO: > proto = IPPROTO_UDP; > type = SOCK_DGRAM; > @@ -1751,10 +1770,17 @@ > sa->sin_addr.s_addr = INADDR_ANY; > if (mos == COMM_MIGD) > sa->sin_port = MIG_DAEMON_PORT; > - else > + else if(mos == COMM_INFO) > sa->sin_port = INFO_DAEMON_PORT; > + else if(mos == COMM_MIGSHM) > + sa->sin_port = MIGSHM_DEAMON_PORT; > break; > case COMM_ACCEPT: > + case MIGSHM_COMM: > + if(mos == MIGSHM_COMM) { > + type = SOCK_DGRAM; > + proto = IPPROTO_UDP; > + } > memset((void *) sa, 0, sizeof (struct sockaddr_in)); > sa->sin_family = AF_INET; > sa->sin_addr.s_addr = INADDR_ANY; > diff -Naur linux-2.4.26-om1/hpc/deputy.c > linux-2.4.26-om1-o/hpc/deputy.c > --- linux-2.4.26-om1/hpc/deputy.c 2006-05-08 15:02:17.000000000 > +0530 > +++ linux-2.4.26-om1-o/hpc/deputy.c 2006-05-07 17:56:02.000000000 > +0530 > @@ -24,6 +24,9 @@ > #include <asm/mmu_context.h> > #include <linux/smp_lock.h> > #include <linux/highmem.h> > +#include <linux/pagemap.h> > +#include <hpc/mig_shm.h> > +#include <hpc/shm_pagemap.h> > #ifdef CONFIG_MOSIX_DFSA > #include <hpc/dfsa.h> > #endif /* CONFIG_MOSIX_DFSA */ > @@ -343,27 +346,30 @@ > deputy_handle_interim_request(int type, void *head, int hlen) > { > switch (type) { > - case REM_NOTHING: > - comm_free(head); > - return (comm_send(REM_NOTHING | REPLY, NULL, 0, NULL, > 0, > 0)); > - case REM_PAGE: > - return (deputy_bring_page((struct bring_page_h *) > head)); > - case REM_GETTSC: > - return (deputy_tsc()); > - case REM_MORESTRINGS: > - return (deputy_more_strings > - ((struct execve_more_strings_h *) head)); > - case REM_BRING_ME_REGS: > - return (deputy_bring_me_regs((unsigned long *) head)); > - case REM_GETALOAD: > - return (send_local_aload(REM_GETALOAD | REPLY)); > - default: > - printk("Process %s, uid=%d, received an unexpected " > - "urgent request\n" "(type 0x%x) from the " > - "remote site where it was running\n", > - desc_mostask(NULL), current->uid, type); > - comm_free(head); > - return (-EDIST); > + > + case REM_UPGRADE: > + return(deputy_upgrade((struct upgrade_h > *)head)); > + case REM_NOTHING: > + comm_free(head); > + return (comm_send(REM_NOTHING | REPLY, NULL, 0, > NULL, > 0, 0)); > + case REM_PAGE: > + return (deputy_bring_page((struct bring_page_h > *) > head)); > + case REM_GETTSC: > + return (deputy_tsc()); > + case REM_MORESTRINGS: > + return (deputy_more_strings > + ((struct execve_more_strings_h *) > head)); > + case REM_BRING_ME_REGS: > + return (deputy_bring_me_regs((unsigned long *) > head)); > + case REM_GETALOAD: > + return (send_local_aload(REM_GETALOAD | > REPLY)); > + default: > + printk("Process %s, uid=%d, received an > unexpected " > + "urgent request\n" "(type 0x%x) from the > " > + "remote site where it was running\n", > + desc_mostask(NULL), current->uid, type); > + comm_free(head); > + return (-EDIST); > } > } > > @@ -431,29 +437,29 @@ > > unsigned long > mosix_deputy_mmap(struct file *fp, unsigned long addr, int fixed, > - unsigned long len, unsigned long flags, unsigned long > off, > - off_t isize, nopage_t nopage) > + unsigned long len, unsigned long flags, unsigned long > off, > + off_t isize, nopage_t nopage) > { > - struct mmap_parameters_h mp; > - int error; > - unsigned long result; > - > - mp.addr = addr; > - mp.fixed = fixed; > - mp.len = len; > - mp.flags = flags; > - mp.pgoff = off; > - mp.origin = PE; > - if ((mp.fp = fp)) { > - mp.dp = fp->f_dentry; > - mp.uniq = mp.fp->f_dentry->d_inode->i_unique; > - mp.isize = mp.fp->f_dentry->d_inode->i_size; > - } > - mp.nopage = nopage; > - if ((error = deputy_request(DEP_MMAP, &mp, sizeof (mp), NULL, 0, > 0, > - (void **) &result, -sizeof > (result)))) > - return (error); > - return (result); > + struct mmap_parameters_h mp; > + int error; > + unsigned long result; > + > + mp.addr = addr; > + mp.fixed = fixed; > + mp.len = len; > + mp.flags = flags; > + mp.pgoff = off; > + mp.origin = PE; > + if ((mp.fp = fp)) { > + mp.dp = fp->f_dentry; > + mp.uniq = mp.fp->f_dentry->d_inode->i_unique; > + mp.isize = mp.fp->f_dentry->d_inode->i_size; > + } > + mp.nopage = nopage; > + if ((error = deputy_request(DEP_MMAP, &mp, sizeof (mp), NULL, 0, > 0, > + (void **) &result, -sizeof > (result)))) > + return (error); > + return (result); > } > > long > @@ -519,9 +525,6 @@ > case FATAL_SIGSEGV: > force_sig(SIGSEGV, current); > break; > - case REMOTE_FILE_RELEASED: > - mosix_rebuild_file_list(); > - break; > case SIGSEGV: > case SIGKILL: > case SIGVTALRM: > @@ -910,31 +913,118 @@ > } > > int > +deputy_upgrade(struct upgrade_h *u) > +{ > + struct shm_page *shm_page = u->rem_shm_page_addr; > + struct page *page = NULL; > + struct shm_page_ret_h r; > + int err; > + > + > + spin_lock(&shm_page->shm_lock); > + if((shm_page->state & PERM_ERR) || (shm_page->state & > UPGRADE_ERR)) > + r.ret = 2; > + else > + if(((shm_page->state & STATE_MASK) == SHARED) && > !(shm_page->state & > > DROPPING) && (!shm_page->readers)) { > + shm_page->state &= ~SHARED; > + shm_page->state |= BUSY_EXCLUSIVE; > + > + spin_unlock(&shm_page->shm_lock); > + page = > find_get_page(shm_page->mapping,shm_page->index); > + > + if(page) { > + invalidate(shm_page,page,1); > + page_cache_release(page); > + } > + > + > + shm_send_message(0,shm_page,NULL,DROP_NEXTPREV); > + > + shm_page->next = shm_page->prev = PE; > + shm_page->next_addr = shm_page->prev_addr = shm_page; > + > + spin_lock(&shm_page->shm_lock); > + shm_page->owner = current->mosix.whereami; > + shm_page->rem_shm_page_addr = u->shm_page; > + + shm_page->state &= ~BUSY_EXCLUSIVE; > + shm_page->state |= EXCLUSIVE; > + r.ret = 0; > + } else > + r.ret = 1; > + > + spin_unlock(&shm_page->shm_lock); > + + comm_free(u); > + cli(); > + r.deputytime = current->mosix.deputytime; > + current->mosix.deputytime = 0; > + sti(); > + err = deputy_reply(REM_UPGRADE, &r, sizeof (r),NULL, 0, 0,2); > + > + return err; > +} +int > deputy_bring_page(struct bring_page_h *b) > { > struct file *fp = b->fp; > struct vm_area_struct v; > - struct page_ret_h r; > + struct shm_page_ret_h r; > int err; > int address = b->offset; > struct page *page; > struct task_struct *p = current; > + struct shm_page *shm_page=NULL; > + > + struct vm_operations_struct file_vm_ops = { > + nopage: b->nopage, > + }; > + > > v.vm_start = v.vm_pgoff = 0; > v.vm_end = address + PAGE_SIZE; > v.vm_mm = p->mm; /* (eg. NULL) */ > v.vm_file = fp; > - v.vm_flags = 0; /* anything really, but VM_SHARED */ > + v.vm_ops = &file_vm_ops; > + + v.vm_flags = (unsigned long)b->rem_shm_page_addr; > > deeper_sleep(); > - page = b->nopage(&v, address, 0); > + > + page = get_nopage(&v, address, &shm_page, (b->access & > WITH_WRITE_ACC) > ? 1 : 0); > + > lighter_sleep(); > if (page == NOPAGE_OOM) { > r.ret = -ENOMEM; > - page = 0; > - } else > - r.ret = page ? 0 : -EFBIG; > - comm_free(b); > + page = NULL; > + } else if(page == PAGE_BUSY) { > + page = NULL; > + r.ret = -EBUSY; > + } > + else + r.ret = (page ? 0 : -EINVAL); > + > + if(page && (b->access & (WITH_WRITE_ACC|WITH_READ_ACC))) { > + > + r.rem_shm_page_addr = shm_page; > + > + if(b->access & WITH_WRITE_ACC ) { > + if((!(v.vm_start)) && (!(v.vm_end))) { > + r.next = 0; > + r.next_addr = NULL; > + } else { > + r.next_addr = (struct shm_page > *)v.vm_start; > + r.next = v.vm_end; > + } > + } else { > + r.next = PE; > + r.next_addr = shm_page; > + r.prev = v.vm_end; > + r.prev_addr = (struct shm_page > *)(v.vm_start); > + } > + > + } > + > cli(); > r.deputytime = p->mosix.deputytime; > p->mosix.deputytime = 0; > @@ -942,13 +1032,77 @@ > err = deputy_reply(REM_PAGE, &r, sizeof (r), > page ? kmap(page) : NULL, page ? PAGE_SIZE : > 0, > 0, > 2); > - if (page) { > - kunmap(page); > - __free_page(page); > + > + if(shm_page) { > + if(err) { > + if(b->access & WITH_WRITE_ACC) { > + spin_lock(&shm_page->shm_lock); > + shm_page->state &= ~BUSY_EXCLUSIVE; + > if(!(v.vm_start) && !(v.vm_end)) { > + shm_page->state |= EXCLUSIVE; > + shm_page->owner = PE; > + shm_page->prev = shm_page->next > = > PE; > + shm_page->next_addr = > shm_page->prev_addr = shm_page; > + spin_unlock(&shm_page->shm_lock); > + shm_pagecache_release(shm_page); > + } else { > + shm_page->state |= > (SHARED|DROPPING); > + spin_unlock(&shm_page->shm_lock); > + shm_page->next = PE; > + shm_page->next_addr = shm_page; > + > if(shm_send_message(shm_page->prev,shm_page,NULL,DROP_NEXT)) { > + printk(KERN_ERR "reader > loop > > broken because of %d Reboot all\n",shm_page->prev); + > shm_page->owner = shm_page->next = shm_page->prev = PE; > + shm_page->next_addr = > > shm_page->prev_addr = shm_page; > + > spin_lock(&shm_page->shm_lock); > + shm_page->state &= > ~(SHARED|DROPPING); > + shm_page->state |= > EXCLUSIVE; > + > spin_unlock(&shm_page->shm_lock); > + > shm_pagecache_release(shm_page); > + goto out; > + } > + shm_page->next = v.vm_end; > + shm_page->next_addr = (struct > shm_page > *)v.vm_start; > + shm_page->state &= ~DROPPING; > + } + } else { > + spin_lock(&shm_page->shm_lock); > + if(shm_page->next == > current->mosix.whereami) { > + shm_page->prev = shm_page->next > = > PE; > + shm_page->prev_addr = > shm_page->next_addr = shm_page; > + } else { > + shm_page->prev = v.vm_end; > + shm_page->prev_addr = (struct > shm_page > *)(v.vm_start); > + } > + shm_page->state &= ~DROPPING; > + spin_unlock(&shm_page->shm_lock); > + } > + } else { > + if(b->access & WITH_WRITE_ACC) { > + spin_lock(&shm_page->shm_lock); > + shm_page->state &= ~BUSY_EXCLUSIVE; > + shm_page->state |= EXCLUSIVE; > + shm_page->owner = > current->mosix.whereami; > + shm_page->rem_shm_page_addr = > b->rem_shm_page_addr; > + shm_page->prev = shm_page->next > = > PE; > + shm_page->next_addr = > shm_page->prev_addr = shm_page; + > spin_unlock(&shm_page->shm_lock); > + } + } + out: > + shm_pagecache_release(shm_page); > } > + + comm_free(b); > + if (page) { > + kunmap(page); > + __free_page(page); > + } > return (err); > } > > + > + > int > deputy_tsc(void) > { > @@ -1143,8 +1297,7 @@ > if (deputy_request(DEP_EXEC_MMAP, NULL, 0, NULL, 0, 0, > (void **) &r, -sizeof (r))) > return (-ENOMEM); > - if (!r) > - mosix_clear_all_held_files(current); > + > return (r); > } > > diff -Naur linux-2.4.26-om1/hpc/init.c linux-2.4.26-om1-o/hpc/init.c > --- linux-2.4.26-om1/hpc/init.c 2006-05-08 15:02:17.000000000 > +0530 > +++ linux-2.4.26-om1-o/hpc/init.c 2006-05-07 17:56:02.000000000 > +0530 > @@ -28,6 +28,30 @@ > void > init_mosix(void) > { > + extern struct super_block bad_super_block; > + static struct super_operations empty_sops = {}; > + struct super_block *s = &bad_super_block; > + if (s) { > + memset(s, 0, sizeof(struct super_block)); > + INIT_LIST_HEAD(&s->s_dirty); > + INIT_LIST_HEAD(&s->s_locked_inodes); > + INIT_LIST_HEAD(&s->s_files); > + INIT_LIST_HEAD(&s->s_instances); > + init_rwsem(&s->s_umount); > + sema_init(&s->s_lock, 1); > + down_write(&s->s_umount); > + s->s_count = S_BIAS; > + atomic_set(&s->s_active, 1); > + sema_init(&s->s_vfs_rename_sem,1); > + sema_init(&s->s_nfsd_free_path_sem,1); > + sema_init(&s->s_dquot.dqio_sem, 1); > + sema_init(&s->s_dquot.dqoff_sem, 1); > + s->s_maxbytes = MAX_NON_LFS; > + s->s_op = &empty_sops; > + s->dq_op = NULL; > + s->s_qcop = NULL; > + } > + > extern int x86_udelay_tsc; > cpuspeed = ((int64_t) loops_per_jiffy) * STD_SPD / STD_LOOPS; > if (!x86_udelay_tsc) > @@ -43,4 +67,5 @@ > mosinfo_update_gateways(); > kernel_thread(mosix_info_daemon, NULL, 0); > kernel_thread(mosix_mem_daemon, NULL, 0); > + kernel_thread(mosix_migshm_daemon,NULL,0); > } > diff -Naur linux-2.4.26-om1/hpc/kernel.c > linux-2.4.26-om1-o/hpc/kernel.c > --- linux-2.4.26-om1/hpc/kernel.c 2006-05-08 15:02:17.000000000 > +0530 > +++ linux-2.4.26-om1-o/hpc/kernel.c 2006-05-07 17:56:02.000000000 > +0530 > @@ -555,8 +555,6 @@ > m->stay |= DSTAY_SYSTEM; > else > m->stay &= ~DSTAY_SYSTEM; > - m->held_files = NULL; > - m->held_allocated = 0; > rwlock_init(&m->state_lock); > m->contact = 0; > m->ucache = NULL; > @@ -597,7 +595,7 @@ > init_waitqueue_head(mos_to_waitp(m)); > m->mosix_log = NULL; > m->dirty_bits = 0; > - return (fork_mosix_remote_files(p)); > + return 0; > } > > void > @@ -729,63 +727,6 @@ > m->pass_regs = 0; > } > > -void > -mosix_bring_monkey_users_back(struct inode *ip) > -{ > - struct task_struct *p, *found, *me = current; > - DECLARE_WAITQUEUE(wait, me); > - > - while (1) { > - found = NULL; > - read_lock(&tasklist_lock); > - for_each_task(p) > - if (p != me && !(p->mosix.dflags & DREMOTE) && > - task_maps_ip(p, ip)) { > - task_lock(p); > - p->mosix.stay |= DSTAY_FOR_MONKEY; > - task_unlock(p); > - if (p->mosix.dflags & DDEPUTY) { > - tell_process(p, DREQ_HOMEWAKE); > - wake_up_mosix(p); > - if (!found) { > - found = p; > - get_task_struct(p); > - } > - } > - } > - if (!found) { > - read_unlock(&tasklist_lock); > - /* VMODIFIED is needed against a > nearly-impossible > - * REMOTE race, when ip is modified, then > unmonkied > - * and a process migrates there even before the > - * previous completed exiting: > - */ > - OPENMOSIX_VMODIFIED(ip); > - return; > - } > - set_current_state(TASK_UNINTERRUPTIBLE); > - add_wait_queue(mos_to_waitp(&found->mosix), &wait); > - read_unlock(&tasklist_lock); > - schedule(); > - remove_wait_queue(mos_to_waitp(&found->mosix), &wait); > - set_current_state(TASK_RUNNING); > - free_task_struct(found); > - } > -} > - > -void > -mosix_no_longer_monkey(struct inode *ip) > -{ > - struct task_struct *p; > - > - read_lock(&tasklist_lock); > - for_each_task(p) > - if (!(p->mosix.dflags & (DREMOTE | DDEPUTY)) && > task_maps_ip(p, > ip)) { > - tell_process(p, DREQ_CHECKSTAY); > - wake_up_mosix(p); > - } > - read_unlock(&tasklist_lock); > -} > > /* > * caller is responsible to > down_[read|write](¤t->mm->mmap_sem) > @@ -824,8 +765,6 @@ > > ip = mpnt->vm_file->f_dentry->d_inode; > mode = ip->i_mode; > - if (ip->i_mapping->i_mmap_shared) > - stay |= DSTAY_FOR_MONKEY; > if (S_ISCHR(mode) || S_ISFIFO(mode) || > S_ISSOCK(mode)) > stay |= DSTAY_FOR_DEV; > @@ -917,8 +856,6 @@ > { > if ((p->mosix.dflags & (DPASSING | DREMOTE)) == DPASSING) > return; > - if (p->mosix.held_files) > - mosix_clear_all_held_files(p); > if (!(p->mosix.dflags & DDEPUTY)) > mosix_pre_dropping_mm(p, p->mm); > task_lock(p); > @@ -940,8 +877,6 @@ > p->mosix.stay &= ~(DSTAY_PER_MM | DSTAY_FOR_CLONE); > task_unlock(p); > p->mosix.pages_i_bring = 0; > - if (p->mosix.held_files) > - mosix_clear_all_held_files(p); > } > > int > diff -Naur linux-2.4.26-om1/hpc/Makefile > linux-2.4.26-om1-o/hpc/Makefile > --- linux-2.4.26-om1/hpc/Makefile 2006-05-08 15:02:17.000000000 > +0530 > +++ linux-2.4.26-om1-o/hpc/Makefile 2006-05-07 17:56:02.000000000 > +0530 > @@ -20,7 +20,7 @@ > obj-y := alternate.o auto_syscalls.o balance.o comm.o config.o > decay.o > \ > deputy.o div.o export.o freemem.o init.o info.o kernel.o > load.o > \ > mig.o hpcadmin.o hpcproc.o prequest.o remote.o rinode.o \ > - service.o syscalls.o ucache.o badops.o > + service.o syscalls.o ucache.o badops.o mig_shm.o shm_comm.o > > shm_filemap.o > > obj-$(CONFIG_MOSIX_DFSA) += dfsa.o > > diff -Naur linux-2.4.26-om1/hpc/mig.c linux-2.4.26-om1-o/hpc/mig.c > --- linux-2.4.26-om1/hpc/mig.c 2006-05-08 15:02:17.000000000 +0530 > +++ linux-2.4.26-om1-o/hpc/mig.c 2006-05-07 17:56:02.000000000 > +0530 > @@ -215,7 +215,9 @@ > if (SHOW_MIGRATIONS) > printk("Weeeeeeeee.....\n"); > #endif /* SHOW_MIGRATIONS */ > + > kickstart(); > + > panic("kickstart returned"); > /*NOTREACHED*/ failed: > if (load_came_in) { > @@ -254,7 +256,6 @@ > { > struct task_struct *p = current; > int error; > - > if (!PE) > return (whereto && whereto != GOBACKHOME && > whereto != MUSTGOHOME ? -EDIST : 0); > @@ -278,7 +279,7 @@ > return (0); > } > #endif /* CONFIG_MOSIX_CHEAT_MIGSELF */ > - if (whereto && ((p->mosix.stay & DSTAY) || !mos_to_net(whereto, > 0))) > + if (whereto && ((p->mosix.stay & DSTAY) || !mos_to_net(whereto, > 0))) > return (-EDIST); > > spin_lock_irq(&runqueue_lock); > @@ -477,9 +478,6 @@ > int error; > int omigpages; > > - if (!p->mosix.held_files && (error = > mosix_rebuild_file_list())) > - return (error); > - > lock_mosix(); > write_lock_irq(&tasklist_lock); > p->mosix.remote_caps = current->cap_effective; > @@ -500,7 +498,7 @@ > unlock_mosix(); > p->mosix.deputy_regs = ALL_REGISTERS; > p->mosix.pass_regs = 0; > - > + > if (!(mlink = comm_open(whereto, 0, comm_connect_timo))) { > error = -EDIST; > goto failed; > @@ -591,10 +589,6 @@ > #endif /*SHOW_MIGRATIONS */ > end_coming_in(0); > current->mosix.pages_i_bring = 0; > - if (p->mosix.dflags & DDELAYHELD) { > - p->mosix.dflags &= ~DDELAYHELD; > - mosix_rebuild_file_list(); > - } > return (0); > } > > @@ -715,8 +709,6 @@ > stop_storing_common_ps_info(); > flush_read_cache(); > free_ucache(); > - if (m->stay & DSTAY_FOR_MONKEY) > - mosix_check_for_freedom_to_move(); > } else { > if (m->contact) { > comm_close(m->contact); > @@ -772,6 +764,7 @@ > m.uniq = ip->i_unique; > m.isize = ip->i_size; > m.nopage = vma->vm_ops->nopage; > + > } > } else { > m.fp = NULL; > @@ -962,9 +955,9 @@ > comm_migration_mode(1); > neutralize_my_load(1); /* don't count me: I'm going to > disappear */ > if (mig_send_mm_stats() || mig_send_mm_areas() || > - (credit = mig_send_pages()) < 0 || > - (current->used_math && mig_send_fp()) || > - (current->mm->context.ldt && mig_send_ldt()) || > + (credit = mig_send_pages()) < 0 || > + (current->used_math && mig_send_fp()) || > + (current->mm->context.ldt && mig_send_ldt()) || > mig_send_misc(credit)) { > comm_send(MIG_NOT_COMING, NULL, 0, NULL, 0, 0); > comm_migration_mode(0); > @@ -1000,6 +993,12 @@ > > /* unconvert prot+flags: */ > flags = MAP_FIXED | MAP_PRIVATE; > + > + if(m->flags & VM_SHARED) { > + flags &= ~(MAP_PRIVATE); > + flags|=MAP_SHARED; > + } > + > prot = 0; > if (m->flags & VM_GROWSDOWN) > flags |= MAP_GROWSDOWN; > @@ -1481,7 +1480,6 @@ > if (to > 0) > return (passto(to, 0) ? > (mos_to_net(to, NULL) ? -ENETUNREACH : -ENXIO) : > 0); > - > switch (to) { > case DM_GOBACKHOME: > return (passto(GOBACKHOME, 0) ? -EDIST : 0); > diff -Naur linux-2.4.26-om1/hpc/mig_shm.c > linux-2.4.26-om1-o/hpc/mig_shm.c > --- linux-2.4.26-om1/hpc/mig_shm.c 1970-01-01 05:30:00.000000000 > +0530 > +++ linux-2.4.26-om1-o/hpc/mig_shm.c 2006-05-08 10:48:35.000000000 > +0530 > @@ -0,0 +1,744 @@ > +#include <linux/module.h> > +#include <linux/slab.h> > +#include <linux/shm.h> > +#include <linux/mman.h> > +#include <linux/locks.h> > +#include <linux/pagemap.h> > +#include <linux/swap.h> > +#include <linux/smp_lock.h> > +#include <linux/blkdev.h> > +#include <linux/file.h> > +#include <linux/swapctl.h> > +#include <linux/init.h> > +#include <linux/mm.h> > +#include <linux/iobuf.h> > +#include<asm/system.h> > + +#include <asm/pgalloc.h> > +#include <asm/uaccess.h> > +#include <asm/mman.h> > + +#include <linux/highmem.h> > +#include<linux/vmalloc.h> > + > + > +#include<hpc/protocol.h> > +#include<hpc/mig_shm.h> > +#include<hpc/shm_pagemap.h> > +#include <linux/hpc.h> > + > + > + > +void invalidate(struct shm_page *shm_page,struct page *page,int > write_access) > +{ > + + pte_t pte; + pte_t *page_table; > + unsigned long address; > + struct vm_area_struct *vma; > + struct mm_struct *mm; > + struct address_space *mapping = page->mapping; > + struct task_struct *p = current; > + int i=1; > + > + lock_page(page); > + + spin_lock(&shm_page->shm_lock); > + > + if(!(p->mosix.dflags & DDEPUTY) && !(p->mosix.dflags & DREMOTE) > && > !(shm_page->state & AT_HOME)) { > + if(write_access) { > + shm_page->state &= ~STATE_MASK; > + shm_page->state |= IDLE; > + } > + else { > + shm_page->state &= ~STATE_MASK; > + shm_page->state |= SHARED; > + } > + } > + > + spin_unlock(&shm_page->shm_lock); > + + if((page->mapping == shm_page->mapping) && (page->index == > shm_page->index)) { > + + spin_lock(&mapping->i_shared_lock); > + vma = mapping->i_mmap_shared; > + > + while(vma) { > + if(page->index >= vma->vm_pgoff) { > + address = ((page->index - vma->vm_pgoff) > << > PAGE_CACHE_SHIFT) + vma->vm_start; > + if(address < vma->vm_end ) { > + mm = vma->vm_mm; > + spin_lock(&mm->page_table_lock); > + page_table = > pte_offset(pmd_offset(pgd_offset(mm,address),address),address); > + if(pte_present(*page_table) && > (i || > > !pte_write(*page_table))) { > + flush_cache_page(vma, > address); > + pte = > ptep_get_and_clear(page_table); > + flush_tlb_page(vma, > address); > + > + if(!write_access) > + > set_pte(page_table,pte_wrprotect(pte)); > + else { > + mm->rss--; > + > page_cache_release(page); > + } > + > + if (pte_dirty(pte)) > + > set_page_dirty(page); > + } + > spin_unlock(&mm->page_table_lock); + } > + } > + vma = vma->vm_next_share; + > if(!vma > && i--) > + vma = mapping->i_mmap; > + } > + + spin_unlock(&mapping->i_shared_lock); > + } > +/* > + * else + * > + * printk("{trancated:%u %u}",page->mapping,page->index); > + */ > + > + + if(write_access && !(p->mosix.dflags & DREMOTE) && > !(p->mosix.dflags > & > DDEPUTY) && !(shm_page->state & AT_HOME)) { > + page->shm_page = NULL; > + shm_pagecache_release(shm_page); > + + ClearPageUptodate(page); > + ClearPageDirty(page); + } > + > + unlock_page(page); > + return; > +} > + + > +static int send_upgrade(struct shm_page *shm_page,struct page *page) > +{ > + int res = 1; > + > + lock_page(page); > + + if((shm_page->state & STATE_MASK) == SHARED) { > + res = remote_upgrade(shm_page); > + if(!res) { > + spin_lock(&shm_page->shm_lock); > + shm_page->state &= ~SHARED; > + shm_page->owner = PE; > + shm_page->state |= EXCLUSIVE; > + spin_unlock(&shm_page->shm_lock); > + } else if(res == 2) { > + shm_page->state |= PERM_ERR; > + printk(KERN_ERR "A shared page here is invalid: > Reboot > !\n"); > + } > + } else if((shm_page->state & STATE_MASK) == EXCLUSIVE && > ((shm_page->owner == PE) || (shm_page->owner == 0))) + res = > 0; > + > + unlock_page(page); > + return res; > +} > + > +static struct page *get_exc_rem(struct vm_area_struct *vma,unsigned > long > address,struct shm_page *shm_page) > +{ > + struct page *page; > + int res = 0; > + + page = vma->vm_ops->nopage(vma,address,WITH_WRITE_ACC); > + > + if(!page || (page == NOPAGE_OOM) || page == PAGE_BUSY) > + return page; > + > + spin_lock(&shm_page->shm_lock); > + + if(!(res = ((shm_page->state & STATE_MASK) == IDLE)) && > > ((shm_page->state & STATE_MASK) == SHARED)) { > + spin_unlock(&shm_page->shm_lock); > + res = send_upgrade(shm_page,page); > + goto out; > + } > + > + spin_unlock(&shm_page->shm_lock); > + > +out: if(!res) > + return page; > + else { > + page_cache_release(page); > + if(res == 1) + return PAGE_BUSY; > + else > + return NULL; > + } > +} > + > + +static struct page *get_page_exc_in_exc(struct vm_area_struct *vma, > unsigned > long address,struct shm_page *shm_page) > +{ > + struct page *page = NULL; > + > + switch(current->mosix.dflags & (DDEPUTY|DREMOTE)) { > + + case DREMOTE : > + > + spin_unlock(&shm_page->shm_lock); > + page = get_exc_rem(vma,address,shm_page); > + > + break; > + > + case DDEPUTY: > + > + if(!vma) goto AS_HERE; > + > + shm_page->state &= ~EXCLUSIVE; > + shm_page->state |= BUSY_EXCLUSIVE; > + spin_unlock(&shm_page->shm_lock); > + > + if(!PE || (shm_page->owner == 0) || > (shm_page->owner > == > PE)) { > + page = > vma->vm_ops->nopage(vma,address,0); > + if((page == NOPAGE_OOM )|| !page) { > + spin_lock(&shm_page->shm_lock); > + shm_page->state &= > ~BUSY_EXCLUSIVE; > + shm_page->state |= EXCLUSIVE; > + > spin_unlock(&shm_page->shm_lock); > + > > > ------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > openMosix-devel mailing list > openMosix-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > https://lists.sourceforge.net/lists/listinfo/openmosix-devel > ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642