Closed rakshasa closed 11 years ago
Thanks fixed in https://github.com/trema/trema-edge/commit/c2273333cc1ced96545b1b8d5a64fe3d4b914e02. I ignored the __thread for portability reasons.
Ok, thanks.
However it now gets allocated on the data segment, not the stack, and might as such share a cache line with variables modified by other threads. Since attribute 'packed' is used already, there should be no portability issue with using "attribute((aligned(128)))" instead of __thread.
Thanks for the comment. One question is every linker capable of aligning variables to a maximum specified value of 128?
Note that the effectiveness of aligned attributes may be limited by inherent limitations in your linker. On many systems, the linker is only able to arrange for variables to be aligned up to a certain maximum alignment. (For some linkers, the maximum supported alignment may be very very small.) If your linker is only able to align variables up to a maximum of 8-byte alignment, then specifying aligned(16) in an attribute still only provides you with 8-byte alignment. See your linker documentation for further information.
http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html
If the linker does not support 128 byte alignment then it should silently fall back to the biggest supported alignment, which should not cause any concurrency issues assuming the linker has this restriction due to a smaller cache line or different handling of memory access.
In the case where the linker does not support aligned large enough to take up a whole cache line you're going to have to use somewhat ugly hacks. However this seems like it would be a rather esoteric combination of linker and architecture.
The 'mac_addr_to_cstr' function causes mac addresses to zero out due to compiler optimization since pointers to stack allocated memory is not valid outside the scope of the function.
Testing is limited to running trema due to issues with compiling the unit tests.