[Devel] [PATCH RH8] sched: Uninline css_tg()

Evgenii Shatokhin eshatokhin at virtuozzo.com
Wed May 5 17:18:42 MSK 2021


On 05.05.2021 13:59, Kirill Tkhai wrote:
> Compilation with custom config fails:
> 
> kernel/ve/ve.c: In function ‘ve_get_cpu_avenrun’:
> kernel/ve/ve.c:1679:27: error: inlining failed in call to always_inline ‘css_tg’: function body not available
>   inline struct task_group *css_tg(struct cgroup_subsys_state *css);
>                             ^~~~~~
> kernel/ve/ve.c:1690:7: note: called from here
>    tg = css_tg(css);
>         ^~~~~~~~~~~
> 
> We may remove "inline" attribute, as compiler is clever enought
> to make itself inlining in kernel/sched/sched.c.
> 
> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
> ---
>   kernel/sched/core.c    |    2 +-
>   kernel/sched/cpuacct.c |    2 +-
>   kernel/ve/ve.c         |    2 +-
>   3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 3bb7953b084e..375de135c132 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -6767,7 +6767,7 @@ void sched_move_task(struct task_struct *tsk)
>   	task_rq_unlock(rq, tsk, &rf);
>   }
>   
> -inline struct task_group *css_tg(struct cgroup_subsys_state *css)
> +struct task_group *css_tg(struct cgroup_subsys_state *css)
>   {
>   	return css ? container_of(css, struct task_group, css) : NULL;
>   }
> diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c
> index 5806d55a5260..33b6987700c2 100644
> --- a/kernel/sched/cpuacct.c
> +++ b/kernel/sched/cpuacct.c
> @@ -376,7 +376,7 @@ struct cgroup_subsys cpuacct_cgrp_subsys = {
>   	.early_init	= true,
>   };
>   
> -extern inline struct task_group *css_tg(struct cgroup_subsys_state *css);
> +extern struct task_group *css_tg(struct cgroup_subsys_state *css);
>   
>   static struct task_group *ve_root_tg(struct task_group *tg) {
>   	struct cgroup *cg;
> diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
> index f164e2d426a6..5bf187705f2a 100644
> --- a/kernel/ve/ve.c
> +++ b/kernel/ve/ve.c
> @@ -1676,7 +1676,7 @@ int ve_show_loadavg(struct ve_struct *ve, struct seq_file *p)
>   	return err;
>   }
>   
> -inline struct task_group *css_tg(struct cgroup_subsys_state *css);
> +struct task_group *css_tg(struct cgroup_subsys_state *css);
>   int get_avenrun_tg(struct task_group *tg, unsigned long *loads,
>   		   unsigned long offset, int shift);
>   
> 
> 
> .
> 

Looks good to me. Thanks, Kirill!

IMO, marking a non-local function inline is almost always a bad 
practice. Let the compiler decide if and when to inline it.

Reviewed-by: Evgenii Shatokhin <eshatokhin at virtuozzo.com>



More information about the Devel mailing list