Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1448607

Re: [kernel,v2,1/2] powerpc/iommu: Stop using @current in mm_iommu_xxx

From Nicholas Piggin <npiggin@ozlabs.au.ibm.com>
Newsgroups linux.kernel
Subject Re: [kernel,v2,1/2] powerpc/iommu: Stop using @current in mm_iommu_xxx
Date 2016-07-22 16:10 +0200
Message-ID <rXJjj-6SA-3@gated-at.bofh.it> (permalink)
References <rWRsC-55G-19@gated-at.bofh.it>
Organization IBM

Show all headers | View raw


On Wed, 20 Jul 2016 14:34:30 +1000
Alexey Kardashevskiy <aik@ozlabs.ru> wrote:



>  static long tce_iommu_register_pages(struct tce_container *container,
> @@ -128,10 +129,17 @@ static long tce_iommu_register_pages(struct
> tce_container *container, ((vaddr + size) < vaddr))
>  		return -EINVAL;
>  
> -	ret = mm_iommu_get(vaddr, entries, &mem);
> +	if (!container->mm) {
> +		if (!current->mm)
> +			return -ESRCH; /* process exited */

This shouldn't happen if we're a userspace process.

> +
> +		atomic_inc(&current->mm->mm_count);
> +		container->mm = current->mm;
> +	}
> +
> +	ret = mm_iommu_get(container->mm, vaddr, entries, &mem);

Is it possible for processes (different mm) to be using the same
container? 


> @@ -354,6 +362,8 @@ static void tce_iommu_release(void *iommu_data)
>  		tce_iommu_free_table(tbl);
>  	}
>  
> +	if (container->mm)
> +		mmdrop(container->mm);
>  	tce_iommu_disable(container);
>  	mutex_destroy(&container->lock);

I'm wondering why keep the mm around at all. There is a bit of
locked_vm accounting there (which maybe doesn't exactly do the
right thing if we're talking about current task's rlimit if the
mm does not belong to current anyway).

The interesting cases are only the ones where a thread does
something with container->mm when current->mm != container->mm
(either a different process or a kernel thread). In what
situations does that happen?

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH kernel v2 0/2] powerpc/mm/iommu: Put pages on process exit Alexey Kardashevskiy <aik@ozlabs.ru> - 2016-07-20 06:40 +0200
  [PATCH kernel v2 2/2] powerpc/mm/iommu: Put pages on process exit Alexey Kardashevskiy <aik@ozlabs.ru> - 2016-07-20 06:40 +0200
  [PATCH kernel v2 1/2] powerpc/iommu: Stop using @current in mm_iommu_xxx Alexey Kardashevskiy <aik@ozlabs.ru> - 2016-07-20 06:40 +0200
    Re: [kernel,v2,1/2] powerpc/iommu: Stop using @current in  mm_iommu_xxx Nicholas Piggin <npiggin@ozlabs.au.ibm.com> - 2016-07-22 16:10 +0200
    Re: [kernel,v2,1/2] powerpc/iommu: Stop using @current in  mm_iommu_xxx Nicholas Piggin <npiggin@gmail.com> - 2016-07-23 08:40 +0200

csiph-web