diff -purN -X /home/mbligh/.diff.exclude 730-schedstats/fs/proc/base.c 740-per_task_TUB/fs/proc/base.c --- 730-schedstats/fs/proc/base.c 2004-02-28 11:22:28.000000000 -0800 +++ 740-per_task_TUB/fs/proc/base.c 2004-02-28 11:24:47.000000000 -0800 @@ -92,6 +92,7 @@ enum pid_directory_inos { PROC_TID_ATTR_EXEC, PROC_TID_ATTR_FSCREATE, #endif + PROC_PID_MAPBASE, PROC_TID_FD_DIR = 0x8000, /* 0x8000-0xffff */ }; @@ -126,6 +127,9 @@ static struct pid_entry tgid_base_stuff[ #ifdef CONFIG_KALLSYMS E(PROC_TGID_WCHAN, "wchan", S_IFREG|S_IRUGO), #endif +#ifdef __HAS_ARCH_PROC_MAPPED_BASE + E(PROC_PID_MAPBASE, "mapped_base",S_IFREG|S_IRUSR|S_IWUSR), +#endif {0,0,NULL,0} }; static struct pid_entry tid_base_stuff[] = { @@ -712,6 +716,58 @@ static struct file_operations proc_mem_o .open = mem_open, }; +#ifdef __HAS_ARCH_PROC_MAPPED_BASE +static ssize_t mapbase_read(struct file * file, char * buf, + size_t count, loff_t *ppos) +{ + struct task_struct *task = PROC_I(file->f_dentry->d_inode)->task; + char buffer[64]; + size_t len; + + sprintf(buffer, "%li", task->map_base); + len=strlen(buffer)+1; + *ppos += len; + if (copy_to_user(buf, buffer, len)) + len = -EFAULT; + + return (len<*ppos)?0:len; +} + +static ssize_t mapbase_write(struct file * file, const char * buf, + size_t count, loff_t *ppos) +{ + struct task_struct *task = PROC_I(file->f_dentry->d_inode)->task; + char buffer[64]; + int len; + unsigned long newbase; + if (!capable(CAP_SYS_ADMIN)) return -EPERM; + memset(buffer, 0, 64); + len = count; + if (len>63) + len = 63; + if (copy_from_user(buffer, buf, len)) + return -EFAULT; + + for (len = 0; len < 64; len++) + if (!buffer[len]) + break; + if (len>60) + return -EFAULT; + + newbase = simple_strtoul(buffer, NULL, 0); + + if (newbase > 0) + task->map_base = newbase; + + return len; +} + +static struct file_operations proc_mapbase_operations = { + read: mapbase_read, + write: mapbase_write, +}; +#endif /* __HAS_ARCH_PROC_MAPPED_BASE */ + static struct inode_operations proc_mem_inode_operations = { .permission = proc_permission, }; @@ -1418,6 +1474,11 @@ static struct dentry *proc_pident_lookup ei->op.proc_read = proc_pid_wchan; break; #endif +#ifdef __HAS_ARCH_PROC_MAPPED_BASE + case PROC_PID_MAPBASE: + inode->i_fop = &proc_mapbase_operations; + break; +#endif default: printk("procfs: impossible type (%d)",p->type); iput(inode); diff -purN -X /home/mbligh/.diff.exclude 730-schedstats/include/asm-i386/processor.h 740-per_task_TUB/include/asm-i386/processor.h --- 730-schedstats/include/asm-i386/processor.h 2004-02-28 11:17:34.000000000 -0800 +++ 740-per_task_TUB/include/asm-i386/processor.h 2004-02-28 11:24:47.000000000 -0800 @@ -295,10 +295,11 @@ extern unsigned int mca_pentium_flag; * space during mmap's. */ #ifdef CONFIG_05GB -#define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 16)) +#define __TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 16)) #else -#define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3)) +#define __TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3)) #endif +#define TASK_UNMAPPED_BASE (current->map_base) /* * Size of io_bitmap, covering ports 0 to 0x3ff. diff -purN -X /home/mbligh/.diff.exclude 730-schedstats/include/asm-ppc64/processor.h 740-per_task_TUB/include/asm-ppc64/processor.h --- 730-schedstats/include/asm-ppc64/processor.h 2004-02-18 14:57:19.000000000 -0800 +++ 740-per_task_TUB/include/asm-ppc64/processor.h 2004-02-28 11:24:47.000000000 -0800 @@ -521,8 +521,9 @@ extern struct task_struct *last_task_use #define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(STACK_TOP_USER32 / 4)) #define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(STACK_TOP_USER64 / 4)) +#define __TASK_UNMAPPED_BASE (PAGE_ALIGN(STACK_TOP_USER32 / 4)) #define TASK_UNMAPPED_BASE ((test_thread_flag(TIF_32BIT)||(ppcdebugset(PPCDBG_BINFMT_32ADDR))) ? \ - TASK_UNMAPPED_BASE_USER32 : TASK_UNMAPPED_BASE_USER64 ) + (current->map_base) : TASK_UNMAPPED_BASE_USER64 ) typedef struct { unsigned long seg; diff -purN -X /home/mbligh/.diff.exclude 730-schedstats/include/asm-s390/processor.h 740-per_task_TUB/include/asm-s390/processor.h --- 730-schedstats/include/asm-s390/processor.h 2004-02-04 16:24:31.000000000 -0800 +++ 740-per_task_TUB/include/asm-s390/processor.h 2004-02-28 11:24:47.000000000 -0800 @@ -62,14 +62,16 @@ extern struct task_struct *last_task_use #ifndef __s390x__ # define TASK_SIZE (0x80000000UL) -# define TASK_UNMAPPED_BASE (TASK_SIZE / 2) +# define __TASK_UNMAPPED_BASE (TASK_SIZE / 2) +# define TASK_UNMAPPED_BASE (current->mmap_base) #else /* __s390x__ */ # define TASK_SIZE (0x40000000000UL) # define TASK31_SIZE (0x80000000UL) +# define __TASK_UNMAPPED_BASE (TASK31_SIZE/2) # define TASK_UNMAPPED_BASE (test_thread_flag(TIF_31BIT) ? \ - (TASK31_SIZE / 2) : (TASK_SIZE / 2)) + (current->map_base) : (TASK_SIZE / 2)) #endif /* __s390x__ */ diff -purN -X /home/mbligh/.diff.exclude 730-schedstats/include/asm-um/processor-generic.h 740-per_task_TUB/include/asm-um/processor-generic.h --- 730-schedstats/include/asm-um/processor-generic.h 2003-02-13 16:36:39.000000000 -0800 +++ 740-per_task_TUB/include/asm-um/processor-generic.h 2004-02-28 11:24:47.000000000 -0800 @@ -121,7 +121,8 @@ extern unsigned long task_size; /* This decides where the kernel will search for a free chunk of vm * space during mmap's. */ -#define TASK_UNMAPPED_BASE (0x40000000) +#define __TASK_UNMAPPED_BASE (0x40000000) +#define TASK_UNMAPPED_BASE (current->map_base) extern void start_thread(struct pt_regs *regs, unsigned long entry, unsigned long stack); diff -purN -X /home/mbligh/.diff.exclude 730-schedstats/include/linux/init_task.h 740-per_task_TUB/include/linux/init_task.h --- 730-schedstats/include/linux/init_task.h 2004-02-28 11:21:09.000000000 -0800 +++ 740-per_task_TUB/include/linux/init_task.h 2004-02-28 11:24:47.000000000 -0800 @@ -110,6 +110,7 @@ .switch_lock = SPIN_LOCK_UNLOCKED, \ .journal_info = NULL, \ .io_wait = NULL, \ + .map_base = __TASK_UNMAPPED_BASE, \ } diff -purN -X /home/mbligh/.diff.exclude 730-schedstats/include/linux/sched.h 740-per_task_TUB/include/linux/sched.h --- 730-schedstats/include/linux/sched.h 2004-02-28 11:22:32.000000000 -0800 +++ 740-per_task_TUB/include/linux/sched.h 2004-02-28 11:24:47.000000000 -0800 @@ -491,6 +491,8 @@ struct task_struct { void *journal_info; /* VM state */ + /* TASK_UNMAPPED_BASE value */ + unsigned long map_base; struct reclaim_state *reclaim_state; struct dentry *proc_dentry; @@ -519,6 +521,12 @@ extern void __put_task_struct(struct tas #define put_task_struct(tsk) \ do { if (atomic_dec_and_test(&(tsk)->usage)) __put_task_struct(tsk); } while(0) +#ifndef __TASK_UNMAPPED_BASE +#define __TASK_UNMAPPED_BASE 0UL +#else +#define __HAS_ARCH_PROC_MAPPED_BASE +#endif + /* * Per process flags */