patch-2.3.16 linux/fs/proc/array.c

Next file: linux/fs/proc/base.c
Previous file: linux/fs/partitions/check.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.15/linux/fs/proc/array.c linux/fs/proc/array.c
@@ -44,6 +44,8 @@
  *
  * Al Viro           :  safe handling of mm_struct
  *
+ * Gerhard Wichert   :  added BIGMEM support
+ * Siemens AG           <Gerhard.Wichert@pdb.siemens.de>
  */
 
 #include <linux/types.h>
@@ -247,9 +249,8 @@
 	int i, len;
 	unsigned sum = 0;
 	extern unsigned long total_forks;
-	unsigned long ticks;
+	unsigned long jif = jiffies;
 
-	ticks = jiffies * smp_num_cpus;
 	for (i = 0 ; i < NR_IRQS ; i++)
 		sum += kstat_irqs(i);
 
@@ -259,14 +260,14 @@
 		kstat.cpu_user,
 		kstat.cpu_nice,
 		kstat.cpu_system,
-		jiffies*smp_num_cpus - (kstat.cpu_user + kstat.cpu_nice + kstat.cpu_system));
+		jif*smp_num_cpus - (kstat.cpu_user + kstat.cpu_nice + kstat.cpu_system));
 	for (i = 0 ; i < smp_num_cpus; i++)
 		len += sprintf(buffer + len, "cpu%d %u %u %u %lu\n",
 			i,
 			kstat.per_cpu_user[cpu_logical_map(i)],
 			kstat.per_cpu_nice[cpu_logical_map(i)],
 			kstat.per_cpu_system[cpu_logical_map(i)],
-			jiffies - (  kstat.per_cpu_user[cpu_logical_map(i)] \
+			jif - (  kstat.per_cpu_user[cpu_logical_map(i)] \
 			           + kstat.per_cpu_nice[cpu_logical_map(i)] \
 			           + kstat.per_cpu_system[cpu_logical_map(i)]));
 	len += sprintf(buffer + len,
@@ -292,7 +293,7 @@
 		kstat.cpu_user,
 		kstat.cpu_nice,
 		kstat.cpu_system,
-		ticks - (kstat.cpu_user + kstat.cpu_nice + kstat.cpu_system),
+		jif*smp_num_cpus - (kstat.cpu_user + kstat.cpu_nice + kstat.cpu_system),
 #endif
 		kstat.dk_drive[0], kstat.dk_drive[1],
 		kstat.dk_drive[2], kstat.dk_drive[3],
@@ -316,7 +317,7 @@
 		"btime %lu\n"
 		"processes %lu\n",
 		kstat.context_swtch,
-		xtime.tv_sec - jiffies / HZ,
+		xtime.tv_sec - jif / HZ,
 		total_forks);
 	return len;
 }
@@ -376,6 +377,8 @@
 		"MemShared: %8lu kB\n"
 		"Buffers:   %8lu kB\n"
 		"Cached:    %8u kB\n"
+		"BigTotal:  %8lu kB\n"
+		"BigFree:   %8lu kB\n"
 		"SwapTotal: %8lu kB\n"
 		"SwapFree:  %8lu kB\n",
 		i.totalram >> 10,
@@ -383,6 +386,8 @@
 		i.sharedram >> 10,
 		i.bufferram >> 10,
 		atomic_read(&page_cache_size) << (PAGE_SHIFT - 10),
+		i.totalbig >> 10,
+		i.freebig >> 10,
 		i.totalswap >> 10,
 		i.freeswap >> 10);
 }
@@ -432,6 +437,8 @@
 	return pte_page(pte) + (ptr & ~PAGE_MASK);
 }
 
+#include <linux/bigmem.h>
+
 static int get_array(struct mm_struct *mm, unsigned long start, unsigned long end, char * buffer)
 {
 	unsigned long addr;
@@ -444,19 +451,25 @@
 		addr = get_phys_addr(mm, start);
 		if (!addr)
 			return result;
+		addr = kmap(addr, KM_READ);
 		do {
 			c = *(char *) addr;
 			if (!c)
 				result = size;
 			if (size < PAGE_SIZE)
 				buffer[size++] = c;
-			else
+			else {
+				kunmap(addr, KM_READ);
 				return result;
+			}
 			addr++;
 			start++;
-			if (!c && start >= end)
+			if (!c && start >= end) {
+				kunmap(addr, KM_READ);
 				return result;
+			}
 		} while (addr & ~PAGE_MASK);
+		kunmap(addr, KM_READ);
 	}
 	return result;
 }
@@ -519,12 +532,12 @@
 
 		stack_page = (unsigned long)p;
 		esp = p->thread.esp;
-		if (!stack_page || esp < stack_page || esp >= 8188+stack_page)
+		if (!stack_page || esp < stack_page || esp > 8188+stack_page)
 			return 0;
 		/* include/asm-i386/system.h:switch_to() pushes ebp last. */
 		ebp = *(unsigned long *) esp;
 		do {
-			if (ebp < stack_page || ebp >= 8188+stack_page)
+			if (ebp < stack_page || ebp > 8184+stack_page)
 				return 0;
 			eip = *(unsigned long *) (ebp+4);
 			if (eip < first_sched || eip >= last_sched)
@@ -593,7 +606,7 @@
 		unsigned long stack_page = (unsigned long) p;
 		int count = 0;
 
-		sp = p->tss.ksp;
+		sp = p->thread.ksp;
 		do {
 			sp = *(unsigned long *)sp;
 			if (sp < stack_page || sp >= stack_page + 8188)
@@ -675,8 +688,8 @@
 	eip; })
 #define	KSTK_ESP(tsk)	((tsk) == current ? rdusp() : (tsk)->thread.usp)
 #elif defined(__powerpc__)
-#define KSTK_EIP(tsk)	((tsk)->tss.regs->nip)
-#define KSTK_ESP(tsk)	((tsk)->tss.regs->gpr[1])
+#define KSTK_EIP(tsk)	((tsk)->thread.regs->nip)
+#define KSTK_ESP(tsk)	((tsk)->thread.regs->gpr[1])
 #elif defined (__sparc_v9__)
 # define KSTK_EIP(tsk)  ((tsk)->thread.kregs->tpc)
 # define KSTK_ESP(tsk)  ((tsk)->thread.kregs->u_regs[UREG_FP])
@@ -689,6 +702,9 @@
 #define KSTK_TOS(tsk) ((unsigned long)(tsk) + KERNEL_STACK_SIZE - 32)
 # define KSTK_EIP(tsk)	(*(unsigned long *)(KSTK_TOS(tsk) + PT_REG(cp0_epc)))
 # define KSTK_ESP(tsk)	(*(unsigned long *)(KSTK_TOS(tsk) + PT_REG(regs[29])))
+#elif defined(__sh__)
+# define KSTK_EIP(tsk)  ((tsk)->thread.pc)
+# define KSTK_ESP(tsk)  ((tsk)->thread.sp)
 #endif
 
 /* Gcc optimizes away "strlen(x)" for constant x */
@@ -1337,7 +1353,7 @@
 		case PROC_MEMINFO:
 			return get_meminfo(page);
 
-#ifdef CONFIG_PCI_OLD_PROC
+#ifdef CONFIG_PCI
 	        case PROC_PCI:
 			return get_pci_list(page);
 #endif
@@ -1456,8 +1472,7 @@
 	if (!p)
 		return 1;
 
-	switch(type)
-	{
+	switch(type) {
 		case PROC_PID_STATUS:
 		case PROC_PID_STATM:
 		case PROC_PID_STAT:
@@ -1524,8 +1539,7 @@
 	start = NULL;
 	dp = (struct proc_dir_entry *) inode->u.generic_ip;
 	
-	if (pid && process_unauthorized(type, pid))
-	{
+	if (pid && process_unauthorized(type, pid)) {
 		free_page(page);
 		return -EIO;
 	}

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)