linux-alpha.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Alpha: suspicious compiler warning in entry.S
@ 2009-10-28  7:03 Michael Cree
  2009-10-28 23:13 ` Richard Henderson
  2009-10-30 13:16 ` Alpha: suspicious compiler warning in entry.S David Howells
  0 siblings, 2 replies; 7+ messages in thread
From: Michael Cree @ 2009-10-28  7:03 UTC (permalink / raw)
  To: linux-alpha; +Cc: linux-kernel, rth, ink, David Howells

Compiler warning when compiling 2.6.32-rc5 as follows:

  AS      arch/alpha/kernel/entry.o
arch/alpha/kernel/entry.S: Assembler messages:
arch/alpha/kernel/entry.S:326: Warning: operand out of range 
(0x0000000000000406 is not between 0x0000000000000000 and 
0x00000000000000ff)
arch/alpha/kernel/entry.S:388: Warning: operand out of range 
(0x0000000000000406 is not between 0x0000000000000000 and 
0x00000000000000ff)

One offending line (326) is:

    and    $5, _TIF_WORK_MASK, $2

The warning occurs because commit d0420c83f39f "KEYS: Extend
TIF_NOTIFY_RESUME to (almost) all architectures [try #6]" introduces
TIF_NOTIFIY_RESUME which sets bit 10 in _TIF_WORK_MASK (see
arch/alpha/include/asm/thread_info.h) but _TIF_WORK_MASK is used in the
immediate addressing mode in the assembler instruction above. The 'and'
instruction can only take an immediate datum in the range 0 to 255.  With
the addition of the TIF_NOTIFY_RESUME bit, _TIF_WORK_MASK is no longer in
the valid range for immediate addressing in the 'and' instruction.

On the assumption that it is important to include the TIF_NOTIFY_RESUME bit
one might be tempted to modify the code to:

    lda    $2, _TIF_WORK_MASK
    and    $5, $2, $2

but this is time critical code.  I am wondering whether it might be better
to rearrange the bits in the thread information flags so that _TIF_WORK_MASK
has a value less than 255 and the single instruction to perform an and
operation can be maintained.

Comments?

Cheers
Michael.


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

* Re: Alpha: suspicious compiler warning in entry.S
  2009-10-28  7:03 Alpha: suspicious compiler warning in entry.S Michael Cree
@ 2009-10-28 23:13 ` Richard Henderson
  2009-10-31  2:33   ` [PATCH] Alpha: Rearrange thread info flags fixing two regressions Michael Cree
  2009-10-30 13:16 ` Alpha: suspicious compiler warning in entry.S David Howells
  1 sibling, 1 reply; 7+ messages in thread
From: Richard Henderson @ 2009-10-28 23:13 UTC (permalink / raw)
  To: Michael Cree; +Cc: linux-alpha, linux-kernel, ink, David Howells

On 10/28/2009 12:03 AM, Michael Cree wrote:
> I am wondering whether it might be better
> to rearrange the bits in the thread information flags so that
> _TIF_WORK_MASK
> has a value less than 255 and the single instruction to perform an and
> operation can be maintained.

It would be better to rearrange TIF_NODIFY_RESUME down to 3.

In fact, you might as well rearrange the ones currently occupying
3-7 up to 8 and leave a hole for _TIF_WORK_MASK expansion, and
add a nice comment there at the same time.


r~

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

* Re: Alpha: suspicious compiler warning in entry.S
  2009-10-28  7:03 Alpha: suspicious compiler warning in entry.S Michael Cree
  2009-10-28 23:13 ` Richard Henderson
@ 2009-10-30 13:16 ` David Howells
  1 sibling, 0 replies; 7+ messages in thread
From: David Howells @ 2009-10-30 13:16 UTC (permalink / raw)
  To: Michael Cree; +Cc: dhowells, linux-alpha, linux-kernel, rth, ink

Michael Cree <mcree@orcon.net.nz> wrote:

> On the assumption that it is important to include the TIF_NOTIFY_RESUME bit
> one might be tempted to modify the code to:
> 
>    lda    $2, _TIF_WORK_MASK
>    and    $5, $2, $2
> 
> but this is time critical code.  I am wondering whether it might be better
> to rearrange the bits in the thread information flags so that _TIF_WORK_MASK
> has a value less than 255 and the single instruction to perform an and
> operation can be maintained.

Unless the LDA can be interleaved around some memory accesses, then yes,
compressing _TIF_WORK_MASK would be good.

David

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

* [PATCH] Alpha: Rearrange thread info flags fixing two regressions
  2009-10-28 23:13 ` Richard Henderson
@ 2009-10-31  2:33   ` Michael Cree
  2009-12-01  4:06     ` Matt Turner
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Cree @ 2009-10-31  2:33 UTC (permalink / raw)
  To: Richard Henderson
  Cc: linux-alpha, linux-kernel, ink, David Howells, Michael Cree

The removal of the TIF_NOTIFY_RESUME flag, commit a583f1b54249b
"remove unused TIF_NOTIFY_RESUME flag," resulted in incorrect
setting of the unaligned access control flags by the prctl syscall.

The re-addition of the TIF_NOTIFY_RESUME flag, commit d0420c83f39f
"KEYS: Extend TIF_NOTIFY_RESUME to (almost) all architectures [try #6]"
further caused problems, namely incorrect operands to assembler code
as evidenced by:

AS      arch/alpha/kernel/entry.o
arch/alpha/kernel/entry.S: Assembler messages:
arch/alpha/kernel/entry.S:326: Warning: operand out of range (0x0000000000000406 is not between 0x0000000000000000 and 0x00000000000000ff)

Both regressions fixed by (1) rearranging TIF_NOTIFY_RESUME flag to be
in lower 8 bits of the thread info flags, and (2) making sure that
ALPHA_UAC_SHIFT matches the rearrangement of the thread info flags.

Signed-off-by: Michael Cree <mcree@orcon.net.nz>
---
 arch/alpha/include/asm/thread_info.h |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/arch/alpha/include/asm/thread_info.h b/arch/alpha/include/asm/thread_info.h
index e7a07f6..3ba4ded 100644
--- a/arch/alpha/include/asm/thread_info.h
+++ b/arch/alpha/include/asm/thread_info.h
@@ -61,21 +61,24 @@ register struct thread_info *__current_thread_info __asm__("$8");
 /*
  * Thread information flags:
  * - these are process state flags and used from assembly
- * - pending work-to-be-done flags come first to fit in and immediate operand.
+ * - pending work-to-be-done flags come first and must be assigned to be
+ *   within bits 0 to 7 to fit in and immediate operand.
+ * - ALPHA_UAC_SHIFT below must be kept consistent with the unaligned 
+ *   control flags.
  *
  * TIF_SYSCALL_TRACE is known to be 0 via blbs.
  */
 #define TIF_SYSCALL_TRACE	0	/* syscall trace active */
-#define TIF_SIGPENDING		1	/* signal pending */
-#define TIF_NEED_RESCHED	2	/* rescheduling necessary */
-#define TIF_POLLING_NRFLAG	3	/* poll_idle is polling NEED_RESCHED */
-#define TIF_DIE_IF_KERNEL	4	/* dik recursion lock */
-#define TIF_UAC_NOPRINT		5	/* see sysinfo.h */
-#define TIF_UAC_NOFIX		6
-#define TIF_UAC_SIGBUS		7
-#define TIF_MEMDIE		8
-#define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal */
-#define TIF_NOTIFY_RESUME	10	/* callback before returning to user */
+#define TIF_NOTIFY_RESUME	1	/* callback before returning to user */
+#define TIF_SIGPENDING		2	/* signal pending */
+#define TIF_NEED_RESCHED	3	/* rescheduling necessary */
+#define TIF_POLLING_NRFLAG	8	/* poll_idle is polling NEED_RESCHED */
+#define TIF_DIE_IF_KERNEL	9	/* dik recursion lock */
+#define TIF_UAC_NOPRINT		10	/* see sysinfo.h */
+#define TIF_UAC_NOFIX		11
+#define TIF_UAC_SIGBUS		12
+#define TIF_MEMDIE		13
+#define TIF_RESTORE_SIGMASK	14	/* restore signal mask in do_signal */
 #define TIF_FREEZE		16	/* is freezing for suspend */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
@@ -94,7 +97,7 @@ register struct thread_info *__current_thread_info __asm__("$8");
 #define _TIF_ALLWORK_MASK	(_TIF_WORK_MASK		\
 				 | _TIF_SYSCALL_TRACE)
 
-#define ALPHA_UAC_SHIFT		6
+#define ALPHA_UAC_SHIFT		10
 #define ALPHA_UAC_MASK		(1 << TIF_UAC_NOPRINT | 1 << TIF_UAC_NOFIX | \
 				 1 << TIF_UAC_SIGBUS)
 
-- 
1.6.3.3


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

* Re: [PATCH] Alpha: Rearrange thread info flags fixing two regressions
  2009-10-31  2:33   ` [PATCH] Alpha: Rearrange thread info flags fixing two regressions Michael Cree
@ 2009-12-01  4:06     ` Matt Turner
  2009-12-01 12:31       ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: Matt Turner @ 2009-12-01  4:06 UTC (permalink / raw)
  To: Michael Cree
  Cc: Richard Henderson, linux-alpha, linux-kernel, ink, David Howells

On Fri, Oct 30, 2009 at 9:33 PM, Michael Cree <mcree@orcon.net.nz> wrote:
> The removal of the TIF_NOTIFY_RESUME flag, commit a583f1b54249b
> "remove unused TIF_NOTIFY_RESUME flag," resulted in incorrect
> setting of the unaligned access control flags by the prctl syscall.
>
> The re-addition of the TIF_NOTIFY_RESUME flag, commit d0420c83f39f
> "KEYS: Extend TIF_NOTIFY_RESUME to (almost) all architectures [try #6]"
> further caused problems, namely incorrect operands to assembler code
> as evidenced by:
>
> AS      arch/alpha/kernel/entry.o
> arch/alpha/kernel/entry.S: Assembler messages:
> arch/alpha/kernel/entry.S:326: Warning: operand out of range (0x0000000000000406 is not between 0x0000000000000000 and 0x00000000000000ff)
>
> Both regressions fixed by (1) rearranging TIF_NOTIFY_RESUME flag to be
> in lower 8 bits of the thread info flags, and (2) making sure that
> ALPHA_UAC_SHIFT matches the rearrangement of the thread info flags.
>
> Signed-off-by: Michael Cree <mcree@orcon.net.nz>
> ---
>  arch/alpha/include/asm/thread_info.h |   27 +++++++++++++++------------
>  1 files changed, 15 insertions(+), 12 deletions(-)
>
> diff --git a/arch/alpha/include/asm/thread_info.h b/arch/alpha/include/asm/thread_info.h
> index e7a07f6..3ba4ded 100644
> --- a/arch/alpha/include/asm/thread_info.h
> +++ b/arch/alpha/include/asm/thread_info.h
> @@ -61,21 +61,24 @@ register struct thread_info *__current_thread_info __asm__("$8");
>  /*
>  * Thread information flags:
>  * - these are process state flags and used from assembly
> - * - pending work-to-be-done flags come first to fit in and immediate operand.
> + * - pending work-to-be-done flags come first and must be assigned to be
> + *   within bits 0 to 7 to fit in and immediate operand.
> + * - ALPHA_UAC_SHIFT below must be kept consistent with the unaligned
> + *   control flags.
>  *
>  * TIF_SYSCALL_TRACE is known to be 0 via blbs.
>  */
>  #define TIF_SYSCALL_TRACE      0       /* syscall trace active */
> -#define TIF_SIGPENDING         1       /* signal pending */
> -#define TIF_NEED_RESCHED       2       /* rescheduling necessary */
> -#define TIF_POLLING_NRFLAG     3       /* poll_idle is polling NEED_RESCHED */
> -#define TIF_DIE_IF_KERNEL      4       /* dik recursion lock */
> -#define TIF_UAC_NOPRINT                5       /* see sysinfo.h */
> -#define TIF_UAC_NOFIX          6
> -#define TIF_UAC_SIGBUS         7
> -#define TIF_MEMDIE             8
> -#define TIF_RESTORE_SIGMASK    9       /* restore signal mask in do_signal */
> -#define TIF_NOTIFY_RESUME      10      /* callback before returning to user */
> +#define TIF_NOTIFY_RESUME      1       /* callback before returning to user */
> +#define TIF_SIGPENDING         2       /* signal pending */
> +#define TIF_NEED_RESCHED       3       /* rescheduling necessary */
> +#define TIF_POLLING_NRFLAG     8       /* poll_idle is polling NEED_RESCHED */
> +#define TIF_DIE_IF_KERNEL      9       /* dik recursion lock */
> +#define TIF_UAC_NOPRINT                10      /* see sysinfo.h */
> +#define TIF_UAC_NOFIX          11
> +#define TIF_UAC_SIGBUS         12
> +#define TIF_MEMDIE             13
> +#define TIF_RESTORE_SIGMASK    14      /* restore signal mask in do_signal */
>  #define TIF_FREEZE             16      /* is freezing for suspend */
>
>  #define _TIF_SYSCALL_TRACE     (1<<TIF_SYSCALL_TRACE)
> @@ -94,7 +97,7 @@ register struct thread_info *__current_thread_info __asm__("$8");
>  #define _TIF_ALLWORK_MASK      (_TIF_WORK_MASK         \
>                                 | _TIF_SYSCALL_TRACE)
>
> -#define ALPHA_UAC_SHIFT                6
> +#define ALPHA_UAC_SHIFT                10
>  #define ALPHA_UAC_MASK         (1 << TIF_UAC_NOPRINT | 1 << TIF_UAC_NOFIX | \
>                                 1 << TIF_UAC_SIGBUS)
>
> --
> 1.6.3.3
>
> --

Applied to alpha-2.6.git. Thanks!

Matt
--
To unsubscribe from this list: send the line "unsubscribe linux-alpha" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] Alpha: Rearrange thread info flags fixing two regressions
  2009-12-01  4:06     ` Matt Turner
@ 2009-12-01 12:31       ` Christoph Hellwig
  2009-12-01 15:58         ` Matt Turner
  0 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2009-12-01 12:31 UTC (permalink / raw)
  To: Matt Turner
  Cc: Michael Cree, Richard Henderson, linux-alpha, linux-kernel, ink,
	David Howells

On Mon, Nov 30, 2009 at 11:06:52PM -0500, Matt Turner wrote:
> Applied to alpha-2.6.git. Thanks!

Can you push this to Linus ASAP so that 2.6.33 will work nicely out of
the box on alpha?


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

* Re: [PATCH] Alpha: Rearrange thread info flags fixing two regressions
  2009-12-01 12:31       ` Christoph Hellwig
@ 2009-12-01 15:58         ` Matt Turner
  0 siblings, 0 replies; 7+ messages in thread
From: Matt Turner @ 2009-12-01 15:58 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Michael Cree, Richard Henderson, linux-alpha, linux-kernel, ink,
	David Howells

On Tue, Dec 1, 2009 at 7:31 AM, Christoph Hellwig <hch@infradead.org> wrote:
> On Mon, Nov 30, 2009 at 11:06:52PM -0500, Matt Turner wrote:
>> Applied to alpha-2.6.git. Thanks!
>
> Can you push this to Linus ASAP so that 2.6.33 will work nicely out of
> the box on alpha?

It's in mainline now. Linus just pulled my tree. :)

Matt

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

end of thread, other threads:[~2009-12-01 15:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-28  7:03 Alpha: suspicious compiler warning in entry.S Michael Cree
2009-10-28 23:13 ` Richard Henderson
2009-10-31  2:33   ` [PATCH] Alpha: Rearrange thread info flags fixing two regressions Michael Cree
2009-12-01  4:06     ` Matt Turner
2009-12-01 12:31       ` Christoph Hellwig
2009-12-01 15:58         ` Matt Turner
2009-10-30 13:16 ` Alpha: suspicious compiler warning in entry.S David Howells

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).