Skip to contentSkip to conversation

mm: Mark create_huge_pmd() inline to prevent build failure

PATCH Applied Geert Uytterhoeven 3 participants 8 messages Jul 12, 2017 – Jul 13, 2017

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

PATCH 1/1 mm: Mark create_huge_pmd() inline to prevent build failure

With gcc 4.1.2:

mm/memory.o: In function `create_huge_pmd':
memory.c:(.text+0x93e): undefined reference to `do_huge_pmd_anonymous_page'

Converting transparent_hugepage_enabled() from a macro to a static inline function reduced the ability of the compiler to remove unused code.

Fix this by marking create_huge_pmd() inline.

Fixes 16981d763501c0e0 ("mm: improve readability of transparent_hugepage_enabled()")

---
Interestingly, create_huge_pmd() is emitted in the assembler output, but never called.

---
 mm/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory.c +1 -1
index cbb57194687e393a..0e517be91a89e162 100644
@@ -3591,7 +3591,7 @@ static int do_numa_page(struct vm_fault *vmf)
 	return 0;
 }
 
-static int create_huge_pmd(struct vm_fault *vmf)
+static inline int create_huge_pmd(struct vm_fault *vmf)
 {
 	if (vma_is_anonymous(vmf->vma))
 		return do_huge_pmd_anonymous_page(vmf);
Signature · 7 lines
2.7.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Geert Uytterhoeven

With gcc 4.1.2:

mm/memory.o: In function `create_huge_pmd':
memory.c:(.text+0x93e): undefined reference to `do_huge_pmd_anonymous_page'

Quoted 8 lines

Converting transparent_hugepage_enabled() from a macro to a static inline function reduced the ability of the compiler to remove unused code.

Fix this by marking create_huge_pmd() inline.

Fixes 16981d763501c0e0 ("mm: improve readability of transparent_hugepage_enabled()")
Quoted 3 lines

---
Interestingly, create_huge_pmd() is emitted in the assembler output, but never called.

I've never seen this before either. I know that early gcc-4 compilers would do this
when a function is referenced from an unused function pointer, but not with a compile-time constant evaluation. I guess that transparent_hugepage_enabled is just slightly more complex than it gcc-4.1 can handle here.

Arnd

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw

Hi Arnd,

Quoted 11 lines · Arnd Bergmann
Quoted 9 lines · Geert Uytterhoeven

With gcc 4.1.2:

mm/memory.o: In function `create_huge_pmd':
memory.c:(.text+0x93e): undefined reference to `do_huge_pmd_anonymous_page'

Converting transparent_hugepage_enabled() from a macro to a static inline function reduced the ability of the compiler to remove unused code.

Quoted 6 lines
Quoted 4 lines

Fix this by marking create_huge_pmd() inline.

Fixes 16981d763501c0e0 ("mm: improve readability of transparent_hugepage_enabled()")

Thanks!

Quoted 9 lines
Quoted 3 lines

---
Interestingly, create_huge_pmd() is emitted in the assembler output, but never called.

I've never seen this before either. I know that early gcc-4 compilers would do this
when a function is referenced from an unused function pointer, but not with a compile-time constant evaluation. I guess that transparent_hugepage_enabled is just slightly more complex than it gcc-4.1 can handle here.

You did mention seeing it with mips-gcc-4.1 in the thread "[RFC] minimum gcc version for kernel: raise to gcc-4.3 or 4.6?", but didn't provide any further details. Finally I started seeing it myself for m68k ;-)

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw
Quoted 3 lines · Geert Uytterhoeven

You did mention seeing it with mips-gcc-4.1 in the thread "[RFC] minimum gcc version for kernel: raise to gcc-4.3 or 4.6?", but didn't provide any further details. Finally I started seeing it myself for m68k ;-)

Ah right, I misremembered that then.

Arnd

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw
In reply to Geert Uytterhoeven
Quoted 25 lines · Geert Uytterhoeven

With gcc 4.1.2:

mm/memory.o: In function `create_huge_pmd':
memory.c:(.text+0x93e): undefined reference to `do_huge_pmd_anonymous_page'

Converting transparent_hugepage_enabled() from a macro to a static inline function reduced the ability of the compiler to remove unused code.

Fix this by marking create_huge_pmd() inline.

Fixes 16981d763501c0e0 ("mm: improve readability of transparent_hugepage_enabled()")

---
Interestingly, create_huge_pmd() is emitted in the assembler output, but never called.

---
 mm/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory.c +0 -0
index cbb57194687e393a..0e517be91a89e162 100644

mm/memory.c static int do_numa_page(struct vm_fault *vmf) · line 3595

Quoted 6 lines
mm/memory.c +1 -1
@@ -3591,7 +3591,7 @@ static int do_numa_page(struct vm_fault *vmf)
        return 0;
 }
 
-static int create_huge_pmd(struct vm_fault *vmf)
+static inline int create_huge_pmd(struct vm_fault *vmf)
 {

This seems fragile, what if the kernel decides to ignore the inline hint? If it must be inlined to avoid compile errors then it should be __always_inline, right?

I also wonder if it's enough to just specify __always_inline to transparent_hugepage_enabled(), i.e. in case the compiler is making an uninlined copy of transparent_hugepage_enabled() in mm/memory.c.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#5 lore raw
Quoted 30 lines · Dan Williams
Quoted 28 lines · Geert Uytterhoeven

With gcc 4.1.2:

mm/memory.o: In function `create_huge_pmd':
memory.c:(.text+0x93e): undefined reference to `do_huge_pmd_anonymous_page'

Converting transparent_hugepage_enabled() from a macro to a static inline function reduced the ability of the compiler to remove unused code.

Fix this by marking create_huge_pmd() inline.

Fixes 16981d763501c0e0 ("mm: improve readability of transparent_hugepage_enabled()")

---
Interestingly, create_huge_pmd() is emitted in the assembler output, but never called.

---
 mm/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory.c +0 -0
index cbb57194687e393a..0e517be91a89e162 100644
@@ -3591,7 +3591,7 @@ static int do_numa_page(struct vm_fault *vmf)
        return 0;
 }
 
Quoted 5 lines

mm/memory.c static int do_numa_page(struct vm_fault *vmf) · line 3595

Quoted 3 lines
mm/memory.c +1 -1
-static int create_huge_pmd(struct vm_fault *vmf)
+static inline int create_huge_pmd(struct vm_fault *vmf)
 {

This seems fragile, what if the kernel decides

...of course I meant *compiler* instead of 'kernel' here

Quoted 8 lines

to ignore the inline
hint? If it must be inlined to avoid compile errors then it should be __always_inline, right?

I also wonder if it's enough to just specify __always_inline to transparent_hugepage_enabled(), i.e. in case the compiler is making an uninlined copy of transparent_hugepage_enabled() in mm/memory.c.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#6 lore raw
In reply to Dan Williams

Hi Dan,

Quoted 30 lines · Dan Williams
Quoted 28 lines · Geert Uytterhoeven

With gcc 4.1.2:

mm/memory.o: In function `create_huge_pmd':
memory.c:(.text+0x93e): undefined reference to `do_huge_pmd_anonymous_page'

Converting transparent_hugepage_enabled() from a macro to a static inline function reduced the ability of the compiler to remove unused code.

Fix this by marking create_huge_pmd() inline.

Fixes 16981d763501c0e0 ("mm: improve readability of transparent_hugepage_enabled()")

---
Interestingly, create_huge_pmd() is emitted in the assembler output, but never called.

---
 mm/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory.c +0 -0
index cbb57194687e393a..0e517be91a89e162 100644
@@ -3591,7 +3591,7 @@ static int do_numa_page(struct vm_fault *vmf)
        return 0;
 }
 
Quoted 7 lines

mm/memory.c static int do_numa_page(struct vm_fault *vmf) · line 3595

Quoted 3 lines
mm/memory.c +1 -1
-static int create_huge_pmd(struct vm_fault *vmf)
+static inline int create_huge_pmd(struct vm_fault *vmf)
 {

This seems fragile, what if the kernel decides to ignore the inline hint? If it must be inlined to avoid compile errors then it should be __always_inline, right?

With gcc-4, "inline" is already #define'd to
#define inline inline __attribute__((always_inline,unused)) notrace

Quoted 3 lines

I also wonder if it's enough to just specify __always_inline to transparent_hugepage_enabled(), i.e. in case the compiler is making an uninlined copy of transparent_hugepage_enabled() in mm/memory.c.

Hence the answer is no.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Acked-by
#7 lore raw
Quoted 41 lines · Geert Uytterhoeven

Hi Dan,

Quoted 30 lines · Dan Williams
Quoted 28 lines · Geert Uytterhoeven

With gcc 4.1.2:

mm/memory.o: In function `create_huge_pmd':
memory.c:(.text+0x93e): undefined reference to `do_huge_pmd_anonymous_page'

Converting transparent_hugepage_enabled() from a macro to a static inline function reduced the ability of the compiler to remove unused code.

Fix this by marking create_huge_pmd() inline.

Fixes 16981d763501c0e0 ("mm: improve readability of transparent_hugepage_enabled()")

---
Interestingly, create_huge_pmd() is emitted in the assembler output, but never called.

---
 mm/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory.c +0 -0
index cbb57194687e393a..0e517be91a89e162 100644
@@ -3591,7 +3591,7 @@ static int do_numa_page(struct vm_fault *vmf)
        return 0;
 }
 
Quoted 7 lines

mm/memory.c static int do_numa_page(struct vm_fault *vmf) · line 3595

Quoted 3 lines
mm/memory.c +1 -1
-static int create_huge_pmd(struct vm_fault *vmf)
+static inline int create_huge_pmd(struct vm_fault *vmf)
 {

This seems fragile, what if the kernel decides to ignore the inline hint? If it must be inlined to avoid compile errors then it should be __always_inline, right?

Quoted 2 lines

With gcc-4, "inline" is already #define'd to
#define inline inline __attribute__((always_inline,unused)) notrace

Ah, ok.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>