Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 16 Jun 2018 14:06:04 -0000 Received: from mx2.suse.de ([195.135.220.15]) by Galois.linutronix.de with esmtps (TLS1.0:DHE_RSA_CAMELLIA_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1fUBq4-0002Pe-KM for speck@linutronix.de; Sat, 16 Jun 2018 16:06:03 +0200 Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 30A96AEB6 for ; Sat, 16 Jun 2018 14:05:54 +0000 (UTC) Date: Sat, 16 Jun 2018 16:05:49 +0200 From: Borislav Petkov Subject: [MODERATED] Re: [patch V3 05/12] cpu/hotplug: Provide knobs to control SMT Message-ID: <20180616140548.GB31768@zn.tnic> References: <20180615162801.748896789@linutronix.de> <20180615162947.853265505@linutronix.de> MIME-Version: 1.0 In-Reply-To: <20180615162947.853265505@linutronix.de> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable To: speck@linutronix.de List-ID: Just nitpicks: On Fri, Jun 15, 2018 at 06:28:06PM +0200, speck for Thomas Gleixner wrote: > Subject: [patch V3 05/12] cpu/hotplug: Provide knobs to control SMT > From: Thomas Gleixner >=20 > Provide a command line and a sysfs knob to control SMT. ... > --- a/kernel/cpu.c > +++ b/kernel/cpu.c > @@ -933,6 +933,29 @@ EXPORT_SYMBOL(cpu_down); > #define takedown_cpu NULL > #endif /*CONFIG_HOTPLUG_CPU*/ > =20 > +#ifdef CONFIG_HOTPLUG_SMT > +enum cpuhp_smt_control cpu_smt_control __read_mostly =3D CPU_SMT_ENABLED; > + > +static int __init smt_cmdline_disable(char *str) > +{ > + cpu_smt_control =3D CPU_SMT_DISABLED; > + if (str && !strcmp(str, "force")) { > + pr_info("SMT: Force disabled\n"); Maybe check if SMT is even supported on the system, if at all possible that early, before even doing anything here... > + cpu_smt_control =3D CPU_SMT_FORCE_DISABLED; > + } > + return 0; > +} > +early_param("nosmt", smt_cmdline_disable); ... > +static int cpuhp_smt_enable(void) > +{ > + cpu_maps_update_begin(); > + cpu_smt_control =3D CPU_SMT_ENABLED; > + cpu_maps_update_done(); > + return 0; > +} That can be void. > + > +static ssize_t > +store_smt_control(struct device *dev, struct device_attribute *attr, > + const char *buf, size_t count) > +{ > + int ctrlval, ret; > + > + if (sysfs_streq(buf, "on")) > + ctrlval =3D CPU_SMT_ENABLED; > + else if (sysfs_streq(buf, "off")) > + ctrlval =3D CPU_SMT_DISABLED; > + else if (sysfs_streq(buf, "forceoff")) > + ctrlval =3D CPU_SMT_FORCE_DISABLED; > + else > + return -EINVAL; > + > + if (cpu_smt_control =3D=3D CPU_SMT_FORCE_DISABLED) > + return -EPERM; You could do that as the first thing when entering this function. > + > + ret =3D lock_device_hotplug_sysfs(); > + if (ret) > + return ret; > + > + if (ctrlval !=3D cpu_smt_control) { > + switch (ctrlval) { > + case CPU_SMT_ENABLED: > + ret =3D cpuhp_smt_enable(); > + break; > + case CPU_SMT_DISABLED: > + case CPU_SMT_FORCE_DISABLED: > + ret =3D cpuhp_smt_disable(ctrlval); > + break; > + } > + } > + > + unlock_device_hotplug(); > + return ret ? ret : count; > +} > +static DEVICE_ATTR(control, 0644, show_smt_control, store_smt_control); --=20 Regards/Gruss, Boris. SUSE Linux GmbH, GF: Felix Imend=C3=B6rffer, Jane Smithard, Graham Norton, HR= B 21284 (AG N=C3=BCrnberg) --=20