[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YRJBA0A7vIF6PKMB@infradead.org>
Date: Tue, 10 Aug 2021 11:04:03 +0200
From: Christoph Hellwig <hch@...radead.org>
To: Alex Williamson <alex.williamson@...hat.com>
Cc: linux-kernel@...r.kernel.org, kvm@...r.kernel.org, jgg@...dia.com,
peterx@...hat.com
Subject: Re: [PATCH 6/7] vfio: Add vfio_device_io_remap_mapping_range()
> +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.
Powered by blists - more mailing lists