Skip to contentSkip to conversation

architecture-independand si_meminfo

PATCH New Christoph Hellwig 1 participant 1 message May 5, 2002

Subsystems (12)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 architecture-independand si_meminfo

Si_meminfo() is basically the same for all architectures (mips is a little different by providing a value for the shared field that is different from the originial intent, I will come back to this later), so it makes to have just one instance of it:

arch/alpha/mm/init.c +0 -14
@@ -36,8 +36,6 @@
 
 mmu_gather_t mmu_gathers[NR_CPUS];
 
-unsigned long totalram_pages;
-
 extern void die_if_kernel(char *,struct pt_regs *,long);
 
 static struct pcb_struct original_pcb;
@@ -390,15 +388,3 @@
 	printk ("Freeing initrd memory: %ldk freed\n", (end - __start) >> 10);
 }
 #endif
-
-void
-si_meminfo(struct sysinfo *val)
-{
-	val->totalram = totalram_pages;
-	val->sharedram = 0;
-	val->freeram = nr_free_pages();
-	val->bufferram = atomic_read(&buffermem_pages);
-	val->totalhigh = 0;
-	val->freehigh = 0;
-	val->mem_unit = PAGE_SIZE;
-}
arch/alpha/mm/numa.c +0 -1
@@ -358,7 +358,6 @@
 	extern int page_is_ram(unsigned long) __init;
 	extern char _text, _etext, _data, _edata;
 	extern char __init_begin, __init_end;
-	extern unsigned long totalram_pages;
 	unsigned long nid, i;
 	mem_map_t * lmem_map;
 
arch/arm/mm/init.c +0 -12
@@ -48,7 +48,6 @@
 
 #define TABLE_SIZE	((TABLE_OFFSET + PTRS_PER_PTE) * sizeof(pte_t))
 
-static unsigned long totalram_pages;
 extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
 extern char _stext, _text, _etext, _end, __init_begin, __init_end;
 
@@ -631,14 +630,3 @@
 
 __setup("keepinitrd", keepinitrd_setup);
 #endif
-
-void si_meminfo(struct sysinfo *val)
-{
-	val->totalram  = totalram_pages;
-	val->sharedram = 0;
-	val->freeram   = nr_free_pages();
-	val->bufferram = atomic_read(&buffermem_pages);
-	val->totalhigh = 0;
-	val->freehigh  = 0;
-	val->mem_unit  = PAGE_SIZE;
-}
arch/cris/mm/init.c +0 -14
@@ -114,8 +114,6 @@
 #include <asm/io.h>
 #include <asm/mmu_context.h>
 
-static unsigned long totalram_pages;
-
 struct pgtable_cache_struct quicklists;  /* see asm/pgalloc.h */
 
 const char bad_pmd_string[] = "Bad pmd in pte_alloc: %08lx\n";
@@ -470,16 +468,4 @@
         }
         printk ("Freeing unused kernel memory: %luk freed\n", 
 		(&__init_end - &__init_begin) >> 10);
-}
-
-void 
-si_meminfo(struct sysinfo *val)
-{
-        val->totalram = totalram_pages;
-        val->sharedram = 0;
-        val->freeram = nr_free_pages();
-        val->bufferram = atomic_read(&buffermem_pages);
-        val->totalhigh = 0;
-        val->freehigh = 0;
-        val->mem_unit = PAGE_SIZE;
 }
arch/i386/mm/init.c +0 -14
@@ -41,8 +41,6 @@
 
 mmu_gather_t mmu_gathers[NR_CPUS];
 unsigned long highstart_pfn, highend_pfn;
-static unsigned long totalram_pages;
-static unsigned long totalhigh_pages;
 
 /*
  * NOTE: pagetable_init alloc all the fixmap pagetables contiguous on the
@@ -560,18 +558,6 @@
 	}
 }
 #endif
-
-void si_meminfo(struct sysinfo *val)
-{
-	val->totalram = totalram_pages;
-	val->sharedram = 0;
-	val->freeram = nr_free_pages();
-	val->bufferram = atomic_read(&buffermem_pages);
-	val->totalhigh = totalhigh_pages;
-	val->freehigh = nr_free_highpages();
-	val->mem_unit = PAGE_SIZE;
-	return;
-}
 
 #if defined(CONFIG_X86_PAE)
 static struct kmem_cache_s *pae_pgd_cachep;
arch/ia64/mm/init.c +0 -15
@@ -36,8 +36,6 @@
 
 unsigned long MAX_DMA_ADDRESS = PAGE_OFFSET + 0x100000000UL;
 
-static unsigned long totalram_pages;
-
 static int pgt_cache_water[2] = { 25, 50 };
 
 void
@@ -156,19 +154,6 @@
 		__free_page(page);
 		++totalram_pages;
 	}
-}
-
-void
-si_meminfo (struct sysinfo *val)
-{
-	val->totalram = totalram_pages;
-	val->sharedram = 0;
-	val->freeram = nr_free_pages();
-	val->bufferram = atomic_read(&buffermem_pages);
-	val->totalhigh = 0;
-	val->freehigh = 0;
-	val->mem_unit = PAGE_SIZE;
-	return;
 }
 
 void
arch/m68k/mm/init.c +0 -17
@@ -35,8 +35,6 @@
 
 mmu_gather_t mmu_gathers[NR_CPUS];
 
-unsigned long totalram_pages = 0;
-
 int do_check_pgt_cache(int low, int high)
 {
 	int freed = 0;
@@ -202,18 +200,3 @@
 	printk ("Freeing initrd memory: %dk freed\n", pages);
 }
 #endif
-
-void si_meminfo(struct sysinfo *val)
-{
-    unsigned long i;
-
-    i = max_mapnr;
-    val->totalram = totalram_pages;
-    val->sharedram = 0;
-    val->freeram = nr_free_pages();
-    val->bufferram = atomic_read(&buffermem_pages);
-    val->totalhigh = 0;
-    val->freehigh = 0;
-    val->mem_unit = PAGE_SIZE;
-    return;
-}
arch/m68k/mm/motorola.c +0 -1
@@ -286,7 +286,6 @@
 }
 
 extern char __init_begin, __init_end;
-extern unsigned long totalram_pages;
 
 void free_initmem(void)
 {
arch/mips/mm/init.c +0 -15
@@ -45,8 +45,6 @@
 
 mmu_gather_t mmu_gathers[NR_CPUS];
 
-static unsigned long totalram_pages;
-
 extern void prom_free_prom_memory(void);
 
 
@@ -264,17 +262,4 @@
 	}
 	printk("Freeing unused kernel memory: %dk freed\n",
 	       (&__init_end - &__init_begin) >> 10);
-}
-
-void si_meminfo(struct sysinfo *val)
-{
-	val->totalram = totalram_pages;
-	val->sharedram = atomic_read(&shmem_nrpages);
-	val->freeram = nr_free_pages();
-	val->bufferram = atomic_read(&buffermem_pages);
-	val->totalhigh = 0;
-	val->freehigh = nr_free_highpages();
-	val->mem_unit = PAGE_SIZE;
-
-	return;
 }
arch/mips64/mm/init.c +0 -16
@@ -40,8 +40,6 @@
 
 mmu_gather_t mmu_gathers[NR_CPUS];
 
-unsigned long totalram_pages;
-
 void pgd_init(unsigned long page)
 {
 	unsigned long *p, *end;
@@ -457,18 +455,4 @@
 	}
 	printk("Freeing unused kernel memory: %ldk freed\n",
 	       (&__init_end - &__init_begin) >> 10);
-}
-
-void
-si_meminfo(struct sysinfo *val)
-{
-	val->totalram = totalram_pages;
-	val->sharedram = atomic_read(&shmem_nrpages);
-	val->freeram = nr_free_pages();
-	val->bufferram = atomic_read(&buffermem_pages);
-	val->totalhigh = 0;
-	val->freehigh = nr_free_highpages();
-	val->mem_unit = PAGE_SIZE;
-
-	return;
 }
arch/mips64/sgi-ip27/ip27-memory.c +0 -1
@@ -265,7 +265,6 @@
 {
 	extern char _stext, _etext, _fdata, _edata;
 	extern char __init_begin, __init_end;
-	extern unsigned long totalram_pages;
 	extern unsigned long setup_zero_pages(void);
 	cnodeid_t nid;
 	unsigned long tmp;
arch/parisc/mm/init.c +0 -27
@@ -20,7 +20,6 @@
 
 #include <asm/pgalloc.h>
 
-static unsigned long totalram_pages;
 extern unsigned long max_pfn, mem_max;
 
 void free_initmem(void)  {
@@ -451,29 +450,3 @@
 #endif
 }
 #endif
-
-void si_meminfo(struct sysinfo *val)
-{
-	int i;
-
-	i = max_mapnr;
-	val->totalram = totalram_pages;
-	val->sharedram = 0;
-	val->freeram = nr_free_pages();
-	val->bufferram = atomic_read(&buffermem_pages);
-#if 0
-	while (i-- > 0)  {
-		if (PageReserved(mem_map+i))
-			continue;
-		val->totalram++;
-		if (!atomic_read(&mem_map[i].count))
-			continue;
-		val->sharedram += atomic_read(&mem_map[i].count) - 1;
-	}
-	val->totalram <<= PAGE_SHIFT;
-	val->sharedram <<= PAGE_SHIFT;
-#endif
-	val->totalhigh = 0;
-	val->freehigh = 0;
-	return;
-}
arch/ppc/mm/init.c +0 -13
@@ -70,8 +70,6 @@
 int mem_init_done;
 int init_bootmem_done;
 int boot_mapsize;
-unsigned long totalram_pages;
-unsigned long totalhigh_pages;
 #ifdef CONFIG_ALL_PPC
 unsigned long agp_special_page;
 #endif
@@ -143,17 +141,6 @@
 	printk("%d pages shared\n",shared);
 	printk("%d pages swap cached\n",cached);
 	printk("%ld buffermem pages\n", nr_buffermem_pages());
-}
-
-void si_meminfo(struct sysinfo *val)
-{
-	val->totalram = totalram_pages;
-	val->sharedram = 0;
-	val->freeram = nr_free_pages();
-	val->bufferram = atomic_read(&buffermem_pages);
-	val->totalhigh = totalhigh_pages;
-	val->freehigh = nr_free_highpages();
-	val->mem_unit = PAGE_SIZE;
 }
 
 /* Free up now-unused memory */
arch/ppc64/mm/init.c +0 -12
@@ -73,7 +73,6 @@
 unsigned long ioremap_bot = IMALLOC_BASE;
 
 static int boot_mapsize;
-static unsigned long totalram_pages;
 
 extern pgd_t swapper_pg_dir[];
 extern char __init_begin, __init_end;
@@ -136,17 +135,6 @@
 	printk("%d pages shared\n",shared);
 	printk("%d pages swap cached\n",cached);
 	printk("%ld buffermem pages\n", nr_buffermem_pages());
-}
-
-void si_meminfo(struct sysinfo *val)
-{
- 	val->totalram = totalram_pages;
-	val->sharedram = 0;
-	val->freeram = nr_free_pages();
-	val->bufferram = atomic_read(&buffermem_pages);
-	val->totalhigh = 0;
-	val->freehigh = 0;
-	val->mem_unit = PAGE_SIZE;
 }
 
 void *
arch/s390/mm/init.c +0 -13
@@ -39,8 +39,6 @@
 
 mmu_gather_t mmu_gathers[NR_CPUS];
 
-static unsigned long totalram_pages;
-
 pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((__aligned__(PAGE_SIZE)));
 char  empty_zero_page[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));
 
@@ -230,14 +228,3 @@
         }
 }
 #endif
-
-void si_meminfo(struct sysinfo *val)
-{
-	val->totalram = totalram_pages;
-	val->sharedram = 0;
-	val->freeram = nr_free_pages();
-	val->bufferram = atomic_read(&buffermem_pages);
-	val->totalhigh = 0;
-	val->freehigh = 0;
-	val->mem_unit = PAGE_SIZE;
-}
arch/s390x/mm/init.c +0 -13
@@ -39,8 +39,6 @@
 
 mmu_gather_t mmu_gathers[NR_CPUS];
 
-static unsigned long totalram_pages;
-
 pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((__aligned__(PAGE_SIZE)));
 char  empty_zero_page[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));
 
@@ -242,17 +240,6 @@
 	}
 }
 #endif
-
-void si_meminfo(struct sysinfo *val)
-{
-        val->totalram = totalram_pages;
-	val->sharedram = 0;
-	val->freeram = nr_free_pages();
-	val->bufferram = atomic_read(&buffermem_pages);
-	val->totalhigh = 0;
-	val->freehigh = 0;
-	val->mem_unit = PAGE_SIZE;
-}
 
 /*
  * Overrides for Emacs so that we follow Linus's tabbing style.
arch/sh/mm/init.c +0 -15
@@ -48,9 +48,6 @@
 bootmem_data_t discontig_node_bdata[NR_NODES];
 #endif
 
-static unsigned long totalram_pages;
-static unsigned long totalhigh_pages;
-
 void show_mem(void)
 {
 	int i, total = 0, reserved = 0;
@@ -203,15 +200,3 @@
 	printk ("Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
 }
 #endif
-
-void si_meminfo(struct sysinfo *val)
-{
-	val->totalram = totalram_pages;
-	val->sharedram = 0;
-	val->freeram = nr_free_pages();
-	val->bufferram = atomic_read(&buffermem_pages);
-	val->totalhigh = totalhigh_pages;
-	val->freehigh = nr_free_highpages();
-	val->mem_unit = PAGE_SIZE;
-	return;
-}
arch/sparc/kernel/sun4d_smp.c +0 -2
@@ -63,8 +63,6 @@
 extern volatile int smp_commenced;
 extern int __smp4d_processor_id(void);
 
-extern unsigned long totalram_pages;
-
 /* #define SMP_DEBUG */
 
 #ifdef SMP_DEBUG
arch/sparc/kernel/sun4m_smp.c +0 -2
@@ -59,8 +59,6 @@
 extern volatile int smp_commenced;
 extern int __smp4m_processor_id(void);
 
-extern unsigned long totalram_pages;
-
 /*#define SMP_DEBUG*/
 
 #ifdef SMP_DEBUG
arch/sparc/mm/init.c +0 -14
@@ -55,8 +55,6 @@
 extern unsigned int sparc_ramdisk_size;
 
 unsigned long highstart_pfn, highend_pfn;
-unsigned long totalram_pages;
-unsigned long totalhigh_pages;
 
 pte_t *kmap_pte;
 pgprot_t kmap_prot;
@@ -504,18 +502,6 @@
 	}
 }
 #endif
-
-void si_meminfo(struct sysinfo *val)
-{
-	val->totalram = totalram_pages;
-	val->sharedram = 0;
-	val->freeram = nr_free_pages();
-	val->bufferram = atomic_read(&buffermem_pages);
-	val->totalhigh = totalhigh_pages;
-	val->freehigh = nr_free_highpages();
-
-	val->mem_unit = PAGE_SIZE;
-}
 
 void flush_page_to_ram(struct page *page)
 {
arch/sparc/mm/srmmu.c +0 -1
@@ -1105,7 +1105,6 @@
 extern void sparc_context_init(int);
 
 extern int linux_num_cpus;
-extern unsigned long totalhigh_pages;
 
 void (*poke_srmmu)(void) __initdata = NULL;
 
arch/sparc64/mm/init.c +0 -14
@@ -1790,17 +1790,3 @@
 	}
 }
 #endif
-
-void si_meminfo(struct sysinfo *val)
-{
-	val->totalram = num_physpages;
-	val->sharedram = 0;
-	val->freeram = nr_free_pages();
-	val->bufferram = atomic_read(&buffermem_pages);
-
-	/* These are always zero on Sparc64. */
-	val->totalhigh = 0;
-	val->freehigh = 0;
-
-	val->mem_unit = PAGE_SIZE;
-}
arch/x86_64/mm/init.c +0 -14
@@ -39,8 +39,6 @@
 
 mmu_gather_t mmu_gathers[NR_CPUS];
 
-static unsigned long totalram_pages;
-
 /*
  * NOTE: pagetable_init alloc all the fixmap pagetables contiguous on the
  * physical space so we can cache the place of the first one and move
@@ -385,15 +383,3 @@
 	}
 }
 #endif
-
-void si_meminfo(struct sysinfo *val)
-{
-	val->totalram = totalram_pages;
-	val->sharedram = 0;
-	val->freeram = nr_free_pages();
-	val->bufferram = atomic_read(&buffermem_pages);
-	val->totalhigh = 0;
-	val->freehigh = nr_free_highpages();
-	val->mem_unit = PAGE_SIZE;
-	return;
-}
include/linux/swap.h +2 -0
@@ -96,6 +96,8 @@
 /* Swap 50% full? Release swapcache more aggressively.. */
 #define vm_swap_full() (nr_swap_pages*2 < total_swap_pages)
 
+extern unsigned long totalram_pages;
+extern unsigned long totalhigh_pages;
 extern unsigned int nr_free_pages(void);
 extern unsigned int nr_free_buffer_pages(void);
 extern unsigned int nr_free_pagecache_pages(void);
mm/page_alloc.c +18 -0
@@ -23,6 +23,8 @@
 #include <linux/compiler.h>
 #include <linux/module.h>
 
+unsigned long totalram_pages;
+unsigned long totalhigh_pages;
 int nr_swap_pages;
 int nr_active_pages;
 int nr_inactive_pages;
@@ -601,6 +603,22 @@
 
 	get_page_state(&ps);
 	return ps.nr_pagecache;
+}
+
+void si_meminfo(struct sysinfo *val)
+{
+	val->totalram = totalram_pages;
+	val->sharedram = 0;
+	val->freeram = nr_free_pages();
+	val->bufferram = atomic_read(&buffermem_pages);
+#ifdef CONFIG_HIGHMEM
+	val->totalhigh = totalhigh_pages;
+	val->freehigh = nr_free_highpages();
+#else
+	val->totalhigh = 0;
+	val->freehigh = 0;
+#endif
+	val->mem_unit = PAGE_SIZE;
 }
 
 #define K(x) ((x) << (PAGE_SHIFT-10))

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/