All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: slub: replace local_irq_save with local_irq_disable
@ 2021-06-06  4:17 Muchun Song
  2021-06-07 12:32 ` Vlastimil Babka
  0 siblings, 1 reply; 3+ messages in thread
From: Muchun Song @ 2021-06-06  4:17 UTC (permalink / raw
  To: cl, penberg, rientjes, iamjoonsoo.kim, akpm, vbabka
  Cc: linux-mm, linux-kernel, Muchun Song

The caller of slub_cpu_dead cannot be irq disabled (because slab_mutex is
holding during the processing), there is no need to use irq_save. Just use
irq_disable directly.

Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
 mm/slub.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index ee51857d8e9b..fbf592ef14ff 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2529,13 +2529,12 @@ static void flush_all(struct kmem_cache *s)
 static int slub_cpu_dead(unsigned int cpu)
 {
 	struct kmem_cache *s;
-	unsigned long flags;
 
 	mutex_lock(&slab_mutex);
 	list_for_each_entry(s, &slab_caches, list) {
-		local_irq_save(flags);
+		local_irq_disable();
 		__flush_cpu_slab(s, cpu);
-		local_irq_restore(flags);
+		local_irq_enable();
 	}
 	mutex_unlock(&slab_mutex);
 	return 0;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: slub: replace local_irq_save with local_irq_disable
  2021-06-06  4:17 [PATCH] mm: slub: replace local_irq_save with local_irq_disable Muchun Song
@ 2021-06-07 12:32 ` Vlastimil Babka
  2021-06-10  4:14   ` [External] " Muchun Song
  0 siblings, 1 reply; 3+ messages in thread
From: Vlastimil Babka @ 2021-06-07 12:32 UTC (permalink / raw
  To: Muchun Song, cl, penberg, rientjes, iamjoonsoo.kim, akpm
  Cc: linux-mm, linux-kernel

On 6/6/21 6:17 AM, Muchun Song wrote:
> The caller of slub_cpu_dead cannot be irq disabled (because slab_mutex is
> holding during the processing), there is no need to use irq_save. Just use
> irq_disable directly.

Well, we shouldn't need to disable irq at all. We are cleaning up for a dead
cpu, so there's nobody else accesing the data. irq save/disable will protect
only the local cpu's data, not of the cpu we are flushing. But we can't simply
remove the irq disable/enable because there are some nested
VM_BUG_ON(!irqs_disabled()) under __flush_cpu_slab(). We basically only disable
irqs here to avoid those from triggering.

My series [1] addresses this completely (among other things), but it's early
stage RFC (v2 should be soon). Your patch is not wrong, but also not urgent or
perf critical. So with that context I'll leave the decision to others :)

[1] https://lore.kernel.org/lkml/20210524233946.20352-1-vbabka@suse.cz/

> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> ---
>  mm/slub.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index ee51857d8e9b..fbf592ef14ff 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -2529,13 +2529,12 @@ static void flush_all(struct kmem_cache *s)
>  static int slub_cpu_dead(unsigned int cpu)
>  {
>  	struct kmem_cache *s;
> -	unsigned long flags;
>  
>  	mutex_lock(&slab_mutex);
>  	list_for_each_entry(s, &slab_caches, list) {
> -		local_irq_save(flags);
> +		local_irq_disable();
>  		__flush_cpu_slab(s, cpu);
> -		local_irq_restore(flags);
> +		local_irq_enable();
>  	}
>  	mutex_unlock(&slab_mutex);
>  	return 0;
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [External] Re: [PATCH] mm: slub: replace local_irq_save with local_irq_disable
  2021-06-07 12:32 ` Vlastimil Babka
@ 2021-06-10  4:14   ` Muchun Song
  0 siblings, 0 replies; 3+ messages in thread
From: Muchun Song @ 2021-06-10  4:14 UTC (permalink / raw
  To: Vlastimil Babka
  Cc: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton, Linux Memory Management List, LKML

On Mon, Jun 7, 2021 at 8:32 PM Vlastimil Babka <vbabka@suse.cz> wrote:
>
> On 6/6/21 6:17 AM, Muchun Song wrote:
> > The caller of slub_cpu_dead cannot be irq disabled (because slab_mutex is
> > holding during the processing), there is no need to use irq_save. Just use
> > irq_disable directly.
>
> Well, we shouldn't need to disable irq at all. We are cleaning up for a dead
> cpu, so there's nobody else accesing the data. irq save/disable will protect
> only the local cpu's data, not of the cpu we are flushing. But we can't simply
> remove the irq disable/enable because there are some nested
> VM_BUG_ON(!irqs_disabled()) under __flush_cpu_slab(). We basically only disable
> irqs here to avoid those from triggering.
>
> My series [1] addresses this completely (among other things), but it's early
> stage RFC (v2 should be soon). Your patch is not wrong, but also not urgent or
> perf critical. So with that context I'll leave the decision to others :)

Got it.

>
> [1] https://lore.kernel.org/lkml/20210524233946.20352-1-vbabka@suse.cz/

Good series. Reducing irq disabling is nice.

Thanks.

>
> > Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> > ---
> >  mm/slub.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/mm/slub.c b/mm/slub.c
> > index ee51857d8e9b..fbf592ef14ff 100644
> > --- a/mm/slub.c
> > +++ b/mm/slub.c
> > @@ -2529,13 +2529,12 @@ static void flush_all(struct kmem_cache *s)
> >  static int slub_cpu_dead(unsigned int cpu)
> >  {
> >       struct kmem_cache *s;
> > -     unsigned long flags;
> >
> >       mutex_lock(&slab_mutex);
> >       list_for_each_entry(s, &slab_caches, list) {
> > -             local_irq_save(flags);
> > +             local_irq_disable();
> >               __flush_cpu_slab(s, cpu);
> > -             local_irq_restore(flags);
> > +             local_irq_enable();
> >       }
> >       mutex_unlock(&slab_mutex);
> >       return 0;
> >
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-10  4:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-06  4:17 [PATCH] mm: slub: replace local_irq_save with local_irq_disable Muchun Song
2021-06-07 12:32 ` Vlastimil Babka
2021-06-10  4:14   ` [External] " Muchun Song

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.