From: Miles Chen <miles.chen@mediatek.com>
To: <robin.murphy@arm.com>
Cc: <Libo.Kang@mediatek.com>, <Ning.Li@mediatek.com>,
<iommu@lists.linux-foundation.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>,
<linux-mediatek@lists.infradead.org>, <matthias.bgg@gmail.com>,
<stable@vger.kernel.org>, <will@kernel.org>,
<wsd_upstream@mediatek.com>, <yf.wang@mediatek.com>
Subject: Re: [PATCH v2] iommu/iova: Reset max32_alloc_size after cleaning
Date: Wed, 2 Mar 2022 07:29:53 +0800 [thread overview]
Message-ID: <20220301232953.17331-1-miles.chen@mediatek.com> (raw)
In-Reply-To: <b10031aa-8e49-70b3-b498-8aa6b7021fbb@arm.com>
Hi Yunfei,
>> Since __alloc_and_insert_iova_range fail will set the current alloc
>> iova size to max32_alloc_size (iovad->max32_alloc_size = size),
>> when the retry is executed into the __alloc_and_insert_iova_range
>> function, the retry action will be blocked by the check condition
>> (size >= iovad->max32_alloc_size) and goto iova32_full directly,
>> causes the action of retry regular alloc iova in
>> __alloc_and_insert_iova_range to not actually be executed.
>>
>> Based on the above, so need reset max32_alloc_size before retry alloc
>> iova when alloc iova fail, that is set the initial dma_32bit_pfn value
>> of iovad to max32_alloc_size, so that the action of retry alloc iova
>> in __alloc_and_insert_iova_range can be executed.
>
> Have you observed this making any difference in practice?
>
> Given that both free_cpu_cached_iovas() and free_global_cached_iovas()
> call iova_magazine_free_pfns(), which calls remove_iova(), which calls
> __cached_rbnode_delete_update(), I'm thinking no...
>
> Robin.
>
Like Robin pointed out, if some cached iovas are freed by
free_global_cached_iovas()/free_cpu_cached_iovas(),
the max32_alloc_size should be reset to iovad->dma_32bit_pfn.
If no cached iova is freed, resetting max32_alloc_size before
the retry allocation only give us a retry. Is it possible that
other users free their iovas during the additional retry?
alloc_iova_fast()
retry:
alloc_iova() // failed, iovad->max32_alloc_size = size
free_cpu_cached_iovas()
iova_magazine_free_pfns()
remove_iova()
__cached_rbnode_delete_update()
iovad->max32_alloc_size = iovad->dma_32bit_pfn // reset
free_global_cached_iovas()
iova_magazine_free_pfns()
remove_iova()
__cached_rbnode_delete_update()
iovad->max32_alloc_size = iovad->dma_32bit_pfn // reset
goto retry;
thanks,
Miles
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-03-01 23:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220301014246.5011-1-yf.wang@mediatek.com>
[not found] ` <20220301015919.5116-1-yf.wang@mediatek.com>
2022-03-01 13:56 ` [PATCH v2] iommu/iova: Reset max32_alloc_size after cleaning rcache in the fail path Robin Murphy
2022-03-01 23:29 ` Miles Chen [this message]
2022-03-02 11:26 ` [PATCH v2] iommu/iova: Reset max32_alloc_size after cleaning Robin Murphy
2022-03-02 23:52 ` Miles Chen
[not found] ` <7a56546b6333cfac175080ff35c74415d35cd628.camel@medaitek.com>
2022-03-03 13:04 ` Robin Murphy
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=20220301232953.17331-1-miles.chen@mediatek.com \
--to=miles.chen@mediatek.com \
--cc=Libo.Kang@mediatek.com \
--cc=Ning.Li@mediatek.com \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=robin.murphy@arm.com \
--cc=stable@vger.kernel.org \
--cc=will@kernel.org \
--cc=wsd_upstream@mediatek.com \
--cc=yf.wang@mediatek.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;
as well as URLs for NNTP newsgroup(s).