linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Muchun Song <songmuchun@bytedance.com>,
	cl@linux.com, penberg@kernel.org, rientjes@google.com,
	iamjoonsoo.kim@lge.com, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: slub: replace local_irq_save with local_irq_disable
Date: Mon, 7 Jun 2021 14:32:48 +0200	[thread overview]
Message-ID: <028651d9-5e3b-8348-00af-e6acf8ea4ced@suse.cz> (raw)
In-Reply-To: <20210606041750.69403-1-songmuchun@bytedance.com>

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;
> 



  reply	other threads:[~2021-06-07 12:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-06  4:17 Muchun Song
2021-06-07 12:32 ` Vlastimil Babka [this message]
2021-06-10  4:14   ` [External] " Muchun Song

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=028651d9-5e3b-8348-00af-e6acf8ea4ced@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=songmuchun@bytedance.com \
    /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