• Andi Kleen's avatar
    x86/topology: Avoid wasting 128k for package id array · 30bb9811
    Andi Kleen authored
    Analyzing large early boot allocations unveiled the logical package id
    storage as a prominent memory waste. Since commit 1f12e32f
    ("x86/topology: Create logical package id") every 64-bit system allocates a
    128k array to convert logical package ids.
    This happens because the array is sized for MAX_LOCAL_APIC which is always
    32k on 64bit systems, and it needs 4 bytes for each entry.
    This is fairly wasteful, especially for the common case of having only one
    socket, which uses exactly 4 byte out of 128K.
    There is no user of the package id map which is performance critical, so
    the lookup is not required to be O(1). Store the logical processor id in
    cpu_data and use a loop based lookup.
    To keep the mapping stable accross cpu hotplug operations, add a flag to
    cpu_data which is set when the CPU is brought up the first time. When the
    flag is set, then cpu_data is not reinitialized by copying boot_cpu_data on
    subsequent bringups.
    [ tglx: Rename the flag to 'initialized', use proper pointers instead of
      	repeated cpu_data(x) evaluation and massage changelog. ]
    Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
    Signed-off-by: default avatarPrarit Bhargava <prarit@redhat.com>
    Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    Cc: Tom Lendacky <thomas.lendacky@amd.com>
    Cc: Christian Borntraeger <borntraeger@de.ibm.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Kan Liang <kan.liang@intel.com>
    Cc: He Chen <he.chen@linux.intel.com>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Dave Hansen <dave.hansen@intel.com>
    Cc: Piotr Luc <piotr.luc@intel.com>
    Cc: Andy Lutomirski <luto@kernel.org>
    Cc: Arvind Yadav <arvind.yadav.cs@gmail.com>
    Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
    Cc: Borislav Petkov <bp@suse.de>
    Cc: Tim Chen <tim.c.chen@linux.intel.com>
    Cc: Mathias Krause <minipli@googlemail.com>
    Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
    Link: https://lkml.kernel.org/r/20171114124257.22013-3-prarit@redhat.com
processor.h 23.4 KB