From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Andy Lutomirski <luto@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org,
Ben Segall <bsegall@google.com>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>,
Vincent Guittot <vincent.guittot@linaro.org>
Subject: Re: [PATCH 7/8] kernel/fork: Only cache the VMAP stack in finish_task_switch().
Date: Mon, 14 Feb 2022 12:10:04 +0000 [thread overview]
Message-ID: <YgpGnFlTS+2Ugfw4@linutronix.de> (raw)
In-Reply-To: <00f9c7a6-2d1d-f871-e9bc-00e2217f40f9@kernel.org>
On 2022-02-11 15:55:01 [-0800], Andy Lutomirski wrote:
> > Set the lowest bit of task_struct::stack if the stack was released via
> > put_task_stack_sched() and needs a final free in
> > delayed_put_task_struct(). If the bit is missing then a reference is
> > held and put_task_stack() will release it.
>
> I don't understand what this bit is for or why the logic needs to be this
> complicated. Can you set ->stack to NULL if and only if you freed it early?
What do I do if put_task_stack() is invoked from finish_task_switch()
and I can't free but have to do something?
> > +static void free_thread_stack(struct task_struct *tsk, bool cache_only)
>
> This is messy. Please clean it up for real:
>
> static bool try_release_thread_stack_to_cache(struct vm_struct *vm)
> {
> for (...) try to put it in this slot;
> }
>
> And the callers can do things like:
>
> if (try_release_thread_stack_to_cache(...))
> return;
>
> /* need to free for real */
> free it or delayed-free it.
I think I could use the first few bytes of the stack as a RCU-head. Let
me try that.
> --Andy
Sebastian
WARNING: multiple messages have this Message-ID (diff)
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Andy Lutomirski <luto@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org,
Ben Segall <bsegall@google.com>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>,
Vincent Guittot <vincent.guittot@linaro.org>
Subject: Re: [PATCH 7/8] kernel/fork: Only cache the VMAP stack in finish_task_switch().
Date: Mon, 14 Feb 2022 13:10:04 +0100 [thread overview]
Message-ID: <YgpGnFlTS+2Ugfw4@linutronix.de> (raw)
In-Reply-To: <00f9c7a6-2d1d-f871-e9bc-00e2217f40f9@kernel.org>
On 2022-02-11 15:55:01 [-0800], Andy Lutomirski wrote:
> > Set the lowest bit of task_struct::stack if the stack was released via
> > put_task_stack_sched() and needs a final free in
> > delayed_put_task_struct(). If the bit is missing then a reference is
> > held and put_task_stack() will release it.
>
> I don't understand what this bit is for or why the logic needs to be this
> complicated. Can you set ->stack to NULL if and only if you freed it early?
What do I do if put_task_stack() is invoked from finish_task_switch()
and I can't free but have to do something?
> > +static void free_thread_stack(struct task_struct *tsk, bool cache_only)
>
> This is messy. Please clean it up for real:
>
> static bool try_release_thread_stack_to_cache(struct vm_struct *vm)
> {
> for (...) try to put it in this slot;
> }
>
> And the callers can do things like:
>
> if (try_release_thread_stack_to_cache(...))
> return;
>
> /* need to free for real */
> free it or delayed-free it.
I think I could use the first few bytes of the stack as a RCU-head. Let
me try that.
> --Andy
Sebastian
next prev parent reply other threads:[~2022-02-14 12:10 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-25 15:26 [PATCH REPOST 0/8] kernel/fork: Move thread stack free otu of the scheduler path Sebastian Andrzej Siewior
2022-01-25 15:26 ` Sebastian Andrzej Siewior
2022-01-25 15:26 ` [PATCH 1/8] kernel/fork: Redo ifdefs around task's handling Sebastian Andrzej Siewior
2022-01-25 15:26 ` Sebastian Andrzej Siewior
2022-01-25 15:26 ` [PATCH 2/8] kernel/fork: Duplicate task_struct before stack allocation Sebastian Andrzej Siewior
2022-01-25 15:26 ` Sebastian Andrzej Siewior
2022-02-11 23:42 ` Andy Lutomirski
2022-02-11 23:42 ` Andy Lutomirski
2022-02-14 11:39 ` Sebastian Andrzej Siewior
2022-02-14 11:39 ` Sebastian Andrzej Siewior
2022-01-25 15:26 ` [PATCH 3/8] kernel/fork, IA64: Provide a alloc_thread_stack_node() for IA64 Sebastian Andrzej Siewior
2022-01-25 15:26 ` Sebastian Andrzej Siewior
2022-02-14 18:00 ` Sebastian Andrzej Siewior
2022-02-14 18:00 ` Sebastian Andrzej Siewior
2022-01-25 15:26 ` [PATCH 4/8] kernel/fork: Don't assign the stack pointer in dup_task_struct() Sebastian Andrzej Siewior
2022-01-25 15:26 ` Sebastian Andrzej Siewior
2022-01-25 15:26 ` [PATCH 5/8] kernel/fork: Move memcg_charge_kernel_stack() into CONFIG_VMAP_STACK Sebastian Andrzej Siewior
2022-01-25 15:26 ` Sebastian Andrzej Siewior
2022-01-25 15:26 ` [PATCH 6/8] kernel/fork: Move task stack account to do_exit() Sebastian Andrzej Siewior
2022-01-25 15:26 ` Sebastian Andrzej Siewior
2022-02-11 23:43 ` Andy Lutomirski
2022-02-11 23:43 ` Andy Lutomirski
2022-01-25 15:26 ` [PATCH 7/8] kernel/fork: Only cache the VMAP stack in finish_task_switch() Sebastian Andrzej Siewior
2022-01-25 15:26 ` Sebastian Andrzej Siewior
2022-02-11 23:55 ` Andy Lutomirski
2022-02-11 23:55 ` Andy Lutomirski
2022-02-14 12:10 ` Sebastian Andrzej Siewior [this message]
2022-02-14 12:10 ` Sebastian Andrzej Siewior
2022-02-14 12:24 ` Sebastian Andrzej Siewior
2022-02-14 12:24 ` Sebastian Andrzej Siewior
2022-02-14 16:54 ` Sebastian Andrzej Siewior
2022-02-14 16:54 ` Sebastian Andrzej Siewior
2022-02-14 17:48 ` Sebastian Andrzej Siewior
2022-02-14 17:48 ` Sebastian Andrzej Siewior
2022-02-14 18:15 ` [PATCH v2 " Sebastian Andrzej Siewior
2022-02-14 18:15 ` Sebastian Andrzej Siewior
2022-01-25 15:26 ` [PATCH 8/8] kernel/fork: Use IS_ENABLED() in account_kernel_stack() Sebastian Andrzej Siewior
2022-01-25 15:26 ` Sebastian Andrzej Siewior
2022-02-08 17:10 ` [PATCH REPOST 0/8] kernel/fork: Move thread stack free otu of the scheduler path Sebastian Andrzej Siewior
2022-02-08 17:10 ` Sebastian Andrzej Siewior
-- strict thread matches above, loose matches on Subject: below --
2021-11-18 14:34 [PATCH " Sebastian Andrzej Siewior
2021-11-18 14:34 ` [PATCH 7/8] kernel/fork: Only cache the VMAP stack in finish_task_switch() Sebastian Andrzej Siewior
2021-11-18 14:34 ` Sebastian Andrzej Siewior
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=YgpGnFlTS+2Ugfw4@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=vincent.guittot@linaro.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 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.