The Linux Kernel Mailing List
 help / color / mirror / Atom feed
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>,
	<miles.chen@mediatek.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: Thu, 3 Mar 2022 07:52:38 +0800	[thread overview]
Message-ID: <20220302235238.13099-1-miles.chen@mediatek.com> (raw)
In-Reply-To: <ca208635-449b-2c94-7317-09ed8eb86a2c@arm.com>

>> 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?
>
> No, it's not possible, since everyone's serialised by iova_rbtree_lock. 
> If the caches were already empty and the retry gets the lock first, it 
> will still fail again - forcing a reset of max32_alloc_size only means 
> it has to take the slow path to that failure. If another caller *did* 
> manage to get in and free something between free_global_cached_iovas() 
> dropping the lock and alloc_iova() re-taking it, then that would have 
> legitimately reset max32_alloc_size anyway.

Thanks for your explanation.

YF showed me some numbers yesterday and maybe we can have a further
discussion in that test case. (It looks like that some iovas are freed but
their pfn_lo(s) are less than cached_iova->pfn_lo, so max32_alloc_size is not
reset. So there are enought free iovas but the allocation still failed)

__cached_rbnode_delete_update(struct iova_domain *iovad, struct iova *free)
{
	struct iova *cached_iova;

	cached_iova = to_iova(iovad->cached32_node);
	if (free == cached_iova ||
		(free->pfn_hi < iovad->dma_32bit_pfn &&
		 free->pfn_lo >= cached_iova->pfn_lo)) {
		iovad->cached32_node = rb_next(&free->node);
		iovad->max32_alloc_size = iovad->dma_32bit_pfn;
	}
	...
}

Hi YF,
Could your share your observation of the iova allocation failure you hit?

Thanks,
Miles


  reply	other threads:[~2022-03-02 23:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-01  1:42 [PATCH] iommu/iova: Reset max32_alloc_size after cleaning rcache in the fail path yf.wang
2022-03-01  1:59 ` [PATCH v2] " yf.wang
2022-03-01 13:56   ` Robin Murphy
2022-03-01 23:29     ` [PATCH v2] iommu/iova: Reset max32_alloc_size after cleaning Miles Chen
2022-03-02 11:26       ` Robin Murphy
2022-03-02 23:52         ` Miles Chen [this message]
2022-03-03 12:43           ` yf.wang
     [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=20220302235238.13099-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