[4/5] cpuidle: governor: Export the needed symbols

Message ID 20201015144431.9979-4-daniel.lezcano@linaro.org
State New
Headers show
Series
  • [1/5] cpuidle: Remove pointless stub
Related show

Commit Message

Daniel Lezcano Oct. 15, 2020, 2:44 p.m.
In the next patch, the governors will be converted to modules. Export
the symbols of the different functions used by the governors.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/cpuidle/governor.c | 3 +++
 include/linux/tick.h       | 2 ++
 kernel/sched/core.c        | 1 +
 kernel/time/tick-sched.c   | 9 +++++++++
 4 files changed, 15 insertions(+)

Comments

Rafael J. Wysocki Nov. 5, 2020, 2:04 p.m. | #1
On Thu, Oct 15, 2020 at 4:45 PM Daniel Lezcano
<daniel.lezcano@linaro.org> wrote:
>

> In the next patch, the governors will be converted to modules. Export

> the symbols of the different functions used by the governors.

>

> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

> ---

>  drivers/cpuidle/governor.c | 3 +++

>  include/linux/tick.h       | 2 ++

>  kernel/sched/core.c        | 1 +

>  kernel/time/tick-sched.c   | 9 +++++++++

>  4 files changed, 15 insertions(+)

>

> diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c

> index 6ec27ef096f5..2791fe352f51 100644

> --- a/drivers/cpuidle/governor.c

> +++ b/drivers/cpuidle/governor.c

> @@ -120,6 +120,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)

>

>         mutex_unlock(&cpuidle_lock);

>  }

> +EXPORT_SYMBOL(cpuidle_unregister_governor);

>

>  /**

>   * cpuidle_register_governor - registers a governor

> @@ -150,6 +151,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)

>

>         return ret;

>  }

> +EXPORT_SYMBOL(cpuidle_register_governor);

>

>  /**

>   * cpuidle_governor_latency_req - Compute a latency constraint for CPU

> @@ -166,3 +168,4 @@ s64 cpuidle_governor_latency_req(unsigned int cpu)

>

>         return (s64)device_req * NSEC_PER_USEC;

>  }

> +EXPORT_SYMBOL(cpuidle_governor_latency_req);

> diff --git a/include/linux/tick.h b/include/linux/tick.h

> index 7340613c7eff..8349ba050b9c 100644

> --- a/include/linux/tick.h

> +++ b/include/linux/tick.h

> @@ -124,6 +124,7 @@ enum tick_dep_bits {

>

>  #ifdef CONFIG_NO_HZ_COMMON

>  extern bool tick_nohz_enabled;

> +extern bool tick_nohz_is_enabled(void);

>  extern bool tick_nohz_tick_stopped(void);

>  extern bool tick_nohz_tick_stopped_cpu(int cpu);

>  extern void tick_nohz_idle_stop_tick(void);

> @@ -149,6 +150,7 @@ static inline void tick_nohz_idle_stop_tick_protected(void)

>

>  #else /* !CONFIG_NO_HZ_COMMON */

>  #define tick_nohz_enabled (0)

> +static inline int tick_nohz_is_enabled(void) { return 0 };

>  static inline int tick_nohz_tick_stopped(void) { return 0; }

>  static inline int tick_nohz_tick_stopped_cpu(int cpu) { return 0; }

>  static inline void tick_nohz_idle_stop_tick(void) { }

> diff --git a/kernel/sched/core.c b/kernel/sched/core.c

> index 2d95dc3f4644..ceba61bb364d 100644

> --- a/kernel/sched/core.c

> +++ b/kernel/sched/core.c

> @@ -3838,6 +3838,7 @@ unsigned long nr_iowait_cpu(int cpu)

>  {

>         return atomic_read(&cpu_rq(cpu)->nr_iowait);

>  }

> +EXPORT_SYMBOL_GPL(nr_iowait_cpu);


Hmm.  See below.

>

>  /*

>   * IO-wait accounting, and how its mostly bollocks (on SMP).

> diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c

> index f0199a4ba1ad..537716124d46 100644

> --- a/kernel/time/tick-sched.c

> +++ b/kernel/time/tick-sched.c

> @@ -500,12 +500,19 @@ static int __init setup_tick_nohz(char *str)

>

>  __setup("nohz=", setup_tick_nohz);

>

> +bool tick_nohz_is_enabled(void)

> +{

> +       return tick_nohz_enabled;

> +}

> +EXPORT_SYMBOL_GPL(tick_nohz_is_enabled);

> +

>  bool tick_nohz_tick_stopped(void)

>  {

>         struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);

>

>         return ts->tick_stopped;

>  }

> +EXPORT_SYMBOL_GPL(tick_nohz_tick_stopped);

>

>  bool tick_nohz_tick_stopped_cpu(int cpu)

>  {

> @@ -1066,6 +1073,7 @@ bool tick_nohz_idle_got_tick(void)

>         }

>         return false;

>  }

> +EXPORT_SYMBOL_GPL(tick_nohz_idle_got_tick);

>

>  /**

>   * tick_nohz_get_next_hrtimer - return the next expiration time for the hrtimer

> @@ -1117,6 +1125,7 @@ ktime_t tick_nohz_get_sleep_length(ktime_t *delta_next)

>

>         return ktime_sub(next_event, now);

>  }

> +EXPORT_SYMBOL_GPL(tick_nohz_get_sleep_length);


Peter please correct me if I'm mistaken, but IMV the above are core
kernel internals and they should not be accessible to random modular
stuff.

>

>  /**

>   * tick_nohz_get_idle_calls_cpu - return the current idle calls counter value

> --
Peter Zijlstra Nov. 9, 2020, 12:34 p.m. | #2
On Thu, Nov 05, 2020 at 03:04:10PM +0100, Rafael J. Wysocki wrote:
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c

> > index 2d95dc3f4644..ceba61bb364d 100644

> > --- a/kernel/sched/core.c

> > +++ b/kernel/sched/core.c

> > @@ -3838,6 +3838,7 @@ unsigned long nr_iowait_cpu(int cpu)

> >  {

> >         return atomic_read(&cpu_rq(cpu)->nr_iowait);

> >  }

> > +EXPORT_SYMBOL_GPL(nr_iowait_cpu);

> 

> Hmm.  See below.


Did anyone read the comment above this function? It's garbage, it should
be deleted, not made available to a wider audience.

> >  /*

> >   * IO-wait accounting, and how its mostly bollocks (on SMP).

> > diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c

> > index f0199a4ba1ad..537716124d46 100644

> > --- a/kernel/time/tick-sched.c

> > +++ b/kernel/time/tick-sched.c

> > @@ -500,12 +500,19 @@ static int __init setup_tick_nohz(char *str)

> >

> >  __setup("nohz=", setup_tick_nohz);

> >

> > +bool tick_nohz_is_enabled(void)

> > +{

> > +       return tick_nohz_enabled;

> > +}

> > +EXPORT_SYMBOL_GPL(tick_nohz_is_enabled);

> > +

> >  bool tick_nohz_tick_stopped(void)

> >  {

> >         struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);

> >

> >         return ts->tick_stopped;

> >  }

> > +EXPORT_SYMBOL_GPL(tick_nohz_tick_stopped);

> >

> >  bool tick_nohz_tick_stopped_cpu(int cpu)

> >  {

> > @@ -1066,6 +1073,7 @@ bool tick_nohz_idle_got_tick(void)

> >         }

> >         return false;

> >  }

> > +EXPORT_SYMBOL_GPL(tick_nohz_idle_got_tick);

> >

> >  /**

> >   * tick_nohz_get_next_hrtimer - return the next expiration time for the hrtimer

> > @@ -1117,6 +1125,7 @@ ktime_t tick_nohz_get_sleep_length(ktime_t *delta_next)

> >

> >         return ktime_sub(next_event, now);

> >  }

> > +EXPORT_SYMBOL_GPL(tick_nohz_get_sleep_length);

> 

> Peter please correct me if I'm mistaken, but IMV the above are core

> kernel internals and they should not be accessible to random modular

> stuff.


Yeah,... making this available seems unfortunate. Also, I don't really
see the point, why do we want the idle governors as modules? On the
cpufreq side we're trying to move away from modules and multiple
governors.

Patch

diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
index 6ec27ef096f5..2791fe352f51 100644
--- a/drivers/cpuidle/governor.c
+++ b/drivers/cpuidle/governor.c
@@ -120,6 +120,7 @@  void cpuidle_unregister_governor(struct cpuidle_governor *gov)
 
 	mutex_unlock(&cpuidle_lock);
 }
+EXPORT_SYMBOL(cpuidle_unregister_governor);
 
 /**
  * cpuidle_register_governor - registers a governor
@@ -150,6 +151,7 @@  int cpuidle_register_governor(struct cpuidle_governor *gov)
 
 	return ret;
 }
+EXPORT_SYMBOL(cpuidle_register_governor);
 
 /**
  * cpuidle_governor_latency_req - Compute a latency constraint for CPU
@@ -166,3 +168,4 @@  s64 cpuidle_governor_latency_req(unsigned int cpu)
 
 	return (s64)device_req * NSEC_PER_USEC;
 }
+EXPORT_SYMBOL(cpuidle_governor_latency_req);
diff --git a/include/linux/tick.h b/include/linux/tick.h
index 7340613c7eff..8349ba050b9c 100644
--- a/include/linux/tick.h
+++ b/include/linux/tick.h
@@ -124,6 +124,7 @@  enum tick_dep_bits {
 
 #ifdef CONFIG_NO_HZ_COMMON
 extern bool tick_nohz_enabled;
+extern bool tick_nohz_is_enabled(void);
 extern bool tick_nohz_tick_stopped(void);
 extern bool tick_nohz_tick_stopped_cpu(int cpu);
 extern void tick_nohz_idle_stop_tick(void);
@@ -149,6 +150,7 @@  static inline void tick_nohz_idle_stop_tick_protected(void)
 
 #else /* !CONFIG_NO_HZ_COMMON */
 #define tick_nohz_enabled (0)
+static inline int tick_nohz_is_enabled(void) { return 0 };
 static inline int tick_nohz_tick_stopped(void) { return 0; }
 static inline int tick_nohz_tick_stopped_cpu(int cpu) { return 0; }
 static inline void tick_nohz_idle_stop_tick(void) { }
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 2d95dc3f4644..ceba61bb364d 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3838,6 +3838,7 @@  unsigned long nr_iowait_cpu(int cpu)
 {
 	return atomic_read(&cpu_rq(cpu)->nr_iowait);
 }
+EXPORT_SYMBOL_GPL(nr_iowait_cpu);
 
 /*
  * IO-wait accounting, and how its mostly bollocks (on SMP).
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index f0199a4ba1ad..537716124d46 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -500,12 +500,19 @@  static int __init setup_tick_nohz(char *str)
 
 __setup("nohz=", setup_tick_nohz);
 
+bool tick_nohz_is_enabled(void)
+{
+	return tick_nohz_enabled;
+}
+EXPORT_SYMBOL_GPL(tick_nohz_is_enabled);
+
 bool tick_nohz_tick_stopped(void)
 {
 	struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);
 
 	return ts->tick_stopped;
 }
+EXPORT_SYMBOL_GPL(tick_nohz_tick_stopped);
 
 bool tick_nohz_tick_stopped_cpu(int cpu)
 {
@@ -1066,6 +1073,7 @@  bool tick_nohz_idle_got_tick(void)
 	}
 	return false;
 }
+EXPORT_SYMBOL_GPL(tick_nohz_idle_got_tick);
 
 /**
  * tick_nohz_get_next_hrtimer - return the next expiration time for the hrtimer
@@ -1117,6 +1125,7 @@  ktime_t tick_nohz_get_sleep_length(ktime_t *delta_next)
 
 	return ktime_sub(next_event, now);
 }
+EXPORT_SYMBOL_GPL(tick_nohz_get_sleep_length);
 
 /**
  * tick_nohz_get_idle_calls_cpu - return the current idle calls counter value