All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpuidle: haltpoll: Add trace points for guest_halt_poll_ns grow/shrink
@ 2022-05-23  6:35 Eiichi Tsukata
  2022-05-23 11:33 ` Eiichi Tsukata
  0 siblings, 1 reply; 2+ messages in thread
From: Eiichi Tsukata @ 2022-05-23  6:35 UTC (permalink / raw)
  To: rafael, daniel.lezcano, rostedt, mingo, linux-pm, linux-kernel,
	joao.m.martins, mtosatti
  Cc: Eiichi Tsukata

Add trace points as are implemented in KVM host halt polling.
This helps tune guest halt polling params.

Signed-off-by: Eiichi Tsukata <eiichi.tsukata@nutanix.com>
---
 drivers/cpuidle/governors/haltpoll.c |  7 +++++-
 include/trace/events/power.h         | 33 ++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/drivers/cpuidle/governors/haltpoll.c b/drivers/cpuidle/governors/haltpoll.c
index cb2a96eafc02..9a6eca41a484 100644
--- a/drivers/cpuidle/governors/haltpoll.c
+++ b/drivers/cpuidle/governors/haltpoll.c
@@ -19,6 +19,7 @@
 #include <linux/sched.h>
 #include <linux/module.h>
 #include <linux/kvm_para.h>
+#include <trace/events/power.h>
 
 static unsigned int guest_halt_poll_ns __read_mostly = 200000;
 module_param(guest_halt_poll_ns, uint, 0644);
@@ -77,13 +78,14 @@ static int haltpoll_select(struct cpuidle_driver *drv,
 
 static void adjust_poll_limit(struct cpuidle_device *dev, u64 block_ns)
 {
-	unsigned int val;
+	unsigned int val, old;
 
 	/* Grow cpu_halt_poll_us if
 	 * cpu_halt_poll_us < block_ns < guest_halt_poll_us
 	 */
 	if (block_ns > dev->poll_limit_ns && block_ns <= guest_halt_poll_ns) {
 		val = dev->poll_limit_ns * guest_halt_poll_grow;
+		old = val;
 
 		if (val < guest_halt_poll_grow_start)
 			val = guest_halt_poll_grow_start;
@@ -91,16 +93,19 @@ static void adjust_poll_limit(struct cpuidle_device *dev, u64 block_ns)
 			val = guest_halt_poll_ns;
 
 		dev->poll_limit_ns = val;
+		trace_guest_halt_poll_ns_grow(smp_processor_id(), val, old);
 	} else if (block_ns > guest_halt_poll_ns &&
 		   guest_halt_poll_allow_shrink) {
 		unsigned int shrink = guest_halt_poll_shrink;
 
 		val = dev->poll_limit_ns;
+		old = val;
 		if (shrink == 0)
 			val = 0;
 		else
 			val /= shrink;
 		dev->poll_limit_ns = val;
+		trace_guest_halt_poll_ns_shrink(smp_processor_id(), val, old);
 	}
 }
 
diff --git a/include/trace/events/power.h b/include/trace/events/power.h
index af5018aa9517..db065af9c3c0 100644
--- a/include/trace/events/power.h
+++ b/include/trace/events/power.h
@@ -500,6 +500,39 @@ DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_remove_request,
 
 	TP_ARGS(name, type, new_value)
 );
+
+TRACE_EVENT(guest_halt_poll_ns,
+
+	TP_PROTO(bool grow, unsigned int cpu_id,
+		 unsigned int new, unsigned int old),
+
+	TP_ARGS(grow, cpu_id, new, old),
+
+	TP_STRUCT__entry(
+		__field(bool, grow)
+		__field(unsigned int, cpu_id)
+		__field(unsigned int, new)
+		__field(unsigned int, old)
+	),
+
+	TP_fast_assign(
+		__entry->grow   = grow;
+		__entry->cpu_id = cpu_id;
+		__entry->new    = new;
+		__entry->old    = old;
+	),
+
+	TP_printk("cpu %u: halt_poll_ns %u (%s %u)",
+		__entry->cpu_id,
+		__entry->new,
+		__entry->grow ? "grow" : "shrink",
+		__entry->old)
+);
+
+#define trace_guest_halt_poll_ns_grow(cpu_id, new, old) \
+	trace_guest_halt_poll_ns(true, cpu_id, new, old)
+#define trace_guest_halt_poll_ns_shrink(cpu_id, new, old) \
+	trace_guest_halt_poll_ns(false, cpu_id, new, old)
 #endif /* _TRACE_POWER_H */
 
 /* This part must be outside protection */
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] cpuidle: haltpoll: Add trace points for guest_halt_poll_ns grow/shrink
  2022-05-23  6:35 [PATCH] cpuidle: haltpoll: Add trace points for guest_halt_poll_ns grow/shrink Eiichi Tsukata
@ 2022-05-23 11:33 ` Eiichi Tsukata
  0 siblings, 0 replies; 2+ messages in thread
From: Eiichi Tsukata @ 2022-05-23 11:33 UTC (permalink / raw)
  To: rafael, daniel.lezcano, rostedt, mingo, linux-pm, linux-kernel,
	joao.m.martins, mtosatti



> On May 23, 2022, at 15:35, Eiichi Tsukata <eiichi.tsukata@nutanix.com> wrote:
> 
> Add trace points as are implemented in KVM host halt polling.
> This helps tune guest halt polling params.
> 
> Signed-off-by: Eiichi Tsukata <eiichi.tsukata@nutanix.com>
> ---
> drivers/cpuidle/governors/haltpoll.c |  7 +++++-
> include/trace/events/power.h         | 33 ++++++++++++++++++++++++++++
> 2 files changed, 39 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/cpuidle/governors/haltpoll.c b/drivers/cpuidle/governors/haltpoll.c
> index cb2a96eafc02..9a6eca41a484 100644
> --- a/drivers/cpuidle/governors/haltpoll.c
> +++ b/drivers/cpuidle/governors/haltpoll.c
> @@ -19,6 +19,7 @@
> #include <linux/sched.h>
> #include <linux/module.h>
> #include <linux/kvm_para.h>
> +#include <trace/events/power.h>
> 
> static unsigned int guest_halt_poll_ns __read_mostly = 200000;
> module_param(guest_halt_poll_ns, uint, 0644);
> @@ -77,13 +78,14 @@ static int haltpoll_select(struct cpuidle_driver *drv,
> 
> static void adjust_poll_limit(struct cpuidle_device *dev, u64 block_ns)
> {
> -	unsigned int val;
> +	unsigned int val, old;
> 
> 	/* Grow cpu_halt_poll_us if
> 	 * cpu_halt_poll_us < block_ns < guest_halt_poll_us
> 	 */
> 	if (block_ns > dev->poll_limit_ns && block_ns <= guest_halt_poll_ns) {
> 		val = dev->poll_limit_ns * guest_halt_poll_grow;
> +		old = val;

This sets wrong old val. Will fix it in v2.

Eiichi


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-23 11:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-23  6:35 [PATCH] cpuidle: haltpoll: Add trace points for guest_halt_poll_ns grow/shrink Eiichi Tsukata
2022-05-23 11:33 ` Eiichi Tsukata

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.