From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757375AbcLBASx (ORCPT ); Thu, 1 Dec 2016 19:18:53 -0500 Received: from terminus.zytor.com ([198.137.202.10]:56122 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756771AbcLBASv (ORCPT ); Thu, 1 Dec 2016 19:18:51 -0500 Date: Thu, 1 Dec 2016 16:18:42 -0800 From: tip-bot for Fenghua Yu Message-ID: Cc: vikas.shivappa@linux.intel.com, mingo@kernel.org, tony.luck@intel.com, mtosatti@redhat.com, sai.praneeth.prakhya@intel.com, tglx@linutronix.de, h.peter.anvin@intel.com, ravi.v.shankar@intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org, fenghua.yu@intel.com Reply-To: mtosatti@redhat.com, tony.luck@intel.com, mingo@kernel.org, vikas.shivappa@linux.intel.com, tglx@linutronix.de, sai.praneeth.prakhya@intel.com, fenghua.yu@intel.com, linux-kernel@vger.kernel.org, hpa@zytor.com, ravi.v.shankar@intel.com, h.peter.anvin@intel.com In-Reply-To: <1480625714-54246-1-git-send-email-fenghua.yu@intel.com> References: <1480625714-54246-1-git-send-email-fenghua.yu@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cache] x86/intel_rdt: Call intel_rdt_sched_in() with preemption disabled Git-Commit-ID: 74fcdae1a7fdf30de5413ccc1eca271415d01124 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 74fcdae1a7fdf30de5413ccc1eca271415d01124 Gitweb: http://git.kernel.org/tip/74fcdae1a7fdf30de5413ccc1eca271415d01124 Author: Fenghua Yu AuthorDate: Thu, 1 Dec 2016 12:55:14 -0800 Committer: Thomas Gleixner CommitDate: Fri, 2 Dec 2016 01:13:02 +0100 x86/intel_rdt: Call intel_rdt_sched_in() with preemption disabled intel_rdt_sched_in() must be called with preemption disabled because the function accesses percpu variables (pqr_state and closid). If a task moves itself via move_myself() preemption is enabled, which violates the calling convention and can result in incorrect closid selection when the task gets preempted or migrated. Add the required protection and a comment about the calling convention. Signed-off-by: Fenghua Yu Cc: "Ravi V Shankar" Cc: "Tony Luck" Cc: "Marcelo Tosatti" Cc: "Sai Prakhya" Cc: "Vikas Shivappa" Cc: "H. Peter Anvin" Link: http://lkml.kernel.org/r/1480625714-54246-1-git-send-email-fenghua.yu@intel.com Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/intel_rdt.h | 2 ++ arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/x86/include/asm/intel_rdt.h b/arch/x86/include/asm/intel_rdt.h index 6e90e87..95ce5c8 100644 --- a/arch/x86/include/asm/intel_rdt.h +++ b/arch/x86/include/asm/intel_rdt.h @@ -192,6 +192,8 @@ int rdtgroup_schemata_show(struct kernfs_open_file *of, * resctrl file system. * - Caches the per cpu CLOSid values and does the MSR write only * when a task with a different CLOSid is scheduled in. + * + * Must be called with preemption disabled. */ static inline void intel_rdt_sched_in(void) { diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c index fb8e03e..1afd3f3 100644 --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c @@ -326,8 +326,10 @@ static void move_myself(struct callback_head *head) kfree(rdtgrp); } + preempt_disable(); /* update PQR_ASSOC MSR to make resource group go into effect */ intel_rdt_sched_in(); + preempt_enable(); kfree(callback); }