2022-09-05 09:50:26

by John Garry

[permalink] [raw]
Subject: [PATCH v2 0/2] iova: Some misc changes

This series removes some checks in the code which are not required.

Differences to v1:
- Drop re-org
- Add RB/AB tags

Based on v6.0-rc4

John Garry (2):
iova: Remove some magazine pointer NULL checks
iova: Remove magazine BUG_ON() checks

drivers/iommu/iova.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)

--
2.35.3


2022-09-05 09:56:42

by John Garry

[permalink] [raw]
Subject: [PATCH v2 2/2] iova: Remove magazine BUG_ON() checks

Two of the magazine helpers have BUG_ON() checks, as follows:
- iova_magazine_pop() - here we ensure that the mag is not empty. However we
already ensure that in the only caller, __iova_rcache_get().
- iova_magazine_push() - here we ensure that the mag is not full. However
we already ensure that in the only caller, __iova_rcache_insert().

As described, the two bug checks are pointless so drop them.

Signed-off-by: John Garry <[email protected]>
Acked-by: Robin Murphy <[email protected]>
---
drivers/iommu/iova.c | 4 ----
1 file changed, 4 deletions(-)

diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
index 580fdf669922..8aece052ce72 100644
--- a/drivers/iommu/iova.c
+++ b/drivers/iommu/iova.c
@@ -694,8 +694,6 @@ static unsigned long iova_magazine_pop(struct iova_magazine *mag,
int i;
unsigned long pfn;

- BUG_ON(iova_magazine_empty(mag));
-
/* Only fall back to the rbtree if we have no suitable pfns at all */
for (i = mag->size - 1; mag->pfns[i] > limit_pfn; i--)
if (i == 0)
@@ -710,8 +708,6 @@ static unsigned long iova_magazine_pop(struct iova_magazine *mag,

static void iova_magazine_push(struct iova_magazine *mag, unsigned long pfn)
{
- BUG_ON(iova_magazine_full(mag));
-
mag->pfns[mag->size++] = pfn;
}

--
2.35.3

2022-09-05 15:21:47

by Jerry Snitselaar

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] iova: Remove magazine BUG_ON() checks

On Mon, Sep 05, 2022 at 05:11:23PM +0800, John Garry wrote:
> Two of the magazine helpers have BUG_ON() checks, as follows:
> - iova_magazine_pop() - here we ensure that the mag is not empty. However we
> already ensure that in the only caller, __iova_rcache_get().
> - iova_magazine_push() - here we ensure that the mag is not full. However
> we already ensure that in the only caller, __iova_rcache_insert().
>
> As described, the two bug checks are pointless so drop them.
>
> Signed-off-by: John Garry <[email protected]>
> Acked-by: Robin Murphy <[email protected]>

Reviewed-by: Jerry Snitselaar <[email protected]

> ---
> drivers/iommu/iova.c | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
> index 580fdf669922..8aece052ce72 100644
> --- a/drivers/iommu/iova.c
> +++ b/drivers/iommu/iova.c
> @@ -694,8 +694,6 @@ static unsigned long iova_magazine_pop(struct iova_magazine *mag,
> int i;
> unsigned long pfn;
>
> - BUG_ON(iova_magazine_empty(mag));
> -
> /* Only fall back to the rbtree if we have no suitable pfns at all */
> for (i = mag->size - 1; mag->pfns[i] > limit_pfn; i--)
> if (i == 0)
> @@ -710,8 +708,6 @@ static unsigned long iova_magazine_pop(struct iova_magazine *mag,
>
> static void iova_magazine_push(struct iova_magazine *mag, unsigned long pfn)
> {
> - BUG_ON(iova_magazine_full(mag));
> -
> mag->pfns[mag->size++] = pfn;
> }
>
> --
> 2.35.3
>