lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220402030822.11441-1-dtcccc@linux.alibaba.com>
Date:   Sat,  2 Apr 2022 11:08:22 +0800
From:   Tianchen Ding <dtcccc@...ux.alibaba.com>
To:     Andrew Morton <akpm@...ux-foundation.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Fenghua Yu <fenghua.yu@...el.com>,
        Borislav Petkov <bp@...e.de>,
        Pavel Tatashin <pasha.tatashin@...een.com>,
        NeilBrown <neilb@...e.de>,
        Vasily Averin <vasily.averin@...ux.dev>,
        "Matthew Wilcox (Oracle)" <willy@...radead.org>
Cc:     linux-kernel@...r.kernel.org
Subject: [RFC PATCH] sched: avoid unnecessary atomic_read when sync_core_before_usermode() is empty

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@...ux.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);
 
-- 
2.33.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ