From: Takashi Iwai <tiwai@suse.de>
To: Luis Chamberlain <mcgrof@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J . Wysocki" <rafael@kernel.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH 3/5] firmware: Use kvmalloc for page tables
Date: Mon, 20 May 2019 11:26:45 +0200 [thread overview]
Message-ID: <20190520092647.8622-4-tiwai@suse.de> (raw)
In-Reply-To: <20190520092647.8622-1-tiwai@suse.de>
This is a minor optimization to use kvmalloc() variant for allocating
the page table for the SG-buffer. They aren't so big in general, so
kmalloc() would fit often better.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
drivers/base/firmware_loader/fallback.c | 7 ++++---
drivers/base/firmware_loader/main.c | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/base/firmware_loader/fallback.c b/drivers/base/firmware_loader/fallback.c
index 8970a5315e85..b5cd96fd0e77 100644
--- a/drivers/base/firmware_loader/fallback.c
+++ b/drivers/base/firmware_loader/fallback.c
@@ -232,7 +232,7 @@ static int map_fw_priv_pages(struct fw_priv *fw_priv)
return -ENOMEM;
/* page table is no longer needed after mapping, let's free */
- vfree(fw_priv->pages);
+ kvfree(fw_priv->pages);
fw_priv->pages = NULL;
return 0;
@@ -397,7 +397,8 @@ static int fw_realloc_pages(struct fw_sysfs *fw_sysfs, int min_size)
fw_priv->page_array_size * 2);
struct page **new_pages;
- new_pages = vmalloc(array_size(new_array_size, sizeof(void *)));
+ new_pages = kvmalloc_array(new_array_size, sizeof(void *),
+ GFP_KERNEL);
if (!new_pages) {
fw_load_abort(fw_sysfs);
return -ENOMEM;
@@ -406,7 +407,7 @@ static int fw_realloc_pages(struct fw_sysfs *fw_sysfs, int min_size)
fw_priv->page_array_size * sizeof(void *));
memset(&new_pages[fw_priv->page_array_size], 0, sizeof(void *) *
(new_array_size - fw_priv->page_array_size));
- vfree(fw_priv->pages);
+ kvfree(fw_priv->pages);
fw_priv->pages = new_pages;
fw_priv->page_array_size = new_array_size;
}
diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c
index 083fc3e4f2fd..2e74a1b73dae 100644
--- a/drivers/base/firmware_loader/main.c
+++ b/drivers/base/firmware_loader/main.c
@@ -276,7 +276,7 @@ void fw_free_paged_buf(struct fw_priv *fw_priv)
for (i = 0; i < fw_priv->nr_pages; i++)
__free_page(fw_priv->pages[i]);
- vfree(fw_priv->pages);
+ kvfree(fw_priv->pages);
fw_priv->pages = NULL;
fw_priv->page_array_size = 0;
fw_priv->nr_pages = 0;
--
2.16.4
next prev parent reply other threads:[~2019-05-20 9:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-20 9:26 [PATCH 0/5] firmware: Add support for loading compressed files Takashi Iwai
2019-05-20 9:26 ` [PATCH 1/5] firmware: Free temporary page table after vmapping Takashi Iwai
2019-05-20 9:26 ` [PATCH 2/5] firmware: Unify the paged buffer release helper Takashi Iwai
2019-05-20 9:26 ` Takashi Iwai [this message]
2019-05-20 9:26 ` [PATCH 4/5] firmware: Factor out the paged buffer handling code Takashi Iwai
2019-05-20 9:26 ` [PATCH 5/5] firmware: Add support for loading compressed files Takashi Iwai
2019-05-20 9:39 ` [PATCH 0/5] " Greg Kroah-Hartman
2019-05-20 9:56 ` Takashi Iwai
2019-05-21 5:30 ` Takashi Iwai
2019-05-20 14:39 ` Takashi Iwai
2019-05-20 15:18 ` Takashi Iwai
2019-05-20 16:22 ` Takashi Iwai
2019-05-20 17:26 ` shuah
2019-05-20 18:07 ` Takashi Iwai
2019-05-20 18:59 ` Takashi Iwai
2019-05-20 21:50 ` Kees Cook
2019-05-28 5:25 ` Takashi Iwai
2019-06-10 17:21 ` Greg Kroah-Hartman
2019-06-10 17:30 ` Takashi Iwai
2019-06-10 17:48 ` Greg Kroah-Hartman
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=20190520092647.8622-4-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=rafael@kernel.org \
/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
all inboxes | Powered by JetHome®