linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Xie <xiehuan09@gmail.com>
To: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	 akpm@linux-foundation.org, x86@kernel.org, bp@alien8.de,
	brauner@kernel.org,  bristot@redhat.com, bsegall@google.com,
	dave.hansen@linux.intel.com,  dianders@chromium.org,
	dietmar.eggemann@arm.com, eric.devolder@oracle.com,
	 hca@linux.ibm.com, hch@infradead.org, hpa@zytor.com,
	 jacob.jun.pan@linux.intel.com, jgg@ziepe.ca,
	jpoimboe@kernel.org,  jroedel@suse.de, juri.lelli@redhat.com,
	kent.overstreet@linux.dev,  kinseyho@google.com,
	kirill.shutemov@linux.intel.com, lstoakes@gmail.com,
	 luto@kernel.org, mgorman@suse.de, mic@digikod.net,
	 michael.christie@oracle.com, mingo@redhat.com,
	mjguzik@gmail.com,  mst@redhat.com, npiggin@gmail.com,
	peterz@infradead.org, pmladek@suse.com,
	 rick.p.edgecombe@intel.com, rostedt@goodmis.org,
	surenb@google.com,  tglx@linutronix.de, urezki@gmail.com,
	vincent.guittot@linaro.org,  vschneid@redhat.com
Subject: Re: [RFC 08/14] fork: separate vmap stack alloction and free calls
Date: Thu, 14 Mar 2024 23:18:21 +0800	[thread overview]
Message-ID: <CAEr6+EDfGyJG3481RUWTamGiG2aNPDWjqSGRJaKGova-Yj8SUw@mail.gmail.com> (raw)
In-Reply-To: <20240311164638.2015063-9-pasha.tatashin@soleen.com>

On Tue, Mar 12, 2024 at 12:47 AM Pasha Tatashin
<pasha.tatashin@soleen.com> wrote:
>
> In preparation for the dynamic stacks, separate out the
> __vmalloc_node_range and vfree calls from the vmap based stack
> allocations. The dynamic stacks will use their own variants of these
> functions.
>
> Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com>
> ---
>  kernel/fork.c | 53 ++++++++++++++++++++++++++++++---------------------
>  1 file changed, 31 insertions(+), 22 deletions(-)
>
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 3004e6ce6c65..bbae5f705773 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -204,6 +204,29 @@ static bool try_release_thread_stack_to_cache(struct vm_struct *vm_area)
>         return false;
>  }
>
> +static inline struct vm_struct *alloc_vmap_stack(int node)
> +{
> +       void *stack;
> +
> +       /*
> +        * Allocated stacks are cached and later reused by new threads,
> +        * so memcg accounting is performed manually on assigning/releasing
> +        * stacks to tasks. Drop __GFP_ACCOUNT.
> +        */
> +       stack = __vmalloc_node_range(THREAD_SIZE, THREAD_ALIGN,
> +                                    VMALLOC_START, VMALLOC_END,
> +                                    THREADINFO_GFP & ~__GFP_ACCOUNT,
> +                                    PAGE_KERNEL,
> +                                    0, node, __builtin_return_address(0));
> +
> +       return (stack) ? find_vm_area(stack) : NULL;
> +}
> +
> +static inline void free_vmap_stack(struct vm_struct *vm_area)
> +{
> +       vfree(vm_area->addr);
> +}
> +
>  static void thread_stack_free_rcu(struct rcu_head *rh)
>  {
>         struct vm_stack *vm_stack = container_of(rh, struct vm_stack, rcu);
> @@ -212,7 +235,7 @@ static void thread_stack_free_rcu(struct rcu_head *rh)
>         if (try_release_thread_stack_to_cache(vm_stack->stack_vm_area))
>                 return;
>
> -       vfree(vm_area->addr);
> +       free_vmap_stack(vm_area);
>  }

I've discovered that the function free_vmap_stack() can trigger a warning.
It appears that free_vmap_stack() should handle interrupt context and
task context separately as vfree().

[root@JeffXie ]# poweroff
[root@JeffXie ]# umount: devtmpfs busy - remounted read-only
[   93.036872] EXT4-fs (vda): re-mounted
2e1f057b-471f-4c08-a7b8-611457b221f2 ro. Quota mode: none.
The system is going down NOW!
Sent SIGTERM to all processes
Sent SIGKILL to all processes
Requesting system poweroff
[   94.043540] ------------[ cut here ]------------
[   94.043977] WARNING: CPU: 0 PID: 0 at kernel/smp.c:786
smp_call_function_many_cond+0x4e5/0x550
[   94.044744] Modules linked in:
[   94.045024] CPU: 0 PID: 0 Comm: swapper/0 Not tainted
6.8.0-00014-g82270db6e1f0 #91
[   94.045697] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009),
BIOS 1.15.0-1 04/01/2014
[   94.046399] RIP: 0010:smp_call_function_many_cond+0x4e5/0x550
[   94.046914] Code: 48 8b 78 08 48 c7 c1 a0 84 16 81 4c 89 f6 e8 22
11 f6 ff 65 ff 0d 23 38 ec 7e 0f 85 a1 fc ff ff 0f 1f 44 00 00 e9 97
fc ff ff <0f> 0b e9 61
[   94.048509] RSP: 0018:ffffc90000003e48 EFLAGS: 00010206
[   94.048965] RAX: ffffffff82cb3fd0 RBX: ffff88811862cbc0 RCX: 0000000000000003
[   94.049598] RDX: 0000000000000100 RSI: 0000000000000000 RDI: 0000000000000000
[   94.050226] RBP: ffff8881052c5090 R08: 0000000000000000 R09: 0000000000000001
[   94.050861] R10: ffffffff82a060c0 R11: 0000000000008847 R12: ffff888102eb3500
[   94.051480] R13: ffff88811862b800 R14: ffff88811862cc38 R15: 0000000000000000
[   94.052109] FS:  0000000000000000(0000) GS:ffff888118600000(0000)
knlGS:0000000000000000
[   94.052812] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   94.053318] CR2: 00000000004759e0 CR3: 0000000002a2e000 CR4: 0000000000750ef0
[   94.053955] PKRU: 55555554
[   94.054203] Call Trace:
[   94.054433]  <IRQ>
[   94.054632]  ? __warn+0x84/0x140
[   94.054925]  ? smp_call_function_many_cond+0x4e5/0x550
[   94.055362]  ? report_bug+0x199/0x1b0
[   94.055697]  ? handle_bug+0x3c/0x70
[   94.056010]  ? exc_invalid_op+0x18/0x70
[   94.056350]  ? asm_exc_invalid_op+0x1a/0x20
[   94.056728]  ? smp_call_function_many_cond+0x4e5/0x550
[   94.057179]  ? __pfx_do_kernel_range_flush+0x10/0x10
[   94.057622]  on_each_cpu_cond_mask+0x24/0x40
[   94.057999]  flush_tlb_kernel_range+0x98/0xb0
[   94.058390]  free_unmap_vmap_area+0x2d/0x40
[   94.058768]  remove_vm_area+0x3a/0x70
[   94.059094]  free_vmap_stack+0x15/0x60
[   94.059427]  rcu_core+0x2bf/0x980
[   94.059735]  ? rcu_core+0x244/0x980
[   94.060046]  ? kvm_clock_get_cycles+0x18/0x30
[   94.060431]  __do_softirq+0xc2/0x292
[   94.060760]  irq_exit_rcu+0x6a/0x90
[   94.061074]  sysvec_apic_timer_interrupt+0x6e/0x90
[   94.061507]  </IRQ>
[   94.061704]  <TASK>
[   94.061903]  asm_sysvec_apic_timer_interrupt+0x1a/0x20
[   94.062367] RIP: 0010:default_idle+0xf/0x20
[   94.062746] Code: 4c 01 c7 4c 29 c2 e9 72 ff ff ff 90 90 90 90 90
90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa eb 07 0f 00 2d 33 b4 2a
00 fb f4 <fa> c3 cc c0
[   94.064342] RSP: 0018:ffffffff82a03e70 EFLAGS: 00000212
[   94.064805] RAX: ffff888118628608 RBX: ffffffff82a0c980 RCX: 0000000000000000
[   94.065429] RDX: 4000000000000000 RSI: ffffffff82725be8 RDI: 000000000000a14c
[   94.066066] RBP: 0000000000000000 R08: 000000000000a14c R09: 0000000000000001
[   94.066705] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
[   94.067311] R13: 0000000000000000 R14: ffffffff82a0c030 R15: 00000000000000ac
[   94.067936]  default_idle_call+0x2c/0xd0
[   94.068284]  do_idle+0x1ce/0x210
[   94.068584]  cpu_startup_entry+0x2a/0x30
[   94.068931]  rest_init+0xc5/0xd0
[   94.069224]  arch_call_rest_init+0xe/0x30
[   94.069597]  start_kernel+0x58e/0x8d0
[   94.069929]  x86_64_start_reservations+0x18/0x30
[   94.070353]  x86_64_start_kernel+0xc6/0xe0
[   94.070725]  secondary_startup_64_no_verify+0x16d/0x17b
[   94.071189]  </TASK>
[   94.071392] ---[ end trace 0000000000000000 ]---
[   95.040718] e1000e: EEE TX LPI TIMER: 00000000
[   95.055005] ACPI: PM: Preparing to enter system sleep state S5
[   95.055619] reboot: Power down


 ./scripts/faddr2line ./vmlinux smp_call_function_many_cond+0x4e5/0x550
smp_call_function_many_cond+0x4e5/0x550:
smp_call_function_many_cond at kernel/smp.c:786 (discriminator 1)

 756 static void smp_call_function_many_cond(const struct cpumask *mask,
 757                                         smp_call_func_t func, void *info,
 758                                         unsigned int scf_flags,
 759                                         smp_cond_func_t cond_func)
[...]
 781          * When @wait we can deadlock when we interrupt between
llist_add() and
 782          * arch_send_call_function_ipi*(); when !@wait we can
deadlock due to
 783          * csd_lock() on because the interrupt context uses the same csd
 784          * storage.
 785          */
 786         WARN_ON_ONCE(!in_task());
// <<< warning here
[...]



-- 
Thanks,
JeffXie


  reply	other threads:[~2024-03-14 15:18 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-11 16:46 [RFC 00/14] Dynamic Kernel Stacks Pasha Tatashin
2024-03-11 16:46 ` [RFC 01/14] task_stack.h: remove obsolete __HAVE_ARCH_KSTACK_END check Pasha Tatashin
2024-03-17 14:36   ` Christophe JAILLET
2024-03-17 15:13     ` Pasha Tatashin
2024-03-11 16:46 ` [RFC 02/14] fork: Clean-up ifdef logic around stack allocation Pasha Tatashin
2024-03-11 16:46 ` [RFC 03/14] fork: Clean-up naming of vm_strack/vm_struct variables in vmap stacks code Pasha Tatashin
2024-03-17 14:42   ` Christophe JAILLET
2024-03-19 16:32     ` Pasha Tatashin
2024-03-11 16:46 ` [RFC 04/14] fork: Remove assumption that vm_area->nr_pages equals to THREAD_SIZE Pasha Tatashin
2024-03-17 14:45   ` Christophe JAILLET
2024-03-17 15:14     ` Pasha Tatashin
2024-03-11 16:46 ` [RFC 05/14] fork: check charging success before zeroing stack Pasha Tatashin
2024-03-12 15:57   ` Kirill A. Shutemov
2024-03-12 16:52     ` Pasha Tatashin
2024-03-11 16:46 ` [RFC 06/14] fork: zero vmap stack using clear_page() instead of memset() Pasha Tatashin
2024-03-12  7:15   ` Nikolay Borisov
2024-03-12 16:53     ` Pasha Tatashin
2024-03-14  7:55       ` Christophe Leroy
2024-03-14 13:52         ` Pasha Tatashin
2024-03-17 14:48   ` Christophe JAILLET
2024-03-17 15:15     ` Pasha Tatashin
2024-03-11 16:46 ` [RFC 07/14] fork: use the first page in stack to store vm_stack in cached_stacks Pasha Tatashin
2024-03-11 16:46 ` [RFC 08/14] fork: separate vmap stack alloction and free calls Pasha Tatashin
2024-03-14 15:18   ` Jeff Xie [this message]
2024-03-14 17:14     ` Pasha Tatashin
2024-03-17 14:51   ` Christophe JAILLET
2024-03-17 15:15     ` Pasha Tatashin
2024-03-11 16:46 ` [RFC 09/14] mm/vmalloc: Add a get_vm_area_node() and vmap_pages_range_noflush() public functions Pasha Tatashin
2024-03-11 16:46 ` [RFC 10/14] fork: Dynamic Kernel Stacks Pasha Tatashin
2024-03-11 19:32   ` Randy Dunlap
2024-03-11 19:55     ` Pasha Tatashin
2024-03-11 16:46 ` [RFC 11/14] x86: add support for " Pasha Tatashin
2024-03-11 22:17   ` Andy Lutomirski
2024-03-11 23:10     ` Pasha Tatashin
2024-03-11 23:33       ` Thomas Gleixner
2024-03-11 23:34       ` Andy Lutomirski
2024-03-12  0:08         ` Pasha Tatashin
2024-03-12  0:23           ` Pasha Tatashin
2024-03-11 23:34     ` Dave Hansen
2024-03-11 23:41       ` Andy Lutomirski
2024-03-11 23:56         ` Nadav Amit
2024-03-12  0:02           ` Andy Lutomirski
2024-03-12  7:20             ` Nadav Amit
2024-03-12  0:53           ` Dave Hansen
2024-03-12  1:25             ` H. Peter Anvin
2024-03-12  2:16               ` Andy Lutomirski
2024-03-12  2:20                 ` H. Peter Anvin
2024-03-12 21:58   ` Andi Kleen
2024-03-13 10:23   ` Thomas Gleixner
2024-03-13 13:43     ` Pasha Tatashin
2024-03-13 15:28       ` Pasha Tatashin
2024-03-13 16:12         ` Thomas Gleixner
2024-03-14 14:03           ` Pasha Tatashin
2024-03-14 18:26             ` Thomas Gleixner
2024-03-11 16:46 ` [RFC 12/14] task_stack.h: Clean-up stack_not_used() implementation Pasha Tatashin
2024-03-11 16:46 ` [RFC 13/14] task_stack.h: Add stack_not_used() support for dynamic stack Pasha Tatashin
2024-03-11 16:46 ` [RFC 14/14] fork: Dynamic Kernel Stack accounting Pasha Tatashin
2024-03-11 17:09 ` [RFC 00/14] Dynamic Kernel Stacks Mateusz Guzik
2024-03-11 18:58   ` Pasha Tatashin
2024-03-11 19:21     ` Mateusz Guzik
2024-03-11 19:55       ` Pasha Tatashin
2024-03-12 17:18 ` H. Peter Anvin
2024-03-12 19:45   ` Pasha Tatashin
2024-03-12 21:36     ` H. Peter Anvin
2024-03-14 19:05       ` Kent Overstreet
2024-03-14 19:23         ` Pasha Tatashin
2024-03-14 19:28           ` Kent Overstreet
2024-03-14 19:34             ` Pasha Tatashin
2024-03-14 19:49               ` Kent Overstreet
2024-03-12 22:18     ` David Laight
2024-03-14 19:43   ` Matthew Wilcox
2024-03-14 19:53     ` Kent Overstreet
2024-03-14 19:57       ` Matthew Wilcox
2024-03-14 19:58         ` Kent Overstreet
2024-03-15  3:13         ` Pasha Tatashin
2024-03-15  3:39           ` H. Peter Anvin
2024-03-16 19:17             ` Pasha Tatashin
2024-03-17  0:41               ` Matthew Wilcox
2024-03-17  1:32                 ` Kent Overstreet
2024-03-17 14:19                 ` Pasha Tatashin
2024-03-17 14:43               ` Brian Gerst
2024-03-17 16:15                 ` Pasha Tatashin
2024-03-17 21:30                   ` Brian Gerst
2024-03-18 14:59                     ` Pasha Tatashin
2024-03-18 21:02                       ` Brian Gerst
2024-03-19 14:56                         ` Pasha Tatashin
2024-03-17 18:57               ` David Laight
2024-03-18 15:09                 ` Pasha Tatashin
2024-03-18 15:13                   ` Pasha Tatashin
2024-03-18 15:19                   ` Matthew Wilcox
2024-03-18 15:30                     ` Pasha Tatashin
2024-03-18 15:53                       ` David Laight
2024-03-18 16:57                         ` Pasha Tatashin
2024-03-18 15:38               ` David Laight
2024-03-18 17:00                 ` Pasha Tatashin
2024-03-18 17:37                   ` Pasha Tatashin
2024-03-15  4:17           ` H. Peter Anvin
2024-03-17  0:47     ` H. Peter Anvin

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=CAEr6+EDfGyJG3481RUWTamGiG2aNPDWjqSGRJaKGova-Yj8SUw@mail.gmail.com \
    --to=xiehuan09@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=brauner@kernel.org \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=dianders@chromium.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=eric.devolder@oracle.com \
    --cc=hca@linux.ibm.com \
    --cc=hch@infradead.org \
    --cc=hpa@zytor.com \
    --cc=jacob.jun.pan@linux.intel.com \
    --cc=jgg@ziepe.ca \
    --cc=jpoimboe@kernel.org \
    --cc=jroedel@suse.de \
    --cc=juri.lelli@redhat.com \
    --cc=kent.overstreet@linux.dev \
    --cc=kinseyho@google.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lstoakes@gmail.com \
    --cc=luto@kernel.org \
    --cc=mgorman@suse.de \
    --cc=mic@digikod.net \
    --cc=michael.christie@oracle.com \
    --cc=mingo@redhat.com \
    --cc=mjguzik@gmail.com \
    --cc=mst@redhat.com \
    --cc=npiggin@gmail.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=rostedt@goodmis.org \
    --cc=surenb@google.com \
    --cc=tglx@linutronix.de \
    --cc=urezki@gmail.com \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=x86@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