public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Luben Tuikov <luben.tuikov@amd.com>
To: Robin Murphy <robin.murphy@arm.com>, iommu@lists.linux.dev
Cc: "Christoph Hellwig" <hch@lst.de>,
	"Alex Deucher" <Alexander.Deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] dma-direct: Optimize get_required_mask
Date: Wed, 14 Dec 2022 23:30:58 -0500	[thread overview]
Message-ID: <62bb5b41-0e76-a5fa-c021-e53c0c528339@amd.com> (raw)
In-Reply-To: <ce1b6720-b460-8e10-7885-31a8b6263908@arm.com>

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


      reply	other threads:[~2022-12-15  4:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-14 18:00 [PATCH] dma-direct: Optimize get_required_mask Luben Tuikov
2022-12-14 20:57 ` Robin Murphy
2022-12-15  4:30   ` Luben Tuikov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=62bb5b41-0e76-a5fa-c021-e53c0c528339@amd.com \
    --to=luben.tuikov@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=christian.koenig@amd.com \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox