vfio iommu type1: Update arguments of vfio_lock_acct
Added task structure as input argument to vfio_lock_acct() function. Signed-off-by: Kirti Wankhede <kwankhede@nvidia.com> Signed-off-by: Neo Jia <cjia@nvidia.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
parent
2169037dc3
commit
3624a2486c
|
@ -150,17 +150,22 @@ static void vfio_lock_acct_bg(struct work_struct *work)
|
||||||
kfree(vwork);
|
kfree(vwork);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vfio_lock_acct(long npage)
|
static void vfio_lock_acct(struct task_struct *task, long npage)
|
||||||
{
|
{
|
||||||
struct vwork *vwork;
|
struct vwork *vwork;
|
||||||
struct mm_struct *mm;
|
struct mm_struct *mm;
|
||||||
|
|
||||||
if (!current->mm || !npage)
|
if (!npage)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mm = get_task_mm(task);
|
||||||
|
if (!mm)
|
||||||
return; /* process exited or nothing to do */
|
return; /* process exited or nothing to do */
|
||||||
|
|
||||||
if (down_write_trylock(¤t->mm->mmap_sem)) {
|
if (down_write_trylock(&mm->mmap_sem)) {
|
||||||
current->mm->locked_vm += npage;
|
mm->locked_vm += npage;
|
||||||
up_write(¤t->mm->mmap_sem);
|
up_write(&mm->mmap_sem);
|
||||||
|
mmput(mm);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,11 +175,8 @@ static void vfio_lock_acct(long npage)
|
||||||
* wouldn't need this silliness
|
* wouldn't need this silliness
|
||||||
*/
|
*/
|
||||||
vwork = kmalloc(sizeof(struct vwork), GFP_KERNEL);
|
vwork = kmalloc(sizeof(struct vwork), GFP_KERNEL);
|
||||||
if (!vwork)
|
if (!vwork) {
|
||||||
return;
|
mmput(mm);
|
||||||
mm = get_task_mm(current);
|
|
||||||
if (!mm) {
|
|
||||||
kfree(vwork);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
INIT_WORK(&vwork->work, vfio_lock_acct_bg);
|
INIT_WORK(&vwork->work, vfio_lock_acct_bg);
|
||||||
|
@ -285,7 +287,7 @@ static long vfio_pin_pages_remote(unsigned long vaddr, long npage,
|
||||||
|
|
||||||
if (unlikely(disable_hugepages)) {
|
if (unlikely(disable_hugepages)) {
|
||||||
if (!rsvd)
|
if (!rsvd)
|
||||||
vfio_lock_acct(1);
|
vfio_lock_acct(current, 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +315,7 @@ static long vfio_pin_pages_remote(unsigned long vaddr, long npage,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rsvd)
|
if (!rsvd)
|
||||||
vfio_lock_acct(i);
|
vfio_lock_acct(current, i);
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -328,7 +330,7 @@ static long vfio_unpin_pages_remote(unsigned long pfn, long npage,
|
||||||
unlocked += put_pfn(pfn++, prot);
|
unlocked += put_pfn(pfn++, prot);
|
||||||
|
|
||||||
if (do_accounting)
|
if (do_accounting)
|
||||||
vfio_lock_acct(-unlocked);
|
vfio_lock_acct(current, -unlocked);
|
||||||
|
|
||||||
return unlocked;
|
return unlocked;
|
||||||
}
|
}
|
||||||
|
@ -390,7 +392,7 @@ static void vfio_unmap_unpin(struct vfio_iommu *iommu, struct vfio_dma *dma)
|
||||||
cond_resched();
|
cond_resched();
|
||||||
}
|
}
|
||||||
|
|
||||||
vfio_lock_acct(-unlocked);
|
vfio_lock_acct(current, -unlocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vfio_remove_dma(struct vfio_iommu *iommu, struct vfio_dma *dma)
|
static void vfio_remove_dma(struct vfio_iommu *iommu, struct vfio_dma *dma)
|
||||||
|
|
Loading…
Reference in New Issue