• Greg Kroah-Hartman's avatar
    device.h: reorganize struct device · 159ef31e
    Greg Kroah-Hartman authored
    struct device is big, around 760 bytes on x86_64.  It's not a critical
    structure, but it is embedded everywhere, so making it smaller is always
    a good thing.
    
    With a recent patch that moved a field from struct device to the private
    structure, some benchmarks showed a very odd regression, despite this
    structure having nothing to do with those benchmarks.  That caused me to
    look into the layout of the structure.  Using 'pahole', it showed a
    number of holes and ways that the structure could be reordered in order
    to align some cachelines better, as well as reduce the size of the
    overall structure.
    
    Move 'struct kobj' to the start of the structure, to keep that access
    in the first cacheline, and try to organize things a bit more compactly
    where possible
    
    By doing these few moves, the result removes at least 8 bytes from
    'struct device' on a 64bit system.  Given we know there are systems with
    at least 30k devices in memory at once, every little byte counts, and
    this change could be a savings of 240k of kernel memory for them.  On
    "normal" systems the overall memory savings would be much less.
    
    Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
    Cc: Johan Hovold <johan@kernel.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    159ef31e
device.h 57.3 KB