On 04/07/2019 06:27, Matthew Wilcox wrote:
On Wed, Jul 03, 2019 at 02:28:41PM -0700, Dan Williams wrote:
<>
+#ifdef CONFIG_XARRAY_MULTI
unsigned int sibs = xas->xa_sibs;
while (sibs) {
order++;
sibs /= 2;
}
Use ilog2() here?
Thought about it. sibs is never going to be more than 31, so I don't know that it's worth eliminating 5 add/shift pairs in favour of whatever the ilog2 instruction is on a given CPU. In practice, on x86, sibs is going to be either 0 (PTEs) or 7 (PMDs). We could also avoid even having this function by passing PMD_ORDER or PTE_ORDER into get_unlocked_entry().
It's probably never going to be noticable in this scenario because it's the very last thing checked before we put ourselves on a waitqueue and go to sleep.
Matthew you must be kidding an ilog2 in binary is zero clocks (Return the highest bit or something like that)
In any way. It took me 5 minutes to understand what you are doing here. And I only fully got it when Dan gave his comment. So please for the sake of stupid guys like me could you please make it ilog2() so to make it easier to understand? (And please don't do the compiler's job. If in some arch the loop is the fastest let the compiler decide?)
Thanks Boaz