public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: current_thread_info() not respecting program order with gcc 4.8.x
@ 2013-11-21  1:52 Luis Lozano
  0 siblings, 0 replies; 30+ messages in thread
From: Luis Lozano @ 2013-11-21  1:52 UTC (permalink / raw)
  To: linux-kernel, Bhaskar Janakiraman, Han Shen

I have been monitoring this thread and trying to understand how could
this happen.

I noticed that the definition for ARM of current_thread_info looks like this:

/*
 * how to get the thread information struct from C
 */
static inline struct thread_info *current_thread_info(void) __attribute_const__;

static inline struct thread_info *current_thread_info(void)
{
register unsigned long sp asm ("sp");
return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
}

Notice this has the __attribute_const__ marking which corresponds to
the __const__ gcc attribute described in:

http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html

This attribute marking seems wrong to me. This function depends on
global state (depends on SP).
This seems to go against the definition of what a "const" function is
(according to GCC)
I noticed this attribute marking is not set for the x86 definition.

Could this be confusing the compiler and causing the problem?
Can you try this?

It would be nice if you could point to the exact location in the code
where one could see the reordering happening. I tried to reproduce
with a small test case and I couldn't. Do you have a small test case?

Luis

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2013-11-22 20:33 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <52803E5D.3050109@mentor.com>
     [not found] ` <52851395.3010306@mentor.com>
     [not found]   ` <67652521.68027.1384482849638.JavaMail.zimbra@efficios.com>
2013-11-19 15:29     ` current_thread_info() not respecting program order with gcc 4.8.x Mathieu Desnoyers
2013-11-19 15:57       ` Peter Zijlstra
2013-11-19 16:13         ` Jakub Jelinek
2013-11-19 16:21           ` Peter Zijlstra
2013-11-19 16:05       ` Will Deacon
2013-11-19 17:02         ` Mathieu Desnoyers
2013-11-19 17:33           ` Peter Zijlstra
2013-11-19 21:56             ` Multiple local register variables w/ same register Richard Henderson
2013-11-19 22:08               ` Jakub Jelinek
2013-11-19 22:13               ` Måns Rullgård
2013-11-19 22:25               ` Mathieu Desnoyers
2013-11-19 22:34                 ` [lttng-dev] " Mathieu Desnoyers
2013-11-20  0:41       ` current_thread_info() not respecting program order with gcc 4.8.x Linus Torvalds
2013-11-20 15:10         ` Mathieu Desnoyers
2013-11-21 16:02         ` Alexander Holler
2013-11-21 22:12           ` Luis Lozano
2013-11-21 22:32           ` Linus Torvalds
2013-11-21 23:18             ` Alexander Holler
2013-11-21 23:45               ` Luis Lozano
2013-11-22  0:39                 ` Jakub Jelinek
2013-11-22  1:57                   ` Mathieu Desnoyers
2013-11-22  2:36                     ` Luis Lozano
2013-11-22  3:38                       ` Mathieu Desnoyers
2013-11-22  8:18                         ` Luis Lozano
2013-11-22  8:33                           ` Luis Lozano
2013-11-22 13:06                           ` Mathieu Desnoyers
2013-11-22 20:33                             ` [lttng-dev] " Mathieu Desnoyers
2013-11-22  0:17               ` Linus Torvalds
2013-11-22  0:34                 ` Alexander Holler
2013-11-21  1:52 Luis Lozano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox