Re: CACHE_LINE_SIZE too small, so struct vpglocks size alignment doesn't work
On Fri, Oct 1, 2010 at 4:01 PM, Matthew Fleming mdf...@gmail.com wrote: On Fri, Oct 1, 2010 at 1:00 PM, Svatopluk Kraus onw...@gmail.com wrote: Hallo, a size of 'struct vpglocks' is padded to CACHE_LINE_SIZE size in 'sys/vm/vm_page.h' header file. I work on a 'coldfire' port where CACHE_LINE_SIZE is 16 bytes and sizeof(struct mtx) is 20 bytes thus size alignment doesn't work. I solved it somehow, but I like to learn how to solve it in spirit of FreeBSD. There are a couple of possibilities: A1. Do nothing for small CACHE_LINE_SIZE. A2. Pad to multiple of CACHE_LINE_SIZE. B1. use #if with CACHE_LINE_SIZE B2. use #if with __coldfire__ When I use B1 solution I need to known sizeof(struct mtx) value in preprocessing time. So, is it correct to use something like 'assym.s' magic (sys/i386/i386/genassym.c) in MI code? Or has someone another suggestion? What about padding to CACHE_LINE_SIZE - (sizeof(struct vpglocks) (CACHE_LINE_SIZE-1)) ? Some compilers will complain about 0-sized arrays, but gcc isn't one of them. Cheers, matthew Thanks for your nice suggestion. Probably, CACHE_LINE_SIZE size is a multiple of 2 at all times, so your solution is applicable. BTW, I use gcc 4.5.1 and when a structure is aligned to a value, then a sizeof of the structure is padded to the value too implicitly. So no explicit padding is needed. Cheers, Svata ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
CACHE_LINE_SIZE too small, so struct vpglocks size alignment doesn't work
Hallo, a size of 'struct vpglocks' is padded to CACHE_LINE_SIZE size in 'sys/vm/vm_page.h' header file. I work on a 'coldfire' port where CACHE_LINE_SIZE is 16 bytes and sizeof(struct mtx) is 20 bytes thus size alignment doesn't work. I solved it somehow, but I like to learn how to solve it in spirit of FreeBSD. There are a couple of possibilities: A1. Do nothing for small CACHE_LINE_SIZE. A2. Pad to multiple of CACHE_LINE_SIZE. B1. use #if with CACHE_LINE_SIZE B2. use #if with __coldfire__ When I use B1 solution I need to known sizeof(struct mtx) value in preprocessing time. So, is it correct to use something like 'assym.s' magic (sys/i386/i386/genassym.c) in MI code? Or has someone another suggestion? Regards, Svata ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: CACHE_LINE_SIZE too small, so struct vpglocks size alignment doesn't work
On Fri, Oct 1, 2010 at 1:00 PM, Svatopluk Kraus onw...@gmail.com wrote: Hallo, a size of 'struct vpglocks' is padded to CACHE_LINE_SIZE size in 'sys/vm/vm_page.h' header file. I work on a 'coldfire' port where CACHE_LINE_SIZE is 16 bytes and sizeof(struct mtx) is 20 bytes thus size alignment doesn't work. I solved it somehow, but I like to learn how to solve it in spirit of FreeBSD. There are a couple of possibilities: A1. Do nothing for small CACHE_LINE_SIZE. A2. Pad to multiple of CACHE_LINE_SIZE. B1. use #if with CACHE_LINE_SIZE B2. use #if with __coldfire__ When I use B1 solution I need to known sizeof(struct mtx) value in preprocessing time. So, is it correct to use something like 'assym.s' magic (sys/i386/i386/genassym.c) in MI code? Or has someone another suggestion? What about padding to CACHE_LINE_SIZE - (sizeof(struct vpglocks) (CACHE_LINE_SIZE-1)) ? Some compilers will complain about 0-sized arrays, but gcc isn't one of them. Cheers, matthew ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org