Unused defines: some numbers

From: Alexey Dobriyan (adobriyan_at_gmail.com)
Date: 08/21/05

  • Next message: Patrick McHardy: "Re: 2.6.12 Performance problems"
    Date:	Mon, 22 Aug 2005 01:45:42 +0400
    To: linux-kernel@vger.kernel.org
    
    

    Inspired by LWN article "Our [desktop] bloat problem" and a comment
    about probability of finding unused prototype in kernel.

    This is purely FYI.

       version | LOC | size | nr_defines | nr_used | bloat |
                 | *.[ch] | *.[ch] | [1] | [2] | % |
    -------------+---------+-----------+------------+---------+-------+
            0.01 | 8413 | 190551 | 698 | 398 | 42.98 | [4]
             1.0 | 165165 | 4413579 | 5791 | 4472 | 22.78 |
             1.2 | 281985 | 7599324 | 10840 | 7721 | 28.77 |
             1.3 | 310545 | 8332410 | 11637 | 8303 | 28.65 |
             2.0 | 674422 | 18866984 | 23804 | 16746 | 29.65 |
    2.6.13-rc6-? | 6133558 | 180252914 | 248063 | 151492 | 38.93 | [3]

    Consider the numbers as zero-order approximation because of obvious
    flaws in this "research":

    * Once one layer of unused defines is removed, another appears
      (real bloat >= bloat).
    * Possible ## obfuscation (real bloat <= bloat).
    * _Of_course_, my regexp-fu sucks (real nr_defines != nr_defines).
    * Counting doesn't understand that
            include/asm-alpha/unistd.h: #define FUBAR 1
            include/asm-sparc/unistd.h: #define FUBAR 1
       means "unused" (real bloat >= bloat).
    * Some numbers in *.c files can be these unused defines
      (real bloat <= bloat).

    HTH to not put every single piece of hardware spec into kernel next
    time.

    P. S.: regk_iop_sw_cfg_rw_fifo_out1_extra_owner_default, no less.
    -------------------------------------------------------------------
    [1] As in

            find . -type f -name *.[ch] | \
                    xargs grep "#[\t ]*define[\t ]" | \
                    sed "s/.*#[\t ]*define[\t ]*//" | \
                    sed "s/[\t (].*//" | \
                    sort -u

    [2] "used" means

            grep $DEFINE -w -r . | wc -l >= 2

    [3] Quite recent 2.6.13-rc6-git-something. I forgot [to cat down] exact version.
    [4] Not Linus's fault ;-). Remember about __NR_*.

    -
    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: Patrick McHardy: "Re: 2.6.12 Performance problems"

    Relevant Pages

    • Re: More convenient way to grab hugepage memory
      ... > kernel, creating special cases and bloat of what you could with simple a ... glibc do transparently use hugetlb pages. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [2.6 patch] schedule obsolete OSS drivers for removal
      ... > E.g. it's clear that unused code or unused EXPORT_SYMBOL's in the kernel ... > are bloat, so I am working on eliminating such bloat. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: 2.6.11-rc1-mm2
      ... release method just so that we add an empty one and bloat the kernel. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [PATCH] 2.6 workaround for Athlon/Opteron prefetch errata
      ... But adding additional bloat ... to support non-targeted processors." ... want to have in so you don't have to build a properly configured kernel ... configures kernel for each hardware configuration. ...
      (Linux-Kernel)
    • Re: klibc and whats the next step?
      ... out kernel bloat, but here it's more important to prototype a mechanism. ... With klibc, it's trivial to share code with even fairly large ... userspace projects; furthermore it is trivial to create ...
      (Linux-Kernel)