public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] avoid unaligned access when accessing poll stack
@ 2006-03-31 15:38 Jes Sorensen
  2006-03-31 16:00 ` Andi Kleen
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Jes Sorensen @ 2006-03-31 15:38 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Andi Kleen, linux-kernel, linux-ia64

Hi,

Patch 70674f95c0a2ea694d5c39f4e514f538a09be36f
  [PATCH] Optimize select/poll by putting small data sets on the stack
resulted in the poll stack being 4-byte aligned on 64-bit
architectures, causing misaligned accesses to elements in the array.

This patch fixes it by declaring the stack in terms of 'long' instead
of 'char'.

Cheers,
Jes

Force alignment of poll stack to long to avoid unaligned access on 64
bit architectures.

Signed-off-by: Jes Sorensen <jes@sgi.com>

---
 fs/select.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Index: linux-2.6/fs/select.c
===================================================================
--- linux-2.6.orig/fs/select.c
+++ linux-2.6/fs/select.c
@@ -639,8 +639,10 @@
  	struct poll_list *walk;
 	struct fdtable *fdt;
 	int max_fdset;
-	/* Allocate small arguments on the stack to save memory and be faster */
-	char stack_pps[POLL_STACK_ALLOC];
+	/* Allocate small arguments on the stack to save memory and be 
+	   faster - use long to make sure the buffer is aligned properly
+	   on 64 bit archs to avoid unaligned access */
+	long stack_pps[POLL_STACK_ALLOC/sizeof(long)];
 	struct poll_list *stack_pp = NULL;
 
 	/* Do a sanity check on nfds ... */

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

end of thread, other threads:[~2006-04-02 14:49 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-31 15:38 [patch] avoid unaligned access when accessing poll stack Jes Sorensen
2006-03-31 16:00 ` Andi Kleen
2006-03-31 16:18   ` Jes Sorensen
2006-04-01  2:35     ` Mitchell Blank Jr
2006-04-01  2:44       ` Andi Kleen
2006-04-01  3:39       ` Mitchell Blank Jr
2006-03-31 16:37 ` OGAWA Hirofumi
2006-03-31 16:53   ` Andi Kleen
2006-03-31 17:16     ` OGAWA Hirofumi
2006-03-31 17:18       ` Andi Kleen
2006-03-31 17:40         ` OGAWA Hirofumi
2006-03-31 17:19       ` OGAWA Hirofumi
2006-03-31 18:20 ` Andrew Morton
2006-04-02 14:49   ` Jes Sorensen

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