From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: speck@linutronix.de
Subject: [MODERATED] Re: [patch V2 05/12] cpu/hotplug: Provide knob to control SMT
Date: Mon, 11 Jun 2018 17:22:05 -0400 [thread overview]
Message-ID: <20180611212205.GE25607@char.us.oracle.com> (raw)
In-Reply-To: <20180606192807.337089954@linutronix.de>
On Wed, Jun 06, 2018 at 09:27:19PM +0200, speck for Thomas Gleixner wrote:
> Subject: [patch V2 05/12] cpu/hotplug: Provide knob to control SMT
> From: Thomas Gleixner <tglx@linutronix.de>
>
> Proide a command line and a sysfs knob to control SMT.
s/Proide/Provide/
>
> Switching SMT control off, offlines all online CPUs which are secondary
> threads of a physical core and prevents onlining of secondary threads after
> that point.
>
> Switching it back on lifts the restrictions again, but does not online the
I am not sure what you mean by 'Switching it back on lifts the restrictions again'
as you said in earlier 'prevents onlining of secondary'. So that sounds like
you can't switch the CPU back on as the restriction is in place?
Oh you mean offlining a _core_ CPU and then onlining it!
Perhaps
"When offlining and onlining a core CPU the restrictions are still in effect -
that is you can't online secondary siblings' ?
[But then I am looking at the patch and you do allow it?!]
> offlined secondary siblings.
>
> It also can be set to force off, which is an irreversible operation and
s/force off/force off (aka, never allow secondary siblings to be onlined)/?
> later changes will add support for x86 to discard secondary threads in the
is it worth to say 'later changes' ? Perhaps just enumerate the name of the patches?
..snip..
> --- a/include/linux/cpu.h
> +++ b/include/linux/cpu.h
> @@ -166,4 +166,16 @@ void cpuhp_report_idle_dead(void);
> static inline void cpuhp_report_idle_dead(void) { }
> #endif /* #ifdef CONFIG_HOTPLUG_CPU */
>
> +enum {
> + CPU_SMT_ENABLED,
> + CPU_SMT_DISABLED,
> + CPU_SMT_FORCE_DISABLED,
> +};
> +
> +#if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_SMT)
> +extern int cpu_smt_control;
Could this be an named enum? We had this disaster with the ssb_something_cmd and
ssb_something mismatch - and if we ever do something similar this can at least
be nicely caught?
> +#else
> +# define cpu_smt_control (CPU_SMT_ENABLED)
> +#endif
> +
> #endif /* _LINUX_CPU_H_ */
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c
> @@ -933,6 +933,29 @@ EXPORT_SYMBOL(cpu_down);
> #define takedown_cpu NULL
> #endif /*CONFIG_HOTPLUG_CPU*/
>
> +#ifdef CONFIG_HOTPLUG_SMT
> +int cpu_smt_control __read_mostly = CPU_SMT_ENABLED;
> +
> +static int __init smt_cmdline_disable(char *str)
> +{
> + cpu_smt_control = CPU_SMT_DISABLED;
> + if (str && !strcmp(str, "force")) {
> + pr_info("SMT: Force disabled\n");
> + cpu_smt_control = CPU_SMT_FORCE_DISABLED;
> + }
> + return 0;
> +}
> +early_param("nosmt", smt_cmdline_disable);
> +
> +static inline bool cpu_smt_blocked(unsigned int cpu)
May I suggest:
cpu_smt_prohibited ?
cpu_smt_allowed ?
blocked sounds like an poll or something that returns -EBUSY whiile
this will most certainly never do that.
> +{
> + return cpu_smt_control != CPU_SMT_ENABLED &&
> + !topology_is_primary_thread(cpu);
Heck, this could even be'
cpu_smt_check
and return -EPERM?
> +}
> +#else
> +static inline bool cpu_smt_blocked(unsigned int cpu) { return false; }
> +#endif
> +
> /**
> * notify_cpu_starting(cpu) - Invoke the callbacks on the starting CPU
> * @cpu: cpu that just started
> @@ -1056,6 +1079,10 @@ static int do_cpu_up(unsigned int cpu, e
> err = -EBUSY;
> goto out;
> }
> + if (cpu_smt_blocked(cpu)) {
> + err = -EPERM;
.. which allow us to remove those '{}' but <shrugs> maybe I am overthinking it.
> + goto out;
> + }
>
> err = _cpu_up(cpu, 0, target);
> out:
> @@ -1904,10 +1931,115 @@ static const struct attribute_group cpuh
> NULL
> };
>
> +#ifdef CONFIG_HOTPLUG_SMT
> +
> +static const char *smt_states[] = {
> + "on",
> + "off",
> + "forceoff",
> +};
May I suggest we follow the same pattern as in bugs.c? That is
static const char *smt_stats[] = {
[SMT_ENABLED] = "on",
... and so on?
> +
..snip..
> +static ssize_t
> +store_smt_control(struct device *dev, struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + int val, ret;
> +
> + if (sysfs_streq(buf, "on"))
> + val = CPU_SMT_ENABLED;
> + else if (sysfs_streq(buf, "off"))
> + val = CPU_SMT_DISABLED;
> + else if (sysfs_streq(buf, "forceoff"))
> + val = CPU_SMT_FORCE_DISABLED;
> + else
> + return -EINVAL;
> +
> + if (cpu_smt_control == CPU_SMT_FORCE_DISABLED)
> + return -EPERM;
> +
> + ret = lock_device_hotplug_sysfs();
> + if (ret)
> + return ret;
> +
> + if (val != cpu_smt_control)
> + ret = val ? cpuhp_smt_disable(val) : cpuhp_smt_enable();
Just in case somebody messed up the enums would it make sense to add
BUILD_BUG_ON(CPU_SMT_ENABLED != 0);
so that this logic can still work properly? Or alterntively switch to an 'switch'
statement?
next prev parent reply other threads:[~2018-06-11 21:22 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-06 19:27 [patch V2 00/12] cpu/hotplug: SMT control Thomas Gleixner
2018-06-06 19:27 ` [patch V2 01/12] sched/smt: Update sched_smt_present at runtime Thomas Gleixner
2018-06-11 18:35 ` [MODERATED] " Konrad Rzeszutek Wilk
2018-06-15 13:17 ` Thomas Gleixner
2018-06-21 11:22 ` [MODERATED] " Peter Zijlstra
2018-06-06 19:27 ` [patch V2 02/12] x86/smp: Provide topology_is_primary_thread() Thomas Gleixner
2018-06-11 19:32 ` [MODERATED] " Konrad Rzeszutek Wilk
2018-06-11 20:15 ` Konrad Rzeszutek Wilk
2018-06-12 10:27 ` Andrew Cooper
2018-06-12 8:05 ` Thomas Gleixner
2018-06-12 10:31 ` [MODERATED] " Andrew Cooper
2018-06-12 20:02 ` Konrad Rzeszutek Wilk
2018-06-06 19:27 ` [patch V2 03/12] cpu/hotplug: Make bringup/teardown of smp threads symmetric Thomas Gleixner
2018-06-11 20:55 ` [MODERATED] " Konrad Rzeszutek Wilk
2018-06-06 19:27 ` [patch V2 04/12] cpu/hotplug: Split do_cpu_down() Thomas Gleixner
2018-06-11 20:56 ` [MODERATED] " Konrad Rzeszutek Wilk
2018-06-06 19:27 ` [patch V2 05/12] cpu/hotplug: Provide knob to control SMT Thomas Gleixner
2018-06-11 21:22 ` Konrad Rzeszutek Wilk [this message]
2018-06-20 20:00 ` [MODERATED] " Dave Hansen
2018-06-20 20:11 ` Thomas Gleixner
2018-06-20 20:25 ` [MODERATED] " Dave Hansen
2018-06-20 20:52 ` Thomas Gleixner
2018-06-06 19:27 ` [patch V2 06/12] x86/cpu: Remove the pointless CPU printout Thomas Gleixner
2018-06-11 21:23 ` [MODERATED] " Konrad Rzeszutek Wilk
2018-06-06 19:27 ` [patch V2 07/12] x86/cpu/AMD: Remove the pointless detect_ht() call Thomas Gleixner
2018-06-11 21:24 ` [MODERATED] " Konrad Rzeszutek Wilk
2018-06-06 19:27 ` [patch V2 08/12] x86/cpu/common: Provide detect_ht_early() Thomas Gleixner
2018-06-12 20:22 ` [MODERATED] " Konrad Rzeszutek Wilk
2018-06-06 19:27 ` [patch V2 09/12] x86/cpu/topology: Provide detect_extended_topology_early() Thomas Gleixner
2018-06-12 20:33 ` [MODERATED] " Konrad Rzeszutek Wilk
2018-06-06 19:27 ` [patch V2 10/12] x86/cpu/intel: Evaluate smp_num_siblings early Thomas Gleixner
2018-06-12 20:44 ` [MODERATED] " Konrad Rzeszutek Wilk
2018-06-15 14:02 ` Thomas Gleixner
2018-06-06 19:27 ` [patch V2 11/12] x86/cpu/AMD: " Thomas Gleixner
2018-06-06 19:27 ` [patch V2 12/12] x86/apic: Ignore secondary threads if nosmt=force Thomas Gleixner
2018-06-06 19:59 ` [MODERATED] " Linus Torvalds
2018-06-06 21:50 ` Thomas Gleixner
2018-06-12 20:51 ` [MODERATED] " Konrad Rzeszutek Wilk
2018-06-15 14:11 ` Thomas Gleixner
2018-06-06 23:16 ` [MODERATED] Re: [patch V2 00/12] cpu/hotplug: SMT control Andi Kleen
2018-06-07 6:50 ` Thomas Gleixner
2018-06-07 7:42 ` [MODERATED] " Jiri Kosina
2018-06-07 20:36 ` Andi Kleen
2018-06-07 20:42 ` Andi Kleen
2018-06-07 15:30 ` Konrad Rzeszutek Wilk
2018-06-07 15:43 ` Thomas Gleixner
2018-06-08 17:51 ` [MODERATED] " Josh Poimboeuf
2018-06-11 19:40 ` Jiri Kosina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180611212205.GE25607@char.us.oracle.com \
--to=konrad.wilk@oracle.com \
--cc=speck@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.