From: Vlastimil Babka <vbabka@suse.cz>
To: Alexey Makhalov <amakhalov@vmware.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
Laurent Dufour <ldufour@linux.ibm.com>
Cc: Dennis Zhou <dennis@kernel.org>, Tejun Heo <tj@kernel.org>,
Christoph Lameter <cl@linux.com>, Roman Gushchin <guro@fb.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Subject: Re: Percpu allocator: CPU hotplug support
Date: Thu, 22 Apr 2021 19:52:43 +0200 [thread overview]
Message-ID: <020a52b6-404a-0427-8bc8-fff75da1ff6f@suse.cz> (raw)
In-Reply-To: <5614778F-AA79-40FD-BB62-A543A9C49CE2@vmware.com>
On 4/22/21 10:22 AM, Alexey Makhalov wrote:
> Hello,
>
>>> 2) It's possible users set particular conditions in percpu variables
>>> that are not tied to just statistics summing (such as the cpu
>>> runqueues). Users would have to provide online init and exit functions
>>> which could get weird.
> I do not think online init/exit function is a right approach.
> There are many places in the Linux where percpu data get initialized right after got allocated:
> ptr = alloc_percpu();
> for_each_possible_cpu(cpu) {
> initialize (per_cpu_ptr(ptr, cpu));
> }
> Let’s keep all such instances untouched. Hope initialize() just touch content of percpu area without allocating substructures. If so - it should be redesigned.
I'm afraid that 'hope' won't get us far. For example in the mm/page_alloc.c we
use INIT_LIST_HEAD() for percpu structures. Which means it's initialized to
empty list_head which are two "self-pointers" and you can't just memcpy that
elsewhere.
You could try to special-case this stuff in your "initialize N from A" approach
but it becomes rather fragile so we would indeed need callbacks for proper
init/exit on online/offline.
> BTW, this loop does extra work (runtime overhead) to initialize areas for possible cpus which might never arrive.
>
> The proposal:
> - in case of possible_cpus > online_cpus, add additional unit (call it A) to the chunks which will contain initialized image of percpu data for possible cpus.
> - for_each_possible_cpu(cpu) from snippet above should go through all online cpus + 1 (for unit A).
> - on new CPU #N arrival, percpu should allocate corresponding unit N and initialize its content by data from unit A. Repeat for all chunks.
> - on CPU D departure - release unit D from the chunks, keeping unit A intact.
> - in case of possible_cpus > online_cpus, overhead will be +1 (for unit A), while current overhead is +(possible_cpus-online_cpus).
> - in case of possible_cpus == online_cpus (no CPU hotplug) - do not allocate unit A, keep percpu allocator as it is now - no overhead.
>
> Does it fully cover 2nd concern?
>
>>> As Roman mentioned, I think it would be much better to not have the
>>> large discrepancy between the cpu_online_mask and the cpu_possible_mask.
>>
>> Indeed it is quite common on PowerPC to set a VM with a possible high number of CPUs but with a reasonnable number of online CPUs. This allows the user to scale up its VM when needed.
Yeah somehow it's always PowerPC with this kind of possible vs online problem :)
Last time I recall it was SLUB page order.
So I'm not against the hotplug support, but it really won't be simple.
>> For instance we may see up to 1024 possible CPUs while the online number is *only* 128.
> Agree. In VMs, vCPUs there are just threads/processes on the host and can be easily added/removed on demand.
>
> Thanks,
> —Alexey
>
>
>
next prev parent reply other threads:[~2021-04-22 17:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-22 0:44 Alexey Makhalov
2021-04-22 1:10 ` Roman Gushchin
2021-04-22 1:33 ` Dennis Zhou
2021-04-22 7:45 ` Laurent Dufour
2021-04-22 8:22 ` Alexey Makhalov
2021-04-22 17:52 ` Vlastimil Babka [this message]
2021-04-29 11:39 ` Pratik Sampat
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=020a52b6-404a-0427-8bc8-fff75da1ff6f@suse.cz \
--to=vbabka@suse.cz \
--cc=amakhalov@vmware.com \
--cc=aneesh.kumar@linux.ibm.com \
--cc=cl@linux.com \
--cc=dennis@kernel.org \
--cc=guro@fb.com \
--cc=ldufour@linux.ibm.com \
--cc=linux-mm@kvack.org \
--cc=srikar@linux.vnet.ibm.com \
--cc=tj@kernel.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