Re: [PATCH -tip] x86: kdebugfs.c cleanup

From: Ingo Molnar
Date: Sun Mar 15 2009 - 00:55:32 EST



* Li Zefan <lizf@xxxxxxxxxxxxxx> wrote:

> > #include <linux/debugfs.h>
> > #include <linux/uaccess.h>
> > -#include <linux/stat.h>
> > +#include <linux/module.h>
> > #include <linux/init.h>
> > +#include <linux/stat.h>
> > #include <linux/io.h>
> > #include <linux/mm.h>
> > -#include <linux/module.h>
> >
>
> Just curious about the rule to sort those includes, and why they need
> to be rearranged.

Such includes (the 'reverse christmas tree'):

#include <linux/interrupt.h>
#include <linux/mmiotrace.h>
#include <linux/bootmem.h>
#include <linux/compiler.h>
#include <linux/highmem.h>
#include <linux/kprobes.h>
#include <linux/uaccess.h>
#include <linux/vmalloc.h>
#include <linux/vt_kern.h>
#include <linux/signal.h>
#include <linux/kernel.h>
#include <linux/ptrace.h>
#include <linux/string.h>
#include <linux/module.h>
#include <linux/kdebug.h>
#include <linux/errno.h>
#include <linux/magic.h>
#include <linux/sched.h>
#include <linux/types.h>
#include <linux/init.h>
#include <linux/mman.h>
#include <linux/tty.h>
#include <linux/smp.h>
#include <linux/mm.h>

#include <asm/kmemcheck.h>
#include <asm/tlbflush.h>
#include <asm/pgalloc.h>
#include <asm/segment.h>
#include <asm/system.h>
#include <asm/proto.h>
#include <asm/traps.h>
#include <asm/desc.h>

are used by x86 architecture code (and some other subsystems) to
reduce the likelyhood of patch conflicts in commonly modified
kernel files.

Without such ordering developers typically append to the
existing list of include files when introducing a new header -
creating an almost certain patch conflict. Via the above
ordering, new headers get distributed roughly evenly amongst the
full range - and thus the chance of patch conflicts is much
smaller.

This way it also looks a bit more structured and bit less messy.
It looks unprofessional and sloppy if a .c file starts with a
big block of thrown-together include files.

Ingo
--
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/