Skip to contentSkip to conversation

cpuidle: haltpoll: Add trace points for guest_halt_poll_ns grow/shrink

PATCH In review Eiichi Tsukata 3 participants 3 messages May 27, 2022 – Jun 14, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 cpuidle: haltpoll: Add trace points for guest_halt_poll_ns grow/shrink

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

---
 drivers/cpuidle/governors/haltpoll.c |  3 +++
 include/trace/events/power.h         | 29 ++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)
drivers/cpuidle/governors/haltpoll.c +3 -0
index cb2a96eafc02..1dff3a52917d 100644
@@ -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);
@@ -90,6 +91,7 @@ static void adjust_poll_limit(struct cpuidle_device *dev, u64 block_ns)
 		if (val > guest_halt_poll_ns)
 			val = guest_halt_poll_ns;
 
+		trace_guest_halt_poll_ns_grow(val, dev->poll_limit_ns);
 		dev->poll_limit_ns = val;
 	} else if (block_ns > guest_halt_poll_ns &&
 		   guest_halt_poll_allow_shrink) {
@@ -100,6 +102,7 @@ static void adjust_poll_limit(struct cpuidle_device *dev, u64 block_ns)
 			val = 0;
 		else
 			val /= shrink;
+		trace_guest_halt_poll_ns_shrink(val, dev->poll_limit_ns);
 		dev->poll_limit_ns = val;
 	}
 }
include/trace/events/power.h +29 -0
index af5018aa9517..c708521e4ed5 100644
@@ -500,6 +500,35 @@ 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 new, unsigned int old),
+
+	TP_ARGS(grow, new, old),
+
+	TP_STRUCT__entry(
+		__field(bool, grow)
+		__field(unsigned int, new)
+		__field(unsigned int, old)
+	),
+
+	TP_fast_assign(
+		__entry->grow   = grow;
+		__entry->new    = new;
+		__entry->old    = old;
+	),
+
+	TP_printk("halt_poll_ns %u (%s %u)",
+		__entry->new,
+		__entry->grow ? "grow" : "shrink",
+		__entry->old)
+);
+
+#define trace_guest_halt_poll_ns_grow(new, old) \
+	trace_guest_halt_poll_ns(true, new, old)
+#define trace_guest_halt_poll_ns_shrink(new, old) \
+	trace_guest_halt_poll_ns(false, new, old)
 #endif /* _TRACE_POWER_H */
 
 /* This part must be outside protection */
Signature · 1 line
2.36.1
#1 lore raw
Quoted 81 lines · Eiichi Tsukata

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

---
 drivers/cpuidle/governors/haltpoll.c |  3 +++
 include/trace/events/power.h         | 29 ++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)
drivers/cpuidle/governors/haltpoll.c +3 -0
index cb2a96eafc02..1dff3a52917d 100644
@@ -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);
@@ -90,6 +91,7 @@ static void adjust_poll_limit(struct cpuidle_device *dev, u64 block_ns)
 		if (val > guest_halt_poll_ns)
 			val = guest_halt_poll_ns;
 
+		trace_guest_halt_poll_ns_grow(val, dev->poll_limit_ns);
 		dev->poll_limit_ns = val;
 	} else if (block_ns > guest_halt_poll_ns &&
 		   guest_halt_poll_allow_shrink) {
@@ -100,6 +102,7 @@ static void adjust_poll_limit(struct cpuidle_device *dev, u64 block_ns)
 			val = 0;
 		else
 			val /= shrink;
+		trace_guest_halt_poll_ns_shrink(val, dev->poll_limit_ns);
 		dev->poll_limit_ns = val;
 	}
 }
include/trace/events/power.h +29 -0
index af5018aa9517..c708521e4ed5 100644
@@ -500,6 +500,35 @@ 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 new, unsigned int old),
+
+	TP_ARGS(grow, new, old),
+
+	TP_STRUCT__entry(
+		__field(bool, grow)
+		__field(unsigned int, new)
+		__field(unsigned int, old)
+	),
+
+	TP_fast_assign(
+		__entry->grow   = grow;
+		__entry->new    = new;
+		__entry->old    = old;
+	),
+
+	TP_printk("halt_poll_ns %u (%s %u)",
+		__entry->new,
+		__entry->grow ? "grow" : "shrink",
+		__entry->old)
+);
+
+#define trace_guest_halt_poll_ns_grow(new, old) \
+	trace_guest_halt_poll_ns(true, new, old)
+#define trace_guest_halt_poll_ns_shrink(new, old) \
+	trace_guest_halt_poll_ns(false, new, old)
 #endif /* _TRACE_POWER_H */
 
 /* This part must be outside protection */
Signature · 1 line
2.36.1
#2 lore raw
Quoted 78 lines · Marcelo Tosatti
Quoted 76 lines · Eiichi Tsukata

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

---
 drivers/cpuidle/governors/haltpoll.c |  3 +++
 include/trace/events/power.h         | 29 ++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)
drivers/cpuidle/governors/haltpoll.c +3 -0
index cb2a96eafc02..1dff3a52917d 100644
@@ -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);
@@ -90,6 +91,7 @@ static void adjust_poll_limit(struct cpuidle_device *dev, u64 block_ns)
              if (val > guest_halt_poll_ns)
                      val = guest_halt_poll_ns;
 
+             trace_guest_halt_poll_ns_grow(val, dev->poll_limit_ns);
              dev->poll_limit_ns = val;
      } else if (block_ns > guest_halt_poll_ns &&
                 guest_halt_poll_allow_shrink) {
@@ -100,6 +102,7 @@ static void adjust_poll_limit(struct cpuidle_device *dev, u64 block_ns)
                      val = 0;
              else
                      val /= shrink;
+             trace_guest_halt_poll_ns_shrink(val, dev->poll_limit_ns);
              dev->poll_limit_ns = val;
      }
 }
include/trace/events/power.h +29 -0
index af5018aa9517..c708521e4ed5 100644
@@ -500,6 +500,35 @@ 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 new, unsigned int old),
+
+     TP_ARGS(grow, new, old),
+
+     TP_STRUCT__entry(
+             __field(bool, grow)
+             __field(unsigned int, new)
+             __field(unsigned int, old)
+     ),
+
+     TP_fast_assign(
+             __entry->grow   = grow;
+             __entry->new    = new;
+             __entry->old    = old;
+     ),
+
+     TP_printk("halt_poll_ns %u (%s %u)",
+             __entry->new,
+             __entry->grow ? "grow" : "shrink",
+             __entry->old)
+);
+
+#define trace_guest_halt_poll_ns_grow(new, old) \
+     trace_guest_halt_poll_ns(true, new, old)
+#define trace_guest_halt_poll_ns_shrink(new, old) \
+     trace_guest_halt_poll_ns(false, new, old)
 #endif /* _TRACE_POWER_H */
 
Quoted 7 lines
Quoted 5 lines
include/trace/events/power.h +0 -1
 /* This part must be outside protection */
--

2.36.1

I took this as an ACK and applied the patch as 5.20 material.

Thanks!