Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: <linux-mm@kvack.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>,
	David Hildenbrand <david@kernel.org>, Zi Yan <ziy@nvidia.com>
Subject: Re: [PATCH mm-new 3/5] mm: mincore: replace __get_free_page() with kmalloc()
Date: Wed, 1 Jul 2026 11:26:28 -0700	[thread overview]
Message-ID: <20260701112628.7e22f17c6ef12771cd3d3649@linux-foundation.org> (raw)
In-Reply-To: <20260701144047.3786939-4-wangkefeng.wang@huawei.com>

On Wed, 1 Jul 2026 22:40:45 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote:

> Remove ugly casts by using the more natural kmalloc/kfree allocation.
> 
> --- a/mm/mincore.c
> +++ b/mm/mincore.c
> @@ -13,6 +13,7 @@
>  #include <linux/pagewalk.h>
>  #include <linux/mman.h>
>  #include <linux/mmap_lock.h>
> +#include <linux/slab.h>
>  #include <linux/syscalls.h>
>  #include <linux/swap.h>
>  #include <linux/leafops.h>
> @@ -312,7 +313,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_USER);

kmalloc(GFP_USER) is a weird combination.  I don't think GFP_USER ever
made sense in here.

>  	if (!tmp)
>  		return -EAGAIN;
>  
> @@ -358,6 +359,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;
>  }



  reply	other threads:[~2026-07-01 18:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01 14:40 [PATCH mm-new 0/5] mm: mincore: reduce lock contention and misc cleanups Kefeng Wang
2026-07-01 14:40 ` [PATCH mm-new 1/5] mm: mincore: attempt per-vma lock during page table walk Kefeng Wang
2026-07-01 14:40 ` [PATCH mm-new 2/5] mm: mincore: remove special handing for VM_PFNMAP Kefeng Wang
2026-07-01 14:40 ` [PATCH mm-new 3/5] mm: mincore: replace __get_free_page() with kmalloc() Kefeng Wang
2026-07-01 18:26   ` Andrew Morton [this message]
2026-07-01 14:40 ` [PATCH mm-new 4/5] mm: mincore: remove xa_is_value() in mincore_swap() Kefeng Wang
2026-07-01 14:40 ` [PATCH mm-new 5/5] mm: mincore: improve mincore_hugetlb() Kefeng Wang
2026-07-01 18:24 ` [PATCH mm-new 0/5] mm: mincore: reduce lock contention and misc cleanups Andrew Morton

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=20260701112628.7e22f17c6ef12771cd3d3649@linux-foundation.org \
    --to=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=wangkefeng.wang@huawei.com \
    --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