From: cel@kernel.org
To: <linux-nfs@vger.kernel.org>
Cc: Christoph Hellwig <hch@lst.de>, Chuck Lever <chuck.lever@oracle.com>
Subject: [RFC PATCH 4/4] nfs/blocklayout: Use bulk page allocation APIs
Date: Wed, 19 Jun 2024 13:39:34 -0400 [thread overview]
Message-ID: <20240619173929.177818-10-cel@kernel.org> (raw)
In-Reply-To: <20240619173929.177818-6-cel@kernel.org>
From: Chuck Lever <chuck.lever@oracle.com>
nfs4_get_device_info() frequently requests more than a few pages
when provisioning a nfs4_deviceid_node object. Make this more
efficient by using alloc_pages_bulk_array(). This API is known to be
several times faster than an open-coded loop around alloc_page().
release_pages() is folio-enabled so it is also more efficient than
repeatedly invoking __free_pages().
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/nfs/pnfs_dev.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/fs/nfs/pnfs_dev.c b/fs/nfs/pnfs_dev.c
index 178001c90156..26a78d69acab 100644
--- a/fs/nfs/pnfs_dev.c
+++ b/fs/nfs/pnfs_dev.c
@@ -101,9 +101,8 @@ nfs4_get_device_info(struct nfs_server *server,
struct nfs4_deviceid_node *d = NULL;
struct pnfs_device *pdev = NULL;
struct page **pages = NULL;
+ int rc, i, max_pages;
u32 max_resp_sz;
- int max_pages;
- int rc, i;
/*
* Use the session max response size as the basis for setting
@@ -125,11 +124,9 @@ nfs4_get_device_info(struct nfs_server *server,
if (!pages)
goto out_free_pdev;
- for (i = 0; i < max_pages; i++) {
- pages[i] = alloc_page(gfp_flags);
- if (!pages[i])
- goto out_free_pages;
- }
+ i = alloc_pages_bulk_array(GFP_KERNEL, max_pages, pages);
+ if (i != max_pages)
+ goto out_free_pages;
memcpy(&pdev->dev_id, dev_id, sizeof(*dev_id));
pdev->layout_type = server->pnfs_curr_ld->id;
@@ -154,8 +151,8 @@ nfs4_get_device_info(struct nfs_server *server,
set_bit(NFS_DEVICEID_NOCACHE, &d->flags);
out_free_pages:
- while (--i >= 0)
- __free_page(pages[i]);
+ if (i)
+ release_pages(pages, i);
kfree(pages);
out_free_pdev:
kfree(pdev);
--
2.45.1
next prev parent reply other threads:[~2024-06-19 17:40 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-19 17:39 [RFC PATCH 0/4] Snapshot of fixes for SCSI PR key registration cel
2024-06-19 17:39 ` [RFC PATCH 1/4] nfs/blocklayout: SCSI layout trace points for reservation key reg/unreg cel
2024-06-20 4:50 ` Christoph Hellwig
2024-06-20 4:52 ` Christoph Hellwig
2024-06-20 14:30 ` Chuck Lever
2024-06-19 17:39 ` [RFC PATCH 2/4] nfs/blocklayout: Report only when /no/ device is found cel
2024-06-20 4:36 ` Christoph Hellwig
2024-06-20 14:59 ` Chuck Lever
2024-06-20 12:17 ` Benjamin Coddington
2024-06-20 14:10 ` Christoph Hellwig
2024-06-19 17:39 ` [RFC PATCH 3/4] nfs/blocklayout: Fix premature PR key unregistration cel
2024-06-20 5:06 ` Christoph Hellwig
2024-06-20 13:52 ` Benjamin Coddington
2024-06-20 13:58 ` Chuck Lever
2024-06-20 14:15 ` Christoph Hellwig
2024-06-20 14:18 ` Chuck Lever III
2024-06-20 15:45 ` Benjamin Coddington
2024-06-20 15:48 ` Chuck Lever
2024-06-20 15:58 ` Benjamin Coddington
2024-06-20 15:39 ` Chuck Lever
2024-06-20 13:51 ` Benjamin Coddington
2024-06-20 14:34 ` Chuck Lever
2024-06-20 14:37 ` Christoph Hellwig
2024-06-20 15:30 ` Benjamin Coddington
2024-06-20 15:46 ` Chuck Lever
2024-06-20 15:56 ` Benjamin Coddington
2024-06-20 16:45 ` Benjamin Coddington
2024-06-20 17:08 ` Chuck Lever
2024-06-19 17:39 ` cel [this message]
2024-06-20 4:44 ` [RFC PATCH 4/4] nfs/blocklayout: Use bulk page allocation APIs 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=20240619173929.177818-10-cel@kernel.org \
--to=cel@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=hch@lst.de \
--cc=linux-nfs@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.