Skip to contentSkip to conversation

proc: switch /proc/meminfo to seq_file

PATCH In review Alexey Dobriyan 1 participant 1 message Oct 17, 2008

Subsystems (6)
Memory management x86 MM core x86 MM +2 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 3/31 proc: switch /proc/meminfo to seq_file

Quoted 2 lines

From 98d49f1a800ef6599eeeaaf49ff5827798055080 Mon Sep 17 00:00:00 2001

From: Alexey Dobriyan <[email protected]>
Date: Wed, 15 Oct 2008 23:50:22 +0400
Subject: [PATCH 03/31] proc: switch /proc/meminfo to seq_file

and move it to fs/proc/meminfo.c while I'm at it.

---
 arch/x86/mm/pageattr.c    |   11 ++--
 fs/proc/Makefile          |    1 +
 fs/proc/meminfo.c         |  147 +++++++++++++++++++++++++++++++++++++++++++++
 fs/proc/proc_misc.c       |  116 -----------------------------------
 include/asm-x86/pgtable.h |    3 +-
 include/linux/hugetlb.h   |    6 +-
 mm/hugetlb.c              |    5 +-
 7 files changed, 162 insertions(+), 127 deletions(-)
 create mode 100644 fs/proc/meminfo.c
arch/x86/mm/pageattr.c +5 -6
index a9ec89c..f782a27 100644
@@ -65,23 +65,22 @@ static void split_page_count(int level)
 	direct_pages_count[level - 1] += PTRS_PER_PTE;
 }
 
-int arch_report_meminfo(char *page)
+void arch_report_meminfo(struct seq_file *m)
 {
-	int n = sprintf(page, "DirectMap4k:  %8lu kB\n",
+	seq_printf(m, "DirectMap4k:  %8lu kB\n",
 			direct_pages_count[PG_LEVEL_4K] << 2);
 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
-	n += sprintf(page + n, "DirectMap2M:  %8lu kB\n",
+	seq_printf(m, "DirectMap2M:  %8lu kB\n",
 			direct_pages_count[PG_LEVEL_2M] << 11);
 #else
-	n += sprintf(page + n, "DirectMap4M:  %8lu kB\n",
+	seq_printf(m, "DirectMap4M:  %8lu kB\n",
 			direct_pages_count[PG_LEVEL_2M] << 12);
 #endif
 #ifdef CONFIG_X86_64
 	if (direct_gbpages)
-		n += sprintf(page + n, "DirectMap1G:  %8lu kB\n",
+		seq_printf(m, "DirectMap1G:  %8lu kB\n",
 			direct_pages_count[PG_LEVEL_1G] << 20);
 #endif
-	return n;
 }
 #else
 static inline void split_page_count(int level) { }
fs/proc/Makefile +1 -0
index 27efa14..70607a0 100644
@@ -10,6 +10,7 @@ proc-$(CONFIG_MMU)	:= mmu.o task_mmu.o
 proc-y       += inode.o root.o base.o generic.o array.o \
 		proc_tty.o proc_misc.o
 proc-y	+= loadavg.o
+proc-y	+= meminfo.o
 proc-y	+= uptime.o
 proc-$(CONFIG_PROC_SYSCTL)	+= proc_sysctl.o
 proc-$(CONFIG_NET)		+= proc_net.o
fs/proc/meminfo.c new file +147 -0

147 lines not on this page · raw message

fs/proc/proc_misc.c +0 -116

128 lines not on this page · raw message

include/asm-x86/pgtable.h +2 -1
index 88a53b1..a3dda6d 100644
@@ -348,7 +348,8 @@ static inline void native_pagetable_setup_start(pgd_t *base) {}
 static inline void native_pagetable_setup_done(pgd_t *base) {}
 #endif
 
-extern int arch_report_meminfo(char *page);
+struct seq_file;
+extern void arch_report_meminfo(struct seq_file *m);
 
 #ifdef CONFIG_PARAVIRT
 #include <asm/paravirt.h>
include/linux/hugetlb.h +4 -2
index 32e0ef0..e1c8afc 100644
@@ -27,7 +27,7 @@ void unmap_hugepage_range(struct vm_area_struct *,
 void __unmap_hugepage_range(struct vm_area_struct *,
 			unsigned long, unsigned long, struct page *);
 int hugetlb_prefault(struct address_space *, struct vm_area_struct *);
-int hugetlb_report_meminfo(char *);
+void hugetlb_report_meminfo(struct seq_file *);
 int hugetlb_report_node_meminfo(int, char *);
 unsigned long hugetlb_total_pages(void);
 int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
@@ -79,7 +79,9 @@ static inline unsigned long hugetlb_total_pages(void)
 #define copy_hugetlb_page_range(src, dst, vma)	({ BUG(); 0; })
 #define hugetlb_prefault(mapping, vma)		({ BUG(); 0; })
 #define unmap_hugepage_range(vma, start, end, page)	BUG()
-#define hugetlb_report_meminfo(buf)		0
+static inline void hugetlb_report_meminfo(struct seq_file *m)
+{
+}
 #define hugetlb_report_node_meminfo(n, buf)	0
 #define follow_huge_pmd(mm, addr, pmd, write)	NULL
 #define follow_huge_pud(mm, addr, pud, write)	NULL
mm/hugetlb.c +3 -2
index 3863386..85ade11 100644
@@ -7,6 +7,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/mm.h>
+#include <linux/seq_file.h>
 #include <linux/sysctl.h>
 #include <linux/highmem.h>
 #include <linux/mmu_notifier.h>
@@ -1455,10 +1456,10 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
 
 #endif /* CONFIG_SYSCTL */
 
-int hugetlb_report_meminfo(char *buf)
+void hugetlb_report_meminfo(struct seq_file *m)
 {
 	struct hstate *h = &default_hstate;
-	return sprintf(buf,
+	seq_printf(m,
 			"HugePages_Total: %5lu\n"
 			"HugePages_Free:  %5lu\n"
 			"HugePages_Rsvd:  %5lu\n"
Signature · 1 line
1.5.6.5