Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2077321ybp; Thu, 10 Oct 2019 01:46:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrjGoBLiRQef47CtkNHl/niEbD0IPEemvrzF7FCnEUvrcxwX2J13XzBkjJ9BN0DgXS/LZf X-Received: by 2002:a17:906:2ada:: with SMTP id m26mr6955430eje.87.1570697207990; Thu, 10 Oct 2019 01:46:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697207; cv=none; d=google.com; s=arc-20160816; b=PZKroywd1OFlX6hl9A5xDD5MnXw/TI9cii+dEsonzgVBVo/9tGouRfK+TnKccaOuSv r9UceOAflHOcjMTcJCjTd8X7yIs7O+wkaC00ErBKV8CgkHtgBTZ+o2+aIen8JS+qIrr5 qwjJDFzs7JPcqi+i7lCbUuAwvyXp/G+T88jrfEHfcDDrHMotcwlVQERWp8dqRnJHootn QGdNqoKZBwMnt0KRpCZnrik4LXRLPBwn85SCNnMjReZ+c9x0r6mELMBRL+oNkyD6jyGv GxDAdJ7CBPuGSCzV5/SN+PF8+Z6xhbHDxmaxR/fVPWv9mk4yEwpFzlpmAZyOz23gAECH OVtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9TCBZ1tdAmSpsck8xYvtnk07TrH6+BQLLj5Ev01h0v4=; b=icRg7Zb30xUGQpM2KoRsvpkzv5ZZmE99trsefZoOwSbqgqzbeMjX36P6hniEeo8uuX 16Aei6DGES4/dJs1F6GsS3iTShqXULiydFRPjf59Zf76lVckN+RDVAiKVDLMc2g+Xhe3 9obnPw8J7/1rYmSSzumUm8MDQcQcGfMunBHB8Gn2tAEjcE2nIrURH7lT3UwHE/K/2cfi SnNOOnQsCHY7FLMXLAKLiA/fk75eAP51PaFHdwQ/ZOKqVHGzqZLRAN/1baOVBn4yOxB0 1zgKVGIzfzrWn+90HL+VrL2NM+4I8N5mF3ILSII4o9fTbSx0D1S5GK+Jo97Am75QpPWR OO/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zkNM18PJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ov27si1310852ejb.410.2019.10.10.01.46.24; Thu, 10 Oct 2019 01:46:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zkNM18PJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387758AbfJJInA (ORCPT + 99 others); Thu, 10 Oct 2019 04:43:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:47624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388643AbfJJIm5 (ORCPT ); Thu, 10 Oct 2019 04:42:57 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B53EB2190F; Thu, 10 Oct 2019 08:42:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570696977; bh=SW5+MJ+dAc9BhA2Qt94J5IT4MmvBAaF7zVFKoytNsbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zkNM18PJaobz8jcnKFd7oARVMwPwKHXSN2wgfRlUKJ0Gb7sfSSW46fyFYFOPNGtVT dOo+siQSFG7D4ogT2XT0vRvT4m9J5iWYSOKX0WQmdZjSgMfJe5eVkVS14xX+ArEQSH 2l0U4EiTmk8/XphT/K5iaB6LSNkz+ve+NU2fqLfo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oleg Nesterov , Mathieu Desnoyers , "Peter Zijlstra (Intel)" , Chris Metcalf , Christoph Lameter , "Eric W. Biederman" , Kirill Tkhai , Linus Torvalds , Mike Galbraith , "Paul E. McKenney" , Russell King - ARM Linux admin , Thomas Gleixner , Ingo Molnar , Sasha Levin Subject: [PATCH 5.3 120/148] sched/membarrier: Call sync_core only before usermode for same mm Date: Thu, 10 Oct 2019 10:36:21 +0200 Message-Id: <20191010083618.331652441@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083609.660878383@linuxfoundation.org> References: <20191010083609.660878383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Desnoyers [ Upstream commit 2840cf02fae627860156737e83326df354ee4ec6 ] 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 Signed-off-by: Peter Zijlstra (Intel) Cc: Chris Metcalf Cc: Christoph Lameter Cc: Eric W. Biederman Cc: Kirill Tkhai Cc: Linus Torvalds Cc: Mike Galbraith Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Russell King - ARM Linux admin Cc: Thomas Gleixner Link: https://lkml.kernel.org/r/20190919173705.2181-4-mathieu.desnoyers@efficios.com Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- 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 4a7944078cc35..8557ec6642130 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.20.1