lkml.org 
[lkml]   [2006]   [Nov]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 1/4] [x86] Add command line option to enable/disable hyper-threading.
    Date
    This patch adds a config option to allow disabling hyper-threading by
    default, and a kernel command line option to changes this default at
    boot time.

    Signed-off-by: Ben Collins <bcollins@ubuntu.com>
    ---
    Documentation/kernel-parameters.txt | 3 +++
    arch/i386/Kconfig | 5 +++++
    arch/i386/kernel/cpu/common.c | 29 +++++++++++++++++++++++++++++
    3 files changed, 37 insertions(+), 0 deletions(-)

    diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
    index 6747384..2b68d6e 100644
    --- a/Documentation/kernel-parameters.txt
    +++ b/Documentation/kernel-parameters.txt
    @@ -600,6 +600,9 @@ and is between 256 and 4096 characters.
    hisax= [HW,ISDN]
    See Documentation/isdn/README.HiSax.

    + ht= [HW,IA-32,SMP] Enable or disable hyper-threading.
    + Format: <on|off>
    +
    hugepages= [HW,IA-32,IA-64] Maximal number of HugeTLB pages.

    noirqbalance [IA-32,SMP,KNL] Disable kernel irq balancing
    diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
    index 8ff1c6f..b4a2461 100644
    --- a/arch/i386/Kconfig
    +++ b/arch/i386/Kconfig
    @@ -1185,6 +1185,11 @@ config X86_HT
    depends on SMP && !(X86_VISWS || X86_VOYAGER)
    default y

    +config X86_HT_DISABLE
    + bool "Disable Hyper-Threading by default"
    + depends on X86_HT
    + default n
    +
    config X86_BIOS_REBOOT
    bool
    depends on !(X86_VISWS || X86_VOYAGER)
    diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c
    index d9f3e3c..42d2361 100644
    --- a/arch/i386/kernel/cpu/common.c
    +++ b/arch/i386/kernel/cpu/common.c
    @@ -482,6 +482,29 @@ void __cpuinit identify_cpu(struct cpuin
    }

    #ifdef CONFIG_X86_HT
    +
    +#ifdef CONFIG_X86_HT_DISABLE
    +static int disable_ht __cpuinitdata = 1;
    +#else
    +static int disable_ht __cpuinitdata;
    +#endif
    +
    +static int __init parse_ht(char *arg)
    +{
    + if (!arg)
    + return -EINVAL;
    +
    + if (!memcmp(arg, "on", 2))
    + disable_ht = 0;
    + else if (!memcmp(arg, "off", 3))
    + disable_ht = 1;
    + else
    + return -EINVAL;
    +
    + return 0;
    +}
    +early_param("ht", parse_ht);
    +
    void __cpuinit detect_ht(struct cpuinfo_x86 *c)
    {
    u32 eax, ebx, ecx, edx;
    @@ -492,6 +515,12 @@ void __cpuinit detect_ht(struct cpuinfo_
    if (!cpu_has(c, X86_FEATURE_HT) || cpu_has(c, X86_FEATURE_CMP_LEGACY))
    return;

    + if (disable_ht) {
    + printk(KERN_INFO "CPU: Hyper-Threading disabled by default. Enable with ht=on\n");
    + smp_num_siblings = 1;
    + return;
    + }
    +
    smp_num_siblings = (ebx & 0xff0000) >> 16;

    if (smp_num_siblings == 1) {
    --
    1.4.1
    -
    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/

    \
     
     \ /
      Last update: 2006-11-30 05:31    [W:0.024 / U:33.568 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site