2018-11-14 04:35:51

by Yi Wang

[permalink] [raw]
Subject: [PATCH v2] fork: Fix some -Wmissing-prototypes warnings

We get a warning when building kernel with W=1:
kernel/fork.c:167:13: warning: no previous prototype for ‘arch_release_thread_stack’ [-Wmissing-prototypes]
kernel/fork.c:779:13: warning: no previous prototype for ‘fork_init’ [-Wmissing-prototypes]

Add the missing declaration in head file to fix this.

Also, remove arch_release_thread_stack() completely because no
arch seems to implement it since bb9d81264 (arch: remove tile port).

Signed-off-by: Yi Wang <[email protected]>
---
v2: remove arch_release_thread_stack(). Thanks to Rasmus.
---
include/linux/sched/task.h | 2 ++
init/main.c | 1 -
kernel/fork.c | 5 -----
3 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h
index 108ede9..44c6f15 100644
--- a/include/linux/sched/task.h
+++ b/include/linux/sched/task.h
@@ -39,6 +39,8 @@

extern void proc_caches_init(void);

+extern void fork_init(void);
+
extern void release_task(struct task_struct * p);

#ifdef CONFIG_HAVE_COPY_THREAD_TLS
diff --git a/init/main.c b/init/main.c
index ee14710..8feda42 100644
--- a/init/main.c
+++ b/init/main.c
@@ -105,7 +105,6 @@
static int kernel_init(void *);

extern void init_IRQ(void);
-extern void fork_init(void);
extern void radix_tree_init(void);

/*
diff --git a/kernel/fork.c b/kernel/fork.c
index 07cddff..c6d02be 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -164,10 +164,6 @@ static inline void free_task_struct(struct task_struct *tsk)
}
#endif

-void __weak arch_release_thread_stack(unsigned long *stack)
-{
-}
-
#ifndef CONFIG_ARCH_THREAD_STACK_ALLOCATOR

/*
@@ -417,7 +413,6 @@ static void release_task_stack(struct task_struct *tsk)
return; /* Better to leak the stack than to free prematurely */

account_kernel_stack(tsk, -1);
- arch_release_thread_stack(tsk->stack);
free_thread_stack(tsk);
tsk->stack = NULL;
#ifdef CONFIG_VMAP_STACK
--
1.8.3.1



2018-11-14 09:23:18

by Michal Hocko

[permalink] [raw]
Subject: Re: [PATCH v2] fork: Fix some -Wmissing-prototypes warnings

On Wed 14-11-18 12:34:47, Yi Wang wrote:
> We get a warning when building kernel with W=1:
> kernel/fork.c:167:13: warning: no previous prototype for ‘arch_release_thread_stack’ [-Wmissing-prototypes]
> kernel/fork.c:779:13: warning: no previous prototype for ‘fork_init’ [-Wmissing-prototypes]
>
> Add the missing declaration in head file to fix this.
>
> Also, remove arch_release_thread_stack() completely because no
> arch seems to implement it since bb9d81264 (arch: remove tile port).
>
> Signed-off-by: Yi Wang <[email protected]>

Looks good to me.

Acked-by: Michal Hocko <[email protected]>

> ---
> v2: remove arch_release_thread_stack(). Thanks to Rasmus.
> ---
> include/linux/sched/task.h | 2 ++
> init/main.c | 1 -
> kernel/fork.c | 5 -----
> 3 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h
> index 108ede9..44c6f15 100644
> --- a/include/linux/sched/task.h
> +++ b/include/linux/sched/task.h
> @@ -39,6 +39,8 @@
>
> extern void proc_caches_init(void);
>
> +extern void fork_init(void);
> +
> extern void release_task(struct task_struct * p);
>
> #ifdef CONFIG_HAVE_COPY_THREAD_TLS
> diff --git a/init/main.c b/init/main.c
> index ee14710..8feda42 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -105,7 +105,6 @@
> static int kernel_init(void *);
>
> extern void init_IRQ(void);
> -extern void fork_init(void);
> extern void radix_tree_init(void);
>
> /*
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 07cddff..c6d02be 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -164,10 +164,6 @@ static inline void free_task_struct(struct task_struct *tsk)
> }
> #endif
>
> -void __weak arch_release_thread_stack(unsigned long *stack)
> -{
> -}
> -
> #ifndef CONFIG_ARCH_THREAD_STACK_ALLOCATOR
>
> /*
> @@ -417,7 +413,6 @@ static void release_task_stack(struct task_struct *tsk)
> return; /* Better to leak the stack than to free prematurely */
>
> account_kernel_stack(tsk, -1);
> - arch_release_thread_stack(tsk->stack);
> free_thread_stack(tsk);
> tsk->stack = NULL;
> #ifdef CONFIG_VMAP_STACK
> --
> 1.8.3.1

--
Michal Hocko
SUSE Labs

2018-11-14 16:10:50

by Mike Rapoport

[permalink] [raw]
Subject: Re: [PATCH v2] fork: Fix some -Wmissing-prototypes warnings

On Wed, Nov 14, 2018 at 12:34:47PM +0800, Yi Wang wrote:
> We get a warning when building kernel with W=1:
> kernel/fork.c:167:13: warning: no previous prototype for ‘arch_release_thread_stack’ [-Wmissing-prototypes]
> kernel/fork.c:779:13: warning: no previous prototype for ‘fork_init’ [-Wmissing-prototypes]
>
> Add the missing declaration in head file to fix this.
>
> Also, remove arch_release_thread_stack() completely because no
> arch seems to implement it since bb9d81264 (arch: remove tile port).
>
> Signed-off-by: Yi Wang <[email protected]>

Acked-by: Mike Rapoport <[email protected]>

> ---
> v2: remove arch_release_thread_stack(). Thanks to Rasmus.
> ---
> include/linux/sched/task.h | 2 ++
> init/main.c | 1 -
> kernel/fork.c | 5 -----
> 3 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h
> index 108ede9..44c6f15 100644
> --- a/include/linux/sched/task.h
> +++ b/include/linux/sched/task.h
> @@ -39,6 +39,8 @@
>
> extern void proc_caches_init(void);
>
> +extern void fork_init(void);
> +
> extern void release_task(struct task_struct * p);
>
> #ifdef CONFIG_HAVE_COPY_THREAD_TLS
> diff --git a/init/main.c b/init/main.c
> index ee14710..8feda42 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -105,7 +105,6 @@
> static int kernel_init(void *);
>
> extern void init_IRQ(void);
> -extern void fork_init(void);
> extern void radix_tree_init(void);
>
> /*
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 07cddff..c6d02be 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -164,10 +164,6 @@ static inline void free_task_struct(struct task_struct *tsk)
> }
> #endif
>
> -void __weak arch_release_thread_stack(unsigned long *stack)
> -{
> -}
> -
> #ifndef CONFIG_ARCH_THREAD_STACK_ALLOCATOR
>
> /*
> @@ -417,7 +413,6 @@ static void release_task_stack(struct task_struct *tsk)
> return; /* Better to leak the stack than to free prematurely */
>
> account_kernel_stack(tsk, -1);
> - arch_release_thread_stack(tsk->stack);
> free_thread_stack(tsk);
> tsk->stack = NULL;
> #ifdef CONFIG_VMAP_STACK
> --
> 1.8.3.1
>

--
Sincerely yours,
Mike.