From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6E03C00306 for ; Fri, 6 Sep 2019 03:13:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D35BE2082C for ; Fri, 6 Sep 2019 03:13:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="ZDThdENw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392095AbfIFDNK (ORCPT ); Thu, 5 Sep 2019 23:13:10 -0400 Received: from mail.efficios.com ([167.114.142.138]:40200 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391352AbfIFDNJ (ORCPT ); Thu, 5 Sep 2019 23:13:09 -0400 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id B6FCE32CD97; Thu, 5 Sep 2019 23:13:08 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id I7PkGRtwE3SS; Thu, 5 Sep 2019 23:13:08 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 352B732CD8B; Thu, 5 Sep 2019 23:13:08 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 352B732CD8B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1567739588; bh=2A9/n7ArrLAzW9IAuwPyXacDtSg9pVuTezAJwqTSuNo=; h=From:To:Date:Message-Id; b=ZDThdENw17KD/ErjaGjuMvkzgkhkwp421myC9lRRUVfmif0IbwYPSxgCNIt2nf2U8 UuF9MM3ZEmpgCX8NLCnuOIHJ53hU7xVLYomDvz74b4lrPSDKowwdHxDMXUwgY/Vt/2 c5itvN3OrwY+owK1nOwsBrcqgEI2OwMmTQSqWJgz85hM7yqk44IpgmM0ilDMXdKms+ 3mtEK4KLDiOTvZXD4IEfClUHAKY62sHfNIG8kyX2X1jQTdRFuo3hP199YsmA7YAT9c inMTYjO+XrGYtTBXtmNdTAZSKbnI00owD/rk+N+zBL+IirYZuc8NTzjQwMuC6/ukXT /ZBDbAUsS8mfg== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id N0lQwGd4mzoc; Thu, 5 Sep 2019 23:13:08 -0400 (EDT) Received: from localhost.localdomain (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by mail.efficios.com (Postfix) with ESMTPSA id 5437032CD74; Thu, 5 Sep 2019 23:13:07 -0400 (EDT) From: Mathieu Desnoyers To: Peter Zijlstra , "Paul E. McKenney" Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Oleg Nesterov , "Eric W. Biederman" , Linus Torvalds , Russell King - ARM Linux admin , Chris Metcalf , Christoph Lameter , Kirill Tkhai , Mike Galbraith , Thomas Gleixner , Mathieu Desnoyers Subject: [RFC PATCH 3/4] Cleanup: sched/membarrier: only sync_core before usermode for same mm Date: Thu, 5 Sep 2019 23:12:59 -0400 Message-Id: <20190906031300.1647-4-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190906031300.1647-1-mathieu.desnoyers@efficios.com> References: <20190906031300.1647-1-mathieu.desnoyers@efficios.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the prev and next task's mm change, switch_mm() provides the core serializing guarantees before returning to usermode. The only case where an explicit core serialization is needed is when the scheduler keeps the same mm for prev and next. Suggested-by: Oleg Nesterov Signed-off-by: Mathieu Desnoyers Cc: "Paul E. McKenney" Cc: Peter Zijlstra Cc: Oleg Nesterov Cc: "Eric W. Biederman" Cc: Linus Torvalds Cc: Russell King - ARM Linux admin Cc: Chris Metcalf Cc: Christoph Lameter Cc: Kirill Tkhai Cc: Mike Galbraith Cc: Thomas Gleixner Cc: Ingo Molnar --- include/linux/sched/mm.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index 4a7944078cc3..8557ec664213 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -362,6 +362,8 @@ enum { static inline void membarrier_mm_sync_core_before_usermode(struct mm_struct *mm) { + if (current->mm != mm) + return; if (likely(!(atomic_read(&mm->membarrier_state) & MEMBARRIER_STATE_PRIVATE_EXPEDITED_SYNC_CORE))) return; -- 2.17.1