[lkml]   [2001]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: optimize DNAME_INLINE_LEN
    On Dec 13, 2001  23:22 +0100, Manfred Spraul wrote:
    > The dcache entries are allocated with SLAB_HWCACHE_ALIGN. For better
    > memory usage, we should increase DNAME_INLINE_LEN so that sizeof(struct
    > dentry) becomes a multiple of the L1 cache line size.
    > On i386 the DNAME_INLINE_LEN becomes 36 bytes instead of 16, which saves
    > thousands of kmallocs for external file names. (12818 on my debug
    > system, after updatedb)

    If the dentries are already aligned on cachelines, I don't see any reason
    NOT to do this. Why waste all the memory for alignment when it can be
    used for something else?

    > The attached patch is preliminary, it doesn't compile with egcs-1.1.2.
    > Which gcc version added support for unnamed structures?

    Hmm, I thought it was gcc 3.0 that supported unnames structures. For
    sure gcc 2.95.2 does not, because unnamed structs are used in the NTFS
    tools, and I couldn't compile them.

    If you wanted to keep compatibility for older compilers (may be a good idea)
    you could do something ugly like using a named struct like "du" and then:

    #define d_inode du.du_inode
    #define d_count du.du_count
    #define d_fsdata du.du_fsdata

    Alternately (also ugly) you could just define struct dentry the as now,
    but have a fixed size declaration for d_iname, like:

    #define DNAME_INLINE_MIN 16

    unsigned char d_iname[DNAME_INLINE_MIN];

    and only set DNAME_INLINE_LEN afterwards like:

    #define DNAME_INLINE_LEN \
    (DNAME_INLINE_MIN+L1_CACHE_BYTES - sizeof(struct dentry)%L1_CACHE_BYTES)

    This _should_ work for all code that uses DNAME_INLINE_LEN, and if the
    alignment doesn't change. It will break horribly if you do sizeof(struct
    dentry), declare a dentry on the stack, or if someone changes the alignment.

    You can also do preprocessor macro tricks to get something like an unnamed
    union in a struct, but it is also a bit ugly.

    Cheers, Andreas
    Andreas Dilger

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:14    [W:0.026 / U:14.604 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site