NOMMU: Fallback for is_vmalloc_or_module_addr() should be inline
Subsystems (4)
PATCH 1/4 NOMMU: Fallback for is_vmalloc_or_module_addr() should be inline
The NOMMU fallback for is_vmalloc_or_module_addr() should be static inline, not just static, in linux/mm.h.
---
include/linux/mm.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/mm.h +1 -1
@@ -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 ; }
PATCH 2/4 NOMMU: There are no pagetables for walk_page_range() in NOMMU mode
walk_page_range() can't walk the page tables in NOMMU mode, so make it unavailable in such circumstances.
---
include/linux/mm.h | 3 +++ mm/Makefile | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-)
include/linux/mm.h +3 -0
@@ -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,
mm/Makefile +2 -2
@@ -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
PATCH 3/4 NOMMU: Make it possible to get the per-task stack usage through /proc for NOMMU
In reply to David HowellsMake 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.
---
fs/proc/array.c | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-)
fs/proc/array.c +30 -0
@@ -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) {
Re: [PATCH 3/4] NOMMU: Make it possible to get the per-task stack usage through /proc for NOMMU
Quoted 11 lines · David Howells
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
Quoted 1 line
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
PATCH 4/4 NOMMU: Ignore mmap() address param as it is a hint
In reply to David HowellsIgnore 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.
---
mm/nommu.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
mm/nommu.c +4 -4
@@ -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);