lkml.org 
[lkml]   [2022]   [Dec]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] dma-direct: Optimize get_required_mask
From
On 2022-12-14 15:57, Robin Murphy wrote:
> On 2022-12-14 18:00, Luben Tuikov wrote:
>> Optimize dma_direct_get_required_mask(), in that we don't need to multiply by
>> two if we don't subtract 1 from the exponent. That is,
>>
>> (1 << (n - 1)) * 2 - 1 <==>
>> 2^(n-1) * 2^1 - 1 = (by rule of exponents)
>> 2^n - 1 <==>
>> (1 << n) - 1.
>
> ...except when n==64 (for the actual code below), in which case the
> result of the shift becomes undefined.

Oh, right, for bit 63 being set. Forgot about that one. Good call.

Thanks,
Luben

\
 
 \ /
  Last update: 2022-12-15 05:31    [W:0.107 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site