lkml.org 
[lkml]   [2018]   [Mar]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] mm: might_sleep warning
> > > >       spin_lock(&deferred_zone_grow_lock);
> > > > - static_branch_disable(&deferred_pages);
> > > > + deferred_zone_grow = false;
> > > > spin_unlock(&deferred_zone_grow_lock);
> > > > + static_branch_disable(&deferred_pages);
> > > >
> > > > /* There will be num_node_state(N_MEMORY) threads */
> > > > atomic_set(&pgdat_init_n_undone, num_node_state(N_MEMORY));
> > >
> > > Kinda ugly, but I can see the logic behind the decisions.
> > >
> > > Can we instead turn deferred_zone_grow_lock into a mutex?
>
> (top-posting repaired. Please don't top-post).
>
> > [CCed everyone]
> >
> > Hi Andrew,
> >
> > I afraid we cannot change this spinlock to mutex
> > because deferred_grow_zone() might be called from an interrupt context if
> > interrupt thread needs to allocate memory.
> >
>
> OK. But if deferred_grow_zone() can be called from interrupt then
> page_alloc_init_late() should be using spin_lock_irq(), shouldn't it?
> I'm surprised that lockdep didn't detect that.

No, page_alloc_init_late() cannot be called from interrupt, it is
called straight from:
kernel_init_freeable(). But, I believe deferred_grow_zone(): can be called:

get_page_from_freelist()
_deferred_grow_zone()
deferred_grow_zone()


>
>
>
> --- a/mm/page_alloc.c~mm-initialize-pages-on-demand-during-boot-fix-4-fix
> +++ a/mm/page_alloc.c
> @@ -1689,9 +1689,9 @@ void __init page_alloc_init_late(void)
> * context. Since, spin_lock() disables preemption, we must use an
> * extra boolean deferred_zone_grow.
> */
> - spin_lock(&deferred_zone_grow_lock);
> + spin_lock_irq(&deferred_zone_grow_lock);
> deferred_zone_grow = false;
> - spin_unlock(&deferred_zone_grow_lock);
> + spin_unlock_irq(&deferred_zone_grow_lock);
> static_branch_disable(&deferred_pages);
>
> /* There will be num_node_state(N_MEMORY) threads */
> _
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

\
 
 \ /
  Last update: 2018-03-06 22:10    [W:0.104 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site