Re: [PATCH 1/7] zram: switch to non-atomic entry locking

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

 



On (25/01/22 14:57), Sergey Senozhatsky wrote:
[..]
>  static bool zram_meta_alloc(struct zram *zram, u64 disksize)
>  {
> -	size_t num_pages, index;
> +	size_t num_ents, index;
>  
> -	num_pages = disksize >> PAGE_SHIFT;
> -	zram->table = vzalloc(array_size(num_pages, sizeof(*zram->table)));
> +	num_ents = disksize >> PAGE_SHIFT;
> +	zram->table = vzalloc(array_size(num_ents, sizeof(*zram->table)));
>  	if (!zram->table)
> -		return false;
> +		goto error;
> +
> +	num_ents /= ZRAM_PAGES_PER_BUCKET_LOCK;
> +	zram->locks = vzalloc(array_size(num_ents, sizeof(*zram->locks)));

This better use ceil().  I'm working on v2.

---

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 0413438e4500..098e86fe70a5 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1486,7 +1486,7 @@ static bool zram_meta_alloc(struct zram *zram, u64 disksize)
 	if (!zram->table)
 		goto error;
 
-	num_ents /= ZRAM_PAGES_PER_BUCKET_LOCK;
+	num_ents = DIV_ROUND_UP(num_ents, ZRAM_PAGES_PER_BUCKET_LOCK);
 	zram->locks = vzalloc(array_size(num_ents, sizeof(*zram->locks)));
 	if (!zram->locks)
 		goto error;




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux