Re: [PATCH] mm: add prototype for __add_to_page_cache_locked()

From: Matthew Wilcox
Date: Tue Dec 22 2020 - 15:40:59 EST


On Tue, Dec 22, 2020 at 07:49:52PM +0530, Souptick Joarder wrote:
> Otherwise it cause gcc warning:
> ^~~~~~~~~~~~~~~

That line is just confusing.

> ../mm/filemap.c:830:14: warning: no previous prototype for
> ‘__add_to_page_cache_locked’ [-Wmissing-prototypes]
> noinline int __add_to_page_cache_locked(struct page *page,
> ^~~~~~~~~~~~~~~~~~~~~~~~~~

And I don't think those two lines add much value, do you?

> A previous attempt to make this function static leads to
> compile error for few architectures.

It might be better to say why it has to be non-static here (because it's
an error injection point). And it's not architecture dependent (afaik),
it's whether error injection is enabled in the config.

> Adding a prototype will silence the warning.
>
> Signed-off-by: Souptick Joarder <jrdr.linux@xxxxxxxxx>
> Cc: Alex Shi <alex.shi@xxxxxxxxxxxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> ---
> include/linux/mm.h | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 5299b90a..ac07f65 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -216,6 +216,12 @@ int overcommit_kbytes_handler(struct ctl_table *, int, void *, size_t *,
> loff_t *);
> int overcommit_policy_handler(struct ctl_table *, int, void *, size_t *,
> loff_t *);
> +/*
> + * Any attempt to mark this function as static leads to build failure
> + * for few architectures. Adding a prototype to silence gcc warning.
> + */

We don't need a comment here for this. The commit log is enough.

> +int __add_to_page_cache_locked(struct page *page, struct address_space *mapping,
> + pgoff_t offset, gfp_t gfp, void **shadowp);

Please name that 'index', not 'offset'.