diff --git a/elks/arch/i86/boot/bootsect.S b/elks/arch/i86/boot/bootsect.S index ed20f8934..f1a70ad7d 100644 --- a/elks/arch/i86/boot/bootsect.S +++ b/elks/arch/i86/boot/bootsect.S @@ -49,9 +49,8 @@ SETUPSEG = DEF_SETUPSEG SYSSEG = DEF_SYSSEG /* system loaded at 0x10000 (65536). */ SYSSEGB = DEF_SYSSEG + 2 -// ROOT_DEV & SWAP_DEV are now written by "build". +// ROOT_DEV is now written by "build". ROOT_DEV = 0 -SWAP_DEV = 0 #ifndef SVGA_MODE #define SVGA_MODE VGA_ASK @@ -564,8 +563,8 @@ root_flags: .word ROOTFLAGS syssize: .word SYSSIZE -swap_dev: - .word SWAP_DEV +unused: + .word 0 ram_size: .word RAMDISK vid_mode: diff --git a/elks/arch/i86/boot/netbootsect.S b/elks/arch/i86/boot/netbootsect.S index 25a785b6a..399f8f77c 100644 --- a/elks/arch/i86/boot/netbootsect.S +++ b/elks/arch/i86/boot/netbootsect.S @@ -41,9 +41,8 @@ INITSEG = DEF_INITSEG ! we move boot here - out of the way SYSSEG = DEF_SYSSEG ! system loaded at 0x10000 (65536). SYSSEGB = DEF_SYSSEG + 2 -! ROOT_DEV & SWAP_DEV are now written by "build". +! ROOT_DEV is now written by "build". ROOT_DEV = 0 -SWAP_DEV = 0 #ifndef SVGA_MODE #define SVGA_MODE VGA_ASK #endif @@ -93,8 +92,8 @@ root_flags: .word ROOTFLAGS syssize: .word SYSSIZE -swap_dev: - .word SWAP_DEV +unused: + .word 0 ram_size: .word RAMDISK vid_mode: diff --git a/elks/arch/i86/boot/setup.S b/elks/arch/i86/boot/setup.S index 19ccae0c1..042b69832 100644 --- a/elks/arch/i86/boot/setup.S +++ b/elks/arch/i86/boot/setup.S @@ -83,7 +83,7 @@ ! 0x1f1: SETUPSECS ! 0x1f2: ROOTFLAGS ! 0x1f4: SYSSIZE -! 0x1f6: SWAP_DEV +! 0x1f6: unused (was SWAP_DEV) ! 0x1f8: RAMDISK ! 0x1fa: SVGA_MODE ! 0x1fc: ROOT_DEV diff --git a/elks/arch/i86/defconfig b/elks/arch/i86/defconfig index b3eea44a9..80f4e4ba0 100644 --- a/elks/arch/i86/defconfig +++ b/elks/arch/i86/defconfig @@ -63,7 +63,6 @@ CONFIG_APM=y # CONFIG_MEM_TABLE is not set CONFIG_MEM_LIST=y CONFIG_ADVANCED_MM=y -# CONFIG_SWAP is not set CONFIG_SMALL_KERNEL=y CONFIG_SYS_VERSION=y # CONFIG_STRACE is not set diff --git a/elks/arch/i86/drivers/block/blk.h b/elks/arch/i86/drivers/block/blk.h index c97c0121d..f905d97f2 100644 --- a/elks/arch/i86/drivers/block/blk.h +++ b/elks/arch/i86/drivers/block/blk.h @@ -21,7 +21,7 @@ struct request { __u8 rq_status; sector_t rq_sector; char *rq_buffer; - seg_t rq_seg; /* Used by swapper */ + seg_t rq_seg; struct buffer_head *rq_bh; struct request *rq_next; diff --git a/elks/arch/i86/drivers/block/genhd.c b/elks/arch/i86/drivers/block/genhd.c index 6bcfe27b5..92e298743 100644 --- a/elks/arch/i86/drivers/block/genhd.c +++ b/elks/arch/i86/drivers/block/genhd.c @@ -221,7 +221,7 @@ static int msdos_partition(struct gendisk *hd, hd->sizes[minor] = (int) (hdp->nr_sects >> (BLOCK_SIZE_BITS - 9)); extended_partition(hd, MKDEV(hd->major, minor)); printk(" >"); - /* prevent someone doing mkfs or mkswap on an + /* prevent someone doing mkfs on an * extended partition, but leave room for LILO */ if (hdp->nr_sects > 2) hdp->nr_sects = 2; diff --git a/elks/arch/i86/drivers/char/mem.c b/elks/arch/i86/drivers/char/mem.c index 7a1ac6c9b..32c2400e2 100644 --- a/elks/arch/i86/drivers/char/mem.c +++ b/elks/arch/i86/drivers/char/mem.c @@ -155,10 +155,6 @@ int kmem_ioctl(struct inode *inode, struct file *file, int cmd, register char *a { struct mem_usage mu; -#ifdef CONFIG_SWAP - struct mem_swap_info si; -#endif - debugmem1("[k]mem_ioctl() %d\n", cmd); switch (cmd) { @@ -196,24 +192,9 @@ int kmem_ioctl(struct inode *inode, struct file *file, int cmd, register char *a mu.free_memory = mm_get_usage(MM_MEM, 0); mu.used_memory = mm_get_usage(MM_MEM, 1); -#ifdef CONFIG_SWAP - mu.free_swap = mm_get_usage(MM_SWAP, 0); - mu.used_swap = mm_get_usage(MM_SWAP, 1); -#else - mu.free_swap = mu.used_swap = 0; -#endif - memcpy_tofs(arg, &mu, sizeof(struct mem_usage)); return 0; - -#ifdef CONFIG_SWAP - case MEM_SETSWAP: - if (!suser()) - return -EPERM; - memcpy_fromfs(&si, arg, sizeof(struct mem_swap_info)); - return mm_swap_on(&si); -#endif } return -EINVAL; } @@ -314,7 +295,7 @@ int memory_open(register struct inode *inode, struct file *filp) NULL, /* */ /* The following two entries assume that virtual memory is identical - * to physical memory. Is this still true now we have swap? + * to physical memory. */ &kmem_fops, /* DEV_MEM_MINOR */ diff --git a/elks/arch/i86/mm/malloc.c b/elks/arch/i86/mm/malloc.c index 77850916a..32685ca96 100644 --- a/elks/arch/i86/mm/malloc.c +++ b/elks/arch/i86/mm/malloc.c @@ -1,5 +1,5 @@ /* - * Memory management support for a swapping rather than paging kernel. + * Memory management support. * * Two possible memory allocators: * @@ -24,7 +24,7 @@ #include #include #include -#include /* for mem_swap_info */ +//#include #include #include @@ -40,7 +40,6 @@ */ #define MAX_SEGMENTS 8+(MAX_TASKS*2) -#define MAX_SWAP_SEGMENTS 8+(MAX_TASKS*2) struct malloc_hole { seg_t page_base; /* Pages */ @@ -51,15 +50,10 @@ struct malloc_hole { #define HOLE_USED 1 #define HOLE_FREE 2 #define HOLE_SPARE 3 -#define HOLE_SWAPPED 8 }; static struct malloc_hole holes[MAX_SEGMENTS]; -#ifdef CONFIG_SWAP -static struct malloc_hole swap_holes[MAX_SWAP_SEGMENTS]; -#endif - struct malloc_head { struct malloc_hole *holes; int size; @@ -67,12 +61,6 @@ struct malloc_head { struct malloc_head memmap = { holes, MAX_SEGMENTS }; -#ifdef CONFIG_SWAP -struct malloc_head swapmap = { swap_holes, MAX_SWAP_SEGMENTS }; -static struct buffer_head swap_buf; -static dev_t swap_dev; -#endif - #endif /* CONFIG_MEM_TABLE */ @@ -217,18 +205,6 @@ static struct malloc_hole *find_hole(register struct malloc_hole *m, seg_t base) return m; } -/* - * Allocate a segment - */ - -#ifdef CONFIG_SWAP - -int swap_out(seg_t base); -seg_t swap_strategy(); -int swap_out_someone(); - -#endif - #endif /* CONFIG_MEM_TABLE */ @@ -342,6 +318,9 @@ static void seg_merge_right (seg_t node_seg) #endif /* CONFIG_MEM_LIST */ +/* + * Allocate a segment + */ seg_t mm_alloc(segext_t pages) { @@ -351,23 +330,10 @@ seg_t mm_alloc(segext_t pages) */ register struct malloc_hole *m; -#ifdef CONFIG_SWAP - seg_t s; - - while ((m = best_fit_hole(holes, pages)) == NULL) { - s = swap_strategy(NULL); - if (s == NULL || swap_out(s) == -1) - return 0; - } - -#else - m = best_fit_hole(holes, pages); if (m == NULL) return 0; -#endif - /* * The hole is (probably) too big */ @@ -408,33 +374,6 @@ void mm_free (seg_t base) #endif /* CONFIG_MEM_LIST */ -/* - * This function will swapin the whole process. After - * there are exact ideas on the implementation of the swap cache - * this sould change - */ - -#ifdef CONFIG_SWAP - -static seg_t validate_address(seg_t base) -{ - register struct task_struct *t; - - for_each_task(t) { - if (t->mm.cseg == base && t->mm.flags & CS_SWAP) { - do_swapper_run(t); - return t->mm.cseg; - } - if (t->mm.dseg == base && t->mm.flags & DS_SWAP) { - do_swapper_run(t); - return t->mm.dseg; - } - } - return base; -} - -#endif - /* Increase segment reference count */ void mm_get(seg_t base) @@ -443,12 +382,6 @@ void mm_get(seg_t base) register struct malloc_hole *m; -#ifdef CONFIG_SWAP - - base = validate_address(base); - -#endif - m = find_hole(holes, base); m->refcount++; @@ -469,9 +402,8 @@ void mm_get(seg_t base) /* Free the segment on no more reference */ /* - * Caution: A process can be killed dead by another. That means we - * might potentially have to kill a swapped task. Be sure to catch - * that in exit... + * Caution: A process can be killed dead by another. + * Be sure to catch that in exit... */ void mm_put(seg_t base) @@ -483,19 +415,8 @@ void mm_put(seg_t base) m = find_hole(mh, base); if (!m) { -#ifdef CONFIG_SWAP - - mh = swap_holes; - m = find_hole(mh, base); - if (!m) - panic("mm_put(): mm corruption from swap\n"); - -#else - panic("mm corruption"); -#endif - } if (m->flags != HOLE_USED) @@ -531,7 +452,7 @@ seg_t mm_dup(seg_t base) debug("MALLOC: mm_dup()\n"); o = find_hole(holes, base); if (o->flags != HOLE_USED) - panic("bad/swapped hole"); + panic("bad hole"); if ((mbase = (char *)mm_alloc(o->extent)) != NULL) fmemcpyb(NULL, (seg_t) mbase, NULL, o->page_base, (word_t) (o->extent << 4)); @@ -556,7 +477,7 @@ seg_t mm_dup(seg_t base) /* * Returns memory usage information in KB's. - * "type" is either MM_MEM or MM_SWAP and "used" + * "type" is either MM_MEM and "used" * selects if we request the used or free memory. */ unsigned int mm_get_usage(int type, int used) @@ -566,16 +487,8 @@ unsigned int mm_get_usage(int type, int used) register struct malloc_hole *m; unsigned int ret = 0; -#ifdef CONFIG_SWAP - - m = type == MM_MEM ? holes : swap_holes; - -#else - m = holes; -#endif - used = used ? HOLE_USED : HOLE_FREE; do { @@ -583,13 +496,6 @@ unsigned int mm_get_usage(int type, int used) ret += m->extent; } while ((m = m->next)); -#ifdef CONFIG_SWAP - - if (type != MM_MEM) - return ret; - -#endif - return ret >> 6; #endif /* CONFIG_MEM_TABLE */ @@ -811,11 +717,6 @@ void mm_init(seg_t start, seg_t end) holep->refcount = 0; holep->next = NULL; -#ifdef CONFIG_SWAP - swap_dev = NULL; - mm_swap_on(NULL); -#endif - #endif /* CONFIG_MEM_TABLE */ #ifdef CONFIG_MEM_LIST @@ -829,239 +730,3 @@ void mm_init(seg_t start, seg_t end) #endif /* CONFIG_MEM_LIST */ } -#ifdef CONFIG_SWAP -/* - * Swapper task - */ - -/* - * Push a segment to disk if possible - */ - -int mm_swap_on(struct mem_swap_info *si) -{ - register struct malloc_hole *holep; - int ct; - if (swap_dev) - return -EPERM; - - for (ct = 1; ct < MAX_SWAP_SEGMENTS; ct++) - swap_holes[ct].flags = HOLE_SPARE; - - if (!si) - return 0; - - holep = &swap_holes[0]; - holep->flags = HOLE_FREE; - holep->page_base = 0; - holep->extent = si->size; - holep->refcount = 0; - holep->next = NULL; - - swap_dev = (si->major << 8) + si->minor; - - return 0; -} - -static int swap_out(seg_t base) -{ - register struct task_struct *t; - register struct malloc_hole *o = find_hole(holes, base); - struct malloc_hole *so; - int ct, blocks; - - /* We can hit disk this time. Allocate a hole in 1K increments */ - blocks = (o->extent + 0x3F) >> 6; - so = best_fit_hole(swap_holes, blocks); - if (so == NULL) { - /* No free swap */ - return -1; - } - split_hole(&swapmap, so, blocks); - so->refcount = o->refcount; - - for_each_task(t) { - int c = t->mm.flags; - if (t->mm.cseg == base && !(c & CS_SWAP)) { - t->mm.cseg = so->page_base; - t->mm.flags |= CS_SWAP; - debug2("MALLOC: swaping out code of pid %d blocks %d\n", - t->pid, blocks); - } - if (t->mm.dseg == base && !(c & DS_SWAP)) { - t->mm.dseg = so->page_base; - t->mm.flags |= DS_SWAP; - debug2("MALLOC: swaping out data of pid %d blocks %d\n", - t->pid, blocks); - } - } - - /* Now write the segment out */ - for (ct = 0; ct < blocks; ct++) { - swap_buf.b_blocknr = so->page_base + ct; - swap_buf.b_dev = swap_dev; - swap_buf.b_lock = 0; - swap_buf.b_dirty = 1; - swap_buf.b_seg = o->page_base; - swap_buf.b_data = ct << 10; - ll_rw_blk(WRITE, &swap_buf); - wait_on_buffer(&swap_buf); - } - free_hole(holes, o); - - return 1; -} - -static int swap_in(seg_t base, int chint) -{ - register struct task_struct *t; - register struct malloc_hole *o; - struct malloc_hole *so; - int ct, blocks; - - so = find_hole(swap_holes, base); - /* Find memory for this segment */ - o = best_fit_hole(holes, so->extent << 6); - if (o == NULL) - return -1; - - /* Now read the segment in */ - split_hole(&memmap, o, so->extent << 6); - o->refcount = so->refcount; - - blocks = so->extent; - - for (ct = 0; ct < blocks; ct++) { - swap_buf.b_blocknr = so->page_base + ct; - swap_buf.b_dev = swap_dev; - swap_buf.b_lock = 0; - swap_buf.b_dirty = 0; - swap_buf.b_uptodate = 0; - swap_buf.b_seg = o->page_base; - swap_buf.b_data = ct << 10; - - ll_rw_blk(READ, &swap_buf); - wait_on_buffer(&swap_buf); - } - - /* - * Update the memory management tables - */ - for_each_task(t) { - int c = t->mm.flags; - if (t->mm.cseg == base && c & CS_SWAP) { - debug2("MALLOC: swapping in code of pid %d seg %x\n", - t->pid, t->mm.cseg); - t->mm.cseg = o->page_base; - t->mm.flags &= ~CS_SWAP; - } - if (t->mm.dseg == base && c & DS_SWAP) { - debug2("MALLOC: swapping in data of pid %d seg %x\n", - t->pid, t->mm.dseg); - t->mm.dseg = o->page_base; - t->mm.flags &= ~DS_SWAP; - } - if (c && !t->mm.flags) { - t->t_xregs.cs = t->mm.cseg; - t->t_regs.ds = t->t_regs.es = t->t_regs.ss = t->mm.dseg; - - put_ustack(t, 4, t->t_xregs.cs); - } - } - - /* Our equivalent of the Linux swap cache. Try and avoid writing CS - * back. Need to kill segments on last exit for this to work, and - * keep a table - TODO - */ -#if 0 - if (chint==0) -#endif - { -/* so->refcount = 0;*//* refcount only meaningful if HOLE_USED */ - free_hole(swap_holes, so); - } - - return 0; -} - -/* - * When the swapper has found a task it wishes to make run we do the - * dirty work. On failure we return -1 - */ -static int make_runnable(register struct task_struct *t) -{ - char flags = t->mm.flags; - - if (flags & CS_SWAP) - if (swap_in(t->mm.cseg, 1) == -1) - return -1; - if (flags & DS_SWAP) - if (swap_in(t->mm.dseg, 0) == -1) - return -1; - return 0; -} - -static seg_t swap_strategy(register struct task_struct *swapin_target) -{ - register struct task_struct *t; - struct malloc_hole *o; - seg_t best_ret = 0; - int ret, rate; - int best_rate = -1; - int best_pid; - - debug1("swap_strategy(pid %d)\n", swapin_target->pid); - for_each_task(t) { - if ( t->state == TASK_UNUSED - || t->pid == 0 - || t->mm.cseg == current->mm.cseg - ) - continue; - if (swapin_target != NULL && t->mm.cseg == swapin_target->mm.cseg) - continue; - - ret = 0; - rate = 0; - if (t->state != TASK_RUNNING) - rate++; - - rate += (jiffies - t->last_running) >> 4; - - if (!(t->mm.flags & CS_SWAP)) { - if (t->mm.flags & DS_SWAP) - rate += 1000; - ret = t->mm.cseg; - } - - if (!(t->mm.flags & DS_SWAP) && ret == 0) { - if (t->mm.flags & CS_SWAP) - rate += 1000; - ret = t->mm.dseg; - } - - if (ret != 0 && rate > best_rate) { - best_rate = rate; - best_ret = ret; - best_pid = t->pid; - } - } - - debug2("Choose pid %d rate %d\n", best_pid, best_rate); - - return best_ret; -} - -/* - * Do an iteration of the swapper - */ -int do_swapper_run(register struct task_struct *swapin_target) -{ - while (make_runnable(swapin_target) == -1) { - seg_t t = swap_strategy(swapin_target); - if (!t || swap_out(t) == -1) - return -1; - } - return 0; -} - -#endif /* CONFIG_SWAP */ diff --git a/elks/config.in b/elks/config.in index f5e570926..776faefbd 100644 --- a/elks/config.in +++ b/elks/config.in @@ -97,10 +97,6 @@ mainmenu_option next_comment bool 'Advanced memory manager' CONFIG_ADVANCED_MM y - if [ "$CONFIG_ADVANCED_MM" = "y" ]; then - bool 'Enable swap support' CONFIG_SWAP n - fi - endmenu bool 'Minimize kernel size' CONFIG_SMALL_KERNEL n diff --git a/elks/include/linuxmt/fs.h b/elks/include/linuxmt/fs.h index 873b1b418..ed2859a0c 100644 --- a/elks/include/linuxmt/fs.h +++ b/elks/include/linuxmt/fs.h @@ -507,7 +507,6 @@ extern struct buffer_head *readbuf(struct buffer_head *); extern void ll_rw_blk(int,struct buffer_head *); extern void ll_rw_page(void); -extern void ll_rw_swap_file(void); extern void map_buffer(struct buffer_head *); extern void unmap_buffer(struct buffer_head *); diff --git a/elks/include/linuxmt/mem.h b/elks/include/linuxmt/mem.h index 62ad609da..af17ad55c 100644 --- a/elks/include/linuxmt/mem.h +++ b/elks/include/linuxmt/mem.h @@ -14,19 +14,10 @@ #define MEM_GETTASK 4 #define MEM_GETDS 5 #define MEM_GETCS 6 -#define MEM_SETSWAP 7 struct mem_usage { unsigned int free_memory; unsigned int used_memory; - unsigned int free_swap; - unsigned int used_swap; -}; - -struct mem_swap_info { - unsigned char major; - unsigned char minor; - unsigned int size; }; #ifdef CONFIG_MODULES diff --git a/elks/include/linuxmt/mm.h b/elks/include/linuxmt/mm.h index 0b7cb248e..7e87be108 100644 --- a/elks/include/linuxmt/mm.h +++ b/elks/include/linuxmt/mm.h @@ -14,9 +14,6 @@ extern unsigned long high_memory; #define VERIFY_WRITE 1 #define MM_MEM 0 -#ifdef CONFIG_SWAP -#define MM_SWAP 1 -#endif /* memory primitives */ /* TODO: move these to a new library header memory.h */ @@ -71,13 +68,5 @@ extern seg_t mm_dup(seg_t); extern void mm_stat(seg_t,seg_t); extern unsigned int mm_get_usage(int,int); -extern int do_swapper_run(struct task_struct *); - -/* FIXME: Following function prototypes are apparently phantom ones, - * so are defined here with void parameters for now. - */ - -extern int mm_swapon(void); - #endif #endif diff --git a/elks/include/linuxmt/sched.h b/elks/include/linuxmt/sched.h index 0d27abb0a..0bcc959a9 100644 --- a/elks/include/linuxmt/sched.h +++ b/elks/include/linuxmt/sched.h @@ -37,8 +37,6 @@ struct mm_struct { seg_t cseg; seg_t dseg; char flags; -#define CS_SWAP 1 -#define DS_SWAP 2 }; struct signal_struct { @@ -89,10 +87,6 @@ struct task_struct { struct signal_struct sig; /* Signal block */ int dumpable; /* Can core dump */ -#ifdef CONFIG_SWAP - jiff_t last_running; -#endif - #ifdef CONFIG_SUPPLEMENTARY_GROUPS gid_t groups[NGROUPS]; #endif @@ -113,7 +107,6 @@ struct task_struct { #define TASK_UNINTERRUPTIBLE 2 #define TASK_ZOMBIE 3 #define TASK_STOPPED 4 -#define TASK_SWAPPING 5 #define TASK_UNUSED 6 #define TASK_WAITING 7 #define TASK_EXITING 8 diff --git a/elks/include/linuxmt/timer.h b/elks/include/linuxmt/timer.h index abdace337..9845b3a07 100644 --- a/elks/include/linuxmt/timer.h +++ b/elks/include/linuxmt/timer.h @@ -14,8 +14,6 @@ * * RS_TIMER timer for the RS-232 ports * - * SWAP_TIMER timer for the background pageout daemon - * * HD_TIMER harddisk timer * * HD_TIMER2 (atdisk2 patches) @@ -38,7 +36,6 @@ #define BLANK_TIMER 0 #define BEEP_TIMER 1 #define RS_TIMER 2 -#define SWAP_TIMER 3 #define HD_TIMER 16 #define FLOPPY_TIMER 17 diff --git a/elks/kernel/sched.c b/elks/kernel/sched.c index 4ba54441b..cb567f6a3 100644 --- a/elks/kernel/sched.c +++ b/elks/kernel/sched.c @@ -52,9 +52,6 @@ void del_from_runqueue(register struct task_struct *p) nr_running--; (p->next_run->prev_run = p->prev_run)->next_run = p->next_run; p->next_run = p->prev_run = NULL; -#ifdef CONFIG_SWAP - p->last_running = jiffies; -#endif } @@ -131,13 +128,6 @@ void schedule(void) add_timer(&timer); } -#ifdef CONFIG_SWAP - if (do_swapper_run(next) == -1){ - printk("Can't become runnable %d\n", next->pid); - panic(""); - } -#endif - previous = prev; current = next;