[PATCH] avoid unaligned access when accessing poll stack

Commit 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'.

Force alignment of poll and select stacks to long to avoid unaligned
access on 64 bit architectures.

Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Jes Sorensen and committed by Linus Torvalds 30c14e40 d21c356b

+5 -3
+5 -3
fs/select.c
··· 314 int ret, size, max_fdset; 315 struct fdtable *fdt; 316 /* Allocate small arguments on the stack to save memory and be faster */ 317 - char stack_fds[SELECT_STACK_ALLOC]; 318 319 ret = -EINVAL; 320 if (n < 0) ··· 639 struct poll_list *walk; 640 struct fdtable *fdt; 641 int max_fdset; 642 - /* Allocate small arguments on the stack to save memory and be faster */ 643 - char stack_pps[POLL_STACK_ALLOC]; 644 struct poll_list *stack_pp = NULL; 645 646 /* Do a sanity check on nfds ... */
··· 314 int ret, size, max_fdset; 315 struct fdtable *fdt; 316 /* Allocate small arguments on the stack to save memory and be faster */ 317 + long stack_fds[SELECT_STACK_ALLOC/sizeof(long)]; 318 319 ret = -EINVAL; 320 if (n < 0) ··· 639 struct poll_list *walk; 640 struct fdtable *fdt; 641 int max_fdset; 642 + /* Allocate small arguments on the stack to save memory and be 643 + faster - use long to make sure the buffer is aligned properly 644 + on 64 bit archs to avoid unaligned access */ 645 + long stack_pps[POLL_STACK_ALLOC/sizeof(long)]; 646 struct poll_list *stack_pp = NULL; 647 648 /* Do a sanity check on nfds ... */