Re: [PATCH 14/14] FRV: Better mmap support in uClinux

From: Christoph Hellwig
Date: Tue Nov 02 2004 - 05:09:09 EST


> diff -uNr /warthog/kernels/linux-2.6.10-rc1-bk10/fs/proc/base.c linux-2.6.10-rc1-bk10-frv/fs/proc/base.c
> --- /warthog/kernels/linux-2.6.10-rc1-bk10/fs/proc/base.c 2004-10-27 17:32:31.000000000 +0100
> +++ linux-2.6.10-rc1-bk10-frv/fs/proc/base.c 2004-11-01 11:47:04.870656963 +0000
> @@ -220,6 +220,9 @@
>
> static int proc_exe_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt)
> {
> +#ifndef CONFIG_MMU
> + struct mm_tblock_struct *tblock;
> +#endif
> struct vm_area_struct * vma;
> int result = -ENOENT;
> struct task_struct *task = proc_task(inode);
> @@ -228,17 +231,32 @@
> if (!mm)
> goto out;
> down_read(&mm->mmap_sem);
> +
> +#ifdef CONFIG_MMU
> vma = mm->mmap;
> while (vma) {
> - if ((vma->vm_flags & VM_EXECUTABLE) &&
> - vma->vm_file) {
> - *mnt = mntget(vma->vm_file->f_vfsmnt);
> - *dentry = dget(vma->vm_file->f_dentry);
> - result = 0;
> + if ((vma->vm_flags & VM_EXECUTABLE) && vma->vm_file)
> break;
> - }
> vma = vma->vm_next;
> }
> +#else
> + tblock = mm->context.tblock;
> + vma = NULL;
> + while (tblock) {
> + if ((tblock->vma->vm_flags & VM_EXECUTABLE) && tblock->vma->vm_file) {
> + vma = tblock->vma;
> + break;
> + }
> + tblock = tblock->next;
> + }
> +#endif
> +
> + if (vma) {
> + *mnt = mntget(vma->vm_file->f_vfsmnt);
> + *dentry = dget(vma->vm_file->f_dentry);
> + result = 0;
> + }
> +
> up_read(&mm->mmap_sem);
> mmput(mm);

please split this up into a mmu and a no-mmu function, in a mmu and nommu
file respectively.

> #include <linux/pagemap.h>
> #include <linux/slab.h>
> #include <linux/vmalloc.h>
> +#include <linux/ptrace.h>
> #include <linux/blkdev.h>
> #include <linux/backing-dev.h>
> #include <linux/syscalls.h>
> @@ -38,6 +40,10 @@
> EXPORT_SYMBOL(sysctl_max_map_count);
> EXPORT_SYMBOL(mem_map);
>
> +/* list of shareable VMAs */
> +LIST_HEAD(shareable_vma_list);
> +DECLARE_RWSEM(shareable_vma_sem);

the should both be static

> + if (flags & MAP_FIXED || addr) {
> +// printk("can't do fixed-address/overlay mmap of RAM\n");

please avoid C++-style comments in core kernel code.

> diff -uNr /warthog/kernels/linux-2.6.10-rc1-bk10/mm/tiny-shmem.c linux-2.6.10-rc1-bk10-frv/mm/tiny-shmem.c
> --- /warthog/kernels/linux-2.6.10-rc1-bk10/mm/tiny-shmem.c 2004-10-27 17:32:38.000000000 +0100
> +++ linux-2.6.10-rc1-bk10-frv/mm/tiny-shmem.c 2004-11-01 14:24:49.419177784 +0000
> @@ -112,7 +112,9 @@
> if (vma->vm_file)
> fput(vma->vm_file);
> vma->vm_file = file;
> +#ifdef CONFIG_MMU
> vma->vm_ops = &generic_file_vm_ops;
> +#endif

please find a nice way to abstract this out without the ifdefs here.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/