linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: add prototype for __add_to_page_cache_locked()
@ 2020-12-22 14:19 Souptick Joarder
  2020-12-22 20:40 ` Matthew Wilcox
  0 siblings, 1 reply; 10+ messages in thread
From: Souptick Joarder @ 2020-12-22 14:19 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, Souptick Joarder, Alex Shi

Otherwise it cause gcc warning:
          ^~~~~~~~~~~~~~~
../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,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~

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

Adding a prototype will silence the warning.

Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Cc: Alex Shi <alex.shi@linux.alibaba.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 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.
+ */
+int __add_to_page_cache_locked(struct page *page, struct address_space *mapping,
+		pgoff_t offset, gfp_t gfp, void **shadowp);
 
 #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
 
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] mm: add prototype for __add_to_page_cache_locked()
  2020-12-22 14:19 [PATCH] mm: add prototype for __add_to_page_cache_locked() Souptick Joarder
@ 2020-12-22 20:40 ` Matthew Wilcox
  2020-12-22 23:53   ` Andrew Morton
  0 siblings, 1 reply; 10+ messages in thread
From: Matthew Wilcox @ 2020-12-22 20:40 UTC (permalink / raw)
  To: Souptick Joarder; +Cc: akpm, linux-mm, linux-kernel, Alex Shi

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@gmail.com>
> Cc: Alex Shi <alex.shi@linux.alibaba.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> ---
>  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'.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] mm: add prototype for __add_to_page_cache_locked()
  2020-12-22 20:40 ` Matthew Wilcox
@ 2020-12-22 23:53   ` Andrew Morton
  2020-12-23  1:19     ` Matthew Wilcox
  2020-12-23  8:31     ` Christoph Hellwig
  0 siblings, 2 replies; 10+ messages in thread
From: Andrew Morton @ 2020-12-22 23:53 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Souptick Joarder, linux-mm, linux-kernel, Alex Shi

On Tue, 22 Dec 2020 20:40:00 +0000 Matthew Wilcox <willy@infradead.org> wrote:

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

I cleaned up the changelog.  It is presently

: Subject: include/linux/mm.h: add prototype for __add_to_page_cache_locked()
: 
: Otherwise it causes a gcc warning:
: 
: ../mm/filemap.c:830:14: warning: no previous prototype for
: `__add_to_page_cache_locked' [-Wmissing-prototypes]
: 
: A previous attempt to make this function static led to compilation
: errors for a few architectures, because __add_to_page_cache_locked() is
: referred to by BPF code.
: 
: Adding a prototype will silence the warning.

> > --- 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.

I think it's OK - people do send patches which remove a prototype and
also make the function static.  A tree-wide grep would catch the bpf
reference but I suspect people tend to grep for "foo(" rather then
"foo".

> > +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'.

I too prefer index over offset.  

X1:/usr/src/linux-5.10> grep -r "pgoff_t offset" . | wc -l
52
X1:/usr/src/linux-5.10> grep -r "pgoff_t index" . | wc -l 
250

But renaming this arg should be a separate patch.

And I don't think we should be preparing large "rename offset to index"
patches, please.  The value/noise ratio is too low.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] mm: add prototype for __add_to_page_cache_locked()
  2020-12-22 23:53   ` Andrew Morton
@ 2020-12-23  1:19     ` Matthew Wilcox
  2020-12-23  8:31     ` Christoph Hellwig
  1 sibling, 0 replies; 10+ messages in thread
From: Matthew Wilcox @ 2020-12-23  1:19 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Souptick Joarder, linux-mm, linux-kernel, Alex Shi

On Tue, Dec 22, 2020 at 03:53:45PM -0800, Andrew Morton wrote:
> : A previous attempt to make this function static led to compilation
> : errors for a few architectures, because __add_to_page_cache_locked() is
> : referred to by BPF code.

Yes, but it's wrong, because it's not architecture dependent.  It
depends on CONFIG_DEBUG_INFO_BTF

> > > +/*
> > > + * 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.
> 
> I think it's OK - people do send patches which remove a prototype and
> also make the function static.  A tree-wide grep would catch the bpf
> reference but I suspect people tend to grep for "foo(" rather then
> "foo".

... and the same wrong information is present here.  If there's going to
be a comment here at least make it something informative like

/* Must be visible for error injection */

> > > +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'.
> 
> I too prefer index over offset.  
> 
> X1:/usr/src/linux-5.10> grep -r "pgoff_t offset" . | wc -l
> 52
> X1:/usr/src/linux-5.10> grep -r "pgoff_t index" . | wc -l 
> 250
> 
> But renaming this arg should be a separate patch.

... but this is a new prototype.  Prototype names don't have to match
the function name (and often don't ...)

> And I don't think we should be preparing large "rename offset to index"
> patches, please.  The value/noise ratio is too low.

I'm only fixing them as I change those functions.  I just object to
introducing new wrong ones.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] mm: add prototype for __add_to_page_cache_locked()
  2020-12-22 23:53   ` Andrew Morton
  2020-12-23  1:19     ` Matthew Wilcox
@ 2020-12-23  8:31     ` Christoph Hellwig
  2020-12-23 12:11       ` Matthew Wilcox
  1 sibling, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2020-12-23  8:31 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Matthew Wilcox, Souptick Joarder, linux-mm, linux-kernel, Alex Shi

Can we please make the eBPF code stop referencing this function instead
of papering over this crap?  It has no business poking into page cache
internals.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] mm: add prototype for __add_to_page_cache_locked()
  2020-12-23  8:31     ` Christoph Hellwig
@ 2020-12-23 12:11       ` Matthew Wilcox
  2020-12-23 15:52         ` Christoph Hellwig
  0 siblings, 1 reply; 10+ messages in thread
From: Matthew Wilcox @ 2020-12-23 12:11 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Andrew Morton, Souptick Joarder, linux-mm, linux-kernel, Alex Shi

On Wed, Dec 23, 2020 at 08:31:26AM +0000, Christoph Hellwig wrote:
> Can we please make the eBPF code stop referencing this function instead
> of papering over this crap?  It has no business poking into page cache
> internals.

The reference from the BPF code is simply "you can inject errors here".
And I think we want to be able to inject errors to test the error paths,
no?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] mm: add prototype for __add_to_page_cache_locked()
  2020-12-23 12:11       ` Matthew Wilcox
@ 2020-12-23 15:52         ` Christoph Hellwig
  2020-12-28  0:59           ` Alexei Starovoitov
  0 siblings, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2020-12-23 15:52 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Christoph Hellwig, Andrew Morton, Souptick Joarder, linux-mm,
	linux-kernel, Alex Shi

On Wed, Dec 23, 2020 at 12:11:36PM +0000, Matthew Wilcox wrote:
> On Wed, Dec 23, 2020 at 08:31:26AM +0000, Christoph Hellwig wrote:
> > Can we please make the eBPF code stop referencing this function instead
> > of papering over this crap?  It has no business poking into page cache
> > internals.
> 
> The reference from the BPF code is simply "you can inject errors here".
> And I think we want to be able to inject errors to test the error paths,
> no?

Something that expects a symbol to be global is just pretty broken.
I think it need to change so that whatever instrumentation is done can
coexist with a static function.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] mm: add prototype for __add_to_page_cache_locked()
  2020-12-23 15:52         ` Christoph Hellwig
@ 2020-12-28  0:59           ` Alexei Starovoitov
  0 siblings, 0 replies; 10+ messages in thread
From: Alexei Starovoitov @ 2020-12-28  0:59 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Matthew Wilcox, Andrew Morton, Souptick Joarder, linux-mm, LKML,
	Alex Shi

On Wed, Dec 23, 2020 at 7:54 AM Christoph Hellwig <hch@infradead.org> wrote:
>
> On Wed, Dec 23, 2020 at 12:11:36PM +0000, Matthew Wilcox wrote:
> > On Wed, Dec 23, 2020 at 08:31:26AM +0000, Christoph Hellwig wrote:
> > > Can we please make the eBPF code stop referencing this function instead
> > > of papering over this crap?  It has no business poking into page cache
> > > internals.
> >
> > The reference from the BPF code is simply "you can inject errors here".
> > And I think we want to be able to inject errors to test the error paths,
> > no?
>
> Something that expects a symbol to be global is just pretty broken.
> I think it need to change so that whatever instrumentation is done can
> coexist with a static function.

Pls read commit description that made it global.
It has nothing to do with bpf.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] mm: add prototype for __add_to_page_cache_locked()
  2020-12-23  3:16 Souptick Joarder
@ 2020-12-23  3:18 ` Souptick Joarder
  0 siblings, 0 replies; 10+ messages in thread
From: Souptick Joarder @ 2020-12-23  3:18 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linux-MM, linux-kernel, Alex Shi, Matthew Wilcox

On Wed, Dec 23, 2020 at 8:46 AM Souptick Joarder <jrdr.linux@gmail.com> wrote:
>
> Otherwise it causes a gcc warning:
>
> ../mm/filemap.c:830:14: warning: no previous prototype for
> `__add_to_page_cache_locked' [-Wmissing-prototypes]
>
> A previous attempt to make this function static led to compilation
> errors when CONFIG_DEBUG_INFO_BTF is enabled because
> __add_to_page_cache_locked() is referred to by BPF code.
>
> Adding a prototype will silence the warning.
>

Please ignore this patch. I forget to update version.

> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
> Cc: Alex Shi <alex.shi@linux.alibaba.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Matthew Wilcox <willy@infradead.org>
> ---
>  include/linux/mm.h | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 5299b90a..c1e9081 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -216,6 +216,13 @@ 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
> + * when CONFIG_DEBUG_INFO_BTF is enabled because __add_to_page_cache_locked()
> + * is referred to by BPF code. This must be visible for error injection.
> + */
> +int __add_to_page_cache_locked(struct page *page, struct address_space *mapping,
> +               pgoff_t index, gfp_t gfp, void **shadowp);
>
>  #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
>
> --
> 1.9.1
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] mm: add prototype for __add_to_page_cache_locked()
@ 2020-12-23  3:16 Souptick Joarder
  2020-12-23  3:18 ` Souptick Joarder
  0 siblings, 1 reply; 10+ messages in thread
From: Souptick Joarder @ 2020-12-23  3:16 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, Souptick Joarder, Alex Shi, Matthew Wilcox

Otherwise it causes a gcc warning:

../mm/filemap.c:830:14: warning: no previous prototype for
`__add_to_page_cache_locked' [-Wmissing-prototypes]

A previous attempt to make this function static led to compilation
errors when CONFIG_DEBUG_INFO_BTF is enabled because
__add_to_page_cache_locked() is referred to by BPF code.

Adding a prototype will silence the warning.

Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Cc: Alex Shi <alex.shi@linux.alibaba.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Matthew Wilcox <willy@infradead.org>
---
 include/linux/mm.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 5299b90a..c1e9081 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -216,6 +216,13 @@ 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
+ * when CONFIG_DEBUG_INFO_BTF is enabled because __add_to_page_cache_locked()
+ * is referred to by BPF code. This must be visible for error injection.
+ */
+int __add_to_page_cache_locked(struct page *page, struct address_space *mapping,
+		pgoff_t index, gfp_t gfp, void **shadowp);
 
 #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
 
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-12-28  0:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-22 14:19 [PATCH] mm: add prototype for __add_to_page_cache_locked() Souptick Joarder
2020-12-22 20:40 ` Matthew Wilcox
2020-12-22 23:53   ` Andrew Morton
2020-12-23  1:19     ` Matthew Wilcox
2020-12-23  8:31     ` Christoph Hellwig
2020-12-23 12:11       ` Matthew Wilcox
2020-12-23 15:52         ` Christoph Hellwig
2020-12-28  0:59           ` Alexei Starovoitov
2020-12-23  3:16 Souptick Joarder
2020-12-23  3:18 ` Souptick Joarder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).