linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Vishal Moola (Oracle)" <vishal.moola@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	hch@infradead.org, urezki@gmail.com,
	intel-gfx@lists.freedesktop.org,
	"Vishal Moola (Oracle)" <vishal.moola@gmail.com>
Subject: [PATCH 2/2] drm: Use vmap_file() in shmem_pin_map()
Date: Thu, 30 Jan 2025 16:18:06 -0800	[thread overview]
Message-ID: <20250131001806.92349-3-vishal.moola@gmail.com> (raw)
In-Reply-To: <20250131001806.92349-1-vishal.moola@gmail.com>

We no longer need to allocate a new array of pages to map this file
to kernel virtual space. This simplifies shmem_pin_map(), and gets rid
of a user of VM_MAP_PUT_PAGES.

Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
---
 drivers/gpu/drm/i915/gt/shmem_utils.c | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.c b/drivers/gpu/drm/i915/gt/shmem_utils.c
index bb696b29ee2c..79d930ed5229 100644
--- a/drivers/gpu/drm/i915/gt/shmem_utils.c
+++ b/drivers/gpu/drm/i915/gt/shmem_utils.c
@@ -57,32 +57,15 @@ struct file *shmem_create_from_object(struct drm_i915_gem_object *obj)
 
 void *shmem_pin_map(struct file *file)
 {
-	struct page **pages;
-	size_t n_pages, i;
 	void *vaddr;
 
-	n_pages = file->f_mapping->host->i_size >> PAGE_SHIFT;
-	pages = kvmalloc_array(n_pages, sizeof(*pages), GFP_KERNEL);
-	if (!pages)
-		return NULL;
-
-	for (i = 0; i < n_pages; i++) {
-		pages[i] = shmem_read_mapping_page_gfp(file->f_mapping, i,
-						       GFP_KERNEL);
-		if (IS_ERR(pages[i]))
-			goto err_page;
-	}
+	vaddr = vmap_file(file->f_mapping, 0, file->f_mapping->host->i_size,
+			VM_MAP, PAGE_KERNEL);
 
-	vaddr = vmap(pages, n_pages, VM_MAP_PUT_PAGES, PAGE_KERNEL);
 	if (!vaddr)
-		goto err_page;
+		return NULL;
 	mapping_set_unevictable(file->f_mapping);
 	return vaddr;
-err_page:
-	while (i--)
-		put_page(pages[i]);
-	kvfree(pages);
-	return NULL;
 }
 
 void shmem_unpin_map(struct file *file, void *ptr)
-- 
2.47.1



  parent reply	other threads:[~2025-01-31  0:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-31  0:18 [PATCH 0/2] vmalloc: Introduce vmap_file() Vishal Moola (Oracle)
2025-01-31  0:18 ` [PATCH 1/2] mm/vmalloc: " Vishal Moola (Oracle)
2025-01-31  7:09   ` Christoph Hellwig
2025-02-03 19:23     ` Vishal Moola
2025-01-31  0:18 ` Vishal Moola (Oracle) [this message]
2025-01-31  0:48 ` [PATCH 0/2] vmalloc: " Andrew Morton
2025-02-03 18:53   ` Vishal Moola
2025-04-08 14:04     ` Brendan Jackman
2025-01-31  7:10 ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250131001806.92349-3-vishal.moola@gmail.com \
    --to=vishal.moola@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=urezki@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox