Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: <linux-mm@kvack.org>, David Hildenbrand <david@kernel.org>,
	"Liam R . Howlett" <liam@infradead.org>,
	Lorenzo Stoakes <ljs@kernel.org>,
	Vlastimil Babka <vbabka@kernel.org>, Jann Horn <jannh@google.com>,
	Pedro Falcato <pfalcato@suse.de>, Zi Yan <ziy@nvidia.com>,
	Kefeng Wang <wangkefeng.wang@huawei.com>
Subject: [PATCH v2 2/5] mm: mincore: replace __get_free_page() with kmalloc()
Date: Fri, 10 Jul 2026 20:00:48 +0800	[thread overview]
Message-ID: <20260710120052.103886-3-wangkefeng.wang@huawei.com> (raw)
In-Reply-To: <20260710120052.103886-1-wangkefeng.wang@huawei.com>

Remove ugly casts by using the more natural kmalloc/kfree allocation,
also replace GFP_USER(pointless here) with GFP_KERNEL.

Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 mm/mincore.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/mincore.c b/mm/mincore.c
index 0eb832ee0a30..bff19a0df9f5 100644
--- a/mm/mincore.c
+++ b/mm/mincore.c
@@ -12,6 +12,7 @@
 #include <linux/gfp.h>
 #include <linux/pagewalk.h>
 #include <linux/mman.h>
+#include <linux/slab.h>
 #include <linux/syscalls.h>
 #include <linux/swap.h>
 #include <linux/leafops.h>
@@ -313,7 +314,7 @@ SYSCALL_DEFINE3(mincore, unsigned long, start, size_t, len,
 	if (!access_ok(vec, pages))
 		return -EFAULT;
 
-	tmp = (void *) __get_free_page(GFP_USER);
+	tmp = kmalloc(PAGE_SIZE, GFP_KERNEL);
 	if (!tmp)
 		return -EAGAIN;
 
@@ -338,6 +339,6 @@ SYSCALL_DEFINE3(mincore, unsigned long, start, size_t, len,
 		start += retval << PAGE_SHIFT;
 		retval = 0;
 	}
-	free_page((unsigned long) tmp);
+	kfree(tmp);
 	return retval;
 }
-- 
2.55.0



  parent reply	other threads:[~2026-07-10 12:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-10 12:00 [PATCH v2 0/5] mm: mincore: misc cleanups Kefeng Wang
2026-07-10 12:00 ` [PATCH v2 1/5] mm: mincore: remove special handling for VM_PFNMAP Kefeng Wang
2026-07-10 12:07   ` David Hildenbrand (Arm)
2026-07-10 12:00 ` Kefeng Wang [this message]
2026-07-10 12:09   ` [PATCH v2 2/5] mm: mincore: replace __get_free_page() with kmalloc() David Hildenbrand (Arm)
2026-07-10 12:00 ` [PATCH v2 3/5] mm: mincore: remove xa_is_value() in mincore_swap() Kefeng Wang
2026-07-10 12:09   ` David Hildenbrand (Arm)
2026-07-10 12:00 ` [PATCH v2 4/5] mm: mincore: improve mincore_hugetlb() Kefeng Wang
2026-07-10 12:17   ` David Hildenbrand (Arm)
2026-07-10 12:00 ` [PATCH v2 5/5] mm: mincore: refactor mincore_page() Kefeng Wang
2026-07-10 12:19   ` David Hildenbrand (Arm)

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=20260710120052.103886-3-wangkefeng.wang@huawei.com \
    --to=wangkefeng.wang@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=jannh@google.com \
    --cc=liam@infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=pfalcato@suse.de \
    --cc=vbabka@kernel.org \
    --cc=ziy@nvidia.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