lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 15 Jan 2024 16:58:36 +0000
From: Hongyan Xia <hongyan.xia2@....com>
To: David Dai <davidai@...gle.com>, "Rafael J. Wysocki" <rafael@...nel.org>,
 Viresh Kumar <viresh.kumar@...aro.org>, Rob Herring <robh+dt@...nel.org>,
 Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
 Conor Dooley <conor+dt@...nel.org>, Sudeep Holla <sudeep.holla@....com>,
 Saravana Kannan <saravanak@...gle.com>
Cc: Quentin Perret <qperret@...gle.com>,
 Masami Hiramatsu <mhiramat@...gle.com>, Will Deacon <will@...nel.org>,
 Peter Zijlstra <peterz@...radead.org>,
 Vincent Guittot <vincent.guittot@...aro.org>, Marc Zyngier <maz@...nel.org>,
 Oliver Upton <oliver.upton@...ux.dev>,
 Dietmar Eggemann <dietmar.eggemann@....com>,
 Pavan Kondeti <quic_pkondeti@...cinc.com>,
 Gupta Pankaj <pankaj.gupta@....com>, Mel Gorman <mgorman@...e.de>,
 kernel-team@...roid.com, linux-pm@...r.kernel.org,
 devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 2/2] cpufreq: add virtual-cpufreq driver

On 11/11/2023 01:49, David Dai wrote:
> [...]
> diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
> index 8d141c71b016..eb72ecdc24db 100644
> --- a/drivers/cpufreq/Makefile
> +++ b/drivers/cpufreq/Makefile
> @@ -16,6 +16,7 @@ obj-$(CONFIG_CPU_FREQ_GOV_ATTR_SET)	+= cpufreq_governor_attr_set.o
>   
>   obj-$(CONFIG_CPUFREQ_DT)		+= cpufreq-dt.o
>   obj-$(CONFIG_CPUFREQ_DT_PLATDEV)	+= cpufreq-dt-platdev.o
> +obj-$(CONFIG_CPUFREQ_VIRT)		+= virtual-cpufreq.o
>   
>   # Traces
>   CFLAGS_amd-pstate-trace.o               := -I$(src)
> diff --git a/drivers/cpufreq/virtual-cpufreq.c b/drivers/cpufreq/virtual-cpufreq.c
> new file mode 100644
> index 000000000000..f828d3345a68
> --- /dev/null
> +++ b/drivers/cpufreq/virtual-cpufreq.c
> @@ -0,0 +1,201 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (C) 2023 Google LLC
> + */
> +
> +#include <linux/arch_topology.h>
> +#include <linux/cpufreq.h>
> +#include <linux/init.h>
> +#include <linux/sched.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/of_address.h>
> +#include <linux/of_platform.h>
> +#include <linux/pm_opp.h>
> +#include <linux/slab.h>
> +
> +#define REG_CUR_FREQ_KHZ_OFFSET 0x0
> +#define REG_SET_FREQ_KHZ_OFFSET 0x4
> +#define PER_CPU_OFFSET 0x8
> +
> +static void __iomem *base;
> +
> +static void virt_scale_freq_tick(void)
> +{
> +	int cpu = smp_processor_id();
> +	u32 max_freq = (u32)cpufreq_get_hw_max_freq(cpu);
> +	u64 cur_freq;
> +	unsigned long scale;
> +
> +	cur_freq = (u64)readl_relaxed(base + cpu * PER_CPU_OFFSET
> +			+ REG_CUR_FREQ_KHZ_OFFSET);
> +
> +	cur_freq <<= SCHED_CAPACITY_SHIFT;
> +	scale = (unsigned long)div_u64(cur_freq, max_freq);
> +	scale = min(scale, SCHED_CAPACITY_SCALE);
> +
> +	this_cpu_write(arch_freq_scale, scale);
> +}

Here we update the scaling factor in the guest, but is there any way to 
let the guest know when the host dequeues the vCPU so that the guest 
PELT signal doesn't appear larger than it actually is? Is this a known 
limitation and is there a way to mitigate it?

> [...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ