Skip to contentSkip to conversation

mm/mremap: fix BUILD_BUG_ON() error in get_extent

PATCH Applied Arnd Bergmann 8 participants 12 messages Dec 30, 2020 – Feb 5, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/mremap: fix BUILD_BUG_ON() error in get_extent

From: Arnd Bergmann <[email protected]>

clang cannt evaluate this function argument at compile time when the function is not inlined, which leads to a link time failure:

ld.lld: error: undefined symbol: __compiletime_assert_414

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by mremap.c
mremap.o:(get_extent) in archive mm/built-in.a

Mark the function as __always_inline to avoid it.

Fixes 9ad9718bfa41 ("mm/mremap: calculate extent in one place")
---
 mm/mremap.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
mm/mremap.c +3 -2
index c5590afe7165..1cb464a07184 100644
@@ -336,8 +336,9 @@ enum pgt_entry {
  * valid. Else returns a smaller extent bounded by the end of the source and
  * destination pgt_entry.
  */
-static unsigned long get_extent(enum pgt_entry entry, unsigned long old_addr,
-			unsigned long old_end, unsigned long new_addr)
+static __always_inline unsigned long get_extent(enum pgt_entry entry,
+			unsigned long old_addr, unsigned long old_end,
+			unsigned long new_addr)
 {
 	unsigned long next, extent, mask, size;
 
Signature · 1 line
2.29.2
#1 lore raw

The subject should say BUILD_BUG()

Quoted 11 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

clang cannt evaluate this function argument at compile time when the function is not inlined, which leads to a link time failure:

ld.lld: error: undefined symbol: __compiletime_assert_414

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by mremap.c
mremap.o:(get_extent) in archive mm/built-in.a

Mark the function as __always_inline to avoid it.

Not sure if it's the ideal fix, maybe just convert it to BUG() instead? Functions shouldn't really have BUILD_BUG depending on parameters and rely on inlining to make it work...

Quoted 1 line
Fixes 9ad9718bfa41 ("mm/mremap: calculate extent in one place")

I think it's rather this one that introduces the BUILD_BUG() ? c49dd3401802 ("mm: speedup mremap on 1GB or larger regions")

Quoted 22 lines
---
 mm/mremap.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
mm/mremap.c +3 -2
index c5590afe7165..1cb464a07184 100644
@@ -336,8 +336,9 @@ enum pgt_entry {
  * valid. Else returns a smaller extent bounded by the end of the source and
  * destination pgt_entry.
  */
-static unsigned long get_extent(enum pgt_entry entry, unsigned long old_addr,
-			unsigned long old_end, unsigned long new_addr)
+static __always_inline unsigned long get_extent(enum pgt_entry entry,
+			unsigned long old_addr, unsigned long old_end,
+			unsigned long new_addr)
 {
 	unsigned long next, extent, mask, size;
 
#2 lore raw
In reply to Arnd Bergmann
Quoted 37 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

clang cannt evaluate this function argument at compile time when the function is not inlined, which leads to a link time failure:

ld.lld: error: undefined symbol: __compiletime_assert_414

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by mremap.c
mremap.o:(get_extent) in archive mm/built-in.a

Mark the function as __always_inline to avoid it.

Fixes 9ad9718bfa41 ("mm/mremap: calculate extent in one place")
---
 mm/mremap.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
mm/mremap.c +3 -2
index c5590afe7165..1cb464a07184 100644
@@ -336,8 +336,9 @@ enum pgt_entry {
  * valid. Else returns a smaller extent bounded by the end of the source and
  * destination pgt_entry.
  */
-static unsigned long get_extent(enum pgt_entry entry, unsigned long old_addr,
-			unsigned long old_end, unsigned long new_addr)
+static __always_inline unsigned long get_extent(enum pgt_entry entry,
+			unsigned long old_addr, unsigned long old_end,
+			unsigned long new_addr)
 {
 	unsigned long next, extent, mask, size;
 
Signature · 1 line
2.29.2

I am in agreement with Vlastimil, I would rather see the BUILD_BUG() dropped or converted into BUG() instead of papering over with __always_inline. For what it's worth, I only see this build failure with CONFIG_UBSAN_UNSIGNED_OVERFLOW, which you proposed disabling:

https://lore.kernel.org/lkml/[email protected]/

Cheers,
Nathan

#3 lore raw
Quoted 4 lines · Nathan Chancellor

I am in agreement with Vlastimil, I would rather see the BUILD_BUG() dropped or converted into BUG() instead of papering over with __always_inline.

I see your point, but I also generally prefer build-time checks over runtime ones wherever possible, and would prefer a way to keep it in a form that allows that, at least if the check is considered useful at all.

Quoted 4 lines

For what it's worth, I only see this build failure
with CONFIG_UBSAN_UNSIGNED_OVERFLOW, which you proposed disabling:

https://lore.kernel.org/lkml/[email protected]/

I'm building more randconfig kernels without this patch but with the __always_inline
reverted now, will see if it comes back. If not, let's just drop this patch.

Arnd

Reviewed-by on v1 1/1
#4 lore raw
In reply to Arnd Bergmann
Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

clang cannt evaluate this function argument at compile time when the function is not inlined, which leads to a link time failure:

Quoted 8 lines

ld.lld: error: undefined symbol: __compiletime_assert_414

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by mremap.c
mremap.o:(get_extent) in archive mm/built-in.a

Mark the function as __always_inline to avoid it.

Fixes 9ad9718bfa41 ("mm/mremap: calculate extent in one place")

I would like to see some movement on getting this fixed in 5.11. As it stands, this is one of three __compiletime_assert references with CONFIG_UBSAN_UNSIGNED_OVERFLOW. If we want to keep the BUILD_BUG() around, I think this is fine. Alternatively, turning it into a runtime check would be fine too.

Quoted 22 lines
---
 mm/mremap.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
mm/mremap.c +3 -2
index c5590afe7165..1cb464a07184 100644
@@ -336,8 +336,9 @@ enum pgt_entry {
  * valid. Else returns a smaller extent bounded by the end of the source and
  * destination pgt_entry.
  */
-static unsigned long get_extent(enum pgt_entry entry, unsigned long old_addr,
-			unsigned long old_end, unsigned long new_addr)
+static __always_inline unsigned long get_extent(enum pgt_entry entry,
+			unsigned long old_addr, unsigned long old_end,
+			unsigned long new_addr)
 {
 	unsigned long next, extent, mask, size;
 
Signature · 1 line
2.29.2
Tested-by
#5 lore raw
Quoted 17 lines · Nathan Chancellor
Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

clang cannt evaluate this function argument at compile time when the function is not inlined, which leads to a link time failure:

Quoted 8 lines

ld.lld: error: undefined symbol: __compiletime_assert_414

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by mremap.c
mremap.o:(get_extent) in archive mm/built-in.a

Mark the function as __always_inline to avoid it.

Fixes 9ad9718bfa41 ("mm/mremap: calculate extent in one place")
Quoted 8 lines

I would like to see some movement on getting this fixed in 5.11. As it stands, this is one of three __compiletime_assert references with CONFIG_UBSAN_UNSIGNED_OVERFLOW. If we want to keep the BUILD_BUG() around, I think this is fine. Alternatively, turning it into a runtime check would be fine too.

I have this patch in my custom 5.11 queue.

Feel free to add my:

- Sedat -

Quoted 28 lines
Quoted 21 lines
---
 mm/mremap.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
mm/mremap.c +3 -3
index c5590afe7165..1cb464a07184 100644
@@ -336,8 +336,9 @@ enum pgt_entry {
  * valid. Else returns a smaller extent bounded by the end of the source and
  * destination pgt_entry.
  */
-static unsigned long get_extent(enum pgt_entry entry, unsigned long old_addr,
-                     unsigned long old_end, unsigned long new_addr)
+static __always_inline unsigned long get_extent(enum pgt_entry entry,
+                     unsigned long old_addr, unsigned long old_end,
+                     unsigned long new_addr)
 {
      unsigned long next, extent, mask, size;
 
--
Quoted 1 line

2.29.2

--
You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20210112191634.GA1587546%40ubuntu-m3-large-x86.

#6 lore raw
In reply to Nathan Chancellor
Quoted 16 lines · Nathan Chancellor
Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

clang cannt evaluate this function argument at compile time when the function is not inlined, which leads to a link time failure:

Quoted 8 lines

ld.lld: error: undefined symbol: __compiletime_assert_414

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by mremap.c
mremap.o:(get_extent) in archive mm/built-in.a

Mark the function as __always_inline to avoid it.

Fixes 9ad9718bfa41 ("mm/mremap: calculate extent in one place")
Quoted 7 lines

I would like to see some movement on getting this fixed in 5.11. As it stands, this is one of three __compiletime_assert references with CONFIG_UBSAN_UNSIGNED_OVERFLOW. If we want to keep the BUILD_BUG() around, I think this is fine. Alternatively, turning it into a runtime check would be fine too.

Ping? It is pretty late into the 5.11 cycle and this is still broken.

Cheers,
Nathan

Quoted 23 lines
Quoted 22 lines
---
 mm/mremap.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
mm/mremap.c +3 -2
index c5590afe7165..1cb464a07184 100644
@@ -336,8 +336,9 @@ enum pgt_entry {
  * valid. Else returns a smaller extent bounded by the end of the source and
  * destination pgt_entry.
  */
-static unsigned long get_extent(enum pgt_entry entry, unsigned long old_addr,
-			unsigned long old_end, unsigned long new_addr)
+static __always_inline unsigned long get_extent(enum pgt_entry entry,
+			unsigned long old_addr, unsigned long old_end,
+			unsigned long new_addr)
 {
 	unsigned long next, extent, mask, size;
 
Signature · 1 line
2.29.2
#7 lore raw
Quoted 23 lines · Nathan Chancellor
Quoted 22 lines · Nathan Chancellor
Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

clang cannt evaluate this function argument at compile time when the function is not inlined, which leads to a link time failure:

Quoted 8 lines

ld.lld: error: undefined symbol: __compiletime_assert_414

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by mremap.c
mremap.o:(get_extent) in archive mm/built-in.a

Mark the function as __always_inline to avoid it.

Fixes 9ad9718bfa41 ("mm/mremap: calculate extent in one place")

I would like to see some movement on getting this fixed in 5.11. As it stands, this is one of three __compiletime_assert references with CONFIG_UBSAN_UNSIGNED_OVERFLOW. If we want to keep the BUILD_BUG() around, I think this is fine. Alternatively, turning it into a runtime check would be fine too.

Quoted 3 lines
Quoted 1 line

Ping? It is pretty late into the 5.11 cycle and this is still broken.

I think we should just do the __always_inline. Who can take this?

-Kees

Quoted 27 lines

Cheers,
Nathan

Quoted 23 lines
Quoted 22 lines
---
 mm/mremap.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
mm/mremap.c +3 -2
index c5590afe7165..1cb464a07184 100644
@@ -336,8 +336,9 @@ enum pgt_entry {
  * valid. Else returns a smaller extent bounded by the end of the source and
  * destination pgt_entry.
  */
-static unsigned long get_extent(enum pgt_entry entry, unsigned long old_addr,
-			unsigned long old_end, unsigned long new_addr)
+static __always_inline unsigned long get_extent(enum pgt_entry entry,
+			unsigned long old_addr, unsigned long old_end,
+			unsigned long new_addr)
 {
 	unsigned long next, extent, mask, size;
 
Signature · 1 line
2.29.2
Signature · 1 line
Kees Cook
#8 lore raw
Quoted 24 lines · Kees Cook
Quoted 23 lines · Nathan Chancellor
Quoted 22 lines · Nathan Chancellor
Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

clang cannt evaluate this function argument at compile time when the function is not inlined, which leads to a link time failure:

Quoted 8 lines

ld.lld: error: undefined symbol: __compiletime_assert_414

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by mremap.c
mremap.o:(get_extent) in archive mm/built-in.a

Mark the function as __always_inline to avoid it.

Fixes 9ad9718bfa41 ("mm/mremap: calculate extent in one place")

I would like to see some movement on getting this fixed in 5.11. As it stands, this is one of three __compiletime_assert references with CONFIG_UBSAN_UNSIGNED_OVERFLOW. If we want to keep the BUILD_BUG() around, I think this is fine. Alternatively, turning it into a runtime check would be fine too.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Ping? It is pretty late into the 5.11 cycle and this is still broken.

I think we should just do the __always_inline. Who can take this?

This should probably go through -mm, unless we get an ack then Nick and I could take it.

Quoted 24 lines
Quoted 24 lines

Cheers,
Nathan

Quoted 20 lines
Quoted 20 lines
---
 mm/mremap.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
mm/mremap.c +3 -2
index c5590afe7165..1cb464a07184 100644
@@ -336,8 +336,9 @@ enum pgt_entry {
  * valid. Else returns a smaller extent bounded by the end of the source and
  * destination pgt_entry.
  */
-static unsigned long get_extent(enum pgt_entry entry, unsigned long old_addr,
-			unsigned long old_end, unsigned long new_addr)
+static __always_inline unsigned long get_extent(enum pgt_entry entry,
+			unsigned long old_addr, unsigned long old_end,
+			unsigned long new_addr)
 {
 	unsigned long next, extent, mask, size;
 
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Signature · 1 line
2.29.2

Cheers,
Nathan

maintainer
#9 lore raw
Quoted 8 lines · On Fri, 5 Feb 2021 12:00:05 -0700 Nathan Chancellor <[email protected]> wrote:
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Ping? It is pretty late into the 5.11 cycle and this is still broken.

I think we should just do the __always_inline. Who can take this?

This should probably go through -mm, unless we get an ack then Nick and I could take it.

I added it to -mm on Wednesday.

#10 lore raw
Quoted 4 lines · Andrew Morton
Quoted 2 lines · On Fri, 5 Feb 2021 12:00:05 -0700 Nathan Chancellor <[email protected]> wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Ping? It is pretty late into the 5.11 cycle and this is still broken.

I think we should just do the __always_inline. Who can take this?

This should probably go through -mm, unless we get an ack then Nick and I could take it.

I added it to -mm on Wednesday.

Thank you! I did not see an email but it looks like my tag did not make it on to the patch so that would make sense. It would be great if this could get into 5.11 but if not, we can always backport it

Cheers,
Nathan

Tested-by on v1 1/1
#11 lore raw
In reply to Arnd Bergmann
Quoted 7 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

clang cannt evaluate this function argument at compile time when the function is not inlined, which leads to a link time failure:

Quoted 8 lines

ld.lld: error: undefined symbol: __compiletime_assert_414

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by mremap.c
mremap.o:(get_extent) in archive mm/built-in.a

Mark the function as __always_inline to avoid it.

Fixes 9ad9718bfa41 ("mm/mremap: calculate extent in one place")
Quoted 27 lines
---
 mm/mremap.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
mm/mremap.c +3 -3
index c5590afe7165..1cb464a07184 100644
@@ -336,8 +336,9 @@ enum pgt_entry {
  * valid. Else returns a smaller extent bounded by the end of the source and
  * destination pgt_entry.
  */
-static unsigned long get_extent(enum pgt_entry entry, unsigned long old_addr,
-                       unsigned long old_end, unsigned long new_addr)
+static __always_inline unsigned long get_extent(enum pgt_entry entry,
+                       unsigned long old_addr, unsigned long old_end,
+                       unsigned long new_addr)
 {
        unsigned long next, extent, mask, size;
 
--

2.29.2

--
You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20201230154104.522605-1-arnd%40kernel.org.

Signature · 2 lines
Thanks,
~Nick Desaulniers