[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Unaligned traps on kernel startup



Richard Henderson wrote:
> 
> On Mon, Aug 31, 1998 at 12:01:06AM -0600, Michal Jaegermann wrote:
.....
> > It is from linux/drivers/block/genhd.c and traps happen on lines
> > marked with '---->':
> > 
> > 329				for (i = 0; i < 4 ; i++) {
> > 330					struct partition *q = &p[i];
> > 331					if (NR_SECTS(q)
> > 332				----->	   && (q->sector & 63) == 1
> > 333				----->	   && (q->end_sector & 63) == 63) {
> 
> Linus, the compiler has gotten smart.  It sees that those two character
> loads are contained in a structure with known alignment, and optimizes.
> 
> I don't see a solution at the moment less gross than just marking the
> structure as packed.  Alternately, I suppose we could turn off the 
> unaligned access message in the kernel for the 2.2 release.

Actually a suggestion from Mike "Ford" Ditto seems to work pretty well.
I replaced the lines in question with:
                          && (get_unaligned(&q->sector) & 63) == 1
                          && (get_unaligned(&q->end_sector) & 63) == 63) {
and now everything seems to be happy.

A macro "get_unaligned" is defined for all architectures.

  Michal



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []