From: Andrew Morton <akpm@linux-foundation.org>
To: "Isaac J. Manjarres" <isaacm@codeaurora.org>
Cc: linux-kernel@vger.kernel.org, christian.brauner@ubuntu.com,
mingo@kernel.org, peterz@infradead.org, ebiederm@xmission.com,
esyr@redhat.com, tglx@linutronix.de, christian@kellner.me,
areber@redhat.com, shakeelb@google.com, cyphar@cyphar.com,
psodagud@codeaurora.org, pratikp@codeaurora.org
Subject: Re: [RFC PATCH] fork: Free per-cpu cached vmalloc'ed thread stacks with
Date: Sun, 13 Sep 2020 20:37:08 -0700 [thread overview]
Message-ID: <20200913203708.ec97aab4ec42b22cac532f38@linux-foundation.org> (raw)
In-Reply-To: <010101745b9b7830-0392d16f-4ee3-4b0e-afc1-51ebb71d0cb3-000000@us-west-2.amazonses.com>
On Sat, 5 Sep 2020 00:12:29 +0000 "Isaac J. Manjarres" <isaacm@codeaurora.org> wrote:
> The per-cpu cached vmalloc'ed stacks are currently freed in the
> CPU hotplug teardown path by the free_vm_stack_cache() callback,
> which invokes vfree(), which may result in purging the list of
> lazily freed vmap areas.
>
> Purging all of the lazily freed vmap areas can take a long time
> when the list of vmap areas is large. This is problematic, as
> free_vm_stack_cache() is invoked prior to the offline CPU's timers
> being migrated. This is not desirable as it can lead to timer
> migration delays in the CPU hotplug teardown path, and timer callbacks
> will be invoked long after the timer has expired.
>
> For example, on a system that has only one online CPU (CPU 1) that is
> running a heavy workload, and another CPU that is being offlined,
> the online CPU will invoke free_vm_stack_cache() to free the cached
> vmalloc'ed stacks for the CPU being offlined. When there are 2702
> vmap areas that total to 13498 pages, free_vm_stack_cache() takes
> over 2 seconds to execute:
>
> [001] 399.335808: cpuhp_enter: cpu: 0005 target: 0 step: 67 (free_vm_stack_cache)
>
> /* The first vmap area to be freed */
> [001] 399.337157: __purge_vmap_area_lazy: [0:2702] 0xffffffc033da8000 - 0xffffffc033dad000 (5 : 13498)
>
> /* After two seconds */
> [001] 401.528010: __purge_vmap_area_lazy: [1563:2702] 0xffffffc02fe10000 - 0xffffffc02fe15000 (5 : 5765)
>
> Instead of freeing the per-cpu cached vmalloc'ed stacks synchronously
> with respect to the CPU hotplug teardown state machine, free them
> asynchronously to help move along the CPU hotplug teardown state machine
> quickly.
>
> ...
>
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -202,7 +202,7 @@ static int free_vm_stack_cache(unsigned int cpu)
> if (!vm_stack)
> continue;
>
> - vfree(vm_stack->addr);
> + vfree_atomic(vm_stack->addr);
> cached_vm_stacks[i] = NULL;
> }
I guess that makes sense, although perhaps we shouldn't be permitting
purge_list to get so large - such latency issues will still appear in
other situations.
If we go with this fix-just-fork approach, can we please have a comment
in there explaining why vfree_atomic() is being used?
next parent reply other threads:[~2020-09-14 3:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <010101745b9b7830-0392d16f-4ee3-4b0e-afc1-51ebb71d0cb3-000000@us-west-2.amazonses.com>
2020-09-14 3:37 ` Andrew Morton [this message]
[not found] <010101745b9b7825-f4d1db4b-83fb-450e-9391-82aad77a1bd6-000000@us-west-2.amazonses.com>
2020-09-07 8:45 ` Christian Brauner
2020-09-07 14:21 ` Uladzislau Rezki
2020-09-05 0:11 Isaac J. Manjarres
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=20200913203708.ec97aab4ec42b22cac532f38@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=areber@redhat.com \
--cc=christian.brauner@ubuntu.com \
--cc=christian@kellner.me \
--cc=cyphar@cyphar.com \
--cc=ebiederm@xmission.com \
--cc=esyr@redhat.com \
--cc=isaacm@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=pratikp@codeaurora.org \
--cc=psodagud@codeaurora.org \
--cc=shakeelb@google.com \
--cc=tglx@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®