mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joseph Qi <joseph.qi@linux.alibaba.com>
To: "Mike Rapoport (Microsoft)" <rppt@kernel.org>,
	Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>,
	akpm <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	ocfs2-devel@lists.linux.dev, linux-nilfs@vger.kernel.org,
	linux-nfs@vger.kernel.org, jfs-discussion@lists.sourceforge.net,
	linux-ext4@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 03/17] ocfs2/dlm: replace __get_free_page() with kmalloc()
Date: Mon, 25 May 2026 10:50:40 +0800	[thread overview]
Message-ID: <a5756f39-31c8-4e8b-939f-f498726c7d8a@linux.alibaba.com> (raw)
In-Reply-To: <20260523-b4-fs-v1-3-275e36a83f0e@kernel.org>



On 5/24/26 1:54 AM, Mike Rapoport (Microsoft) wrote:
> A few places in ocsfs2 allocate temporary buffers with __get_free_page() or
> get_zeroed_page().
> 
> kmalloc() is a better API for such use and it also provides better
> scalability and more debugging possibilities.
> 
> Replace use of __get_free_page() and get_zeroed_page() with kmalloc() and
> kzalloc() respectively.
> 
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>

Looks fine.
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>

> ---
>  fs/ocfs2/dlm/dlmdebug.c    | 24 +++++++++---------------
>  fs/ocfs2/dlm/dlmdomain.c   |  8 +++++---
>  fs/ocfs2/dlm/dlmmaster.c   |  5 ++---
>  fs/ocfs2/dlm/dlmrecovery.c |  4 ++--
>  4 files changed, 18 insertions(+), 23 deletions(-)
> 
> diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c
> index fe4fdd09bae3..6ca8b3b68eef 100644
> --- a/fs/ocfs2/dlm/dlmdebug.c
> +++ b/fs/ocfs2/dlm/dlmdebug.c
> @@ -260,10 +260,10 @@ void dlm_print_one_mle(struct dlm_master_list_entry *mle)
>  {
>  	char *buf;
>  
> -	buf = (char *) get_zeroed_page(GFP_ATOMIC);
> +	buf = kzalloc(PAGE_SIZE, GFP_ATOMIC);
>  	if (buf) {
>  		dump_mle(mle, buf, PAGE_SIZE - 1);
> -		free_page((unsigned long)buf);
> +		kfree(buf);
>  	}
>  }
>  
> @@ -280,7 +280,7 @@ static struct dentry *dlm_debugfs_root;
>  /* begin - utils funcs */
>  static int debug_release(struct inode *inode, struct file *file)
>  {
> -	free_page((unsigned long)file->private_data);
> +	kfree(file->private_data);
>  	return 0;
>  }
>  
> @@ -327,17 +327,15 @@ static int debug_purgelist_open(struct inode *inode, struct file *file)
>  	struct dlm_ctxt *dlm = inode->i_private;
>  	char *buf = NULL;
>  
> -	buf = (char *) get_zeroed_page(GFP_NOFS);
> +	buf = kzalloc(PAGE_SIZE, GFP_NOFS);
>  	if (!buf)
> -		goto bail;
> +		return -ENOMEM;
>  
>  	i_size_write(inode, debug_purgelist_print(dlm, buf, PAGE_SIZE - 1));
>  
>  	file->private_data = buf;
>  
>  	return 0;
> -bail:
> -	return -ENOMEM;
>  }
>  
>  static const struct file_operations debug_purgelist_fops = {
> @@ -384,17 +382,15 @@ static int debug_mle_open(struct inode *inode, struct file *file)
>  	struct dlm_ctxt *dlm = inode->i_private;
>  	char *buf = NULL;
>  
> -	buf = (char *) get_zeroed_page(GFP_NOFS);
> +	buf = kzalloc(PAGE_SIZE, GFP_NOFS);
>  	if (!buf)
> -		goto bail;
> +		return -ENOMEM;
>  
>  	i_size_write(inode, debug_mle_print(dlm, buf, PAGE_SIZE - 1));
>  
>  	file->private_data = buf;
>  
>  	return 0;
> -bail:
> -	return -ENOMEM;
>  }
>  
>  static const struct file_operations debug_mle_fops = {
> @@ -775,17 +771,15 @@ static int debug_state_open(struct inode *inode, struct file *file)
>  	struct dlm_ctxt *dlm = inode->i_private;
>  	char *buf = NULL;
>  
> -	buf = (char *) get_zeroed_page(GFP_NOFS);
> +	buf = kzalloc(PAGE_SIZE, GFP_NOFS);
>  	if (!buf)
> -		goto bail;
> +		return -ENOMEM;
>  
>  	i_size_write(inode, debug_state_print(dlm, buf, PAGE_SIZE - 1));
>  
>  	file->private_data = buf;
>  
>  	return 0;
> -bail:
> -	return -ENOMEM;
>  }
>  
>  static const struct file_operations debug_state_fops = {
> diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
> index dc9da9133c8e..97bb9400e24b 100644
> --- a/fs/ocfs2/dlm/dlmdomain.c
> +++ b/fs/ocfs2/dlm/dlmdomain.c
> @@ -63,7 +63,7 @@ static inline void byte_copymap(u8 dmap[], unsigned long smap[],
>  static void dlm_free_pagevec(void **vec, int pages)
>  {
>  	while (pages--)
> -		free_page((unsigned long)vec[pages]);
> +		kfree(vec[pages]);
>  	kfree(vec);
>  }
>  
> @@ -75,9 +75,11 @@ static void **dlm_alloc_pagevec(int pages)
>  	if (!vec)
>  		return NULL;
>  
> -	for (i = 0; i < pages; i++)
> -		if (!(vec[i] = (void *)__get_free_page(GFP_KERNEL)))
> +	for (i = 0; i < pages; i++) {
> +		vec[i] = kmalloc(PAGE_SIZE, GFP_KERNEL);
> +		if (!vec[i])
>  			goto out_free;
> +	}
>  
>  	mlog(0, "Allocated DLM hash pagevec; %d pages (%lu expected), %lu buckets per page\n",
>  	     pages, (unsigned long)DLM_HASH_PAGES,
> diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
> index 93eff38fdadd..aee3b4c56dcc 100644
> --- a/fs/ocfs2/dlm/dlmmaster.c
> +++ b/fs/ocfs2/dlm/dlmmaster.c
> @@ -2548,7 +2548,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,
>  
>  	/* preallocate up front. if this fails, abort */
>  	ret = -ENOMEM;
> -	mres = (struct dlm_migratable_lockres *) __get_free_page(GFP_NOFS);
> +	mres = kmalloc(PAGE_SIZE, GFP_NOFS);
>  	if (!mres) {
>  		mlog_errno(ret);
>  		goto leave;
> @@ -2725,8 +2725,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,
>  	if (wake)
>  		wake_up(&res->wq);
>  
> -	if (mres)
> -		free_page((unsigned long)mres);
> +	kfree(mres);
>  
>  	dlm_put(dlm);
>  
> diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
> index 128872bd945d..9b97bf73df22 100644
> --- a/fs/ocfs2/dlm/dlmrecovery.c
> +++ b/fs/ocfs2/dlm/dlmrecovery.c
> @@ -837,7 +837,7 @@ int dlm_request_all_locks_handler(struct o2net_msg *msg, u32 len, void *data,
>  	}
>  
>  	/* this will get freed by dlm_request_all_locks_worker */
> -	buf = (char *) __get_free_page(GFP_NOFS);
> +	buf = kmalloc(PAGE_SIZE, GFP_NOFS);
>  	if (!buf) {
>  		kfree(item);
>  		dlm_put(dlm);
> @@ -933,7 +933,7 @@ static void dlm_request_all_locks_worker(struct dlm_work_item *item, void *data)
>  		}
>  	}
>  leave:
> -	free_page((unsigned long)data);
> +	kfree(data);
>  }
>  
>  
> 


  reply	other threads:[~2026-05-25  2:56 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-23 17:54 [PATCH 00/17] fs: replace __get_free_pages() call " Mike Rapoport (Microsoft)
2026-05-23 17:54 ` [PATCH 01/17] quota: allocate dquot_hash " Mike Rapoport (Microsoft)
2026-05-25 16:10   ` Jan Kara
2026-05-23 17:54 ` [PATCH 02/17] proc: replace __get_free_page() " Mike Rapoport (Microsoft)
2026-05-25 16:11   ` Jan Kara
2026-05-23 17:54 ` [PATCH 03/17] ocfs2/dlm: " Mike Rapoport (Microsoft)
2026-05-25  2:50   ` Joseph Qi [this message]
2026-05-25 16:13   ` Jan Kara
2026-05-23 17:54 ` [PATCH 04/17] nilfs2: replace get_zeroed_page() with kzalloc() Mike Rapoport (Microsoft)
2026-05-25 17:07   ` Viacheslav Dubeyko
2026-05-27 16:02     ` Ryusuke Konishi
2026-05-23 17:54 ` [PATCH 05/17] NFS: replace __get_free_page() with kmalloc() in nfs_show_devname() Mike Rapoport (Microsoft)
2026-05-23 17:54 ` [PATCH 06/17] NFS: remove unused page and page2 in nfs4_replace_transport() Mike Rapoport (Microsoft)
2026-05-23 17:54 ` [PATCH 07/17] NFSD: replace __get_free_page() with kmalloc() in nfsd_buffered_readdir() Mike Rapoport (Microsoft)
2026-05-23 18:45   ` Jeff Layton
2026-05-23 17:54 ` [PATCH 08/17] libfs: simple_transaction_get(): replace get_zeroed_page() with kzalloc() Mike Rapoport (Microsoft)
2026-05-23 17:54 ` [PATCH 09/17] jfs: replace __get_free_page() with kmalloc() Mike Rapoport (Microsoft)
2026-05-23 17:54 ` [PATCH 10/17] jbd2: replace __get_free_pages() " Mike Rapoport (Microsoft)
2026-05-25 16:17   ` Jan Kara
2026-05-25 17:21     ` David Laight
2026-05-25 17:55       ` Matthew Wilcox
2026-05-26  9:35         ` David Laight
2026-06-03 13:50   ` Theodore Tso
2026-06-04  6:14     ` Mike Rapoport
2026-06-04 14:05       ` Theodore Tso
2026-06-04 14:46         ` Matthew Wilcox
2026-06-05  8:33         ` David Laight
2026-06-05  9:50           ` Uladzislau Rezki
2026-06-05 20:54           ` Matthew Wilcox
2026-05-23 17:54 ` [PATCH 11/17] isofs: replace __get_free_page() " Mike Rapoport (Microsoft)
2026-05-25 16:17   ` Jan Kara
2026-05-23 17:54 ` [PATCH 12/17] fuse: " Mike Rapoport (Microsoft)
2026-05-26 15:00   ` Miklos Szeredi
2026-05-23 17:54 ` [PATCH 13/17] fs/select: " Mike Rapoport (Microsoft)
2026-05-25 16:19   ` Jan Kara
2026-05-23 17:54 ` [PATCH 14/17] fs/namespace: use __getname() to allocate mntpath buffer Mike Rapoport (Microsoft)
2026-05-25 16:22   ` Jan Kara
2026-05-26  9:06     ` Mike Rapoport
2026-05-28 11:54       ` Christian Brauner
2026-05-23 17:54 ` [PATCH 15/17] configfs: replace __get_free_pages() with kzalloc() Mike Rapoport (Microsoft)
2026-05-25 16:22   ` Jan Kara
2026-05-23 17:54 ` [PATCH 16/17] binfmt_misc: replace __get_free_page() with kmalloc() Mike Rapoport (Microsoft)
2026-05-23 17:54 ` [PATCH 17/17] bfs: replace get_zeroed_page() with kzalloc() Mike Rapoport (Microsoft)
2026-05-27 12:05 ` [PATCH 00/17] fs: replace __get_free_pages() call with kmalloc() Christian Brauner
2026-06-05 20:00 ` [PATCH 00/17] " Zi Yan
2026-06-11  9:09   ` Mike Rapoport

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=a5756f39-31c8-4e8b-939f-f498726c7d8a@linux.alibaba.com \
    --to=joseph.qi@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=jlbec@evilplan.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-nilfs@vger.kernel.org \
    --cc=mark@fasheh.com \
    --cc=ocfs2-devel@lists.linux.dev \
    --cc=rppt@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®