[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <62bb5b41-0e76-a5fa-c021-e53c0c528339@amd.com>
Date: Wed, 14 Dec 2022 23:30:58 -0500
From: Luben Tuikov <luben.tuikov@....com>
To: Robin Murphy <robin.murphy@....com>, iommu@...ts.linux.dev
Cc: Christoph Hellwig <hch@....de>,
Alex Deucher <Alexander.Deucher@....com>,
Christian König <christian.koenig@....com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] dma-direct: Optimize get_required_mask
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
Powered by blists - more mailing lists