[Devel] [PATCH 1/4] blk-cbt: Remove needless zeroing
Alexander Atanasov
alexander.atanasov at virtuozzo.com
Fri Jan 27 16:07:31 MSK 2023
On 27.01.23 13:34, Nikolay Borisov wrote:
> The per-cpu allocator guarantees the returned memory is going to be
> zeroed out so it's redundant to do our own zeroing when initialising
> cbt. Simply remove this code.
>
> Signed-off-by: Nikolay Borisov <nikolay.borisov at virtuozzo.com>
> ---
> block/blk-cbt.c | 11 +----------
> 1 file changed, 1 insertion(+), 10 deletions(-)
>
> diff --git a/block/blk-cbt.c b/block/blk-cbt.c
> index c7cf7b0ae264..e2a9be83ac0d 100644
> --- a/block/blk-cbt.c
> +++ b/block/blk-cbt.c
> @@ -265,12 +265,8 @@ inline void blk_cbt_bio_queue(struct request_queue *q, struct bio *bio)
> static struct cbt_info* do_cbt_alloc(struct request_queue *q, __u8 *uuid,
> loff_t size, loff_t blocksize)
> {
> - struct cbt_info *cbt;
> - struct cbt_extent *ex;
> - int i;
> -
> + struct cbt_info *cbt = kzalloc(sizeof(*cbt), GFP_KERNEL);
>
> - cbt = kzalloc(sizeof(*cbt), GFP_KERNEL);
> if (!cbt)
> return ERR_PTR(-ENOMEM);
>
> @@ -282,11 +278,6 @@ static struct cbt_info* do_cbt_alloc(struct request_queue *q, __u8 *uuid,
> if (!cbt->cache)
> goto err_cbt;
>
> - for_each_possible_cpu(i) {
> - ex = per_cpu_ptr(cbt->cache, i);
> - memset(ex, 0, sizeof (*ex));
> - }
> -
> cbt->map = vmalloc(NR_PAGES(cbt->block_max) * sizeof(void*));
> if (!cbt->map)
> goto err_pcpu;
LGTM - alloc_percpu(...) -> __alloc_percpu_gfp which allocates
zero-filled percpu area - so no need to explicitly zero.
--
Regards,
Alexander Atanasov
More information about the Devel
mailing list