Re: [PATCH 6/7] vfio: Add vfio_device_io_remap_mapping_range()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> +int vfio_device_io_remap_mapping_range(struct vfio_device *device,
> +				       loff_t start, loff_t len)
> +{
> +	struct address_space *mapping = device->inode->i_mapping;
> +	int ret = 0;
> +
> +	i_mmap_lock_write(mapping);
> +	if (mapping_mapped(mapping)) {
> +		struct rb_root_cached *root = &mapping->i_mmap;
> +		pgoff_t pgstart = start >> PAGE_SHIFT;
> +		pgoff_t pgend = (start + len - 1) >> PAGE_SHIFT;
> +		struct vm_area_struct *vma;
> +
> +		vma_interval_tree_foreach(vma, root, pgstart, pgend) {

There is no need for the mapping_mapped check here,
vma_interval_tree_foreach will the right thing for an empty tree.
That also allows to move a few more instructions out of the lock.

> +			/*
> +			 * Force NOFS memory allocation context to avoid
> +			 * deadlock while we hold i_mmap_rwsem.
> +			 */
> +			flags = memalloc_nofs_save();

Please move this out of the loop.

> +extern int vfio_device_io_remap_mapping_range(struct vfio_device *device,
> +					      loff_t start, loff_t len);

No need for the extern.



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux