2013-10-22 16:12:34

by Andi Kleen

[permalink] [raw]
Subject: Various asmlinkage fixes for LTO

LTO (Link Time Optimization) requires all C symbols used from
assembler to be marked visible. This patchkit marks various
functions over the tree asmlinkage or __visible, when they
are used by assembler.

-Andi


2013-10-22 16:12:33

by Andi Kleen

[permalink] [raw]
Subject: [PATCH 10/11] asmlinkage: Mark rwsem functions that can be called from assembler asmlinkage

From: Andi Kleen <[email protected]>

Signed-off-by: Andi Kleen <[email protected]>
---
lib/rwsem.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/lib/rwsem.c b/lib/rwsem.c
index 19c5fa9..1d66e08 100644
--- a/lib/rwsem.c
+++ b/lib/rwsem.c
@@ -143,6 +143,7 @@ __rwsem_do_wake(struct rw_semaphore *sem, enum rwsem_wake_type wake_type)
/*
* wait for the read lock to be granted
*/
+__visible
struct rw_semaphore __sched *rwsem_down_read_failed(struct rw_semaphore *sem)
{
long count, adjustment = -RWSEM_ACTIVE_READ_BIAS;
@@ -190,6 +191,7 @@ struct rw_semaphore __sched *rwsem_down_read_failed(struct rw_semaphore *sem)
/*
* wait until we successfully acquire the write lock
*/
+__visible
struct rw_semaphore __sched *rwsem_down_write_failed(struct rw_semaphore *sem)
{
long count, adjustment = -RWSEM_ACTIVE_WRITE_BIAS;
@@ -252,6 +254,7 @@ struct rw_semaphore __sched *rwsem_down_write_failed(struct rw_semaphore *sem)
* handle waking up a waiter on the semaphore
* - up_read/up_write has decremented the active part of count if we come here
*/
+__visible
struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem)
{
unsigned long flags;
@@ -272,6 +275,7 @@ struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem)
* - caller incremented waiting part of count and discovered it still negative
* - just wake up any readers at the front of the queue
*/
+__visible
struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem)
{
unsigned long flags;
--
1.8.3.1

2013-10-22 16:12:50

by Andi Kleen

[permalink] [raw]
Subject: [PATCH 11/11] asmlinkage, wan/sbni: Make inline assembler symbols visible and assembler global

From: Andi Kleen <[email protected]>

- Inline assembler defining C callable code has to be global
- The function has to be visible

Do this in wan/sbni

Cc: [email protected]
Signed-off-by: Andi Kleen <[email protected]>
---
drivers/net/wan/sbni.c | 6 +++---
drivers/net/wan/sbni.h | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wan/sbni.c b/drivers/net/wan/sbni.c
index 5bbcb5e..571db25 100644
--- a/drivers/net/wan/sbni.c
+++ b/drivers/net/wan/sbni.c
@@ -160,7 +160,7 @@ static int scandone __initdata = 0;
static int num __initdata = 0;

static unsigned char rxl_tab[];
-static u32 crc32tab[];
+__visible u32 sbni_crc32tab[];

/* A list of all installed devices, for removing the driver module. */
static struct net_device *sbni_cards[ SBNI_MAX_NUM_CARDS ];
@@ -1563,7 +1563,7 @@ calc_crc32( u32 crc, u8 *p, u32 len )
"xorl %%ebx, %%ebx\n"
"movl %2, %%esi\n"
"movl %3, %%ecx\n"
- "movl $crc32tab, %%edi\n"
+ "movl $sbni_crc32tab, %%edi\n"
"shrl $2, %%ecx\n"
"jz 1f\n"

@@ -1645,7 +1645,7 @@ calc_crc32( u32 crc, u8 *p, u32 len )
#endif /* ASM_CRC */


-static u32 crc32tab[] __attribute__ ((aligned(8))) = {
+__visible u32 sbni_crc32tab[] __attribute__ ((aligned(8))) = {
0xD202EF8D, 0xA505DF1B, 0x3C0C8EA1, 0x4B0BBE37,
0xD56F2B94, 0xA2681B02, 0x3B614AB8, 0x4C667A2E,
0xDCD967BF, 0xABDE5729, 0x32D70693, 0x45D03605,
diff --git a/drivers/net/wan/sbni.h b/drivers/net/wan/sbni.h
index 8426451..7e6d980 100644
--- a/drivers/net/wan/sbni.h
+++ b/drivers/net/wan/sbni.h
@@ -132,7 +132,7 @@ struct sbni_flags {
/*
* CRC-32 stuff
*/
-#define CRC32(c,crc) (crc32tab[((size_t)(crc) ^ (c)) & 0xff] ^ (((crc) >> 8) & 0x00FFFFFF))
+#define CRC32(c,crc) (sbni_crc32tab[((size_t)(crc) ^ (c)) & 0xff] ^ (((crc) >> 8) & 0x00FFFFFF))
/* CRC generator 0xEDB88320 */
/* CRC remainder 0x2144DF1C */
/* CRC initial value 0x00000000 */
--
1.8.3.1

2013-10-22 16:13:08

by Andi Kleen

[permalink] [raw]
Subject: [PATCH 04/11] asmlinkage, pnp: Make variables used from assembler code visible

From: Andi Kleen <[email protected]>

Mark variables referenced from assembler files visible.

This fixes compile problems with LTO

Cc: [email protected]
Signed-off-by: Andi Kleen <[email protected]>
---
drivers/pnp/pnpbios/bioscalls.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
index 769d265..deb7f4b 100644
--- a/drivers/pnp/pnpbios/bioscalls.c
+++ b/drivers/pnp/pnpbios/bioscalls.c
@@ -21,7 +21,7 @@

#include "pnpbios.h"

-static struct {
+__visible struct {
u16 offset;
u16 segment;
} pnp_bios_callpoint;
@@ -41,6 +41,7 @@ asmlinkage void pnp_bios_callfunc(void);

__asm__(".text \n"
__ALIGN_STR "\n"
+ ".globl pnp_bios_callfunc\n"
"pnp_bios_callfunc:\n"
" pushl %edx \n"
" pushl %ecx \n"
@@ -66,9 +67,9 @@ static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
* after PnP BIOS oopses.
*/

-u32 pnp_bios_fault_esp;
-u32 pnp_bios_fault_eip;
-u32 pnp_bios_is_utter_crap = 0;
+__visible u32 pnp_bios_fault_esp;
+__visible u32 pnp_bios_fault_eip;
+__visible u32 pnp_bios_is_utter_crap = 0;

static spinlock_t pnp_bios_lock;

--
1.8.3.1

2013-10-22 16:13:18

by Andi Kleen

[permalink] [raw]
Subject: [PATCH 02/11] asmlinkage: Make __iowrite32_copy visible

From: Andi Kleen <[email protected]>

This is a assembler function on x86, so it should be visible.

Cc: [email protected]
Signed-off-by: Andi Kleen <[email protected]>
---
include/linux/io.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/io.h b/include/linux/io.h
index f4f42fa..8a18e75 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -24,7 +24,7 @@

struct device;

-void __iowrite32_copy(void __iomem *to, const void *from, size_t count);
+__visible void __iowrite32_copy(void __iomem *to, const void *from, size_t count);
void __iowrite64_copy(void __iomem *to, const void *from, size_t count);

#ifdef CONFIG_MMU
--
1.8.3.1

2013-10-22 16:13:15

by Andi Kleen

[permalink] [raw]
Subject: [PATCH 09/11] asmlinkage: Make main_extable_sort_needed visible

From: Andi Kleen <[email protected]>

main_extable_sort_needed is used by the build system and needs
to be a normal ELF symbol. Make it visible so that LTO
does not remove or mangle it.

Signed-off-by: Andi Kleen <[email protected]>
---
kernel/extable.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/extable.c b/kernel/extable.c
index 832cb28..829afaa 100644
--- a/kernel/extable.c
+++ b/kernel/extable.c
@@ -36,7 +36,7 @@ extern struct exception_table_entry __start___ex_table[];
extern struct exception_table_entry __stop___ex_table[];

/* Cleared by build time tools if the table is already sorted. */
-u32 __initdata main_extable_sort_needed = 1;
+u32 __initdata __visible main_extable_sort_needed = 1;

/* Sort the kernel's built-in exception table */
void __init sort_main_extable(void)
--
1.8.3.1

2013-10-22 16:13:14

by Andi Kleen

[permalink] [raw]
Subject: [PATCH 03/11] asmlinkage: Make jiffies visible

From: Andi Kleen <[email protected]>

Jiffies is referenced by the linker script, so it has to be visible.

Handled both the generic and the x86 version.

Cc: [email protected]
Signed-off-by: Andi Kleen <[email protected]>
---
arch/x86/kernel/time.c | 2 +-
kernel/timer.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
index 24d3c91..6ec91c0 100644
--- a/arch/x86/kernel/time.c
+++ b/arch/x86/kernel/time.c
@@ -23,7 +23,7 @@
#include <asm/time.h>

#ifdef CONFIG_X86_64
-DEFINE_VVAR(volatile unsigned long, jiffies) = INITIAL_JIFFIES;
+__visible DEFINE_VVAR(volatile unsigned long, jiffies) = INITIAL_JIFFIES;
#endif

unsigned long profile_pc(struct pt_regs *regs)
diff --git a/kernel/timer.c b/kernel/timer.c
index 4296d13..a3ae2da 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -52,7 +52,7 @@
#define CREATE_TRACE_POINTS
#include <trace/events/timer.h>

-u64 jiffies_64 __cacheline_aligned_in_smp = INITIAL_JIFFIES;
+__visible u64 jiffies_64 __cacheline_aligned_in_smp = INITIAL_JIFFIES;

EXPORT_SYMBOL(jiffies_64);

--
1.8.3.1

2013-10-22 16:13:12

by Andi Kleen

[permalink] [raw]
Subject: [PATCH 01/11] asmlinkage, kvm: Make kvm_rebooting visible

From: Andi Kleen <[email protected]>

kvm_rebooting is referenced from assembler code, thus
needs to be visible.

Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Andi Kleen <[email protected]>
---
virt/kvm/kvm_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index a9dd682..6ca3564 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -95,7 +95,7 @@ static void hardware_disable_all(void);

static void kvm_io_bus_destroy(struct kvm_io_bus *bus);

-bool kvm_rebooting;
+__visible bool kvm_rebooting;
EXPORT_SYMBOL_GPL(kvm_rebooting);

static bool largepages_enabled = true;
--
1.8.3.1

2013-10-22 16:13:10

by Andi Kleen

[permalink] [raw]
Subject: [PATCH 07/11] asmlinkage, module: Make ksymtab and kcrctab symbols and __this_module __visible

From: Andi Kleen <[email protected]>

Make the ksymtab symbols for EXPORT_SYMBOL visible.
This prevents the LTO compiler from adding a .NUMBER prefix,
which avoids various problems in later export processing.

Cc: [email protected]
Signed-off-by: Andi Kleen <[email protected]>
---
include/linux/export.h | 4 ++--
scripts/mod/modpost.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/export.h b/include/linux/export.h
index 412cd50..3f2793d 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -43,7 +43,7 @@ extern struct module __this_module;
/* Mark the CRC weak since genksyms apparently decides not to
* generate a checksums for some symbols */
#define __CRC_SYMBOL(sym, sec) \
- extern void *__crc_##sym __attribute__((weak)); \
+ extern __visible void *__crc_##sym __attribute__((weak)); \
static const unsigned long __kcrctab_##sym \
__used \
__attribute__((section("___kcrctab" sec "+" #sym), unused)) \
@@ -59,7 +59,7 @@ extern struct module __this_module;
static const char __kstrtab_##sym[] \
__attribute__((section("__ksymtab_strings"), aligned(1))) \
= VMLINUX_SYMBOL_STR(sym); \
- static const struct kernel_symbol __ksymtab_##sym \
+ __visible const struct kernel_symbol __ksymtab_##sym \
__used \
__attribute__((section("___ksymtab" sec "+" #sym), unused)) \
= { (unsigned long)&sym, __kstrtab_##sym }
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 8247979..0971bac 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1853,7 +1853,7 @@ static void add_header(struct buffer *b, struct module *mod)
buf_printf(b, "\n");
buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");
buf_printf(b, "\n");
- buf_printf(b, "struct module __this_module\n");
+ buf_printf(b, "__visible struct module __this_module\n");
buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n");
buf_printf(b, "\t.name = KBUILD_MODNAME,\n");
if (mod->has_init)
--
1.8.3.1

2013-10-22 16:14:57

by Andi Kleen

[permalink] [raw]
Subject: [PATCH 06/11] asmlinkage: Make trace_hardirq visible

From: Andi Kleen <[email protected]>

Can be called from assembler code.

Cc: [email protected]
Cc: [email protected]
Signed-off-by: Andi Kleen <[email protected]>
---
kernel/lockdep.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index d3749fe..d1a047d 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -2555,7 +2555,7 @@ static void __trace_hardirqs_on_caller(unsigned long ip)
debug_atomic_inc(hardirqs_on_events);
}

-void trace_hardirqs_on_caller(unsigned long ip)
+__visible void trace_hardirqs_on_caller(unsigned long ip)
{
time_hardirqs_on(CALLER_ADDR0, ip);

@@ -2608,7 +2608,7 @@ EXPORT_SYMBOL(trace_hardirqs_on);
/*
* Hardirqs were disabled:
*/
-void trace_hardirqs_off_caller(unsigned long ip)
+__visible void trace_hardirqs_off_caller(unsigned long ip)
{
struct task_struct *curr = current;

--
1.8.3.1

2013-10-22 16:15:20

by Andi Kleen

[permalink] [raw]
Subject: [PATCH 05/11] asmlinkage: Make lockdep_sys_exit asmlinkage

From: Andi Kleen <[email protected]>

lockdep_sys_exit can be called from assembler code, so make it
asmlinkage

Cc: [email protected]
Cc: [email protected]
Signed-off-by: Andi Kleen <[email protected]>
---
include/linux/lockdep.h | 2 +-
kernel/lockdep.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index cfc2f11..18e19e4 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -265,7 +265,7 @@ extern void lockdep_info(void);
extern void lockdep_reset(void);
extern void lockdep_reset_lock(struct lockdep_map *lock);
extern void lockdep_free_key_range(void *start, unsigned long size);
-extern void lockdep_sys_exit(void);
+extern asmlinkage void lockdep_sys_exit(void);

extern void lockdep_off(void);
extern void lockdep_on(void);
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index e16c45b..d3749fe 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -4187,7 +4187,7 @@ void debug_show_held_locks(struct task_struct *task)
}
EXPORT_SYMBOL_GPL(debug_show_held_locks);

-void lockdep_sys_exit(void)
+asmlinkage void lockdep_sys_exit(void)
{
struct task_struct *curr = current;

--
1.8.3.1

2013-10-22 16:15:57

by Andi Kleen

[permalink] [raw]
Subject: [PATCH 08/11] asmlinkage, mutex: Mark __visible

From: Andi Kleen <[email protected]>

Various kernel/mutex.c functions can be called from
inline assembler, so they should be all global and
__visible

Cc: [email protected]
Signed-off-by: Andi Kleen <[email protected]>
---
kernel/mutex.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/mutex.c b/kernel/mutex.c
index 6d647ae..ffba8e9 100644
--- a/kernel/mutex.c
+++ b/kernel/mutex.c
@@ -67,8 +67,7 @@ EXPORT_SYMBOL(__mutex_init);
* We also put the fastpath first in the kernel image, to make sure the
* branch is predicted by the CPU as default-untaken.
*/
-static __used noinline void __sched
-__mutex_lock_slowpath(atomic_t *lock_count);
+__visible void __sched __mutex_lock_slowpath(atomic_t *lock_count);

/**
* mutex_lock - acquire the mutex
@@ -225,7 +224,8 @@ static inline int mutex_can_spin_on_owner(struct mutex *lock)
}
#endif

-static __used noinline void __sched __mutex_unlock_slowpath(atomic_t *lock_count);
+__visible __used noinline
+void __sched __mutex_unlock_slowpath(atomic_t *lock_count);

/**
* mutex_unlock - release the mutex
@@ -746,7 +746,7 @@ __mutex_unlock_common_slowpath(atomic_t *lock_count, int nested)
/*
* Release the lock, slowpath:
*/
-static __used noinline void
+__visible void
__mutex_unlock_slowpath(atomic_t *lock_count)
{
__mutex_unlock_common_slowpath(lock_count, 1);
@@ -803,7 +803,7 @@ int __sched mutex_lock_killable(struct mutex *lock)
}
EXPORT_SYMBOL(mutex_lock_killable);

-static __used noinline void __sched
+__visible void __sched
__mutex_lock_slowpath(atomic_t *lock_count)
{
struct mutex *lock = container_of(lock_count, struct mutex, count);
--
1.8.3.1

2013-10-22 17:59:31

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 11/11] asmlinkage, wan/sbni: Make inline assembler symbols visible and assembler global

From: Andi Kleen <[email protected]>
Date: Tue, 22 Oct 2013 09:12:26 -0700

> From: Andi Kleen <[email protected]>
>
> - Inline assembler defining C callable code has to be global
> - The function has to be visible
>
> Do this in wan/sbni
>
> Cc: [email protected]
> Signed-off-by: Andi Kleen <[email protected]>

Is it really impossible to use the generic crc32 support instead of this
unsightly custom inline assembler?

Subject: [PATCH] net: wan: sbni: remove assembly crc32 code


There is also a C function doing the same thing. Unless the asm code is
110% faster we could stick to the C function.

Signed-off-by: Sebastian Andrzej Siewior <[email protected]>
---

On Tue, Oct 22, 2013 at 01:59:28PM -0400, David Miller wrote:
>
> Is it really impossible to use the generic crc32 support instead of this
> unsightly custom inline assembler?

Since you asked for this here step 1.

drivers/net/wan/sbni.c | 89 --------------------------------------------------
1 file changed, 89 deletions(-)

diff --git a/drivers/net/wan/sbni.c b/drivers/net/wan/sbni.c
index 5bbcb5e..388ddf6 100644
--- a/drivers/net/wan/sbni.c
+++ b/drivers/net/wan/sbni.c
@@ -148,10 +148,6 @@ static int enslave( struct net_device *, struct net_device * );
static int emancipate( struct net_device * );
#endif

-#ifdef __i386__
-#define ASM_CRC 1
-#endif
-
static const char version[] =
"Granch SBNI12 driver ver 5.0.1 Jun 22 2001 Denis I.Timofeev.\n";

@@ -1551,88 +1547,6 @@ __setup( "sbni=", sbni_setup );

/* -------------------------------------------------------------------------- */

-#ifdef ASM_CRC
-
-static u32
-calc_crc32( u32 crc, u8 *p, u32 len )
-{
- register u32 _crc;
- _crc = crc;
-
- __asm__ __volatile__ (
- "xorl %%ebx, %%ebx\n"
- "movl %2, %%esi\n"
- "movl %3, %%ecx\n"
- "movl $crc32tab, %%edi\n"
- "shrl $2, %%ecx\n"
- "jz 1f\n"
-
- ".align 4\n"
- "0:\n"
- "movb %%al, %%bl\n"
- "movl (%%esi), %%edx\n"
- "shrl $8, %%eax\n"
- "xorb %%dl, %%bl\n"
- "shrl $8, %%edx\n"
- "xorl (%%edi,%%ebx,4), %%eax\n"
-
- "movb %%al, %%bl\n"
- "shrl $8, %%eax\n"
- "xorb %%dl, %%bl\n"
- "shrl $8, %%edx\n"
- "xorl (%%edi,%%ebx,4), %%eax\n"
-
- "movb %%al, %%bl\n"
- "shrl $8, %%eax\n"
- "xorb %%dl, %%bl\n"
- "movb %%dh, %%dl\n"
- "xorl (%%edi,%%ebx,4), %%eax\n"
-
- "movb %%al, %%bl\n"
- "shrl $8, %%eax\n"
- "xorb %%dl, %%bl\n"
- "addl $4, %%esi\n"
- "xorl (%%edi,%%ebx,4), %%eax\n"
-
- "decl %%ecx\n"
- "jnz 0b\n"
-
- "1:\n"
- "movl %3, %%ecx\n"
- "andl $3, %%ecx\n"
- "jz 2f\n"
-
- "movb %%al, %%bl\n"
- "shrl $8, %%eax\n"
- "xorb (%%esi), %%bl\n"
- "xorl (%%edi,%%ebx,4), %%eax\n"
-
- "decl %%ecx\n"
- "jz 2f\n"
-
- "movb %%al, %%bl\n"
- "shrl $8, %%eax\n"
- "xorb 1(%%esi), %%bl\n"
- "xorl (%%edi,%%ebx,4), %%eax\n"
-
- "decl %%ecx\n"
- "jz 2f\n"
-
- "movb %%al, %%bl\n"
- "shrl $8, %%eax\n"
- "xorb 2(%%esi), %%bl\n"
- "xorl (%%edi,%%ebx,4), %%eax\n"
- "2:\n"
- : "=a" (_crc)
- : "0" (_crc), "g" (p), "g" (len)
- : "bx", "cx", "dx", "si", "di"
- );
-
- return _crc;
-}
-
-#else /* ASM_CRC */
-
static u32
calc_crc32( u32 crc, u8 *p, u32 len )
{
@@ -1642,9 +1556,6 @@ calc_crc32( u32 crc, u8 *p, u32 len )
return crc;
}

-#endif /* ASM_CRC */
-
-
static u32 crc32tab[] __attribute__ ((aligned(8))) = {
0xD202EF8D, 0xA505DF1B, 0x3C0C8EA1, 0x4B0BBE37,
0xD56F2B94, 0xA2681B02, 0x3B614AB8, 0x4C667A2E,
--
1.8.4.rc3

2013-10-22 18:38:44

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] net: wan: sbni: remove assembly crc32 code

From: Sebastian Andrzej Siewior <[email protected]>
Date: Tue, 22 Oct 2013 20:36:25 +0200

>
> There is also a C function doing the same thing. Unless the asm code is
> 110% faster we could stick to the C function.
>
> Signed-off-by: Sebastian Andrzej Siewior <[email protected]>
> ---
>
> On Tue, Oct 22, 2013 at 01:59:28PM -0400, David Miller wrote:
>>
>> Is it really impossible to use the generic crc32 support instead of this
>> unsightly custom inline assembler?
>
> Since you asked for this here step 1.

If it's that simple, this is definitely what we should do.

On the off chance, is there anyone actually able to test this
change? :-)))

2013-10-22 20:19:04

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH 06/11] asmlinkage: Make trace_hardirq visible

On Tue, Oct 22, 2013 at 09:12:21AM -0700, Andi Kleen wrote:
> From: Andi Kleen <[email protected]>
>
> Can be called from assembler code.
>
> Cc: [email protected]
> Cc: [email protected]
> Signed-off-by: Andi Kleen <[email protected]>
> ---
> kernel/lockdep.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/lockdep.c b/kernel/lockdep.c
> index d3749fe..d1a047d 100644
> --- a/kernel/lockdep.c
> +++ b/kernel/lockdep.c
> @@ -2555,7 +2555,7 @@ static void __trace_hardirqs_on_caller(unsigned long ip)
> debug_atomic_inc(hardirqs_on_events);
> }
>
> -void trace_hardirqs_on_caller(unsigned long ip)
> +__visible void trace_hardirqs_on_caller(unsigned long ip)
> {
> time_hardirqs_on(CALLER_ADDR0, ip);
>

$sub talks about asmlinkage, yet here you insert __visible; 'sup?

2013-10-23 01:34:01

by Rusty Russell

[permalink] [raw]
Subject: Re: [PATCH 07/11] asmlinkage, module: Make ksymtab and kcrctab symbols and __this_module __visible

Andi Kleen <[email protected]> writes:
> From: Andi Kleen <[email protected]>
>
> Make the ksymtab symbols for EXPORT_SYMBOL visible.
> This prevents the LTO compiler from adding a .NUMBER prefix,
> which avoids various problems in later export processing.

Applied, thanks.

Cheers,
Rusty.

> Cc: [email protected]
> Signed-off-by: Andi Kleen <[email protected]>
> ---
> include/linux/export.h | 4 ++--
> scripts/mod/modpost.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/export.h b/include/linux/export.h
> index 412cd50..3f2793d 100644
> --- a/include/linux/export.h
> +++ b/include/linux/export.h
> @@ -43,7 +43,7 @@ extern struct module __this_module;
> /* Mark the CRC weak since genksyms apparently decides not to
> * generate a checksums for some symbols */
> #define __CRC_SYMBOL(sym, sec) \
> - extern void *__crc_##sym __attribute__((weak)); \
> + extern __visible void *__crc_##sym __attribute__((weak)); \
> static const unsigned long __kcrctab_##sym \
> __used \
> __attribute__((section("___kcrctab" sec "+" #sym), unused)) \
> @@ -59,7 +59,7 @@ extern struct module __this_module;
> static const char __kstrtab_##sym[] \
> __attribute__((section("__ksymtab_strings"), aligned(1))) \
> = VMLINUX_SYMBOL_STR(sym); \
> - static const struct kernel_symbol __ksymtab_##sym \
> + __visible const struct kernel_symbol __ksymtab_##sym \
> __used \
> __attribute__((section("___ksymtab" sec "+" #sym), unused)) \
> = { (unsigned long)&sym, __kstrtab_##sym }
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index 8247979..0971bac 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -1853,7 +1853,7 @@ static void add_header(struct buffer *b, struct module *mod)
> buf_printf(b, "\n");
> buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");
> buf_printf(b, "\n");
> - buf_printf(b, "struct module __this_module\n");
> + buf_printf(b, "__visible struct module __this_module\n");
> buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n");
> buf_printf(b, "\t.name = KBUILD_MODNAME,\n");
> if (mod->has_init)
> --
> 1.8.3.1

2013-10-23 02:09:58

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH 11/11] asmlinkage, wan/sbni: Make inline assembler symbols visible and assembler global

On Tue, Oct 22, 2013 at 01:59:28PM -0400, David Miller wrote:
> From: Andi Kleen <[email protected]>
> Date: Tue, 22 Oct 2013 09:12:26 -0700
>
> > From: Andi Kleen <[email protected]>
> >
> > - Inline assembler defining C callable code has to be global
> > - The function has to be visible
> >
> > Do this in wan/sbni
> >
> > Cc: [email protected]
> > Signed-off-by: Andi Kleen <[email protected]>
>
> Is it really impossible to use the generic crc32 support instead of this
> unsightly custom inline assembler?

Yes it's impossible.

There's no way for me to test it, and this would be a far too big change
to submit untested.

Also my only interest here is this thing not breaking my LTO
allyesconfig build. I'm not even sure what it does.

Just because some legacy driver breaks my build you cannot make me
accountable for maintaining it now.

If it's not possible to get this trivial change in I would need
to mark it "depends on !LTO" in Kconfig.

-Andi

2013-10-23 02:11:58

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH] net: wan: sbni: remove assembly crc32 code

On Tue, Oct 22, 2013 at 08:36:25PM +0200, Sebastian Andrzej Siewior wrote:
>
> There is also a C function doing the same thing. Unless the asm code is
> 110% faster we could stick to the C function.

I have no idea if it is or not. But doing it this way would be
acceptable for me.

Thanks for the patch.

-Andi

2013-10-23 02:15:33

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH 06/11] asmlinkage: Make trace_hardirq visible

> $sub talks about asmlinkage, yet here you insert __visible; 'sup?

I use __visible for anything with arguments, because asmlinkage
changes the ABI from register to stack on i386.

I still used "asmlinkage" as the generic patch group name as that is more
descriptive, and "asmlinkage/visible" would look too ugly.

-Andi

--
[email protected] -- Speaking for myself only.

2013-10-23 02:16:41

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH 11/11] asmlinkage, wan/sbni: Make inline assembler symbols visible and assembler global

2013/10/22 Andi Kleen <[email protected]>:
> On Tue, Oct 22, 2013 at 01:59:28PM -0400, David Miller wrote:
>> From: Andi Kleen <[email protected]>
>> Date: Tue, 22 Oct 2013 09:12:26 -0700
>>
>> > From: Andi Kleen <[email protected]>
>> >
>> > - Inline assembler defining C callable code has to be global
>> > - The function has to be visible
>> >
>> > Do this in wan/sbni
>> >
>> > Cc: [email protected]
>> > Signed-off-by: Andi Kleen <[email protected]>
>>
>> Is it really impossible to use the generic crc32 support instead of this
>> unsightly custom inline assembler?
>
> Yes it's impossible.
>
> There's no way for me to test it, and this would be a far too big change
> to submit untested.
>
> Also my only interest here is this thing not breaking my LTO
> allyesconfig build. I'm not even sure what it does.
>
> Just because some legacy driver breaks my build you cannot make me
> accountable for maintaining it now.
>
> If it's not possible to get this trivial change in I would need
> to mark it "depends on !LTO" in Kconfig.

How about scheduling the WAN drivers for removal? Does anybody
actually use them nowadays?
--
Florian

2013-10-23 02:22:33

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH 11/11] asmlinkage, wan/sbni: Make inline assembler symbols visible and assembler global

> How about scheduling the WAN drivers for removal? Does anybody
> actually use them nowadays?

Perhaps at least the ISA devices? ISA hardware should be nearing
end of live by now.

Looking at the git log there doesn't seem to be any real changes,
other than tree sweeps or build fixes.

But I must admit I don't really know much about them.

-Andi

2013-10-23 06:28:46

by Francois Romieu

[permalink] [raw]
Subject: Re: [PATCH 11/11] asmlinkage, wan/sbni: Make inline assembler symbols visible and assembler global

Florian Fainelli <[email protected]> :
[...]
> How about scheduling the WAN drivers for removal? Does anybody
> actually use them nowadays?

There is still some interest in WAN drivers, see Christophe Leroy
posting on 2013/10/13 "[PATCH] WAN: Adding support for Infineon PEF2256
E1 chipset" (buggy but it's a different topic).

--
Ueimor

2013-10-25 23:27:13

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] net: wan: sbni: remove assembly crc32 code

From: Sebastian Andrzej Siewior <[email protected]>
Date: Tue, 22 Oct 2013 20:36:25 +0200

> There is also a C function doing the same thing. Unless the asm code is
> 110% faster we could stick to the C function.
>
> Signed-off-by: Sebastian Andrzej Siewior <[email protected]>

Applied.

2013-10-26 10:02:26

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 02/11] asmlinkage: Make __iowrite32_copy visible


* Andi Kleen <[email protected]> wrote:

> From: Andi Kleen <[email protected]>
>
> This is a assembler function on x86, so it should be visible.
>
> Cc: [email protected]
> Signed-off-by: Andi Kleen <[email protected]>
> ---
> include/linux/io.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

NAK for this and all the other patches, for two technical reasons:

- Please squash most of these trivial patches into a single patch
that also describes the context completely, at least the x86 and
core kernel ones that I'd apply within a single maintenance
domain.

- Please use the customary changelog style we use in the kernel:

" Current code does (A), this has a problem when (B).
We can improve this doing (C), because (D)."

Just saying 'because of LTO' is not enough, obviously. You need to
talk about and explain things Andi. Being cryptic, mysterious and
curt might work with some ladies, but it's outright harmful on lkml.

Thanks,

Ingo

2013-10-30 09:28:24

by Gleb Natapov

[permalink] [raw]
Subject: Re: [PATCH 01/11] asmlinkage, kvm: Make kvm_rebooting visible

On Tue, Oct 22, 2013 at 09:12:16AM -0700, Andi Kleen wrote:
> From: Andi Kleen <[email protected]>
>
> kvm_rebooting is referenced from assembler code, thus
> needs to be visible.
>
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Signed-off-by: Andi Kleen <[email protected]>
Acked-by: Gleb Natapov <[email protected]>

> ---
> virt/kvm/kvm_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index a9dd682..6ca3564 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -95,7 +95,7 @@ static void hardware_disable_all(void);
>
> static void kvm_io_bus_destroy(struct kvm_io_bus *bus);
>
> -bool kvm_rebooting;
> +__visible bool kvm_rebooting;
> EXPORT_SYMBOL_GPL(kvm_rebooting);
>
> static bool largepages_enabled = true;
> --
> 1.8.3.1

--
Gleb.