Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753841AbcDUR5l (ORCPT ); Thu, 21 Apr 2016 13:57:41 -0400 Received: from mail.kernel.org ([198.145.29.136]:52595 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753796AbcDUR5j (ORCPT ); Thu, 21 Apr 2016 13:57:39 -0400 From: Andy Lutomirski To: x86@kernel.org Cc: "linux-kernel@vger.kernel.org" , Borislav Petkov , Peter Zijlstra , Andy Lutomirski Subject: [PATCH 1/3] sched: Add switch_mm_irqs_off and use it in the scheduler Date: Thu, 21 Apr 2016 10:57:28 -0700 Message-Id: <19228c98a8aad8a88c95e2c723d643f59f244d46.1461261284.git.luto@kernel.org> X-Mailer: git-send-email 2.5.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1803 Lines: 64 By defailt, this is the same thing as switch_mm. x86 will override it as an optimization. Cc: Peter Zijlstra Signed-off-by: Andy Lutomirski --- 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..f9e09613c113 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 d8465eeab8b3..3636abcafac0 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -2712,7 +2712,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; @@ -5202,7 +5202,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.5.5