Dividing a loff_t
Hi
I have a scenario where I need to use non-power-of-2 storage page sizes within a file system.
If I just try something like
my_page_offset = loff_t_offset / my_page_size;
I get link errors because of a missing _divsi3. If nobody else is using _divsi3 then it is probably poor form to consider using it.
Questions:
1) Is there a safe/better way to divide loff_t by a value.
2) Is there a better way to do this sort of thing? Any examples where this kind of thing happen?
BTW: Yes, I know there are going to be performance issues etc due to alignment issues between the Linux page cache and "my pages". I have a plan to deal with that.
TIA
-- Charles
Quoted 9 lines · Charles Manning
Hi
I have a scenario where I need to use non-power-of-2 storage page sizes within a file system.
If I just try something like
my_page_offset = loff_t_offset / my_page_size;
Quoted 7 lines
I get link errors because of a missing
_divsi3. If nobody else is using_divsi3then it is probably poor form to consider using it.Questions:
1) Is there a safe/better way to divideloff_tby a value.
2) Is there a better way to do this sort of thing? Any examples where this kind of thing happen?
The issue is that in the 32-bit intel processors the 64 bit division is not a native thing, and instead is done by a libgcc intrinsics (_divsi3)
We have not wanted to have the arbitrary 64-bit division available within
the kernel because a) it is slow as hell, b) not having it will quickly
reveal places where coding is done for simplicity and not for performance.
With 64-bit x86-84 it would be native division..
The kernel does have almost arbitrary 64-bit division, that one is used by kprintf() to convert binary values to text format. Search for do_div()
Quoted 7 lines
BTW: Yes, I know there are going to be performance issues etc due to alignment issues between the Linux page cache and "my pages". I have a plan to deal with that.
TIA
-- Charles
/Matti Aarnio
Quoted 6 lines · Matti Aarnio
Quoted 5 lines · Charles Manning
Hi
I have a scenario where I need to use non-power-of-2 storage page sizes within a file system.
Quoted 6 lines
Quoted 6 lines
If I just try something like
my_page_offset = loff_t_offset / my_page_size;I get link errors because of a missing
_divsi3. If nobody else is using_divsi3then it is probably poor form to consider using it.
My bad it is actually __divdi3.
Quoted 8 lines
Quoted 5 lines
Questions:
1) Is there a safe/better way to divideloff_tby a value.
2) Is there a better way to do this sort of thing? Any examples where this kind of thing happen?The issue is that in the 32-bit intel processors the 64 bit division is not a native thing, and instead is done by a libgcc intrinsics (
_divsi3)
Actually, the file system I work on is typically used with ARM processors, some or all of which don't even have a divide instruction.
Quoted 4 lines
We have not wanted to have the arbitrary 64-bit division available within
the kernel because a) it is slow as hell, b) not having it will quickly
reveal places where coding is done for simplicity and not for performance.
Thanx. I fully appreciate the reasons why this is done.
Quoted 5 lines
With 64-bit x86-84 it would be native division..
The kernel does have almost arbitrary 64-bit division, that one is used by
kprintf()to convert binary values to text format. Search fordo_div()
I'll give that a try.
-- CHarles