[PATCH v1 2/3] mm/memfd_luo: remove unnecessary memset in zero-size memfd path

Chenghao Duan posted 3 patches 2 weeks, 4 days ago
There is a newer version of this series
[PATCH v1 2/3] mm/memfd_luo: remove unnecessary memset in zero-size memfd path
Posted by Chenghao Duan 2 weeks, 4 days ago
The memset(kho_vmalloc, 0, sizeof(*kho_vmalloc)) call in the zero-size
file handling path is unnecessary because the allocation of the ser
structure already uses the __GFP_ZERO flag, ensuring the memory is
already zero-initialized.

Signed-off-by: Chenghao Duan <duanchenghao@kylinos.cn>
---
 mm/memfd_luo.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/mm/memfd_luo.c b/mm/memfd_luo.c
index 5ddd3657d8be..413df8c75c1d 100644
--- a/mm/memfd_luo.c
+++ b/mm/memfd_luo.c
@@ -103,7 +103,6 @@ static int memfd_luo_preserve_folios(struct file *file,
 	if (!size) {
 		*nr_foliosp = 0;
 		*out_folios_ser = NULL;
-		memset(kho_vmalloc, 0, sizeof(*kho_vmalloc));
 		return 0;
 	}
 
-- 
2.25.1
Re: [PATCH v1 2/3] mm/memfd_luo: remove unnecessary memset in zero-size memfd path
Posted by Mike Rapoport 2 weeks, 3 days ago
On Thu, Mar 19, 2026 at 09:28:44AM +0800, Chenghao Duan wrote:
> The memset(kho_vmalloc, 0, sizeof(*kho_vmalloc)) call in the zero-size
> file handling path is unnecessary because the allocation of the ser
> structure already uses the __GFP_ZERO flag, ensuring the memory is
> already zero-initialized.
> 
> Signed-off-by: Chenghao Duan <duanchenghao@kylinos.cn>

Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>

> ---
>  mm/memfd_luo.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/mm/memfd_luo.c b/mm/memfd_luo.c
> index 5ddd3657d8be..413df8c75c1d 100644
> --- a/mm/memfd_luo.c
> +++ b/mm/memfd_luo.c
> @@ -103,7 +103,6 @@ static int memfd_luo_preserve_folios(struct file *file,
>  	if (!size) {
>  		*nr_foliosp = 0;
>  		*out_folios_ser = NULL;
> -		memset(kho_vmalloc, 0, sizeof(*kho_vmalloc));
>  		return 0;
>  	}
>  
> -- 
> 2.25.1
> 

-- 
Sincerely yours,
Mike.
Re: [PATCH v1 2/3] mm/memfd_luo: remove unnecessary memset in zero-size memfd path
Posted by Pratyush Yadav 2 weeks, 3 days ago
On Thu, Mar 19 2026, Chenghao Duan wrote:

> The memset(kho_vmalloc, 0, sizeof(*kho_vmalloc)) call in the zero-size
> file handling path is unnecessary because the allocation of the ser
> structure already uses the __GFP_ZERO flag, ensuring the memory is
> already zero-initialized.
>
> Signed-off-by: Chenghao Duan <duanchenghao@kylinos.cn>

Reviewed-by: Pratyush Yadav <pratyush@kernel.org>

[...]

-- 
Regards,
Pratyush Yadav
Re: [PATCH v1 2/3] mm/memfd_luo: remove unnecessary memset in zero-size memfd path
Posted by Pasha Tatashin 2 weeks, 3 days ago
On Wed, Mar 18, 2026 at 9:29 PM Chenghao Duan <duanchenghao@kylinos.cn> wrote:
>
> The memset(kho_vmalloc, 0, sizeof(*kho_vmalloc)) call in the zero-size
> file handling path is unnecessary because the allocation of the ser
> structure already uses the __GFP_ZERO flag, ensuring the memory is
> already zero-initialized.
>
> Signed-off-by: Chenghao Duan <duanchenghao@kylinos.cn>
> ---
>  mm/memfd_luo.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/mm/memfd_luo.c b/mm/memfd_luo.c
> index 5ddd3657d8be..413df8c75c1d 100644
> --- a/mm/memfd_luo.c
> +++ b/mm/memfd_luo.c
> @@ -103,7 +103,6 @@ static int memfd_luo_preserve_folios(struct file *file,
>         if (!size) {
>                 *nr_foliosp = 0;
>                 *out_folios_ser = NULL;
> -               memset(kho_vmalloc, 0, sizeof(*kho_vmalloc));
>                 return 0;
>         }
>
> --
> 2.25.1
>

Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>