Received: by 10.223.185.116 with SMTP id b49csp3214444wrg; Mon, 5 Mar 2018 16:43:23 -0800 (PST) X-Google-Smtp-Source: AG47ELvIEWZKUTuCRG/ZCmwfybtVWVR7EYqGHl6N4HTsm8RjK7Z0eKHsk1jkTRmXkARq5FQDRqi2 X-Received: by 2002:a17:902:7290:: with SMTP id d16-v6mr14788227pll.31.1520297003710; Mon, 05 Mar 2018 16:43:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520297003; cv=none; d=google.com; s=arc-20160816; b=g9eYG1q+oSXJnz0BIsOxiqSGXpAs5TTUFrQtQKz2Q0D/nMjuD2OlIejPDAKA13mHd+ X736RE1BWbFQ0rmoqdgTiymZQa4ZN0mdu36zPUS05GsBr+bR0u+/u27v3/LHDawEoE9w OYu2+2vsYFnX9loJrDISB6LvqhVSNQY+JmUBpyJCfKGJmBv+NQdnGD7+g/pUB9DOPlWM zRfalmdhx7KU3l3wz1SuZyHZJO/gD4WpMBePLSFDfXGLDF2bBfS1ppo+SAcQVFvDwahi G5Bh2HUb89xHfIrbmqoj5ziP+Hu4fAqI8jhwNZFIgDkkeBdHoQ7nr17WqNmPWBpSy+l4 jfqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:arc-authentication-results; bh=NbVnWObOf2m0mPKrE143jFhhKQEJywxSUK6kzu8bxxI=; b=giSs5XVMolLnucO9mEQGiav/KGASB1FH0Nn7ZfsycGOkwIPph6O+NKiUQLfo82QSpY ev9g3eShRVGo5o2sxuTakvd3cPCP97A+sUbCaWQ1+2xloetFRBdbnIgcBgozic7O5jOQ CeOy0rIP+1Af/KXXG/p0o2I6S+cIR0oAldF8MPObcpYHCrEWrxj8OfIpOxCB+UpWsLZd sJKMR9aFpaVpQU7/ZuQiiiUq2lB3AlTJFc29N0MB8Q4+h2UI8xN1g14PEGUEkicJdPSP zFqmFHB0/YAdmhfbrhe/38UNFP5LHv59kwXXAVgLaRJO/r7SNGktdwMCGSmvMB2Ei6bM s2SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=kMFNsTHt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b91-v6si10071316plb.268.2018.03.05.16.43.09; Mon, 05 Mar 2018 16:43:23 -0800 (PST) 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=@oracle.com header.s=corp-2017-10-26 header.b=kMFNsTHt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933265AbeCFAlV (ORCPT + 99 others); Mon, 5 Mar 2018 19:41:21 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:40434 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932850AbeCFA0H (ORCPT ); Mon, 5 Mar 2018 19:26:07 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w260LT1p187149; Tue, 6 Mar 2018 00:26:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=NbVnWObOf2m0mPKrE143jFhhKQEJywxSUK6kzu8bxxI=; b=kMFNsTHtuN3W4GwPBNXVyZsWsJ4YAk7202X46yhS9ZuQ4zB7+Q42saU/teQCdpvxj/My 9J1H0HrJ5TVTUFMxTlV9AUmqwGxQxSkZGgHa+yhpRGCz0M5MhcYT3+Ar+md26vxVCOnk KiT5j8RateY/TE/2R/451IOz+O7P8ynvEs0PmUk4EiRh1Wi08zVGQ2WVToOd336am0kS 769QeSyGwoVL0ePFNhrUEBizZoP65ZcrkTYf+lnzSw6c55cdMtUYHhLyqh08o/U+Rjzx lQgWVDxZsNrx/pndwjAj1RCf0yCHXZQSm/bow3A3VOyAlK2XQxHJf5y/kgSB/vLkE1w5 ng== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2ghdxf8jqa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Mar 2018 00:26:02 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w260Q2BB024267 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 6 Mar 2018 00:26:02 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w260Q1ma032639; Tue, 6 Mar 2018 00:26:01 GMT Received: from localhost.localdomain (/98.216.35.41) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Mar 2018 16:26:01 -0800 From: Pavel Tatashin To: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, linux-kernel@vger.kernel.org, Alexander.Levin@microsoft.com, dan.j.williams@intel.com, sathyanarayanan.kuppuswamy@intel.com, pankaj.laxminarayan.bharadiya@intel.com, akuster@mvista.com, cminyard@mvista.com, pasha.tatashin@oracle.com, gregkh@linuxfoundation.org, stable@vger.kernel.org Subject: [PATCH 4.1 06/65] sched/core: Add switch_mm_irqs_off() and use it in the scheduler Date: Mon, 5 Mar 2018 19:24:39 -0500 Message-Id: <20180306002538.1761-7-pasha.tatashin@oracle.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180306002538.1761-1-pasha.tatashin@oracle.com> References: <20180306002538.1761-1-pasha.tatashin@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8823 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=917 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803060003 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andy Lutomirski commit f98db6013c557c216da5038d9c52045be55cd039 upstream. By default, this is the same thing as switch_mm(). x86 will override it as an optimization. Signed-off-by: Andy Lutomirski Reviewed-by: Borislav Petkov Cc: Borislav Petkov Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/df401df47bdd6be3e389c6f1e3f5310d70e81b2c.1461688545.git.luto@kernel.org Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 425f13a36652523d604fd96413d6c438d415dd70) Signed-off-by: Pavel Tatashin --- include/linux/mmu_context.h | 7 +++++++ kernel/sched/core.c | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/linux/mmu_context.h b/include/linux/mmu_context.h index 70fffeba7495..a4441784503b 100644 --- a/include/linux/mmu_context.h +++ b/include/linux/mmu_context.h @@ -1,9 +1,16 @@ #ifndef _LINUX_MMU_CONTEXT_H #define _LINUX_MMU_CONTEXT_H +#include + struct mm_struct; void use_mm(struct mm_struct *mm); void unuse_mm(struct mm_struct *mm); +/* Architectures that care about IRQ state in switch_mm can override this. */ +#ifndef switch_mm_irqs_off +# define switch_mm_irqs_off switch_mm +#endif + #endif diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 8fbedeb5553f..d253618d09c6 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include @@ -2339,7 +2339,7 @@ context_switch(struct rq *rq, struct task_struct *prev, atomic_inc(&oldmm->mm_count); enter_lazy_tlb(oldmm, next); } else - switch_mm(oldmm, mm, next); + switch_mm_irqs_off(oldmm, mm, next); if (!prev->mm) { prev->active_mm = NULL; @@ -4979,7 +4979,7 @@ void idle_task_exit(void) BUG_ON(cpu_online(smp_processor_id())); if (mm != &init_mm) { - switch_mm(mm, &init_mm, current); + switch_mm_irqs_off(mm, &init_mm, current); finish_arch_post_lock_switch(); } mmdrop(mm); -- 2.16.2