mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
6fe07ce35e
The resource control feature is supported by both Intel and AMD. So, rename CONFIG_INTEL_RDT to the vendor-neutral CONFIG_RESCTRL. Now CONFIG_RESCTRL will be used for both Intel and AMD to enable Resource Control support. Update the texts in config and condition accordingly. [ bp: Simplify Kconfig text. ] Signed-off-by: Babu Moger <babu.moger@amd.com> Signed-off-by: Borislav Petkov <bp@suse.de> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andy Lutomirski <luto@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Brijesh Singh <brijesh.singh@amd.com> Cc: "Chang S. Bae" <chang.seok.bae@intel.com> Cc: David Miller <davem@davemloft.net> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Dmitry Safonov <dima@arista.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jann Horn <jannh@google.com> Cc: Joerg Roedel <jroedel@suse.de> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Kate Stewart <kstewart@linuxfoundation.org> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Cc: <linux-doc@vger.kernel.org> Cc: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Philippe Ombredanne <pombredanne@nexb.com> Cc: Pu Wen <puwen@hygon.cn> Cc: <qianyue.zj@alibaba-inc.com> Cc: "Rafael J. Wysocki" <rafael@kernel.org> Cc: Reinette Chatre <reinette.chatre@intel.com> Cc: Rian Hunter <rian@alum.mit.edu> Cc: Sherry Hurwitz <sherry.hurwitz@amd.com> Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Thomas Lendacky <Thomas.Lendacky@amd.com> Cc: Tony Luck <tony.luck@intel.com> Cc: Vitaly Kuznetsov <vkuznets@redhat.com> Cc: <xiaochen.shen@intel.com> Link: https://lkml.kernel.org/r/20181121202811.4492-9-babu.moger@amd.com
94 lines
2.6 KiB
C
94 lines
2.6 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _ASM_X86_RESCTRL_SCHED_H
|
|
#define _ASM_X86_RESCTRL_SCHED_H
|
|
|
|
#ifdef CONFIG_RESCTRL
|
|
|
|
#include <linux/sched.h>
|
|
#include <linux/jump_label.h>
|
|
|
|
#define IA32_PQR_ASSOC 0x0c8f
|
|
|
|
/**
|
|
* struct resctrl_pqr_state - State cache for the PQR MSR
|
|
* @cur_rmid: The cached Resource Monitoring ID
|
|
* @cur_closid: The cached Class Of Service ID
|
|
* @default_rmid: The user assigned Resource Monitoring ID
|
|
* @default_closid: The user assigned cached Class Of Service ID
|
|
*
|
|
* The upper 32 bits of IA32_PQR_ASSOC contain closid and the
|
|
* lower 10 bits rmid. The update to IA32_PQR_ASSOC always
|
|
* contains both parts, so we need to cache them. This also
|
|
* stores the user configured per cpu CLOSID and RMID.
|
|
*
|
|
* The cache also helps to avoid pointless updates if the value does
|
|
* not change.
|
|
*/
|
|
struct resctrl_pqr_state {
|
|
u32 cur_rmid;
|
|
u32 cur_closid;
|
|
u32 default_rmid;
|
|
u32 default_closid;
|
|
};
|
|
|
|
DECLARE_PER_CPU(struct resctrl_pqr_state, pqr_state);
|
|
|
|
DECLARE_STATIC_KEY_FALSE(rdt_enable_key);
|
|
DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key);
|
|
DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key);
|
|
|
|
/*
|
|
* __resctrl_sched_in() - Writes the task's CLOSid/RMID to IA32_PQR_MSR
|
|
*
|
|
* Following considerations are made so that this has minimal impact
|
|
* on scheduler hot path:
|
|
* - This will stay as no-op unless we are running on an Intel SKU
|
|
* which supports resource control or monitoring and we enable by
|
|
* mounting the resctrl file system.
|
|
* - Caches the per cpu CLOSid/RMID values and does the MSR write only
|
|
* when a task with a different CLOSid/RMID is scheduled in.
|
|
* - We allocate RMIDs/CLOSids globally in order to keep this as
|
|
* simple as possible.
|
|
* Must be called with preemption disabled.
|
|
*/
|
|
static void __resctrl_sched_in(void)
|
|
{
|
|
struct resctrl_pqr_state *state = this_cpu_ptr(&pqr_state);
|
|
u32 closid = state->default_closid;
|
|
u32 rmid = state->default_rmid;
|
|
|
|
/*
|
|
* If this task has a closid/rmid assigned, use it.
|
|
* Else use the closid/rmid assigned to this cpu.
|
|
*/
|
|
if (static_branch_likely(&rdt_alloc_enable_key)) {
|
|
if (current->closid)
|
|
closid = current->closid;
|
|
}
|
|
|
|
if (static_branch_likely(&rdt_mon_enable_key)) {
|
|
if (current->rmid)
|
|
rmid = current->rmid;
|
|
}
|
|
|
|
if (closid != state->cur_closid || rmid != state->cur_rmid) {
|
|
state->cur_closid = closid;
|
|
state->cur_rmid = rmid;
|
|
wrmsr(IA32_PQR_ASSOC, rmid, closid);
|
|
}
|
|
}
|
|
|
|
static inline void resctrl_sched_in(void)
|
|
{
|
|
if (static_branch_likely(&rdt_enable_key))
|
|
__resctrl_sched_in();
|
|
}
|
|
|
|
#else
|
|
|
|
static inline void resctrl_sched_in(void) {}
|
|
|
|
#endif /* CONFIG_RESCTRL */
|
|
|
|
#endif /* _ASM_X86_RESCTRL_SCHED_H */
|