History

ocfs2/dlm: move BITS_TO_BYTES() to bitops.h for wider use

There are users already and will be more of BITS_TO_BYTES() macro. Move it to bitops.h for wider use. In the case of ocfs2 the replacement is identical. As for bnx2x, there are two places where floor version is used. In the first case to calculate the amount of structures that can fit one memory page. In this case obviously the ceiling variant is correct and original code might have a potential bug, if amount of bits % 8 is not 0. In the second case the macro is used to calculate bytes transmitted in one microsecond. This will work for all speeds which is multiply of 1Gbps without any change, for the rest new code will give ceiling value, for instance 100Mbps will give 13 bytes, while old code gives 12 bytes and the arithmetically correct one is 12.5 bytes. Further the value is used to setup timer threshold which in any case has its own margins due to certain resolution. I don't see here an issue with slightly shifting thresholds for low speed connections, the card is supposed to utilize highest available rate, which is usually 10Gbps.

Andy Shevchenko committed 6 years ago

Commit dd3e7cb1 parent d8f18753 files · +1 −5Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/bitops.h+1−0
@@ -13,6 +13,7 @@ · 12 unmodified lines
13 13
14#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE)14#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE)
15#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(long))15#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(long))
16#define BITS_TO_BYTES(nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(char))
16 17
17extern unsigned int __sw_hweight8(unsigned int w);18extern unsigned int __sw_hweight8(unsigned int w);
18extern unsigned int __sw_hweight16(unsigned int w);19extern unsigned int __sw_hweight16(unsigned int w);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t