Skip to contentSkip to conversation

mm/filemap: add static for function __add_to_page_cache_locked

PATCH Applied Alex Shi 13 participants 22 messages Nov 6, 2020 – Dec 10, 2020

Subsystems (4)
lore
Share & tools
lore

Alex Shi

author
#0 lore raw

PATCH 1/1 mm/filemap: add static for function __add_to_page_cache_locked

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,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/filemap.c +1 -1
index d90614f501da..249cf489f5df 100644
@@ -827,7 +827,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
 }
 EXPORT_SYMBOL_GPL(replace_page_cache_page);
 
-noinline int __add_to_page_cache_locked(struct page *page,
+static noinline int __add_to_page_cache_locked(struct page *page,
 					struct address_space *mapping,
 					pgoff_t offset, gfp_t gfp,
 					void **shadowp)
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 7 lines · 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,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~

Does this affect the use in:

kernel/bpf/verifier.c|11478| BTF_ID(func, __add_to_page_cache_locked)

?

It does not look like that calls the function but I'm not sure what BTF_ID does?

Ira

Quoted 25 lines
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/filemap.c +1 -1
index d90614f501da..249cf489f5df 100644
@@ -827,7 +827,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
 }
 EXPORT_SYMBOL_GPL(replace_page_cache_page);
 
-noinline int __add_to_page_cache_locked(struct page *page,
+static noinline int __add_to_page_cache_locked(struct page *page,
 					struct address_space *mapping,
 					pgoff_t offset, gfp_t gfp,
 					void **shadowp)
Signature · 1 line
1.8.3.1
#2 lore raw
In reply to Alex Shi
Quoted 7 lines · 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,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~

Is CONFIG_DEBUG_INFO_BTF enabled in your .config ?

Quoted 26 lines
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/filemap.c +1 -2
index d90614f501da..249cf489f5df 100644
@@ -827,7 +827,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
 }
 EXPORT_SYMBOL_GPL(replace_page_cache_page);
 
-noinline int __add_to_page_cache_locked(struct page *page,
+static noinline int __add_to_page_cache_locked(struct page *page,
                                        struct address_space *mapping,
                                        pgoff_t offset, gfp_t gfp,
                                        void **shadowp)
--

1.8.3.1

author
#3 lore raw
Quoted 10 lines · Souptick Joarder
Quoted 7 lines · 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,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~

Is CONFIG_DEBUG_INFO_BTF enabled in your .config ?

Sorry, I tried to buld the configure with bzImage, but failed on pahole version too low, and compiled pahole still can not run in git://git.kernel.org/pub/scm/devel/pahole/pahole.git
#pahole
pahole: symbol lookup error: pahole: undefined symbol: tabs

Quoted 27 lines
Quoted 27 lines
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/filemap.c +1 -2
index d90614f501da..249cf489f5df 100644
@@ -827,7 +827,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
 }
 EXPORT_SYMBOL_GPL(replace_page_cache_page);
 
-noinline int __add_to_page_cache_locked(struct page *page,
+static noinline int __add_to_page_cache_locked(struct page *page,
                                        struct address_space *mapping,
                                        pgoff_t offset, gfp_t gfp,
                                        void **shadowp)
--

1.8.3.1

maintainer
#4 lore raw
In reply to Souptick Joarder
Quoted 10 lines · On Tue, 10 Nov 2020 08:39:24 +0530 Souptick Joarder <[email protected]>…
Quoted 7 lines · 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,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~

Is CONFIG_DEBUG_INFO_BTF enabled in your .config ?

hm, yes.

Quoted 17 lines
Quoted 17 lines
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/filemap.c +0 -0
index d90614f501da..249cf489f5df 100644
@@ -827,7 +827,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
 }
 EXPORT_SYMBOL_GPL(replace_page_cache_page);
 
Quoted 5 lines

mm/filemap.c int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask) · line 833

Quoted 5 lines
mm/filemap.c +1 -1
-noinline int __add_to_page_cache_locked(struct page *page,
+static noinline int __add_to_page_cache_locked(struct page *page,
                                        struct address_space *mapping,
                                        pgoff_t offset, gfp_t gfp,
                                        void **shadowp)

It's unclear to me whether BTF_ID() requires that the target symbol be non-static. It doesn't actually reference the symbol:

#define BTF_ID(prefix, name) \
        __BTF_ID(__ID(__BTF_ID__##prefix##__##name##__))

Alexei, can you please comment?

author
#5 lore raw
Quoted 11 lines · Andrew Morton
Quoted 9 lines · On Tue, 10 Nov 2020 08:39:24 +0530 Souptick Joarder <[email protected]>…
Quoted 7 lines · 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,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 3 lines
Quoted 1 line

Is CONFIG_DEBUG_INFO_BTF enabled in your .config ?

hm, yes.

When the config enabled, compiling looks good untill pahole tool used to get BTF info, but I still failed on a right version pahole

Quoted 29 lines

1.16. Sorry.

Quoted 17 lines
Quoted 17 lines
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/filemap.c +0 -0
index d90614f501da..249cf489f5df 100644
@@ -827,7 +827,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
 }
 EXPORT_SYMBOL_GPL(replace_page_cache_page);
 
Quoted 5 lines

mm/filemap.c int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask) · line 833

Quoted 5 lines
mm/filemap.c +1 -1
-noinline int __add_to_page_cache_locked(struct page *page,
+static noinline int __add_to_page_cache_locked(struct page *page,
                                        struct address_space *mapping,
                                        pgoff_t offset, gfp_t gfp,
                                        void **shadowp)

It's unclear to me whether BTF_ID() requires that the target symbol be non-static. It doesn't actually reference the symbol:

Quoted 3 lines
#define BTF_ID(prefix, name) \
        __BTF_ID(__ID(__BTF_ID__##prefix##__##name##__))

The above usage make me thought BTF don't require the symbol, though the symbol still exist in vmlinux with 'static'.

So any comments of this, Alexei?

Quoted 2 lines

Alexei, can you please comment?

#6 lore raw
Quoted 12 lines · Alex Shi
Quoted 11 lines · Andrew Morton
Quoted 9 lines · On Tue, 10 Nov 2020 08:39:24 +0530 Souptick Joarder <[email protected]>…
Quoted 7 lines · 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,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Is CONFIG_DEBUG_INFO_BTF enabled in your .config ?

hm, yes.

When the config enabled, compiling looks good untill pahole tool used to get BTF info, but I still failed on a right version pahole

Quoted 1 line

1.16. Sorry.

I'm seeing an issue with this patch. My build system has pahole v1.17, but I don't think the pahole version is key.

$ git checkout 3351b16af494  # recently added to linus/master
$ make defconfig
$ make menuconfig  # set CONFIG_BPF_SYSCALL and CONFIG_DEBUG_INFO_BTF
$ make V=1
+ ./tools/bpf/resolve_btfids/resolve_btfids vmlinux
FAILED unresolved symbol __add_to_page_cache_locked

Reverting 3351b16af494 ("mm/filemap: add static for function __add_to_page_cache_locked") fixes the issue.

I don't see the warning which motivated this patch, but maybe it requires particular a .config or gcc version. Perhaps adding a __add_to_page_cache_locked() prototype would meet avoid it. But I haven't studied enough on BTF to know if there's a better answer.

Quoted 36 lines
Quoted 25 lines
Quoted 16 lines
Quoted 16 lines
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/filemap.c +0 -0
index d90614f501da..249cf489f5df 100644
@@ -827,7 +827,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
 }
 EXPORT_SYMBOL_GPL(replace_page_cache_page);
 
Quoted 5 lines

mm/filemap.c int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask) · line 833

Quoted 5 lines
mm/filemap.c +1 -1
-noinline int __add_to_page_cache_locked(struct page *page,
+static noinline int __add_to_page_cache_locked(struct page *page,
                                        struct address_space *mapping,
                                        pgoff_t offset, gfp_t gfp,
                                        void **shadowp)

It's unclear to me whether BTF_ID() requires that the target symbol be non-static. It doesn't actually reference the symbol:

Quoted 3 lines
#define BTF_ID(prefix, name) \
        __BTF_ID(__ID(__BTF_ID__##prefix##__##name##__))

The above usage make me thought BTF don't require the symbol, though the symbol still exist in vmlinux with 'static'.

So any comments of this, Alexei?

Quoted 2 lines

Alexei, can you please comment?

#7 lore raw
In reply to Alex Shi
Quoted 49 lines · Alex Shi
Quoted 11 lines · Andrew Morton
Quoted 9 lines · On Tue, 10 Nov 2020 08:39:24 +0530 Souptick Joarder <[email protected]>…
Quoted 7 lines · 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,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 3 lines
Quoted 1 line

Is CONFIG_DEBUG_INFO_BTF enabled in your .config ?

hm, yes.

When the config enabled, compiling looks good untill pahole tool used to get BTF info, but I still failed on a right version pahole

Quoted 29 lines

1.16. Sorry.

Quoted 17 lines
Quoted 17 lines
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/filemap.c +0 -0
index d90614f501da..249cf489f5df 100644
@@ -827,7 +827,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
 }
 EXPORT_SYMBOL_GPL(replace_page_cache_page);
 
Quoted 5 lines

mm/filemap.c int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask) · line 833

Quoted 5 lines
mm/filemap.c +1 -1
-noinline int __add_to_page_cache_locked(struct page *page,
+static noinline int __add_to_page_cache_locked(struct page *page,
                                        struct address_space *mapping,
                                        pgoff_t offset, gfp_t gfp,
                                        void **shadowp)

It's unclear to me whether BTF_ID() requires that the target symbol be non-static. It doesn't actually reference the symbol:

Quoted 8 lines
Quoted 3 lines
#define BTF_ID(prefix, name) \
        __BTF_ID(__ID(__BTF_ID__##prefix##__##name##__))

The above usage make me thought BTF don't require the symbol, though the symbol still exist in vmlinux with 'static'.

So any comments of this, Alexei?

It's probably more complicated: our v5.10-rc7 builds with CONFIG_DEBUG_INFO_BTF=y fail on ppc64 and ppc64le with

BTFIDS vmlinux
FAILED unresolved symbol __add_to_page_cache_locked

but succeed on x86_64, i586, aarch64 and s390x. So far I don't see why this should depend on architecture.

Michal

#8 lore raw
Quoted 63 lines · Michal Kubecek
Quoted 49 lines · Alex Shi
Quoted 11 lines · Andrew Morton
Quoted 9 lines · On Tue, 10 Nov 2020 08:39:24 +0530 Souptick Joarder <[email protected]>…
Quoted 7 lines · 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,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 3 lines
Quoted 1 line

Is CONFIG_DEBUG_INFO_BTF enabled in your .config ?

hm, yes.

When the config enabled, compiling looks good untill pahole tool used to get BTF info, but I still failed on a right version pahole

Quoted 29 lines

1.16. Sorry.

Quoted 17 lines
Quoted 17 lines
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/filemap.c +0 -0
index d90614f501da..249cf489f5df 100644
@@ -827,7 +827,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
 }
 EXPORT_SYMBOL_GPL(replace_page_cache_page);
 
Quoted 5 lines

mm/filemap.c int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask) · line 833

Quoted 5 lines
mm/filemap.c +1 -1
-noinline int __add_to_page_cache_locked(struct page *page,
+static noinline int __add_to_page_cache_locked(struct page *page,
                                        struct address_space *mapping,
                                        pgoff_t offset, gfp_t gfp,
                                        void **shadowp)

It's unclear to me whether BTF_ID() requires that the target symbol be non-static. It doesn't actually reference the symbol:

Quoted 8 lines
Quoted 3 lines
#define BTF_ID(prefix, name) \
        __BTF_ID(__ID(__BTF_ID__##prefix##__##name##__))

The above usage make me thought BTF don't require the symbol, though the symbol still exist in vmlinux with 'static'.

So any comments of this, Alexei?

It's probably more complicated: our v5.10-rc7 builds with CONFIG_DEBUG_INFO_BTF=y fail on ppc64 and ppc64le with

Quoted 7 lines

BTFIDS vmlinux
FAILED unresolved symbol __add_to_page_cache_locked

but succeed on x86_64, i586, aarch64 and s390x. So far I don't see why this should depend on architecture.

Fedora is failing with rc7 on the same issue on PPC only.

Justin

#9 lore raw
Quoted 53 lines · Justin Forbes
Quoted 51 lines · Michal Kubecek
Quoted 49 lines · Alex Shi
Quoted 11 lines · Andrew Morton
Quoted 9 lines · On Tue, 10 Nov 2020 08:39:24 +0530 Souptick Joarder <[email protected]>…
Quoted 7 lines · 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,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 3 lines
Quoted 1 line

Is CONFIG_DEBUG_INFO_BTF enabled in your .config ?

hm, yes.

When the config enabled, compiling looks good untill pahole tool used to get BTF info, but I still failed on a right version pahole

Quoted 29 lines

1.16. Sorry.

Quoted 17 lines
Quoted 17 lines
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/filemap.c +0 -0
index d90614f501da..249cf489f5df 100644
@@ -827,7 +827,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
 }
 EXPORT_SYMBOL_GPL(replace_page_cache_page);
 
Quoted 5 lines

mm/filemap.c int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask) · line 833

Quoted 5 lines
mm/filemap.c +1 -1
-noinline int __add_to_page_cache_locked(struct page *page,
+static noinline int __add_to_page_cache_locked(struct page *page,
                                        struct address_space *mapping,
                                        pgoff_t offset, gfp_t gfp,
                                        void **shadowp)

It's unclear to me whether BTF_ID() requires that the target symbol be non-static. It doesn't actually reference the symbol:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
#define BTF_ID(prefix, name) \
        __BTF_ID(__ID(__BTF_ID__##prefix##__##name##__))

The above usage make me thought BTF don't require the symbol, though the symbol still exist in vmlinux with 'static'.

So any comments of this, Alexei?

Sorry. I've completely missed this thread.
Now I have a hard time finding context in archives.
If I understood what's going on the removal of "static" cases issues? Yes. That's expected.
noinline alone is not enough to work reliably.

#10 lore raw
Quoted 61 lines · Alexei Starovoitov
Quoted 60 lines · Justin Forbes
Quoted 58 lines · Michal Kubecek
Quoted 56 lines · Alex Shi
Quoted 11 lines · Andrew Morton
Quoted 9 lines · On Tue, 10 Nov 2020 08:39:24 +0530 Souptick Joarder <[email protected]>…
Quoted 7 lines · 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,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 3 lines
Quoted 1 line

Is CONFIG_DEBUG_INFO_BTF enabled in your .config ?

hm, yes.

When the config enabled, compiling looks good untill pahole tool used to get BTF info, but I still failed on a right version pahole

Quoted 29 lines

1.16. Sorry.

Quoted 17 lines
Quoted 17 lines
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/filemap.c +0 -0
index d90614f501da..249cf489f5df 100644
@@ -827,7 +827,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
 }
 EXPORT_SYMBOL_GPL(replace_page_cache_page);
 
Quoted 5 lines

mm/filemap.c int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask) · line 833

Quoted 5 lines
mm/filemap.c +1 -1
-noinline int __add_to_page_cache_locked(struct page *page,
+static noinline int __add_to_page_cache_locked(struct page *page,
                                        struct address_space *mapping,
                                        pgoff_t offset, gfp_t gfp,
                                        void **shadowp)

It's unclear to me whether BTF_ID() requires that the target symbol be non-static. It doesn't actually reference the symbol:

Quoted 3 lines
#define BTF_ID(prefix, name) \
        __BTF_ID(__ID(__BTF_ID__##prefix##__##name##__))

The above usage make me thought BTF don't require the symbol, though the symbol still exist in vmlinux with 'static'.

Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

So any comments of this, Alexei?

Sorry. I've completely missed this thread.
Now I have a hard time finding context in archives.
If I understood what's going on the removal of "static" cases issues? Yes. That's expected.
noinline alone is not enough to work reliably.

Not removal, commit 3351b16af494 ("mm/filemap: add static for function __add_to_page_cache_locked") made the function static which breaks the build in btfids phase - but it seems to happen only on some architectures. In our case, ppc64, ppc64le and riscv64 are broken, x86_64, i586 and s390x succeed. (I made a mistake above, aarch64 did not fail - but only because it was not built at all.)

The thread starts with
http://lkml.kernel.org/r/[email protected]

Michal

#11 lore raw
Quoted 78 lines · Michal Kubecek
Quoted 61 lines · Alexei Starovoitov
Quoted 60 lines · Justin Forbes
Quoted 58 lines · Michal Kubecek
Quoted 56 lines · Alex Shi
Quoted 11 lines · Andrew Morton
Quoted 9 lines · On Tue, 10 Nov 2020 08:39:24 +0530 Souptick Joarder <[email protected]>…
Quoted 7 lines · 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,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 3 lines
Quoted 1 line

Is CONFIG_DEBUG_INFO_BTF enabled in your .config ?

hm, yes.

When the config enabled, compiling looks good untill pahole tool used to get BTF info, but I still failed on a right version pahole

Quoted 29 lines

1.16. Sorry.

Quoted 17 lines
Quoted 17 lines
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/filemap.c +0 -0
index d90614f501da..249cf489f5df 100644
@@ -827,7 +827,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
 }
 EXPORT_SYMBOL_GPL(replace_page_cache_page);
 
Quoted 5 lines

mm/filemap.c int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask) · line 833

Quoted 5 lines
mm/filemap.c +1 -1
-noinline int __add_to_page_cache_locked(struct page *page,
+static noinline int __add_to_page_cache_locked(struct page *page,
                                        struct address_space *mapping,
                                        pgoff_t offset, gfp_t gfp,
                                        void **shadowp)

It's unclear to me whether BTF_ID() requires that the target symbol be non-static. It doesn't actually reference the symbol:

Quoted 3 lines
#define BTF_ID(prefix, name) \
        __BTF_ID(__ID(__BTF_ID__##prefix##__##name##__))

The above usage make me thought BTF don't require the symbol, though the symbol still exist in vmlinux with 'static'.

Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

So any comments of this, Alexei?

Sorry. I've completely missed this thread.
Now I have a hard time finding context in archives.
If I understood what's going on the removal of "static" cases issues? Yes. That's expected.
noinline alone is not enough to work reliably.

Not removal, commit 3351b16af494 ("mm/filemap: add static for function __add_to_page_cache_locked") made the function static which breaks the build in btfids phase - but it seems to happen only on some architectures. In our case, ppc64, ppc64le and riscv64 are broken, x86_64, i586 and s390x succeed. (I made a mistake above, aarch64 did not fail - but only because it was not built at all.)

Quoted 2 lines

The thread starts with
http://lkml.kernel.org/r/[email protected]

Got it. So the above commit is wrong.
The addition of "static" is incorrect here.
Regardless of btf_id generation.
"static noinline" means that the error injection in that spot is unreliable. Even when bpf is completely compiled out of the kernel.

#12 lore raw
Quoted 80 lines · Alexei Starovoitov
Quoted 78 lines · Michal Kubecek
Quoted 61 lines · Alexei Starovoitov
Quoted 60 lines · Justin Forbes
Quoted 58 lines · Michal Kubecek
Quoted 56 lines · Alex Shi
Quoted 11 lines · Andrew Morton
Quoted 9 lines · On Tue, 10 Nov 2020 08:39:24 +0530 Souptick Joarder <[email protected]>…
Quoted 7 lines · 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,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 3 lines
Quoted 1 line

Is CONFIG_DEBUG_INFO_BTF enabled in your .config ?

hm, yes.

When the config enabled, compiling looks good untill pahole tool used to get BTF info, but I still failed on a right version pahole

Quoted 29 lines

1.16. Sorry.

Quoted 17 lines
Quoted 17 lines
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/filemap.c +0 -0
index d90614f501da..249cf489f5df 100644
@@ -827,7 +827,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
 }
 EXPORT_SYMBOL_GPL(replace_page_cache_page);
 
Quoted 5 lines

mm/filemap.c int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask) · line 833

Quoted 5 lines
mm/filemap.c +1 -1
-noinline int __add_to_page_cache_locked(struct page *page,
+static noinline int __add_to_page_cache_locked(struct page *page,
                                        struct address_space *mapping,
                                        pgoff_t offset, gfp_t gfp,
                                        void **shadowp)

It's unclear to me whether BTF_ID() requires that the target symbol be non-static. It doesn't actually reference the symbol:

Quoted 3 lines
#define BTF_ID(prefix, name) \
        __BTF_ID(__ID(__BTF_ID__##prefix##__##name##__))

The above usage make me thought BTF don't require the symbol, though the symbol still exist in vmlinux with 'static'.

Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

So any comments of this, Alexei?

Sorry. I've completely missed this thread.
Now I have a hard time finding context in archives.
If I understood what's going on the removal of "static" cases issues? Yes. That's expected.
noinline alone is not enough to work reliably.

Not removal, commit 3351b16af494 ("mm/filemap: add static for function __add_to_page_cache_locked") made the function static which breaks the build in btfids phase - but it seems to happen only on some architectures. In our case, ppc64, ppc64le and riscv64 are broken, x86_64, i586 and s390x succeed. (I made a mistake above, aarch64 did not fail - but only because it was not built at all.)

Quoted 8 lines
Quoted 2 lines

The thread starts with
http://lkml.kernel.org/r/[email protected]

Got it. So the above commit is wrong.
The addition of "static" is incorrect here.
Regardless of btf_id generation.
"static noinline" means that the error injection in that spot is unreliable. Even when bpf is completely compiled out of the kernel.

I finally realized that the addition of 'static' was pushed into Linus's tree :( Please revert commit 3351b16af494 ("mm/filemap: add static for function __add_to_page_cache_locked")

#13 lore raw
Quoted 11 lines · Alexei Starovoitov
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 5 lines

Review

Quoted 5 lines
(quoted diff) +1 -1
-noinline int __add_to_page_cache_locked(struct page *page,
+static noinline int __add_to_page_cache_locked(struct page *page,
                                        struct address_space *mapping,
                                        pgoff_t offset, gfp_t gfp,
                                        void **shadowp)

It's unclear to me whether BTF_ID() requires that the target symbol be non-static. It doesn't actually reference the symbol:

#define BTF_ID(prefix, name) \
        __BTF_ID(__ID(__BTF_ID__##prefix##__##name##__))

[snip]

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

__add_to_page_cache_locked") made the function static which breaks the build in btfids phase - but it seems to happen only on some architectures. In our case, ppc64, ppc64le and riscv64 are broken, x86_64, i586 and s390x succeed. (I made a mistake above, aarch64 did not fail - but only because it was not built at all.)

The thread starts with
http://lkml.kernel.org/r/[email protected]

I have 5.10-rc7 build failure because of this on x86_64:

BTFIDS vmlinux
FAILED unresolved symbol __add_to_page_cache_locked
make: *** [Makefile:1170: vmlinux] Error 255

Quoted 9 lines
Quoted 5 lines

Got it. So the above commit is wrong.
The addition of "static" is incorrect here.
Regardless of btf_id generation.
"static noinline" means that the error injection in that spot is unreliable. Even when bpf is completely compiled out of the kernel.

I finally realized that the addition of 'static' was pushed into Linus's tree :( Please revert commit 3351b16af494 ("mm/filemap: add static for function __add_to_page_cache_locked")

At this point of release cycle we should probably go with revert, but I think the main problem is that BPF and ERROR_INJECTION use function that is not intended to be used externally. For external users add_to_page_cache_lru() and add_to_page_cache_locked() are exported and I think those should be used (see the patch below).

Stanislaw

kernel/bpf/verifier.c +2 -1
index 1388bf733071..dd6357802504 100644
@@ -11487,7 +11487,8 @@ BTF_SET_START(btf_non_sleepable_error_inject)
 /* Three functions below can be called from sleepable and non-sleepable context.
  * Assume non-sleepable from bpf safety point of view.
  */
-BTF_ID(func, __add_to_page_cache_locked)
+BTF_ID(func, add_to_page_cache_locked)
+BTF_ID(func, add_to_page_cache_lru)
 BTF_ID(func, should_fail_alloc_page)
 BTF_ID(func, should_failslab)
 BTF_SET_END(btf_non_sleepable_error_inject)
mm/filemap.c +6 -5
index 331f4261d723..168deec64a10 100644
@@ -827,10 +827,10 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
 }
 EXPORT_SYMBOL_GPL(replace_page_cache_page);
 
-static noinline int __add_to_page_cache_locked(struct page *page,
-					struct address_space *mapping,
-					pgoff_t offset, gfp_t gfp,
-					void **shadowp)
+static int __add_to_page_cache_locked(struct page *page,
+				      struct address_space *mapping,
+				      pgoff_t offset, gfp_t gfp,
+				      void **shadowp)
 {
 	XA_STATE(xas, &mapping->i_pages, offset);
 	int huge = PageHuge(page);
@@ -907,7 +907,6 @@ static noinline int __add_to_page_cache_locked(struct page *page,
 	put_page(page);
 	return error;
 }
-ALLOW_ERROR_INJECTION(__add_to_page_cache_locked, ERRNO);
 
 /**
  * add_to_page_cache_locked - add a locked page to the pagecache
@@ -928,6 +927,7 @@ int add_to_page_cache_locked(struct page *page, struct address_space *mapping,
 					  gfp_mask, NULL);
 }
 EXPORT_SYMBOL(add_to_page_cache_locked);
+ALLOW_ERROR_INJECTION(add_to_page_cache_locked, ERRNO);
 
 int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
 				pgoff_t offset, gfp_t gfp_mask)
@@ -957,6 +957,7 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
 	return ret;
 }
 EXPORT_SYMBOL_GPL(add_to_page_cache_lru);
+ALLOW_ERROR_INJECTION(add_to_page_cache_lru, ERRNO);
 
 #ifdef CONFIG_NUMA
 struct page *__page_cache_alloc(gfp_t gfp)
maintainer
#14 lore raw
Quoted 5 lines · Stanislaw Gruszka

At this point of release cycle we should probably go with revert, but I think the main problem is that BPF and ERROR_INJECTION use function that is not intended to be used externally. For external users add_to_page_cache_lru() and add_to_page_cache_locked() are exported and I think those should be used (see the patch below).

FWIW, I intend to do some consolidation/renaming in this area. I trust that will not be a problem?

#15 lore raw
Quoted 9 lines · Matthew Wilcox
Quoted 5 lines · Stanislaw Gruszka

At this point of release cycle we should probably go with revert, but I think the main problem is that BPF and ERROR_INJECTION use function that is not intended to be used externally. For external users add_to_page_cache_lru() and add_to_page_cache_locked() are exported and I think those should be used (see the patch below).

FWIW, I intend to do some consolidation/renaming in this area. I trust that will not be a problem?

If it does not break anything, it will be not a problem ;-)

It's possible that __add_to_page_cache_locked() can be a global symbol with add_to_page_cache_lru() + add_to_page_cache_locked() being just static/inline wrappers around it.

Stanislaw

#16 lore raw
Quoted 8 lines · Stanislaw Gruszka
Quoted 7 lines · Matthew Wilcox
Quoted 5 lines · Stanislaw Gruszka

At this point of release cycle we should probably go with revert, but I think the main problem is that BPF and ERROR_INJECTION use function that is not intended to be used externally. For external users add_to_page_cache_lru() and add_to_page_cache_locked() are exported and I think those should be used (see the patch below).

Quoted 8 lines
Quoted 2 lines

FWIW, I intend to do some consolidation/renaming in this area. I trust that will not be a problem?

If it does not break anything, it will be not a problem ;-)

It's possible that __add_to_page_cache_locked() can be a global symbol with add_to_page_cache_lru() + add_to_page_cache_locked() being just static/inline wrappers around it.

So what happens to BTF if we change this area entirely? Your IDs sound like some kind of ABI to me, which is extremely scary.

#17 lore raw
Quoted 12 lines · Christoph Hellwig
Quoted 11 lines · Stanislaw Gruszka
Quoted 9 lines · Matthew Wilcox
Quoted 5 lines · Stanislaw Gruszka

At this point of release cycle we should probably go with revert, but I think the main problem is that BPF and ERROR_INJECTION use function that is not intended to be used externally. For external users add_to_page_cache_lru() and add_to_page_cache_locked() are exported and I think those should be used (see the patch below).

FWIW, I intend to do some consolidation/renaming in this area. I trust that will not be a problem?

Quoted 8 lines
Quoted 5 lines

If it does not break anything, it will be not a problem ;-)

It's possible that __add_to_page_cache_locked() can be a global symbol with add_to_page_cache_lru() + add_to_page_cache_locked() being just static/inline wrappers around it.

So what happens to BTF if we change this area entirely? Your IDs sound like some kind of ABI to me, which is extremely scary.

Is BTF becoming the new tracepoint? That is, random additions of things like:

BTF_ID(func,__add_to_page_cache_locked)

Like was done in commit 1e6c62a882155 ("bpf: Introduce sleepable BPF programs") without any notification to the maintainers of the __add_to_page_cache_locked code, will suddenly become an API?

There's no mention in the change log to why __add_to_page_cache_locked was added. And interesting enough, __add_to_page_cache_locked is not in any header file, which is why it was switched to static.

-- Steve

#18 lore raw
Quoted 23 lines · Steven Rostedt
Quoted 12 lines · Christoph Hellwig
Quoted 11 lines · Stanislaw Gruszka
Quoted 9 lines · Matthew Wilcox
Quoted 5 lines · Stanislaw Gruszka

At this point of release cycle we should probably go with revert, but I think the main problem is that BPF and ERROR_INJECTION use function that is not intended to be used externally. For external users add_to_page_cache_lru() and add_to_page_cache_locked() are exported and I think those should be used (see the patch below).

FWIW, I intend to do some consolidation/renaming in this area. I trust that will not be a problem?

Quoted 8 lines
Quoted 5 lines

If it does not break anything, it will be not a problem ;-)

It's possible that __add_to_page_cache_locked() can be a global symbol with add_to_page_cache_lru() + add_to_page_cache_locked() being just static/inline wrappers around it.

So what happens to BTF if we change this area entirely? Your IDs sound like some kind of ABI to me, which is extremely scary.

Quoted 7 lines

Is BTF becoming the new tracepoint? That is, random additions of things like:

   BTF_ID(func,__add_to_page_cache_locked)

Like was done in commit 1e6c62a882155 ("bpf: Introduce sleepable BPF programs") without any notification to the maintainers of the __add_to_page_cache_locked code, will suddenly become an API?

huh? what api/abi you're talking about?

#19 lore raw
Quoted 14 lines · On Wed, 9 Dec 2020 17:12:43 -0800 Alexei Starovoitov…
Quoted 14 lines
Quoted 11 lines
Quoted 8 lines
Quoted 2 lines

FWIW, I intend to do some consolidation/renaming in this area. I trust that will not be a problem?

If it does not break anything, it will be not a problem ;-)

It's possible that __add_to_page_cache_locked() can be a global symbol with add_to_page_cache_lru() + add_to_page_cache_locked() being just static/inline wrappers around it.

So what happens to BTF if we change this area entirely? Your IDs sound like some kind of ABI to me, which is extremely scary.

Is BTF becoming the new tracepoint? That is, random additions of things like:

Quoted 7 lines
Quoted 5 lines
   BTF_ID(func,__add_to_page_cache_locked)

Like was done in commit 1e6c62a882155 ("bpf: Introduce sleepable BPF programs") without any notification to the maintainers of the __add_to_page_cache_locked code, will suddenly become an API?

huh? what api/abi you're talking about?

If the function __add_to_page_cache_locked were to be removed due to the code being rewritten, would it break any user space? If not, then there's nothing to worry about. ;-)

-- Steve

#20 lore raw
Quoted 24 lines · Steven Rostedt
Quoted 20 lines · On Wed, 9 Dec 2020 17:12:43 -0800 Alexei Starovoitov…
Quoted 19 lines
Quoted 11 lines
Quoted 8 lines
Quoted 2 lines

FWIW, I intend to do some consolidation/renaming in this area. I trust that will not be a problem?

If it does not break anything, it will be not a problem ;-)

It's possible that __add_to_page_cache_locked() can be a global symbol with add_to_page_cache_lru() + add_to_page_cache_locked() being just static/inline wrappers around it.

So what happens to BTF if we change this area entirely? Your IDs sound like some kind of ABI to me, which is extremely scary.

Is BTF becoming the new tracepoint? That is, random additions of things like:

   BTF_ID(func,__add_to_page_cache_locked)

Like was done in commit 1e6c62a882155 ("bpf: Introduce sleepable BPF programs") without any notification to the maintainers of the __add_to_page_cache_locked code, will suddenly become an API?

Quoted 5 lines
Quoted 1 line

huh? what api/abi you're talking about?

If the function __add_to_page_cache_locked were to be removed due to the code being rewritten, would it break any user space? If not, then there's nothing to worry about. ;-)

That function is marked with ALLOW_ERROR_INJECTION.
So any script that exercises it via debugfs (or via bpf) will not work. That's nothing new. Same "breakage" happens with kprobes, etc. The function was marked with error_inject for a reason though. The refactoring or renaming of this code ideally should provide a way to do similar pattern of injecting errors in this code path.
It could be a completely new function, of course.

#21 lore raw
In reply to Michal Kubecek
Quoted 6 lines · Michal Kubecek

Not removal, commit 3351b16af494 ("mm/filemap: add static for function __add_to_page_cache_locked") made the function static which breaks the build in btfids phase - but it seems to happen only on some architectures. In our case, ppc64, ppc64le and riscv64 are broken, x86_64, i586 and s390x succeed. (I made a mistake above, aarch64 did not fail - but only because it was not built at all.)

x86_64 fails for me:

LD vmlinux
BTFIDS vmlinux
FAILED unresolved symbol __add_to_page_cache_locked
make: *** [Makefile:1170: vmlinux] Error 255