mbox series

[0/2] vmalloc: Introduce vmap_file()

Message ID 20250131001806.92349-1-vishal.moola@gmail.com (mailing list archive)
Headers show
Series vmalloc: Introduce vmap_file() | expand

Message

Vishal Moola (Oracle) Jan. 31, 2025, 12:18 a.m. UTC
Currently, users have to call vmap() or vmap_pfn() to map pages to
kernel virtual space. vmap() requires the page references, and
vmap_pfn() requires page pfns. If we have a file but no page references,
we have to do extra work to map them.

Create a function, vmap_file(), to map a specified range of a given
file to kernel virtual space. Also convert a user that benefits from
vmap_file().

Vishal Moola (Oracle) (2):
  mm/vmalloc: Introduce vmap_file()
  drm: Use vmap_file() in shmem_pin_map()

 drivers/gpu/drm/i915/gt/shmem_utils.c | 23 +------
 include/linux/vmalloc.h               |  2 +
 mm/vmalloc.c                          | 97 +++++++++++++++++++++++++++
 3 files changed, 102 insertions(+), 20 deletions(-)

Comments

Andrew Morton Jan. 31, 2025, 12:48 a.m. UTC | #1
On Thu, 30 Jan 2025 16:18:04 -0800 "Vishal Moola (Oracle)" <vishal.moola@gmail.com> wrote:

> Currently, users have to call vmap() or vmap_pfn() to map pages to
> kernel virtual space. vmap() requires the page references, and
> vmap_pfn() requires page pfns. If we have a file but no page references,
> we have to do extra work to map them.
> 
> Create a function, vmap_file(), to map a specified range of a given
> file to kernel virtual space. Also convert a user that benefits from
> vmap_file().
> 

Seems like a pretty specialized thing.  Have you identified any other
potential users of vmap_file()?  I couldn't see any.

If drm is likely to remain the only user of this, perhaps we should
leave the code down in drivers/gpu/drm for now?


Also, the amount of copy-n-pasting from vmap() into vmap_file() is
undesirable - code size, maintenance overhead, etc.
Christoph Hellwig Jan. 31, 2025, 7:10 a.m. UTC | #2
On Thu, Jan 30, 2025 at 04:18:04PM -0800, Vishal Moola (Oracle) wrote:
> Currently, users have to call vmap() or vmap_pfn() to map pages to
> kernel virtual space. vmap() requires the page references, and
> vmap_pfn() requires page pfns. If we have a file but no page references,
> we have to do extra work to map them.
> 
> Create a function, vmap_file(), to map a specified range of a given
> file to kernel virtual space. Also convert a user that benefits from
> vmap_file().

As far as I can tell there is exatly one user that maps file pages
into vmalloc space.  It's a pretty odd thing to do, so figuring out
a way to get rid of that might be a better use of time.