From mboxrd@z Thu Jan 1 00:00:00 1970 From: OGAWA Hirofumi Date: Fri, 31 Mar 2006 17:16:25 +0000 Subject: Re: [patch] avoid unaligned access when accessing poll stack Message-Id: <87ek0ipmae.fsf@duaron.myhome.or.jp> List-Id: References: <87irpupo3y.fsf@duaron.myhome.or.jp> <200603311853.32870.ak@suse.de> In-Reply-To: <200603311853.32870.ak@suse.de> (Andi Kleen's message of "Fri, 31 Mar 2006 18:53:32 +0200") MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Andi Kleen Cc: Jes Sorensen , Linus Torvalds , Andrew Morton , linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org Andi Kleen writes: > On Friday 31 March 2006 18:37, OGAWA Hirofumi wrote: >> Jes Sorensen writes: >> >> > 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; >> >> struct poll_list stack_pps[POLL_STACK_ALLOC / sizeof(struct poll_list)]; >> >> is more readable, and probably gcc align it rightly? > > Yes, but it would be wrong OK. So how about this? char stack_pps[POLL_STACK_ALLOC] __attribute__((aligned (sizeof(struct poll_list)))); -- OGAWA Hirofumi