Welcome! Log In Create A New Profile Recent Messages

Advanced

[PATCH] um: Adjust current_thread_info() for gcc-4.6

Posted by Richard Weinberger 
Richard Weinberger
[PATCH] um: Adjust current_thread_info() for gcc-4.6
April 16, 2011 03:04PM
In some cases gcc-4.6 will optimize away current_thread_info().
To prevent gcc from doing so the stack address has to be obtained
via inline asm.

LKML-Reference: [marc.info]

Signed-off-by: Richard Weinberger <richard@nod.at>
---
arch/um/include/asm/thread_info.h | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/arch/um/include/asm/thread_info.h b/arch/um/include/asm/thread_info.h
index e2cf786..5bd1bad 100644
--- a/arch/um/include/asm/thread_info.h
+++ b/arch/um/include/asm/thread_info.h
@@ -49,7 +49,10 @@ static inline struct thread_info *current_thread_info(void)
{
struct thread_info *ti;
unsigned long mask = THREAD_SIZE - 1;
- ti = (struct thread_info *) (((unsigned long) &ti) & ~mask);
+ void *p;
+
+ asm volatile ("" : "=r" (p) : "0" (&ti));
+ ti = (struct thread_info *) (((unsigned long)p) & ~mask);
return ti;
}

--
1.6.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at [vger.kernel.org]
Please read the FAQ at [www.tux.org]
Kirill A. Shutemov
Re: [PATCH] um: Adjust current_thread_info() for gcc-4.6
April 22, 2011 04:12PM
On Sat, Apr 16, 2011 at 01:03:13AM +0200, Richard Weinberger wrote:
> In some cases gcc-4.6 will optimize away current_thread_info().
> To prevent gcc from doing so the stack address has to be obtained
> via inline asm.
>
> LKML-Reference: [marc.info]
>
> Signed-off-by: Richard Weinberger <richard@nod.at>

Acked-by: Kirill A. Shutemov <kirill@shutemov.name>

Also reproducible with gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4).

> ---
> arch/um/include/asm/thread_info.h | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/arch/um/include/asm/thread_info.h b/arch/um/include/asm/thread_info.h
> index e2cf786..5bd1bad 100644
> --- a/arch/um/include/asm/thread_info.h
> +++ b/arch/um/include/asm/thread_info.h
> @@ -49,7 +49,10 @@ static inline struct thread_info *current_thread_info(void)
> {
> struct thread_info *ti;
> unsigned long mask = THREAD_SIZE - 1;
> - ti = (struct thread_info *) (((unsigned long) &ti) & ~mask);
> + void *p;
> +
> + asm volatile ("" : "=r" (p) : "0" (&ti));
> + ti = (struct thread_info *) (((unsigned long)p) & ~mask);
> return ti;
> }
>
> --
> 1.6.6.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at [vger.kernel.org]
> Please read the FAQ at [www.tux.org]

--
Kirill A. Shutemov
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at [vger.kernel.org]
Please read the FAQ at [www.tux.org]
Richard Weinberger
Re: [PATCH] um: Adjust current_thread_info() for gcc-4.6
April 23, 2011 02:00AM
Am Freitag 22 April 2011, 02:10:50 schrieb Kirill A. Shutemov:
> Also reproducible with gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4).

Interesting.
Using gcc 4.5.1 it's not reproducible.
So I've to rewrite the commit message.

Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at [vger.kernel.org]
Please read the FAQ at [www.tux.org]
Sorry, you do not have permission to post/reply in this forum.