mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tianchen Ding <dtcccc@linux.alibaba.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Fenghua Yu <fenghua.yu@intel.com>, Borislav Petkov <bp@suse.de>,
	Pavel Tatashin <pasha.tatashin@soleen.com>,
	NeilBrown <neilb@suse.de>,
	Vasily Averin <vasily.averin@linux.dev>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] sched: avoid unnecessary atomic_read when sync_core_before_usermode() is empty
Date: Wed, 6 Apr 2022 10:47:22 +0800	[thread overview]
Message-ID: <802b944d-d168-d9c8-add3-1fe17f3985f5@linux.alibaba.com> (raw)
In-Reply-To: <20220402030822.11441-1-dtcccc@linux.alibaba.com>

We've run schbench and found wakeup latency on some arm64 machines worse 
than others. Perf shows there's a hotspot on 
atomic_read(&mm->membarrier_state);

We're still working for the real reason behind it (maybe cache or sth 
hardware related), and we do see remove this function can help improve 
performance.

Thanks.

On 2022/4/2 11:08, Tianchen Ding wrote:
> On archs except x86, CONFIG_ARCH_HAS_SYNC_CORE_BEFORE_USERMODE is not
> defined. We found membarrier_mm_sync_core_before_usermode() looks like
> this when compiled by gcc10:
> 
> 	if (current->mm != mm)
> 		return;
> 	atomic_read(&mm->membarrier_state);
> 
> This memory access is unnecessary. Remove it to improve performance.
> 
> Signed-off-by: Tianchen Ding <dtcccc@linux.alibaba.com>
> ---
>   include/linux/sched/mm.h | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h
> index a80356e9dc69..3ded68d9f913 100644
> --- a/include/linux/sched/mm.h
> +++ b/include/linux/sched/mm.h
> @@ -401,6 +401,7 @@ enum {
>   #include <asm/membarrier.h>
>   #endif
>   
> +#ifdef CONFIG_ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
>   static inline void membarrier_mm_sync_core_before_usermode(struct mm_struct *mm)
>   {
>   	if (current->mm != mm)
> @@ -410,6 +411,11 @@ static inline void membarrier_mm_sync_core_before_usermode(struct mm_struct *mm)
>   		return;
>   	sync_core_before_usermode();
>   }
> +#else
> +static inline void membarrier_mm_sync_core_before_usermode(struct mm_struct *mm)
> +{
> +}
> +#endif
>   
>   extern void membarrier_exec_mmap(struct mm_struct *mm);
>   


      reply	other threads:[~2022-04-06 14:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-02  3:08 Tianchen Ding
2022-04-06  2:47 ` Tianchen Ding [this message]

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=802b944d-d168-d9c8-add3-1fe17f3985f5@linux.alibaba.com \
    --to=dtcccc@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@suse.de \
    --cc=fenghua.yu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=pasha.tatashin@soleen.com \
    --cc=tglx@linutronix.de \
    --cc=vasily.averin@linux.dev \
    --cc=willy@infradead.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

all inboxes | Powered by JetHome®