Commit 323925ed authored by Andrew Jones's avatar Andrew Jones Committed by Anup Patel
Browse files

RISC-V: paravirt: Add skeleton for pv-time support



Add the files and functions needed to support paravirt time on
RISC-V. Also include the common code needed for the first
application of pv-time, which is steal-time. In the next
patches we'll complete the functions to fully enable steal-time
support.

Acked-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
Reviewed-by: default avatarAnup Patel <anup@brainfault.org>
Reviewed-by: default avatarAtish Patra <atishp@rivosinc.com>
Signed-off-by: default avatarAndrew Jones <ajones@ventanamicro.com>
Signed-off-by: default avatarAnup Patel <anup@brainfault.org>
parent 4c460eb3
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -3985,9 +3985,9 @@
			vulnerability. System may allow data leaks with this
			option.

	no-steal-acc	[X86,PV_OPS,ARM64,PPC/PSERIES] Disable paravirtualized
			steal time accounting. steal time is computed, but
			won't influence scheduler behaviour
	no-steal-acc	[X86,PV_OPS,ARM64,PPC/PSERIES,RISCV] Disable
			paravirtualized steal time accounting. steal time is
			computed, but won't influence scheduler behaviour

	nosync		[HW,M68K] Disables sync negotiation for all devices.

+28 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_RISCV_PARAVIRT_H
#define _ASM_RISCV_PARAVIRT_H

#ifdef CONFIG_PARAVIRT
#include <linux/static_call_types.h>

struct static_key;
extern struct static_key paravirt_steal_enabled;
extern struct static_key paravirt_steal_rq_enabled;

u64 dummy_steal_clock(int cpu);

DECLARE_STATIC_CALL(pv_steal_clock, dummy_steal_clock);

static inline u64 paravirt_steal_clock(int cpu)
{
	return static_call(pv_steal_clock)(cpu);
}

int __init pv_time_init(void);

#else

#define pv_time_init() do {} while (0)

#endif /* CONFIG_PARAVIRT */
#endif /* _ASM_RISCV_PARAVIRT_H */
+1 −0
Original line number Diff line number Diff line
#include <asm/paravirt.h>
+1 −0
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ obj-$(CONFIG_SMP) += sbi-ipi.o
obj-$(CONFIG_SMP) += cpu_ops_sbi.o
endif
obj-$(CONFIG_HOTPLUG_CPU)	+= cpu-hotplug.o
obj-$(CONFIG_PARAVIRT)		+= paravirt.o
obj-$(CONFIG_KGDB)		+= kgdb.o
obj-$(CONFIG_KEXEC_CORE)	+= kexec_relocate.o crash_save_regs.o machine_kexec.o
obj-$(CONFIG_KEXEC_FILE)	+= elf_kexec.o machine_kexec_file.o
+79 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2023 Ventana Micro Systems Inc.
 */

#define pr_fmt(fmt) "riscv-pv: " fmt

#include <linux/cpuhotplug.h>
#include <linux/init.h>
#include <linux/jump_label.h>
#include <linux/printk.h>
#include <linux/static_call.h>
#include <linux/types.h>

#include <asm/paravirt.h>

struct static_key paravirt_steal_enabled;
struct static_key paravirt_steal_rq_enabled;

static u64 native_steal_clock(int cpu)
{
	return 0;
}

DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock);

static bool steal_acc = true;
static int __init parse_no_stealacc(char *arg)
{
	steal_acc = false;
	return 0;
}

early_param("no-steal-acc", parse_no_stealacc);

static bool __init has_pv_steal_clock(void)
{
	return false;
}

static int pv_time_cpu_online(unsigned int cpu)
{
	return 0;
}

static int pv_time_cpu_down_prepare(unsigned int cpu)
{
	return 0;
}

static u64 pv_time_steal_clock(int cpu)
{
	return 0;
}

int __init pv_time_init(void)
{
	int ret;

	if (!has_pv_steal_clock())
		return 0;

	ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
				"riscv/pv_time:online",
				pv_time_cpu_online,
				pv_time_cpu_down_prepare);
	if (ret < 0)
		return ret;

	static_call_update(pv_steal_clock, pv_time_steal_clock);

	static_key_slow_inc(&paravirt_steal_enabled);
	if (steal_acc)
		static_key_slow_inc(&paravirt_steal_rq_enabled);

	pr_info("Computing paravirt steal-time\n");

	return 0;
}
Loading