提交 d14ec0e7 编写于 作者: W Wang Yuanheng 提交者: guzitao

sw64: kvm: enable binding_vcpu debug dynamically

Sunway inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5GFR5

--------------------------------

Add a bool debugfs file /sys/kernel/debug/sw_64/bind_vcpu, you can
echo 1/Y to enable bind vcpu, or echo 0/N to disable it. Determin which
node to bind the core according to the physical address assigned to the
guest.
Signed-off-by: NWang Yuanheng <wangyuanheng@wxiat.com>
Signed-off-by: NGu Zitao <guzitao@wxiat.com>
上级 a3266d17
......@@ -31,7 +31,7 @@ obj-$(CONFIG_HIBERNATION) += hibernate_asm.o hibernate.o
obj-$(CONFIG_AUDIT) += audit.o
obj-$(CONFIG_PCI) += pci_common.o
obj-$(CONFIG_RELOCATABLE) += relocate.o
obj-$(CONFIG_DEBUG_FS) += segvdbg.o
obj-$(CONFIG_DEBUG_FS) += segvdbg.o bindvcpu.o
obj-$(CONFIG_JUMP_LABEL) += jump_label.o
ifndef CONFIG_PCI
......
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2022 Wang Yuanheng
* Author: Wang Yuanheng
*
*/
#include <linux/kernel.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/uaccess.h>
#include <asm/debug.h>
extern bool bind_vcpu_enabled;
static int __init bind_vcpu_init(void)
{
struct dentry *bindvcpu;
if (!sw64_debugfs_dir)
return -ENODEV;
bindvcpu = debugfs_create_bool("bind_vcpu", 0644,
sw64_debugfs_dir, &bind_vcpu_enabled);
if (!bindvcpu)
return -ENOMEM;
return 0;
}
late_initcall(bind_vcpu_init);
......@@ -12,7 +12,7 @@
#include <linux/sched/signal.h>
#include <linux/kvm.h>
#include <linux/uaccess.h>
#include <linux/sched.h>
#include <asm/kvm_timer.h>
#include <asm/kvm_emulate.h>
......@@ -21,6 +21,7 @@
bool set_msi_flag;
unsigned long sw64_kvm_last_vpn[NR_CPUS];
__read_mostly bool bind_vcpu_enabled;
#define cpu_last_vpn(cpuid) sw64_kvm_last_vpn[cpuid]
#ifdef CONFIG_SUBARCH_C3B
......@@ -537,6 +538,16 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
#ifndef CONFIG_KVM_MEMHOTPLUG
vcpu->arch.vcb.vpcr
= get_vpcr(vcpu->kvm->arch.host_phys_addr, vcpu->kvm->arch.size, 0);
if (unlikely(bind_vcpu_enabled)) {
int nid;
unsigned long end;
end = vcpu->kvm->arch.host_phys_addr + vcpu->kvm->arch.size;
nid = pfn_to_nid(PHYS_PFN(vcpu->kvm->arch.host_phys_addr));
if (pfn_to_nid(PHYS_PFN(end)) == nid)
set_cpus_allowed_ptr(vcpu->arch.tsk, node_to_cpumask_map[nid]);
}
#else
unsigned long seg_base = virt_to_phys(vcpu->kvm->arch.seg_pgd);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册