linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] iommu/iova: Free all CPU rcache for retry when iova alloc failure
       [not found] <20220304044635.4273-1-yf.wang@mediatek.com>
@ 2022-03-04  9:22 ` John Garry
  2022-03-07  3:18   ` yf.wang
  2022-03-04 14:03 ` Robin Murphy
  1 sibling, 1 reply; 5+ messages in thread
From: John Garry @ 2022-03-04  9:22 UTC (permalink / raw)
  To: yf.wang, Joerg Roedel, Will Deacon, Matthias Brugger,
	open list:IOMMU DRIVERS, open list,
	moderated list:ARM/Mediatek SoC support,
	moderated list:ARM/Mediatek SoC support
  Cc: wsd_upstream, Libo Kang, stable, Ning Li

On 04/03/2022 04:46, yf.wang--- via iommu wrote:
> ************* MEDIATEK Confidentiality Notice ********************
> The information contained in this e-mail message (including any
> attachments) may be confidential, proprietary, privileged, or otherwise
> exempt from disclosure under applicable laws. It is intended to be

Can you please stop sending patches with this?

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] iommu/iova: Free all CPU rcache for retry when iova alloc failure
       [not found] <20220304044635.4273-1-yf.wang@mediatek.com>
  2022-03-04  9:22 ` [PATCH] iommu/iova: Free all CPU rcache for retry when iova alloc failure John Garry
@ 2022-03-04 14:03 ` Robin Murphy
  2022-03-07  3:32   ` yf.wang
  2022-03-07  3:49   ` yf.wang
  1 sibling, 2 replies; 5+ messages in thread
From: Robin Murphy @ 2022-03-04 14:03 UTC (permalink / raw)
  To: yf.wang, Joerg Roedel, Will Deacon, Matthias Brugger,
	open list:IOMMU DRIVERS, open list,
	moderated list:ARM/Mediatek SoC support,
	moderated list:ARM/Mediatek SoC support
  Cc: wsd_upstream, Libo Kang, stable, Ning Li

On 2022-03-04 04:46, yf.wang--- via iommu wrote:
> From: Yunfei Wang <yf.wang@mediatek.com>
> 
> In alloc_iova_fast function, if an iova alloc request fail,
> it will free the iova ranges present in the percpu iova
> rcaches and free global iova rcache and then retry, but
> flushing CPU iova rcaches only for each online CPU, which
> will cause incomplete rcache cleaning, and iova rcaches of
> not online CPU cannot be flushed, because iova rcaches may
> also lead to fragmentation of iova space, so the next retry
> action may still be fail.
> 
> Based on the above, so need to flushing all iova rcaches
> for each possible CPU, use for_each_possible_cpu instead of
> for_each_online_cpu like in free_iova_rcaches function,
> so that all rcaches can be completely released to try
> replenishing IOVAs.

OK, so either there's a mystery bug where IOVAs somehow get freed on 
offline CPUs, or the hotplug notifier isn't working correctly, or you've 
contrived a situation where alloc_iova_fast() is actually racing against 
iova_cpuhp_dead(). In the latter case, the solution is "don't do that".

This change should not be necessary.

Thanks,
Robin.

> Signed-off-by: Yunfei Wang <yf.wang@mediatek.com>
> Cc: <stable@vger.kernel.org> # 5.4.*
> ---
>   drivers/iommu/iova.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
> index b28c9435b898..5a0637cd7bc2 100644
> --- a/drivers/iommu/iova.c
> +++ b/drivers/iommu/iova.c
> @@ -460,7 +460,7 @@ alloc_iova_fast(struct iova_domain *iovad, unsigned long size,
>   
>   		/* Try replenishing IOVAs by flushing rcache. */
>   		flush_rcache = false;
> -		for_each_online_cpu(cpu)
> +		for_each_possible_cpu(cpu)
>   			free_cpu_cached_iovas(cpu, iovad);
>   		free_global_cached_iovas(iovad);
>   		goto retry;
> 
> 
> _______________________________________________
> iommu mailing list
> iommu@lists.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/iommu

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] iommu/iova: Free all CPU rcache for retry when iova alloc failure
  2022-03-04  9:22 ` [PATCH] iommu/iova: Free all CPU rcache for retry when iova alloc failure John Garry
@ 2022-03-07  3:18   ` yf.wang
  0 siblings, 0 replies; 5+ messages in thread
From: yf.wang @ 2022-03-07  3:18 UTC (permalink / raw)
  To: iommu
  Cc: Libo.Kang, Ning.Li, john.garry, joro, linux-arm-kernel,
	linux-kernel, linux-mediatek, matthias.bgg, stable, will,
	wsd_upstream, yf.wang

On 2022-03-04 9:22, John Garry wrote:
> On 04/03/2022 04:46, yf.wang--- via iommu wrote:
> > ************* MEDIATEK Confidentiality Notice ********************
> > The 
> > information contained in this e-mail message (including any
> > attachments) may be confidential, proprietary, privileged, or 
> > otherwise exempt from disclosure under applicable laws. It is
> > intended 
> > to be
> 
> Can you please stop sending patches with this?

Hi John,

I will remote it later.

Thanks,
Yunfei.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] iommu/iova: Free all CPU rcache for retry when iova alloc failure
  2022-03-04 14:03 ` Robin Murphy
@ 2022-03-07  3:32   ` yf.wang
  2022-03-07  3:49   ` yf.wang
  1 sibling, 0 replies; 5+ messages in thread
From: yf.wang @ 2022-03-07  3:32 UTC (permalink / raw)
  To: robin.murphy
  Cc: Libo.Kang, Ning.Li, iommu, joro, linux-arm-kernel, linux-kernel,
	linux-mediatek, matthias.bgg, stable, will, wsd_upstream, yf.wang

On Fri, 2022-03-04 at 14:03 +0000, Robin Murphy wrote:
> 
> OK, so either there's a mystery bug where IOVAs somehow get freed on 
> offline CPUs, or the hotplug notifier isn't working correctly, or
> you've 
> contrived a situation where alloc_iova_fast() is actually racing
> against 
> iova_cpuhp_dead(). In the latter case, the solution is "don't do
> that".
> 
> This change should not be necessary.
> 
> Thanks,
> Robin.

Hi Robin,

1.As long as iova domain is not destroyed, the cached iovas will always
exist, the only chance to free the cache is the retry flushing
mechanism when alloc fail, but not free cached iova of not online CPU.

2.Iova rcache mechanism is by cpu, but there is no free rcache
mechanism when the CPU state switch.

3.iova.c does not know about CPU state switching, eg.online <--> offline.

Based on the above basic information, this is not a user bug, it is
more like a defect of the iova rcache mechanism.

Thanks,
Yunfei.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] iommu/iova: Free all CPU rcache for retry when iova alloc failure
  2022-03-04 14:03 ` Robin Murphy
  2022-03-07  3:32   ` yf.wang
@ 2022-03-07  3:49   ` yf.wang
  1 sibling, 0 replies; 5+ messages in thread
From: yf.wang @ 2022-03-07  3:49 UTC (permalink / raw)
  To: robin.murphy
  Cc: Libo.Kang, Ning.Li, iommu, joro, linux-arm-kernel, linux-kernel,
	linux-mediatek, matthias.bgg, stable, will, wsd_upstream, yf.wang

On Fri, 2022-03-04 at 14:03 +0000, Robin Murphy wrote:
> 
> OK, so either there's a mystery bug where IOVAs somehow get freed on 
> offline CPUs, or the hotplug notifier isn't working correctly, or
> you've 
> contrived a situation where alloc_iova_fast() is actually racing
> against 
> iova_cpuhp_dead(). In the latter case, the solution is "don't do
> that".
> 
> This change should not be necessary.
> 
> Thanks,
> Robin.

Hi Robin,

You are right, kernel 5.15 already has this patch, but kernel 5.10
not contain.

Thanks,
Yunfei.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-03-07  3:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20220304044635.4273-1-yf.wang@mediatek.com>
2022-03-04  9:22 ` [PATCH] iommu/iova: Free all CPU rcache for retry when iova alloc failure John Garry
2022-03-07  3:18   ` yf.wang
2022-03-04 14:03 ` Robin Murphy
2022-03-07  3:32   ` yf.wang
2022-03-07  3:49   ` yf.wang

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).