public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] NOMMU: Fallback for is_vmalloc_or_module_addr() should be inline
@ 2009-09-24 11:33 David Howells
  2009-09-24 11:33 ` [PATCH 2/4] NOMMU: There are no pagetables for walk_page_range() in NOMMU mode David Howells
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: David Howells @ 2009-09-24 11:33 UTC (permalink / raw)
  To: torvalds, akpm; +Cc: linux-kernel, David Howells

The NOMMU fallback for is_vmalloc_or_module_addr() should be static inline,
not just static, in linux/mm.h.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 include/linux/mm.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/include/linux/mm.h b/include/linux/mm.h
index b6eae5e..23e7fd6 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -288,7 +288,7 @@ static inline int is_vmalloc_addr(const void *x)
 #ifdef CONFIG_MMU
 extern int is_vmalloc_or_module_addr(const void *x);
 #else
-static int is_vmalloc_or_module_addr(const void *x)
+static inline int is_vmalloc_or_module_addr(const void *x)
 {
 	return 0;
 }


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] NOMMU: There are no pagetables for walk_page_range() in NOMMU mode
  2009-09-24 11:33 [PATCH 1/4] NOMMU: Fallback for is_vmalloc_or_module_addr() should be inline David Howells
@ 2009-09-24 11:33 ` David Howells
  2009-09-24 11:33 ` [PATCH 3/4] NOMMU: Make it possible to get the per-task stack usage through /proc for NOMMU David Howells
  2009-09-24 11:33 ` [PATCH 4/4] NOMMU: Ignore mmap() address param as it is a hint David Howells
  2 siblings, 0 replies; 5+ messages in thread
From: David Howells @ 2009-09-24 11:33 UTC (permalink / raw)
  To: torvalds, akpm; +Cc: linux-kernel, David Howells

walk_page_range() can't walk the page tables in NOMMU mode, so make it
unavailable in such circumstances.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 include/linux/mm.h |    3 +++
 mm/Makefile        |    4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)


diff --git a/include/linux/mm.h b/include/linux/mm.h
index 23e7fd6..17dc39f 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -750,6 +750,7 @@ unsigned long unmap_vmas(struct mmu_gather **tlb,
 		unsigned long end_addr, unsigned long *nr_accounted,
 		struct zap_details *);
 
+#ifdef CONFIG_MMU
 /**
  * mm_walk - callbacks for walk_page_range
  * @pgd_entry: if set, called for each non-empty PGD (top-level) entry
@@ -772,6 +773,8 @@ struct mm_walk {
 
 int walk_page_range(unsigned long addr, unsigned long end,
 		struct mm_walk *walk);
+#endif
+
 void free_pgd_range(struct mmu_gather *tlb, unsigned long addr,
 		unsigned long end, unsigned long floor, unsigned long ceiling);
 int copy_page_range(struct mm_struct *dst, struct mm_struct *src,
diff --git a/mm/Makefile b/mm/Makefile
index 88193d7..5ac31a1 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -5,14 +5,14 @@
 mmu-y			:= nommu.o
 mmu-$(CONFIG_MMU)	:= fremap.o highmem.o madvise.o memory.o mincore.o \
 			   mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \
-			   vmalloc.o
+			   vmalloc.o pagewalk.o
 
 obj-y			:= bootmem.o filemap.o mempool.o oom_kill.o fadvise.o \
 			   maccess.o page_alloc.o page-writeback.o \
 			   readahead.o swap.o truncate.o vmscan.o shmem.o \
 			   prio_tree.o util.o mmzone.o vmstat.o backing-dev.o \
 			   page_isolation.o mm_init.o mmu_context.o \
-			   pagewalk.o $(mmu-y)
+			   $(mmu-y)
 obj-y += init-mm.o
 
 obj-$(CONFIG_BOUNCE)	+= bounce.o


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] NOMMU: Make it possible to get the per-task stack usage through /proc for NOMMU
  2009-09-24 11:33 [PATCH 1/4] NOMMU: Fallback for is_vmalloc_or_module_addr() should be inline David Howells
  2009-09-24 11:33 ` [PATCH 2/4] NOMMU: There are no pagetables for walk_page_range() in NOMMU mode David Howells
@ 2009-09-24 11:33 ` David Howells
  2009-09-24 17:20   ` David Howells
  2009-09-24 11:33 ` [PATCH 4/4] NOMMU: Ignore mmap() address param as it is a hint David Howells
  2 siblings, 1 reply; 5+ messages in thread
From: David Howells @ 2009-09-24 11:33 UTC (permalink / raw)
  To: torvalds, akpm
  Cc: linux-kernel, David Howells, Mike Frysinger, Paul Mundt,
	Robin Getz

Make it possible to get the per-task stack usage through /proc on a NOMMU
system.  This is required because walk_page_range() doesn't work on NOMMU.

	# grep "Stack usage:" /proc/*/status
	/proc/1/status:Stack usage:	2 kB
	/proc/56/status:Stack usage:	2 kB
	/proc/57/status:Stack usage:	1 kB
	/proc/58/status:Stack usage:	2 kB
	/proc/59/status:Stack usage:	5 kB
	/proc/self/status:Stack usage:	1 kB

I've only tested it with ELF-FDPIC, though it should work with FLAT too.

Signed-off-by: David Howells <dhowells@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Robin Getz <rgetz@blackfin.uclinux.org>
---

 fs/proc/array.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)


diff --git a/fs/proc/array.c b/fs/proc/array.c
index 0c6bc60..4b8f9e5 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -328,6 +328,7 @@ struct stack_stats {
 	unsigned long	usage;
 };
 
+#ifdef CONFIG_MMU
 static int stack_usage_pte_range(pmd_t *pmd, unsigned long addr,
 				unsigned long end, struct mm_walk *walk)
 {
@@ -403,6 +404,35 @@ static inline void task_show_stack_usage(struct seq_file *m,
 	}
 }
 
+#else /* CONFIG_MMU */
+
+/*
+ * Calculate the size of a NOMMU process's stack
+ */
+static void task_show_stack_usage(struct seq_file *m, struct task_struct *task)
+{
+	struct mm_struct *mm = get_task_mm(task);
+	unsigned long sp, base, limit, size;
+
+	if (mm) {
+		down_read(&mm->mmap_sem);
+
+		/* we assume the stack grows down towards the brk point */
+		sp = KSTK_ESP(task);
+		base = roundup(mm->arg_start, sizeof(long));
+		limit = mm->context.end_brk;
+		up_read(&mm->mmap_sem);
+		mmput(mm);
+
+		if (limit <= sp && sp <= base)
+			size = base - sp;
+		else
+			size = base - limit;
+		seq_printf(m, "Stack usage:\t%lu kB\n", (size + 1023) >> 10);
+	}
+}
+#endif /* CONFIG_MMU */
+
 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
 			struct pid *pid, struct task_struct *task)
 {


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] NOMMU: Ignore mmap() address param as it is a hint
  2009-09-24 11:33 [PATCH 1/4] NOMMU: Fallback for is_vmalloc_or_module_addr() should be inline David Howells
  2009-09-24 11:33 ` [PATCH 2/4] NOMMU: There are no pagetables for walk_page_range() in NOMMU mode David Howells
  2009-09-24 11:33 ` [PATCH 3/4] NOMMU: Make it possible to get the per-task stack usage through /proc for NOMMU David Howells
@ 2009-09-24 11:33 ` David Howells
  2 siblings, 0 replies; 5+ messages in thread
From: David Howells @ 2009-09-24 11:33 UTC (permalink / raw)
  To: torvalds, akpm; +Cc: linux-kernel, David Howells

Ignore the address parameter given to NOMMU mmap() as it is a hint, rather
than giving an error if it's non-zero.  MAP_FIXED still gets an error.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 mm/nommu.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)


diff --git a/mm/nommu.c b/mm/nommu.c
index bd94b5a..62ac312 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -866,7 +866,7 @@ static int validate_mmap_request(struct file *file,
 	int ret;
 
 	/* do the simple checks first */
-	if (flags & MAP_FIXED || addr) {
+	if (flags & MAP_FIXED) {
 		printk(KERN_DEBUG
 		       "%d: Can't do fixed-address/overlay mmap of RAM\n",
 		       current->pid);
@@ -1223,9 +1223,6 @@ unsigned long do_mmap_pgoff(struct file *file,
 
 	kenter(",%lx,%lx,%lx,%lx,%lx", addr, len, prot, flags, pgoff);
 
-	if (!(flags & MAP_FIXED))
-		addr = round_hint_to_min(addr);
-
 	/* decide whether we should attempt the mapping, and if so what sort of
 	 * mapping */
 	ret = validate_mmap_request(file, addr, len, prot, flags, pgoff,
@@ -1235,6 +1232,9 @@ unsigned long do_mmap_pgoff(struct file *file,
 		return ret;
 	}
 
+	/* we ignore the address hint */
+	addr = 0;
+
 	/* we've determined that we can make the mapping, now translate what we
 	 * now know into VMA flags */
 	vm_flags = determine_vm_flags(file, prot, flags, capabilities);


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/4] NOMMU: Make it possible to get the per-task stack usage through /proc for NOMMU
  2009-09-24 11:33 ` [PATCH 3/4] NOMMU: Make it possible to get the per-task stack usage through /proc for NOMMU David Howells
@ 2009-09-24 17:20   ` David Howells
  0 siblings, 0 replies; 5+ messages in thread
From: David Howells @ 2009-09-24 17:20 UTC (permalink / raw)
  Cc: dhowells, torvalds, akpm, linux-kernel, Mike Frysinger,
	Paul Mundt, Robin Getz

David Howells <dhowells@redhat.com> wrote:

> Make it possible to get the per-task stack usage through /proc on a NOMMU
> system.  This is required because walk_page_range() doesn't work on NOMMU.
> 
> 	# grep "Stack usage:" /proc/*/status
> 	/proc/1/status:Stack usage:	2 kB
> 	/proc/56/status:Stack usage:	2 kB
> 	/proc/57/status:Stack usage:	1 kB
> 	/proc/58/status:Stack usage:	2 kB
> 	/proc/59/status:Stack usage:	5 kB
> 	/proc/self/status:Stack usage:	1 kB
> 
> I've only tested it with ELF-FDPIC, though it should work with FLAT too.

Ignore this patch, please.  It only works for single-threaded processes.

David

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-09-24 17:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-24 11:33 [PATCH 1/4] NOMMU: Fallback for is_vmalloc_or_module_addr() should be inline David Howells
2009-09-24 11:33 ` [PATCH 2/4] NOMMU: There are no pagetables for walk_page_range() in NOMMU mode David Howells
2009-09-24 11:33 ` [PATCH 3/4] NOMMU: Make it possible to get the per-task stack usage through /proc for NOMMU David Howells
2009-09-24 17:20   ` David Howells
2009-09-24 11:33 ` [PATCH 4/4] NOMMU: Ignore mmap() address param as it is a hint David Howells

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox