[PATCH] um: protect VMA iteration

Anton Ivanov anton.ivanov at cambridgegreys.com
Mon Oct 17 04:51:42 PDT 2022



On 17/10/2022 10:06, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg at intel.com>
> 
> Looks like this is needed now, otherwise we get RCU
> splats from lockdep. But I don't know anything about
> this code ...

I went through it several times a couple of years ago looking if there is a way to optimize some of the flushes.

A lock there will not hurt. I do not think that it would do anything as that bit should be single-threaded (and most invocations are under locks too), but it will not hurt.

So if it is needed to make lockdep shut up - let it be.

> 
> Signed-off-by: Johannes Berg <johannes.berg at intel.com>
> ---
>   arch/um/kernel/tlb.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c
> index ad449173a1a1..3cc6b753e579 100644
> --- a/arch/um/kernel/tlb.c
> +++ b/arch/um/kernel/tlb.c
> @@ -587,8 +587,10 @@ void flush_tlb_mm(struct mm_struct *mm)
>   	struct vm_area_struct *vma;
>   	VMA_ITERATOR(vmi, mm, 0);
>   
> +	rcu_read_lock();
>   	for_each_vma(vmi, vma)
>   		fix_range(mm, vma->vm_start, vma->vm_end, 0);
> +	rcu_read_unlock();
>   }
>   
>   void force_flush_all(void)
> @@ -597,6 +599,8 @@ void force_flush_all(void)
>   	struct vm_area_struct *vma;
>   	VMA_ITERATOR(vmi, mm, 0);
>   
> +	rcu_read_lock();
>   	for_each_vma(vmi, vma)
>   		fix_range(mm, vma->vm_start, vma->vm_end, 1);
> +	rcu_read_unlock();
>   }

Acked-By: Anton Ivanov <anton.ivanov at cambridgegreys.com>

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/



More information about the linux-um mailing list