From: Daniel Jordan <daniel.m.jordan-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: Alexey Klimov <aklimov-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org,
yury.norov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org,
jobaker-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
audralmitchel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
arnd-r2nGTMty4D4@public.gmane.org,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org,
rafael-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
qais.yousef-5wv7dgnIgG8@public.gmane.org,
hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org,
klimov.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH v2] cpu/hotplug: wait for cpuset_hotplug_work to finish on cpu onlining
Date: Fri, 12 Feb 2021 14:41:58 -0500 [thread overview]
Message-ID: <87tuqhrs3d.fsf@oracle.com> (raw)
In-Reply-To: <20210212003032.2037750-1-aklimov-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Alexey Klimov <aklimov-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> writes:
> int cpu_device_up(struct device *dev)
Yeah, definitely better to do the wait here.
> int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)
> {
> - int cpu, ret = 0;
> + struct device *dev;
> + cpumask_var_t mask;
> + int cpu, ret;
> +
> + if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
> + return -ENOMEM;
>
> + ret = 0;
> cpu_maps_update_begin();
> for_each_online_cpu(cpu) {
> if (topology_is_primary_thread(cpu))
> @@ -2099,18 +2098,35 @@ int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)
> * called under the sysfs hotplug lock, so it is properly
> * serialized against the regular offline usage.
> */
> - cpuhp_offline_cpu_device(cpu);
> + dev = get_cpu_device(cpu);
> + dev->offline = true;
> +
> + cpumask_set_cpu(cpu, mask);
> }
> if (!ret)
> cpu_smt_control = ctrlval;
> cpu_maps_update_done();
> +
> + /* Tell user space about the state changes */
> + for_each_cpu(cpu, mask) {
> + dev = get_cpu_device(cpu);
> + kobject_uevent(&dev->kobj, KOBJ_OFFLINE);
> + }
> +
> + free_cpumask_var(mask);
> return ret;
> }
Hrm, should the dev manipulation be kept in one place, something like
this?
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 8817ccdc8e112..aa21219a7b7c4 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -2085,11 +2085,20 @@ int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)
ret = cpu_down_maps_locked(cpu, CPUHP_OFFLINE);
if (ret)
break;
+
+ cpumask_set_cpu(cpu, mask);
+ }
+ if (!ret)
+ cpu_smt_control = ctrlval;
+ cpu_maps_update_done();
+
+ /* Tell user space about the state changes */
+ for_each_cpu(cpu, mask) {
/*
- * As this needs to hold the cpu maps lock it's impossible
+ * When the cpu maps lock was taken above it was impossible
* to call device_offline() because that ends up calling
* cpu_down() which takes cpu maps lock. cpu maps lock
- * needs to be held as this might race against in kernel
+ * needed to be held as this might race against in kernel
* abusers of the hotplug machinery (thermal management).
*
* So nothing would update device:offline state. That would
@@ -2100,16 +2109,6 @@ int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)
*/
dev = get_cpu_device(cpu);
dev->offline = true;
-
- cpumask_set_cpu(cpu, mask);
- }
- if (!ret)
- cpu_smt_control = ctrlval;
- cpu_maps_update_done();
-
- /* Tell user space about the state changes */
- for_each_cpu(cpu, mask) {
- dev = get_cpu_device(cpu);
kobject_uevent(&dev->kobj, KOBJ_OFFLINE);
}
@@ -2136,9 +2135,6 @@ int cpuhp_smt_enable(void)
ret = _cpu_up(cpu, 0, CPUHP_ONLINE);
if (ret)
break;
- /* See comment in cpuhp_smt_disable() */
- dev = get_cpu_device(cpu);
- dev->offline = false;
cpumask_set_cpu(cpu, mask);
}
@@ -2152,7 +2148,9 @@ int cpuhp_smt_enable(void)
/* Tell user space about the state changes */
for_each_cpu(cpu, mask) {
+ /* See comment in cpuhp_smt_disable() */
dev = get_cpu_device(cpu);
+ dev->offline = false;
kobject_uevent(&dev->kobj, KOBJ_ONLINE);
}
next prev parent reply other threads:[~2021-02-12 19:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-12 0:30 [PATCH v2] cpu/hotplug: wait for cpuset_hotplug_work to finish on cpu onlining Alexey Klimov
[not found] ` <20210212003032.2037750-1-aklimov-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2021-02-12 19:41 ` Daniel Jordan [this message]
2021-03-16 3:15 ` Alexey Klimov
[not found] ` <CAFBcO+99Ax5MuOtzNx=NrmnUN=+913Sc-DV83ObOi01A=kkN3w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-03-18 19:12 ` Daniel Jordan
2021-02-16 18:29 ` Qais Yousef
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=87tuqhrs3d.fsf@oracle.com \
--to=daniel.m.jordan-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
--cc=aklimov-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.org \
--cc=audralmitchel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
--cc=jobaker-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=klimov.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
--cc=qais.yousef-5wv7dgnIgG8@public.gmane.org \
--cc=rafael-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=yury.norov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).