Re: [PATCH 1/9] io_uring: Fold allocation into alloc_cache helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/18/24 6:22 PM, Gabriel Krisman Bertazi wrote:
> diff --git a/io_uring/alloc_cache.h b/io_uring/alloc_cache.h
> index b7a38a2069cf..6b34e491a30a 100644
> --- a/io_uring/alloc_cache.h
> +++ b/io_uring/alloc_cache.h
> @@ -30,6 +30,13 @@ static inline void *io_alloc_cache_get(struct io_alloc_cache *cache)
>  	return NULL;
>  }
>  
> +static inline void *io_alloc_cache_alloc(struct io_alloc_cache *cache, gfp_t gfp)
> +{
> +	if (!cache->nr_cached)
> +		return kzalloc(cache->elem_size, gfp);
> +	return io_alloc_cache_get(cache);
> +}

I don't think you want to use kzalloc here. The caller will need to
clear what its needs for the cached path anyway, so has no other option
than to clear/set things twice for that case.

-- 
Jens Axboe




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux