Re: [PATCH 9/14] FRV: CONFIG_MMU fixes

From: Christoph Hellwig (hch_at_infradead.org)
Date: 11/02/04

  • Next message: Mark Watts: "[Patch] bonding.txt documentation patch"
    Date:	Tue, 2 Nov 2004 09:43:36 +0000
    To: dhowells@redhat.com
    
    

    this is a real ifdef mess, let's sort this out better (aka on file
    boundaries)

    >
    > diff -uNr /warthog/kernels/linux-2.6.10-rc1-bk10/fs/proc/kcore.c linux-2.6.10-rc1-bk10-frv/fs/proc/kcore.c
    > --- /warthog/kernels/linux-2.6.10-rc1-bk10/fs/proc/kcore.c 2004-09-16 12:06:14.000000000 +0100
    > +++ linux-2.6.10-rc1-bk10-frv/fs/proc/kcore.c 2004-11-01 11:47:04.872656796 +0000
    > @@ -344,6 +344,7 @@
    > if (m == NULL) {
    > if (clear_user(buffer, tsz))
    > return -EFAULT;
    > +#ifdef CONFIG_MMU
    > } else if ((start >= VMALLOC_START) && (start < VMALLOC_END)) {
    > char * elf_buf;
    > struct vm_struct *m;
    > @@ -389,6 +390,7 @@
    > return -EFAULT;
    > }
    > kfree(elf_buf);
    > +#endif

    move this into a helper function that can be compiled away for the !MMU case

    > --- /warthog/kernels/linux-2.6.10-rc1-bk10/fs/proc/proc_misc.c 2004-11-01 11:45:28.000000000 +0000
    > +++ linux-2.6.10-rc1-bk10-frv/fs/proc/proc_misc.c 2004-11-01 11:47:04.873656713 +0000
    > @@ -100,6 +100,7 @@
    > unsigned long largest_chunk;
    > };
    >
    > +#ifdef CONFIG_MMU
    > static struct vmalloc_info get_vmalloc_info(void)
    > {
    > unsigned long prev_end = VMALLOC_START;
    > @@ -129,6 +130,7 @@
    > read_unlock(&vmlist_lock);
    > return vmi;
    > }
    > +#endif

    move the whole function to a CONFIG_MMU-only file

    > static int uptime_read_proc(char *page, char **start, off_t off,
    > int count, int *eof, void *data)
    > @@ -176,10 +178,16 @@
    > allowed = ((totalram_pages - hugetlb_total_pages())
    > * sysctl_overcommit_ratio / 100) + total_swap_pages;
    >
    > +#ifdef CONFIG_MMU
    > vmtot = (VMALLOC_END-VMALLOC_START)>>10;
    > vmi = get_vmalloc_info();
    > vmi.used >>= 10;
    > vmi.largest_chunk >>= 10;
    > +#else
    > + vmtot = 0;
    > + vmi.used = 0;
    > + vmi.largest_chunk = 0;
    > +#endif

    add a small helper for this. In fact it's the only caller of get_vmalloc_info,
    so that could be merged into the helper, ala:

    void get_vmalloc_info(struct vmalloc_info vmi *vmi)
    {
            /* contents of old get_vmalloc_info here */
            vmi->used = 0;
            vmi->largest_chunk = 0;
            }
    }

    and define both VMALLOC_START and VMALLOC_END to 0 for !MMU

    > --- /warthog/kernels/linux-2.6.10-rc1-bk10/include/linux/mm.h 2004-11-01 11:45:33.371274107 +0000
    > +++ linux-2.6.10-rc1-bk10-frv/include/linux/mm.h 2004-11-01 14:16:26.408497251 +0000
    > @@ -58,6 +58,7 @@
    > * space that has a special rule for the page-fault handlers (ie a shared
    > * library, the executable area etc).
    > */
    > +#ifdef CONFIG_MMU
    > struct vm_area_struct {
    > struct mm_struct * vm_mm; /* The address space we belong to. */
    > unsigned long vm_start; /* Our start address within vm_mm. */
    > @@ -658,12 +688,14 @@

    you're missing an endif.

    > for (prio_tree_iter_init(iter, root, begin, end), vma = NULL; \
    > (vma = vma_prio_tree_next(vma, iter)); )
    >
    > +#ifdef CONFIG_MMU
    > static inline void vma_nonlinear_insert(struct vm_area_struct *vma,
    > struct list_head *list)
    > {
    > vma->shared.vm_set.parent = NULL;
    > list_add_tail(&vma->shared.vm_set.list, list);
    > }
    > +#endif

    I's day just move this out of line into a MMU-only file.

    > /* mmap.c */
    > extern void vma_adjust(struct vm_area_struct *vma, unsigned long start,
    > @@ -780,6 +812,7 @@
    > }
    > #endif /* CONFIG_PROC_FS */
    >
    > +#ifdef CONFIG_MMU
    > static inline void vm_stat_account(struct vm_area_struct *vma)
    > {
    > __vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
    > @@ -791,6 +824,7 @@
    > __vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
    > -vma_pages(vma));
    > }
    > +#endif

    or at least keep a single MMU ifdef block per file

    > +#ifdef CONFIG_MMU
    > pgtable_cache_init();
    > prio_tree_init();
    > +#endif

    provide stubs please. pgtable_cache_init is a per-arch things anyway.

    > diff -uNr /warthog/kernels/linux-2.6.10-rc1-bk10/kernel/sysctl.c linux-2.6.10-rc1-bk10-frv/kernel/sysctl.c
    > --- /warthog/kernels/linux-2.6.10-rc1-bk10/kernel/sysctl.c 2004-11-01 11:45:34.879148578 +0000
    > +++ linux-2.6.10-rc1-bk10-frv/kernel/sysctl.c 2004-11-01 11:47:05.181631075 +0000
    > @@ -755,6 +755,7 @@
    > .strategy = &sysctl_intvec,
    > .extra1 = &zero,
    > },
    > +#ifdef CONFIG_MMU
    > {
    > .ctl_name = VM_MAX_MAP_COUNT,
    > .procname = "max_map_count",
    > @@ -763,6 +764,7 @@
    > .mode = 0644,
    > .proc_handler = &proc_dointvec
    > },
    > +#endif

    just move the whole systctl registration into a MMU-only file

    also please split this patch up into individual, small ones
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/


  • Next message: Mark Watts: "[Patch] bonding.txt documentation patch"

    Relevant Pages