[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ae535698-33fc-42a1-8a5a-ed8dd192f697@linux.intel.com>
Date: Tue, 25 Nov 2025 15:54:56 +0800
From: Baolu Lu <baolu.lu@...ux.intel.com>
To: Mostafa Saleh <smostafa@...gle.com>, linux-mm@...ck.org,
iommu@...ts.linux.dev, linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org
Cc: corbet@....net, joro@...tes.org, will@...nel.org, robin.murphy@....com,
akpm@...ux-foundation.org, vbabka@...e.cz, surenb@...gle.com,
mhocko@...e.com, jackmanb@...gle.com, hannes@...xchg.org, ziy@...dia.com,
david@...hat.com, lorenzo.stoakes@...cle.com, Liam.Howlett@...cle.com,
rppt@...nel.org, xiaqinxin@...wei.com
Subject: Re: [PATCH v3 3/4] drivers/iommu-debug-pagealloc: Track IOMMU pages
On 11/25/25 04:08, Mostafa Saleh wrote:
> void __iommu_debug_unmap_end(struct iommu_domain *domain,
> unsigned long iova, size_t size,
> size_t unmapped)
> {
> + if (unmapped == size)
> + return;
> +
> + /*
> + * If unmap failed, re-increment the refcount, but if it unmapped
> + * larger size, decrement the extra part.
> + */
> + if (unmapped < size)
> + __iommu_debug_update_iova(domain, iova + unmapped,
> + size - unmapped, true);
> + else
> + __iommu_debug_update_iova(domain, iova + size,
> + unmapped - size, false);
In any case, could the 'else' branch become a real operation?
In the __iommu_unmap():
/*
* Keep iterating until we either unmap 'size' bytes (or more)
* or we hit an area that isn't mapped.
*/
while (unmapped < size) {
size_t pgsize, count;
pgsize = iommu_pgsize(domain, iova, iova, size -
unmapped, &count);
unmapped_page = ops->unmap_pages(domain, iova, pgsize,
count, iotlb_gather);
if (!unmapped_page)
break;
pr_debug("unmapped: iova 0x%lx size 0x%zx\n",
iova, unmapped_page);
iova += unmapped_page;
unmapped += unmapped_page;
}
The comments say that it is possible to unmap more bytes than 'size',
but isn't it a bug if this helper unmaps more than the caller desired?
Thanks,
baolu
Powered by blists - more mailing lists