Skip to contentSkip to conversation

kvm: remove dependence on delay-accounting

PATCH Superseded Konstantin Khlebnikov 3 participants 7 messages Jan 14, 2012 – Jan 16, 2012

Subsystems (5)
x86 KVM Library code Scheduler +1 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kvm: remove dependence on delay-accounting

KVM selects delay-accounting only to get sched-info for steal-time accounting. Meanwhile delay-accounting can be disabled by boot option. This is ridiculous.

This patch adds internal boolean option CONFIG_TASK_SCHED_INFO to enable only task->sched_info and its collecting inside scheduler.

---
 arch/x86/kvm/Kconfig  |    5 +----
 include/linux/sched.h |    6 ++----
 init/Kconfig          |    7 +++++++
 kernel/sched/core.c   |    2 +-
 kernel/sched/stats.h  |    4 ++--
 lib/Kconfig.debug     |    1 +
 6 files changed, 14 insertions(+), 11 deletions(-)
arch/x86/kvm/Kconfig +1 -4
index 1a7fe86..2e27d8c 100644
@@ -22,8 +22,6 @@ config KVM
 	depends on HAVE_KVM
 	# for device assignment:
 	depends on PCI
-	# for TASKSTATS/TASK_DELAY_ACCT:
-	depends on NET
 	select PREEMPT_NOTIFIERS
 	select MMU_NOTIFIER
 	select ANON_INODES
@@ -33,8 +31,7 @@ config KVM
 	select KVM_ASYNC_PF
 	select USER_RETURN_NOTIFIER
 	select KVM_MMIO
-	select TASKSTATS
-	select TASK_DELAY_ACCT
+	select TAKS_SCHED_INFO
 	select PERF_EVENTS
 	---help---
 	  Support hosting fully virtualized guest machines using hardware
include/linux/sched.h +2 -4
index 868cb83..dd5bf78 100644
@@ -734,7 +734,6 @@ extern struct user_struct root_user;
 
 struct backing_dev_info;
 
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
 struct sched_info {
 	/* cumulative counters */
 	unsigned long pcount;	      /* # of times run on this cpu */
@@ -744,7 +743,6 @@ struct sched_info {
 	unsigned long long last_arrival,/* when we last ran on a cpu */
 			   last_queued;	/* when we were last queued to run */
 };
-#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */
 
 #ifdef CONFIG_TASK_DELAY_ACCT
 struct task_delay_info {
@@ -782,7 +780,7 @@ struct task_delay_info {
 
 static inline int sched_info_on(void)
 {
-#ifdef CONFIG_SCHEDSTATS
+#if IS_ENABLED(CONFIG_SCHEDSTATS) || IS_ENABLED(CONFIG_KVM)
 	return 1;
 #elif defined(CONFIG_TASK_DELAY_ACCT)
 	extern int delayacct_on;
@@ -1285,7 +1283,7 @@ struct task_struct {
 	struct rt_mutex *rcu_boost_mutex;
 #endif /* #ifdef CONFIG_RCU_BOOST */
 
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+#ifdef CONFIG_TASK_SCHED_INFO
 	struct sched_info sched_info;
 #endif
 
init/Kconfig +7 -0
index 6ac2236..ee0dd4b 100644
@@ -318,6 +318,7 @@ config TASKSTATS
 config TASK_DELAY_ACCT
 	bool "Enable per-task delay accounting (EXPERIMENTAL)"
 	depends on TASKSTATS
+	select TASK_SCHED_INFO
 	help
 	  Collect information on time spent by a task waiting for system
 	  resources like cpu, synchronous block I/O completion and swapping
@@ -860,6 +861,12 @@ config SCHED_AUTOGROUP
 	  desktop applications.  Task group autogeneration is currently based
 	  upon task session.
 
+#
+# collect per-task scheduler statistics
+#
+config TASK_SCHED_INFO
+	bool
+
 config MM_OWNER
 	bool
 
kernel/sched/core.c +1 -1
index fd7b25e..bf5616d 100644
@@ -1758,7 +1758,7 @@ void sched_fork(struct task_struct *p)
 	set_task_cpu(p, cpu);
 	raw_spin_unlock_irqrestore(&p->pi_lock, flags);
 
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+#ifdef CONFIG_TASK_SCHED_INFO
 	if (likely(sched_info_on()))
 		memset(&p->sched_info, 0, sizeof(p->sched_info));
 #endif
kernel/sched/stats.h +2 -2
index 2ef90a5..2322b86 100644
@@ -47,7 +47,7 @@ rq_sched_info_depart(struct rq *rq, unsigned long long delta)
 # define schedstat_set(var, val)	do { } while (0)
 #endif
 
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+#ifdef CONFIG_TASK_SCHED_INFO
 static inline void sched_info_reset_dequeued(struct task_struct *t)
 {
 	t->sched_info.last_queued = 0;
@@ -153,7 +153,7 @@ sched_info_switch(struct task_struct *prev, struct task_struct *next)
 #define sched_info_reset_dequeued(t)	do { } while (0)
 #define sched_info_dequeued(t)			do { } while (0)
 #define sched_info_switch(t, next)		do { } while (0)
-#endif /* CONFIG_SCHEDSTATS || CONFIG_TASK_DELAY_ACCT */
+#endif /* CONFIG_TASK_SCHED_INFO */
 
 /*
  * The following are functions that support scheduler-internal time accounting.
lib/Kconfig.debug +1 -0
index 82928f5..f2e9ee3 100644
@@ -290,6 +290,7 @@ config SCHED_DEBUG
 config SCHEDSTATS
 	bool "Collect scheduler statistics"
 	depends on DEBUG_KERNEL && PROC_FS
+	select TASK_SCHED_INFO
 	help
 	  If you say Y here, additional code will be inserted into the
 	  scheduler and related routines to collect statistics about
#1 lore raw

PATCH v2 1/1 kvm: remove dependence on delay-accounting

KVM selects delay-accounting only to get sched-info for steal-time accounting. Meanwhile delay-accounting can be disabled by boot option. This is ridiculous.

This patch adds internal boolean option CONFIG_TASK_SCHED_INFO to enable only task->sched_info and its collecting inside scheduler.

v2:
* stupid misprint fixed

---
 arch/x86/kvm/Kconfig  |    5 +----
 include/linux/sched.h |    6 ++----
 init/Kconfig          |    7 +++++++
 kernel/sched/core.c   |    2 +-
 kernel/sched/stats.h  |    4 ++--
 lib/Kconfig.debug     |    1 +
 6 files changed, 14 insertions(+), 11 deletions(-)
arch/x86/kvm/Kconfig +1 -4
index 1a7fe86..e3952e8 100644
@@ -22,8 +22,6 @@ config KVM
 	depends on HAVE_KVM
 	# for device assignment:
 	depends on PCI
-	# for TASKSTATS/TASK_DELAY_ACCT:
-	depends on NET
 	select PREEMPT_NOTIFIERS
 	select MMU_NOTIFIER
 	select ANON_INODES
@@ -33,8 +31,7 @@ config KVM
 	select KVM_ASYNC_PF
 	select USER_RETURN_NOTIFIER
 	select KVM_MMIO
-	select TASKSTATS
-	select TASK_DELAY_ACCT
+	select TASK_SCHED_INFO
 	select PERF_EVENTS
 	---help---
 	  Support hosting fully virtualized guest machines using hardware
include/linux/sched.h +2 -4
index 868cb83..dd5bf78 100644
@@ -734,7 +734,6 @@ extern struct user_struct root_user;
 
 struct backing_dev_info;
 
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
 struct sched_info {
 	/* cumulative counters */
 	unsigned long pcount;	      /* # of times run on this cpu */
@@ -744,7 +743,6 @@ struct sched_info {
 	unsigned long long last_arrival,/* when we last ran on a cpu */
 			   last_queued;	/* when we were last queued to run */
 };
-#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */
 
 #ifdef CONFIG_TASK_DELAY_ACCT
 struct task_delay_info {
@@ -782,7 +780,7 @@ struct task_delay_info {
 
 static inline int sched_info_on(void)
 {
-#ifdef CONFIG_SCHEDSTATS
+#if IS_ENABLED(CONFIG_SCHEDSTATS) || IS_ENABLED(CONFIG_KVM)
 	return 1;
 #elif defined(CONFIG_TASK_DELAY_ACCT)
 	extern int delayacct_on;
@@ -1285,7 +1283,7 @@ struct task_struct {
 	struct rt_mutex *rcu_boost_mutex;
 #endif /* #ifdef CONFIG_RCU_BOOST */
 
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+#ifdef CONFIG_TASK_SCHED_INFO
 	struct sched_info sched_info;
 #endif
 
init/Kconfig +7 -0
index 6ac2236..ee0dd4b 100644
@@ -318,6 +318,7 @@ config TASKSTATS
 config TASK_DELAY_ACCT
 	bool "Enable per-task delay accounting (EXPERIMENTAL)"
 	depends on TASKSTATS
+	select TASK_SCHED_INFO
 	help
 	  Collect information on time spent by a task waiting for system
 	  resources like cpu, synchronous block I/O completion and swapping
@@ -860,6 +861,12 @@ config SCHED_AUTOGROUP
 	  desktop applications.  Task group autogeneration is currently based
 	  upon task session.
 
+#
+# collect per-task scheduler statistics
+#
+config TASK_SCHED_INFO
+	bool
+
 config MM_OWNER
 	bool
 
kernel/sched/core.c +1 -1
index fd7b25e..bf5616d 100644
@@ -1758,7 +1758,7 @@ void sched_fork(struct task_struct *p)
 	set_task_cpu(p, cpu);
 	raw_spin_unlock_irqrestore(&p->pi_lock, flags);
 
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+#ifdef CONFIG_TASK_SCHED_INFO
 	if (likely(sched_info_on()))
 		memset(&p->sched_info, 0, sizeof(p->sched_info));
 #endif
kernel/sched/stats.h +2 -2
index 2ef90a5..2322b86 100644
@@ -47,7 +47,7 @@ rq_sched_info_depart(struct rq *rq, unsigned long long delta)
 # define schedstat_set(var, val)	do { } while (0)
 #endif
 
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+#ifdef CONFIG_TASK_SCHED_INFO
 static inline void sched_info_reset_dequeued(struct task_struct *t)
 {
 	t->sched_info.last_queued = 0;
@@ -153,7 +153,7 @@ sched_info_switch(struct task_struct *prev, struct task_struct *next)
 #define sched_info_reset_dequeued(t)	do { } while (0)
 #define sched_info_dequeued(t)			do { } while (0)
 #define sched_info_switch(t, next)		do { } while (0)
-#endif /* CONFIG_SCHEDSTATS || CONFIG_TASK_DELAY_ACCT */
+#endif /* CONFIG_TASK_SCHED_INFO */
 
 /*
  * The following are functions that support scheduler-internal time accounting.
lib/Kconfig.debug +1 -0
index 82928f5..f2e9ee3 100644
@@ -290,6 +290,7 @@ config SCHED_DEBUG
 config SCHEDSTATS
 	bool "Collect scheduler statistics"
 	depends on DEBUG_KERNEL && PROC_FS
+	select TASK_SCHED_INFO
 	help
 	  If you say Y here, additional code will be inserted into the
 	  scheduler and related routines to collect statistics about
#2 lore raw
Quoted 63 lines · Konstantin Khlebnikov

KVM selects delay-accounting only to get sched-info for steal-time accounting. Meanwhile delay-accounting can be disabled by boot option. This is ridiculous.

This patch adds internal boolean option CONFIG_TASK_SCHED_INFO to enable only task->sched_info and its collecting inside scheduler.

v2:
* stupid misprint fixed

---
 arch/x86/kvm/Kconfig  |    5 +----
 include/linux/sched.h |    6 ++----
 init/Kconfig          |    7 +++++++
 kernel/sched/core.c   |    2 +-
 kernel/sched/stats.h  |    4 ++--
 lib/Kconfig.debug     |    1 +
 6 files changed, 14 insertions(+), 11 deletions(-)
arch/x86/kvm/Kconfig +1 -4
index 1a7fe86..e3952e8 100644
@@ -22,8 +22,6 @@ config KVM
 	depends on HAVE_KVM
 	# for device assignment:
 	depends on PCI
-	# for TASKSTATS/TASK_DELAY_ACCT:
-	depends on NET
 	select PREEMPT_NOTIFIERS
 	select MMU_NOTIFIER
 	select ANON_INODES
@@ -33,8 +31,7 @@ config KVM
 	select KVM_ASYNC_PF
 	select USER_RETURN_NOTIFIER
 	select KVM_MMIO
-	select TASKSTATS
-	select TASK_DELAY_ACCT
+	select TASK_SCHED_INFO
 	select PERF_EVENTS
 	---help---
 	  Support hosting fully virtualized guest machines using hardware
include/linux/sched.h +0 -2
index 868cb83..dd5bf78 100644
@@ -734,7 +734,6 @@ extern struct user_struct root_user;
 
 struct backing_dev_info;
 
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
 struct sched_info {
 	/* cumulative counters */
 	unsigned long pcount;	      /* # of times run on this cpu */
@@ -744,7 +743,6 @@ struct sched_info {
 	unsigned long long last_arrival,/* when we last ran on a cpu */
 			   last_queued;	/* when we were last queued to run */
 };
-#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */
 
 #ifdef CONFIG_TASK_DELAY_ACCT
 struct task_delay_info {

include/linux/sched.h struct task_delay_info { · line 784

Quoted 6 lines
include/linux/sched.h +1 -1
@@ -782,7 +780,7 @@ struct task_delay_info {
 
 static inline int sched_info_on(void)
 {
-#ifdef CONFIG_SCHEDSTATS
+#if IS_ENABLED(CONFIG_SCHEDSTATS) || IS_ENABLED(CONFIG_KVM)
 	return 1;

CONFIG_TASK_SCHED_INFO?

maintainer
#4 lore raw
In reply to Konstantin Khlebnikov
Quoted 5 lines · Konstantin Khlebnikov

KVM selects delay-accounting only to get sched-info for steal-time accounting. Meanwhile delay-accounting can be disabled by boot option. This is ridiculous.

This patch adds internal boolean option CONFIG_TASK_SCHED_INFO to enable only task->sched_info and its collecting inside scheduler.

Urgh, more stupid config knobs, we should be removing them, not adding moar.

Quoted 13 lines
include/linux/sched.h +0 -1
index 868cb83..dd5bf78 100644
@@ -734,7 +734,6 @@ extern struct user_struct root_user;
 
 struct backing_dev_info;
 
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
 struct sched_info {
 	/* cumulative counters */
 	unsigned long pcount;	      /* # of times run on this cpu */

include/linux/sched.h struct sched_info { · line 747

Quoted 4 lines
include/linux/sched.h +0 -1
@@ -744,7 +743,6 @@ struct sched_info {
 	unsigned long long last_arrival,/* when we last ran on a cpu */
 			   last_queued;	/* when we were last queued to run */
 };
-#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */

Not having that structure helps with compile errors.

include/linux/sched.h struct task_delay_info { · line 783

Quoted 8 lines
include/linux/sched.h +1 -1
 #ifdef CONFIG_TASK_DELAY_ACCT
 struct task_delay_info {
@@ -782,7 +780,7 @@ struct task_delay_info {
 
 static inline int sched_info_on(void)
 {
-#ifdef CONFIG_SCHEDSTATS
+#if IS_ENABLED(CONFIG_SCHEDSTATS) || IS_ENABLED(CONFIG_KVM)

WTF is IS_ENABLED and why do you use it?

Not much like this stuff.

#3 lore raw
In reply to Marcelo Tosatti
Quoted 7 lines · Marcelo Tosatti
Quoted 6 lines · Konstantin Khlebnikov

KVM selects delay-accounting only to get sched-info for steal-time accounting. Meanwhile delay-accounting can be disabled by boot option. This is ridiculous.

This patch adds internal boolean option CONFIG_TASK_SCHED_INFO to enable only task->sched_info and its collecting inside scheduler.

<cut>

Quoted 8 lines

include/linux/sched.h struct task_delay_info { · line 784

Quoted 5 lines
  static inline int sched_info_on(void)
  {
include/linux/sched.h +1 -1
-#ifdef CONFIG_SCHEDSTATS
+#if IS_ENABLED(CONFIG_SCHEDSTATS) || IS_ENABLED(CONFIG_KVM)
  	return 1;

CONFIG_TASK_SCHED_INFO?

It makes it equal to constant 1, because all its callers are under #ifdef CONFIG_TASK_SCHED_INFO =)

its current code:

static inline int sched_info_on(void)
{

#ifdef CONFIG_SCHEDSTATS
	return 1;
#elif defined(CONFIG_TASK_DELAY_ACCT)
	extern int delayacct_on;
	return delayacct_on;
#else
	return 0;

#endif
}

CONFIG_SCHEDSTATS == debug option in lib/Kconfig.debug for /proc/schedstat CONFIG_TASK_DELAY_ACCT == wierd net-link based statistics collecting tool

Thus, may be better to remove this function, because it can return 0 only if delay-accounting is compiled but disabled by boot option (delayacct_on =1 by default since 2.6.18)

patch follows...

#6 lore raw

PATCH 1/1 sched: remove task-sched-info dynamic disabler

In reply to Konstantin Khlebnikov

Currently per-task sched-info statistics can be disabled if delay-accounting is disabled by boot option. There is no reason for it, sched-info is built-in into task-struct, and its collecting does not add any extra atomic operations. In other combinations it either not compiled or cannot be disabled.

This patch removes sched_info_on() and fixes all its users.

---
 arch/x86/kvm/cpuid.c  |    6 ++----
 arch/x86/kvm/x86.c    |    4 ----
 include/linux/sched.h |   12 ------------
 kernel/sched/core.c   |    3 +--
 kernel/sched/stats.h  |   18 +++++-------------
 5 files changed, 8 insertions(+), 35 deletions(-)
arch/x86/kvm/cpuid.c +2 -4
index 89b02bf..12870d8 100644
@@ -408,10 +408,8 @@ static int do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 			     (1 << KVM_FEATURE_NOP_IO_DELAY) |
 			     (1 << KVM_FEATURE_CLOCKSOURCE2) |
 			     (1 << KVM_FEATURE_ASYNC_PF) |
-			     (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT);
-
-		if (sched_info_on())
-			entry->eax |= (1 << KVM_FEATURE_STEAL_TIME);
+			     (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT) |
+			     (1 << KVM_FEATURE_STEAL_TIME);
 
 		entry->ebx = 0;
 		entry->ecx = 0;
arch/x86/kvm/x86.c +0 -4
index 14d6cad..a60645c 100644
@@ -1579,10 +1579,6 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
 			return 1;
 		break;
 	case MSR_KVM_STEAL_TIME:
-
-		if (unlikely(!sched_info_on()))
-			return 1;
-
 		if (data & KVM_STEAL_RESERVED_MASK)
 			return 1;
 
include/linux/sched.h +0 -12
index dd5bf78..eb8842e 100644
@@ -778,18 +778,6 @@ struct task_delay_info {
 };
 #endif	/* CONFIG_TASK_DELAY_ACCT */
 
-static inline int sched_info_on(void)
-{
-#if IS_ENABLED(CONFIG_SCHEDSTATS) || IS_ENABLED(CONFIG_KVM)
-	return 1;
-#elif defined(CONFIG_TASK_DELAY_ACCT)
-	extern int delayacct_on;
-	return delayacct_on;
-#else
-	return 0;
-#endif
-}
-
 enum cpu_idle_type {
 	CPU_IDLE,
 	CPU_NOT_IDLE,
kernel/sched/core.c +1 -2
index 0c59dcb..73acf77 100644
@@ -1759,8 +1759,7 @@ void sched_fork(struct task_struct *p)
 	raw_spin_unlock_irqrestore(&p->pi_lock, flags);
 
 #ifdef CONFIG_TASK_SCHED_INFO
-	if (likely(sched_info_on()))
-		memset(&p->sched_info, 0, sizeof(p->sched_info));
+	memset(&p->sched_info, 0, sizeof(p->sched_info));
 #endif
 #if defined(CONFIG_SMP)
 	p->on_cpu = 0;
kernel/sched/stats.h +5 -13
index 2322b86..e6363ed 100644
@@ -63,9 +63,8 @@ static inline void sched_info_dequeued(struct task_struct *t)
 {
 	unsigned long long now = task_rq(t)->clock, delta = 0;
 
-	if (unlikely(sched_info_on()))
-		if (t->sched_info.last_queued)
-			delta = now - t->sched_info.last_queued;
+	if (t->sched_info.last_queued)
+		delta = now - t->sched_info.last_queued;
 	sched_info_reset_dequeued(t);
 	t->sched_info.run_delay += delta;
 
@@ -98,9 +97,8 @@ static void sched_info_arrive(struct task_struct *t)
  */
 static inline void sched_info_queued(struct task_struct *t)
 {
-	if (unlikely(sched_info_on()))
-		if (!t->sched_info.last_queued)
-			t->sched_info.last_queued = task_rq(t)->clock;
+	if (!t->sched_info.last_queued)
+		t->sched_info.last_queued = task_rq(t)->clock;
 }
 
 /*
@@ -127,7 +125,7 @@ static inline void sched_info_depart(struct task_struct *t)
  * the idle task.)  We are only called when prev != next.
  */
 static inline void
-__sched_info_switch(struct task_struct *prev, struct task_struct *next)
+sched_info_switch(struct task_struct *prev, struct task_struct *next)
 {
 	struct rq *rq = task_rq(prev);
 
@@ -142,12 +140,6 @@ __sched_info_switch(struct task_struct *prev, struct task_struct *next)
 	if (next != rq->idle)
 		sched_info_arrive(next);
 }
-static inline void
-sched_info_switch(struct task_struct *prev, struct task_struct *next)
-{
-	if (unlikely(sched_info_on()))
-		__sched_info_switch(prev, next);
-}
 #else
 #define sched_info_queued(t)			do { } while (0)
 #define sched_info_reset_dequeued(t)	do { } while (0)
#5 lore raw
In reply to Peter Zijlstra
Quoted 9 lines · Peter Zijlstra
Quoted 5 lines · Konstantin Khlebnikov

KVM selects delay-accounting only to get sched-info for steal-time accounting. Meanwhile delay-accounting can be disabled by boot option. This is ridiculous.

This patch adds internal boolean option CONFIG_TASK_SCHED_INFO to enable only task->sched_info and its collecting inside scheduler.

Urgh, more stupid config knobs, we should be removing them, not adding moar.

Unfortunately, removing task-delay-accounting is not the option =)

Quoted 9 lines
Quoted 9 lines
include/linux/sched.h +0 -0
index 868cb83..dd5bf78 100644
@@ -734,7 +734,6 @@ extern struct user_struct root_user;
 
  struct backing_dev_info;
 
Quoted 11 lines

include/linux/sched.h struct sched_info { · line 747

Quoted 9 lines
include/linux/sched.h +0 -2
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
  struct sched_info {
  	/* cumulative counters */
  	unsigned long pcount;	      /* # of times run on this cpu */
@@ -744,7 +743,6 @@ struct sched_info {
  	unsigned long long last_arrival,/* when we last ran on a cpu */
  			   last_queued;	/* when we were last queued to run */
  };
-#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */

Not having that structure helps with compile errors.

I don't think so, this only helps to catch useless declarations and definitions in code and inside other structures.

Quoted 11 lines

include/linux/sched.h struct task_delay_info { · line 783

Quoted 9 lines
include/linux/sched.h +1 -1
  #ifdef CONFIG_TASK_DELAY_ACCT
  struct task_delay_info {
@@ -782,7 +780,7 @@ struct task_delay_info {
 
  static inline int sched_info_on(void)
  {
-#ifdef CONFIG_SCHEDSTATS
+#if IS_ENABLED(CONFIG_SCHEDSTATS) || IS_ENABLED(CONFIG_KVM)

WTF is IS_ENABLED and why do you use it?

IS_ENABLED(smth) == (defined(smth) || defined(smth_MODULE)) but using it for CONFIG_SCHEDSTATS is overkill, indeed.

Quoted 3 lines

Not much like this stuff.